documentation.d.ts 3.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101
  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. * The options Interface for creating a Capsule Mesh
  6820. */
  6821. export interface ICreateCapsuleOptions {
  6822. /** The Orientation of the capsule. Default : Vector3.Up() */
  6823. orientation?: Vector3;
  6824. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6825. subdivisions: number;
  6826. /** Number of cylindrical segments on the capsule. */
  6827. tessellation: number;
  6828. /** Height or Length of the capsule. */
  6829. height: number;
  6830. /** Radius of the capsule. */
  6831. radius: number;
  6832. /** Height or Length of the capsule. */
  6833. capSubdivisions: number;
  6834. /** Overwrite for the top radius. */
  6835. radiusTop?: number;
  6836. /** Overwrite for the bottom radius. */
  6837. radiusBottom?: number;
  6838. /** Overwrite for the top capSubdivisions. */
  6839. topCapSubdivisions?: number;
  6840. /** Overwrite for the bottom capSubdivisions. */
  6841. bottomCapSubdivisions?: number;
  6842. }
  6843. /**
  6844. * Class containing static functions to help procedurally build meshes
  6845. */
  6846. export class CapsuleBuilder {
  6847. /**
  6848. * Creates a capsule or a pill mesh
  6849. * @param name defines the name of the mesh
  6850. * @param options The constructors options.
  6851. * @param scene The scene the mesh is scoped to.
  6852. * @returns Capsule Mesh
  6853. */
  6854. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6855. }
  6856. }
  6857. declare module BABYLON {
  6858. /**
  6859. * @hidden
  6860. */
  6861. export class IntersectionInfo {
  6862. bu: Nullable<number>;
  6863. bv: Nullable<number>;
  6864. distance: number;
  6865. faceId: number;
  6866. subMeshId: number;
  6867. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6868. }
  6869. }
  6870. declare module BABYLON {
  6871. /**
  6872. * Class used to store bounding sphere information
  6873. */
  6874. export class BoundingSphere {
  6875. /**
  6876. * Gets the center of the bounding sphere in local space
  6877. */
  6878. readonly center: Vector3;
  6879. /**
  6880. * Radius of the bounding sphere in local space
  6881. */
  6882. radius: number;
  6883. /**
  6884. * Gets the center of the bounding sphere in world space
  6885. */
  6886. readonly centerWorld: Vector3;
  6887. /**
  6888. * Radius of the bounding sphere in world space
  6889. */
  6890. radiusWorld: number;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * Creates a new bounding sphere
  6903. * @param min defines the minimum vector (in local space)
  6904. * @param max defines the maximum vector (in local space)
  6905. * @param worldMatrix defines the new world matrix
  6906. */
  6907. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6908. /**
  6909. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6910. * @param min defines the new minimum vector (in local space)
  6911. * @param max defines the new maximum vector (in local space)
  6912. * @param worldMatrix defines the new world matrix
  6913. */
  6914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6915. /**
  6916. * Scale the current bounding sphere by applying a scale factor
  6917. * @param factor defines the scale factor to apply
  6918. * @returns the current bounding box
  6919. */
  6920. scale(factor: number): BoundingSphere;
  6921. /**
  6922. * Gets the world matrix of the bounding box
  6923. * @returns a matrix
  6924. */
  6925. getWorldMatrix(): DeepImmutable<Matrix>;
  6926. /** @hidden */
  6927. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6928. /**
  6929. * Tests if the bounding sphere is intersecting the frustum planes
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @returns true if there is an intersection
  6932. */
  6933. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if the bounding sphere center is in between the frustum planes.
  6936. * Used for optimistic fast inclusion.
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @returns true if the sphere center is in between the frustum planes
  6939. */
  6940. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. /**
  6942. * Tests if a point is inside the bounding sphere
  6943. * @param point defines the point to test
  6944. * @returns true if the point is inside the bounding sphere
  6945. */
  6946. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Checks if two sphere intersct
  6949. * @param sphere0 sphere 0
  6950. * @param sphere1 sphere 1
  6951. * @returns true if the speres intersect
  6952. */
  6953. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6954. }
  6955. }
  6956. declare module BABYLON {
  6957. /**
  6958. * Class used to store bounding box information
  6959. */
  6960. export class BoundingBox implements ICullable {
  6961. /**
  6962. * Gets the 8 vectors representing the bounding box in local space
  6963. */
  6964. readonly vectors: Vector3[];
  6965. /**
  6966. * Gets the center of the bounding box in local space
  6967. */
  6968. readonly center: Vector3;
  6969. /**
  6970. * Gets the center of the bounding box in world space
  6971. */
  6972. readonly centerWorld: Vector3;
  6973. /**
  6974. * Gets the extend size in local space
  6975. */
  6976. readonly extendSize: Vector3;
  6977. /**
  6978. * Gets the extend size in world space
  6979. */
  6980. readonly extendSizeWorld: Vector3;
  6981. /**
  6982. * Gets the OBB (object bounding box) directions
  6983. */
  6984. readonly directions: Vector3[];
  6985. /**
  6986. * Gets the 8 vectors representing the bounding box in world space
  6987. */
  6988. readonly vectorsWorld: Vector3[];
  6989. /**
  6990. * Gets the minimum vector in world space
  6991. */
  6992. readonly minimumWorld: Vector3;
  6993. /**
  6994. * Gets the maximum vector in world space
  6995. */
  6996. readonly maximumWorld: Vector3;
  6997. /**
  6998. * Gets the minimum vector in local space
  6999. */
  7000. readonly minimum: Vector3;
  7001. /**
  7002. * Gets the maximum vector in local space
  7003. */
  7004. readonly maximum: Vector3;
  7005. private _worldMatrix;
  7006. private static readonly TmpVector3;
  7007. /**
  7008. * @hidden
  7009. */
  7010. _tag: number;
  7011. /**
  7012. * Creates a new bounding box
  7013. * @param min defines the minimum vector (in local space)
  7014. * @param max defines the maximum vector (in local space)
  7015. * @param worldMatrix defines the new world matrix
  7016. */
  7017. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7018. /**
  7019. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7020. * @param min defines the new minimum vector (in local space)
  7021. * @param max defines the new maximum vector (in local space)
  7022. * @param worldMatrix defines the new world matrix
  7023. */
  7024. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7025. /**
  7026. * Scale the current bounding box by applying a scale factor
  7027. * @param factor defines the scale factor to apply
  7028. * @returns the current bounding box
  7029. */
  7030. scale(factor: number): BoundingBox;
  7031. /**
  7032. * Gets the world matrix of the bounding box
  7033. * @returns a matrix
  7034. */
  7035. getWorldMatrix(): DeepImmutable<Matrix>;
  7036. /** @hidden */
  7037. _update(world: DeepImmutable<Matrix>): void;
  7038. /**
  7039. * Tests if the bounding box is intersecting the frustum planes
  7040. * @param frustumPlanes defines the frustum planes to test
  7041. * @returns true if there is an intersection
  7042. */
  7043. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7044. /**
  7045. * Tests if the bounding box is entirely inside the frustum planes
  7046. * @param frustumPlanes defines the frustum planes to test
  7047. * @returns true if there is an inclusion
  7048. */
  7049. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7050. /**
  7051. * Tests if a point is inside the bounding box
  7052. * @param point defines the point to test
  7053. * @returns true if the point is inside the bounding box
  7054. */
  7055. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7056. /**
  7057. * Tests if the bounding box intersects with a bounding sphere
  7058. * @param sphere defines the sphere to test
  7059. * @returns true if there is an intersection
  7060. */
  7061. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7062. /**
  7063. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7064. * @param min defines the min vector to use
  7065. * @param max defines the max vector to use
  7066. * @returns true if there is an intersection
  7067. */
  7068. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7069. /**
  7070. * Tests if two bounding boxes are intersections
  7071. * @param box0 defines the first box to test
  7072. * @param box1 defines the second box to test
  7073. * @returns true if there is an intersection
  7074. */
  7075. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7076. /**
  7077. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7078. * @param minPoint defines the minimum vector of the bounding box
  7079. * @param maxPoint defines the maximum vector of the bounding box
  7080. * @param sphereCenter defines the sphere center
  7081. * @param sphereRadius defines the sphere radius
  7082. * @returns true if there is an intersection
  7083. */
  7084. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7085. /**
  7086. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7087. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7088. * @param frustumPlanes defines the frustum planes to test
  7089. * @return true if there is an inclusion
  7090. */
  7091. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7092. /**
  7093. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7094. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7095. * @param frustumPlanes defines the frustum planes to test
  7096. * @return true if there is an intersection
  7097. */
  7098. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7099. }
  7100. }
  7101. declare module BABYLON {
  7102. /** @hidden */
  7103. export class Collider {
  7104. /** Define if a collision was found */
  7105. collisionFound: boolean;
  7106. /**
  7107. * Define last intersection point in local space
  7108. */
  7109. intersectionPoint: Vector3;
  7110. /**
  7111. * Define last collided mesh
  7112. */
  7113. collidedMesh: Nullable<AbstractMesh>;
  7114. private _collisionPoint;
  7115. private _planeIntersectionPoint;
  7116. private _tempVector;
  7117. private _tempVector2;
  7118. private _tempVector3;
  7119. private _tempVector4;
  7120. private _edge;
  7121. private _baseToVertex;
  7122. private _destinationPoint;
  7123. private _slidePlaneNormal;
  7124. private _displacementVector;
  7125. /** @hidden */
  7126. _radius: Vector3;
  7127. /** @hidden */
  7128. _retry: number;
  7129. private _velocity;
  7130. private _basePoint;
  7131. private _epsilon;
  7132. /** @hidden */
  7133. _velocityWorldLength: number;
  7134. /** @hidden */
  7135. _basePointWorld: Vector3;
  7136. private _velocityWorld;
  7137. private _normalizedVelocity;
  7138. /** @hidden */
  7139. _initialVelocity: Vector3;
  7140. /** @hidden */
  7141. _initialPosition: Vector3;
  7142. private _nearestDistance;
  7143. private _collisionMask;
  7144. get collisionMask(): number;
  7145. set collisionMask(mask: number);
  7146. /**
  7147. * Gets the plane normal used to compute the sliding response (in local space)
  7148. */
  7149. get slidePlaneNormal(): Vector3;
  7150. /** @hidden */
  7151. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7152. /** @hidden */
  7153. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7154. /** @hidden */
  7155. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7156. /** @hidden */
  7157. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7158. /** @hidden */
  7159. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7160. /** @hidden */
  7161. _getResponse(pos: Vector3, vel: Vector3): void;
  7162. }
  7163. }
  7164. declare module BABYLON {
  7165. /**
  7166. * Interface for cullable objects
  7167. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7168. */
  7169. export interface ICullable {
  7170. /**
  7171. * Checks if the object or part of the object is in the frustum
  7172. * @param frustumPlanes Camera near/planes
  7173. * @returns true if the object is in frustum otherwise false
  7174. */
  7175. isInFrustum(frustumPlanes: Plane[]): boolean;
  7176. /**
  7177. * Checks if a cullable object (mesh...) is in the camera frustum
  7178. * Unlike isInFrustum this cheks the full bounding box
  7179. * @param frustumPlanes Camera near/planes
  7180. * @returns true if the object is in frustum otherwise false
  7181. */
  7182. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7183. }
  7184. /**
  7185. * Info for a bounding data of a mesh
  7186. */
  7187. export class BoundingInfo implements ICullable {
  7188. /**
  7189. * Bounding box for the mesh
  7190. */
  7191. readonly boundingBox: BoundingBox;
  7192. /**
  7193. * Bounding sphere for the mesh
  7194. */
  7195. readonly boundingSphere: BoundingSphere;
  7196. private _isLocked;
  7197. private static readonly TmpVector3;
  7198. /**
  7199. * Constructs bounding info
  7200. * @param minimum min vector of the bounding box/sphere
  7201. * @param maximum max vector of the bounding box/sphere
  7202. * @param worldMatrix defines the new world matrix
  7203. */
  7204. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7205. /**
  7206. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7207. * @param min defines the new minimum vector (in local space)
  7208. * @param max defines the new maximum vector (in local space)
  7209. * @param worldMatrix defines the new world matrix
  7210. */
  7211. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7212. /**
  7213. * min vector of the bounding box/sphere
  7214. */
  7215. get minimum(): Vector3;
  7216. /**
  7217. * max vector of the bounding box/sphere
  7218. */
  7219. get maximum(): Vector3;
  7220. /**
  7221. * If the info is locked and won't be updated to avoid perf overhead
  7222. */
  7223. get isLocked(): boolean;
  7224. set isLocked(value: boolean);
  7225. /**
  7226. * Updates the bounding sphere and box
  7227. * @param world world matrix to be used to update
  7228. */
  7229. update(world: DeepImmutable<Matrix>): void;
  7230. /**
  7231. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7232. * @param center New center of the bounding info
  7233. * @param extend New extend of the bounding info
  7234. * @returns the current bounding info
  7235. */
  7236. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7237. /**
  7238. * Scale the current bounding info by applying a scale factor
  7239. * @param factor defines the scale factor to apply
  7240. * @returns the current bounding info
  7241. */
  7242. scale(factor: number): BoundingInfo;
  7243. /**
  7244. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7245. * @param frustumPlanes defines the frustum to test
  7246. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7247. * @returns true if the bounding info is in the frustum planes
  7248. */
  7249. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7250. /**
  7251. * Gets the world distance between the min and max points of the bounding box
  7252. */
  7253. get diagonalLength(): number;
  7254. /**
  7255. * Checks if a cullable object (mesh...) is in the camera frustum
  7256. * Unlike isInFrustum this cheks the full bounding box
  7257. * @param frustumPlanes Camera near/planes
  7258. * @returns true if the object is in frustum otherwise false
  7259. */
  7260. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7261. /** @hidden */
  7262. _checkCollision(collider: Collider): boolean;
  7263. /**
  7264. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7265. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7266. * @param point the point to check intersection with
  7267. * @returns if the point intersects
  7268. */
  7269. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7270. /**
  7271. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7272. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7273. * @param boundingInfo the bounding info to check intersection with
  7274. * @param precise if the intersection should be done using OBB
  7275. * @returns if the bounding info intersects
  7276. */
  7277. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7278. }
  7279. }
  7280. declare module BABYLON {
  7281. /**
  7282. * Extracts minimum and maximum values from a list of indexed positions
  7283. * @param positions defines the positions to use
  7284. * @param indices defines the indices to the positions
  7285. * @param indexStart defines the start index
  7286. * @param indexCount defines the end index
  7287. * @param bias defines bias value to add to the result
  7288. * @return minimum and maximum values
  7289. */
  7290. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7291. minimum: Vector3;
  7292. maximum: Vector3;
  7293. };
  7294. /**
  7295. * Extracts minimum and maximum values from a list of positions
  7296. * @param positions defines the positions to use
  7297. * @param start defines the start index in the positions array
  7298. * @param count defines the number of positions to handle
  7299. * @param bias defines bias value to add to the result
  7300. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7301. * @return minimum and maximum values
  7302. */
  7303. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7304. minimum: Vector3;
  7305. maximum: Vector3;
  7306. };
  7307. }
  7308. declare module BABYLON {
  7309. /** @hidden */
  7310. export class WebGLDataBuffer extends DataBuffer {
  7311. private _buffer;
  7312. constructor(resource: WebGLBuffer);
  7313. get underlyingResource(): any;
  7314. }
  7315. }
  7316. declare module BABYLON {
  7317. /** @hidden */
  7318. export class WebGLPipelineContext implements IPipelineContext {
  7319. engine: ThinEngine;
  7320. program: Nullable<WebGLProgram>;
  7321. context?: WebGLRenderingContext;
  7322. vertexShader?: WebGLShader;
  7323. fragmentShader?: WebGLShader;
  7324. isParallelCompiled: boolean;
  7325. onCompiled?: () => void;
  7326. transformFeedback?: WebGLTransformFeedback | null;
  7327. vertexCompilationError: Nullable<string>;
  7328. fragmentCompilationError: Nullable<string>;
  7329. programLinkError: Nullable<string>;
  7330. programValidationError: Nullable<string>;
  7331. get isAsync(): boolean;
  7332. get isReady(): boolean;
  7333. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7334. _getVertexShaderCode(): string | null;
  7335. _getFragmentShaderCode(): string | null;
  7336. }
  7337. }
  7338. declare module BABYLON {
  7339. interface ThinEngine {
  7340. /**
  7341. * Create an uniform buffer
  7342. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7343. * @param elements defines the content of the uniform buffer
  7344. * @returns the webGL uniform buffer
  7345. */
  7346. createUniformBuffer(elements: FloatArray): DataBuffer;
  7347. /**
  7348. * Create a dynamic uniform buffer
  7349. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7350. * @param elements defines the content of the uniform buffer
  7351. * @returns the webGL uniform buffer
  7352. */
  7353. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7354. /**
  7355. * Update an existing uniform buffer
  7356. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7357. * @param uniformBuffer defines the target uniform buffer
  7358. * @param elements defines the content to update
  7359. * @param offset defines the offset in the uniform buffer where update should start
  7360. * @param count defines the size of the data to update
  7361. */
  7362. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7363. /**
  7364. * Bind an uniform buffer to the current webGL context
  7365. * @param buffer defines the buffer to bind
  7366. */
  7367. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7368. /**
  7369. * Bind a buffer to the current webGL context at a given location
  7370. * @param buffer defines the buffer to bind
  7371. * @param location defines the index where to bind the buffer
  7372. */
  7373. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7374. /**
  7375. * Bind a specific block at a given index in a specific shader program
  7376. * @param pipelineContext defines the pipeline context to use
  7377. * @param blockName defines the block name
  7378. * @param index defines the index where to bind the block
  7379. */
  7380. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7381. }
  7382. }
  7383. declare module BABYLON {
  7384. /**
  7385. * Uniform buffer objects.
  7386. *
  7387. * Handles blocks of uniform on the GPU.
  7388. *
  7389. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7390. *
  7391. * For more information, please refer to :
  7392. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7393. */
  7394. export class UniformBuffer {
  7395. private _engine;
  7396. private _buffer;
  7397. private _data;
  7398. private _bufferData;
  7399. private _dynamic?;
  7400. private _uniformLocations;
  7401. private _uniformSizes;
  7402. private _uniformLocationPointer;
  7403. private _needSync;
  7404. private _noUBO;
  7405. private _currentEffect;
  7406. /** @hidden */
  7407. _alreadyBound: boolean;
  7408. private static _MAX_UNIFORM_SIZE;
  7409. private static _tempBuffer;
  7410. /**
  7411. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7412. * This is dynamic to allow compat with webgl 1 and 2.
  7413. * You will need to pass the name of the uniform as well as the value.
  7414. */
  7415. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7416. /**
  7417. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7418. * This is dynamic to allow compat with webgl 1 and 2.
  7419. * You will need to pass the name of the uniform as well as the value.
  7420. */
  7421. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7422. /**
  7423. * Lambda to Update a single float in a uniform buffer.
  7424. * This is dynamic to allow compat with webgl 1 and 2.
  7425. * You will need to pass the name of the uniform as well as the value.
  7426. */
  7427. updateFloat: (name: string, x: number) => void;
  7428. /**
  7429. * Lambda to Update a vec2 of float in a uniform buffer.
  7430. * This is dynamic to allow compat with webgl 1 and 2.
  7431. * You will need to pass the name of the uniform as well as the value.
  7432. */
  7433. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7434. /**
  7435. * Lambda to Update a vec3 of float in a uniform buffer.
  7436. * This is dynamic to allow compat with webgl 1 and 2.
  7437. * You will need to pass the name of the uniform as well as the value.
  7438. */
  7439. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7440. /**
  7441. * Lambda to Update a vec4 of float in a uniform buffer.
  7442. * This is dynamic to allow compat with webgl 1 and 2.
  7443. * You will need to pass the name of the uniform as well as the value.
  7444. */
  7445. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7446. /**
  7447. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7448. * This is dynamic to allow compat with webgl 1 and 2.
  7449. * You will need to pass the name of the uniform as well as the value.
  7450. */
  7451. updateMatrix: (name: string, mat: Matrix) => void;
  7452. /**
  7453. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7454. * This is dynamic to allow compat with webgl 1 and 2.
  7455. * You will need to pass the name of the uniform as well as the value.
  7456. */
  7457. updateVector3: (name: string, vector: Vector3) => void;
  7458. /**
  7459. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7460. * This is dynamic to allow compat with webgl 1 and 2.
  7461. * You will need to pass the name of the uniform as well as the value.
  7462. */
  7463. updateVector4: (name: string, vector: Vector4) => void;
  7464. /**
  7465. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7466. * This is dynamic to allow compat with webgl 1 and 2.
  7467. * You will need to pass the name of the uniform as well as the value.
  7468. */
  7469. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7470. /**
  7471. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7472. * This is dynamic to allow compat with webgl 1 and 2.
  7473. * You will need to pass the name of the uniform as well as the value.
  7474. */
  7475. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7476. /**
  7477. * Instantiates a new Uniform buffer objects.
  7478. *
  7479. * Handles blocks of uniform on the GPU.
  7480. *
  7481. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7482. *
  7483. * For more information, please refer to :
  7484. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7485. * @param engine Define the engine the buffer is associated with
  7486. * @param data Define the data contained in the buffer
  7487. * @param dynamic Define if the buffer is updatable
  7488. */
  7489. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7490. /**
  7491. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7492. * or just falling back on setUniformXXX calls.
  7493. */
  7494. get useUbo(): boolean;
  7495. /**
  7496. * Indicates if the WebGL underlying uniform buffer is in sync
  7497. * with the javascript cache data.
  7498. */
  7499. get isSync(): boolean;
  7500. /**
  7501. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7502. * Also, a dynamic UniformBuffer will disable cache verification and always
  7503. * update the underlying WebGL uniform buffer to the GPU.
  7504. * @returns if Dynamic, otherwise false
  7505. */
  7506. isDynamic(): boolean;
  7507. /**
  7508. * The data cache on JS side.
  7509. * @returns the underlying data as a float array
  7510. */
  7511. getData(): Float32Array;
  7512. /**
  7513. * The underlying WebGL Uniform buffer.
  7514. * @returns the webgl buffer
  7515. */
  7516. getBuffer(): Nullable<DataBuffer>;
  7517. /**
  7518. * std140 layout specifies how to align data within an UBO structure.
  7519. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7520. * for specs.
  7521. */
  7522. private _fillAlignment;
  7523. /**
  7524. * Adds an uniform in the buffer.
  7525. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7526. * for the layout to be correct !
  7527. * @param name Name of the uniform, as used in the uniform block in the shader.
  7528. * @param size Data size, or data directly.
  7529. */
  7530. addUniform(name: string, size: number | number[]): void;
  7531. /**
  7532. * Adds a Matrix 4x4 to the uniform buffer.
  7533. * @param name Name of the uniform, as used in the uniform block in the shader.
  7534. * @param mat A 4x4 matrix.
  7535. */
  7536. addMatrix(name: string, mat: Matrix): void;
  7537. /**
  7538. * Adds a vec2 to the uniform buffer.
  7539. * @param name Name of the uniform, as used in the uniform block in the shader.
  7540. * @param x Define the x component value of the vec2
  7541. * @param y Define the y component value of the vec2
  7542. */
  7543. addFloat2(name: string, x: number, y: number): void;
  7544. /**
  7545. * Adds a vec3 to the uniform buffer.
  7546. * @param name Name of the uniform, as used in the uniform block in the shader.
  7547. * @param x Define the x component value of the vec3
  7548. * @param y Define the y component value of the vec3
  7549. * @param z Define the z component value of the vec3
  7550. */
  7551. addFloat3(name: string, x: number, y: number, z: number): void;
  7552. /**
  7553. * Adds a vec3 to the uniform buffer.
  7554. * @param name Name of the uniform, as used in the uniform block in the shader.
  7555. * @param color Define the vec3 from a Color
  7556. */
  7557. addColor3(name: string, color: Color3): void;
  7558. /**
  7559. * Adds a vec4 to the uniform buffer.
  7560. * @param name Name of the uniform, as used in the uniform block in the shader.
  7561. * @param color Define the rgb components from a Color
  7562. * @param alpha Define the a component of the vec4
  7563. */
  7564. addColor4(name: string, color: Color3, alpha: number): void;
  7565. /**
  7566. * Adds a vec3 to the uniform buffer.
  7567. * @param name Name of the uniform, as used in the uniform block in the shader.
  7568. * @param vector Define the vec3 components from a Vector
  7569. */
  7570. addVector3(name: string, vector: Vector3): void;
  7571. /**
  7572. * Adds a Matrix 3x3 to the uniform buffer.
  7573. * @param name Name of the uniform, as used in the uniform block in the shader.
  7574. */
  7575. addMatrix3x3(name: string): void;
  7576. /**
  7577. * Adds a Matrix 2x2 to the uniform buffer.
  7578. * @param name Name of the uniform, as used in the uniform block in the shader.
  7579. */
  7580. addMatrix2x2(name: string): void;
  7581. /**
  7582. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7583. */
  7584. create(): void;
  7585. /** @hidden */
  7586. _rebuild(): void;
  7587. /**
  7588. * Updates the WebGL Uniform Buffer on the GPU.
  7589. * If the `dynamic` flag is set to true, no cache comparison is done.
  7590. * Otherwise, the buffer will be updated only if the cache differs.
  7591. */
  7592. update(): void;
  7593. /**
  7594. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7595. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7596. * @param data Define the flattened data
  7597. * @param size Define the size of the data.
  7598. */
  7599. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7600. private _valueCache;
  7601. private _cacheMatrix;
  7602. private _updateMatrix3x3ForUniform;
  7603. private _updateMatrix3x3ForEffect;
  7604. private _updateMatrix2x2ForEffect;
  7605. private _updateMatrix2x2ForUniform;
  7606. private _updateFloatForEffect;
  7607. private _updateFloatForUniform;
  7608. private _updateFloat2ForEffect;
  7609. private _updateFloat2ForUniform;
  7610. private _updateFloat3ForEffect;
  7611. private _updateFloat3ForUniform;
  7612. private _updateFloat4ForEffect;
  7613. private _updateFloat4ForUniform;
  7614. private _updateMatrixForEffect;
  7615. private _updateMatrixForUniform;
  7616. private _updateVector3ForEffect;
  7617. private _updateVector3ForUniform;
  7618. private _updateVector4ForEffect;
  7619. private _updateVector4ForUniform;
  7620. private _updateColor3ForEffect;
  7621. private _updateColor3ForUniform;
  7622. private _updateColor4ForEffect;
  7623. private _updateColor4ForUniform;
  7624. /**
  7625. * Sets a sampler uniform on the effect.
  7626. * @param name Define the name of the sampler.
  7627. * @param texture Define the texture to set in the sampler
  7628. */
  7629. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7630. /**
  7631. * Directly updates the value of the uniform in the cache AND on the GPU.
  7632. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7633. * @param data Define the flattened data
  7634. */
  7635. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7636. /**
  7637. * Binds this uniform buffer to an effect.
  7638. * @param effect Define the effect to bind the buffer to
  7639. * @param name Name of the uniform block in the shader.
  7640. */
  7641. bindToEffect(effect: Effect, name: string): void;
  7642. /**
  7643. * Disposes the uniform buffer.
  7644. */
  7645. dispose(): void;
  7646. }
  7647. }
  7648. declare module BABYLON {
  7649. /**
  7650. * Enum that determines the text-wrapping mode to use.
  7651. */
  7652. export enum InspectableType {
  7653. /**
  7654. * Checkbox for booleans
  7655. */
  7656. Checkbox = 0,
  7657. /**
  7658. * Sliders for numbers
  7659. */
  7660. Slider = 1,
  7661. /**
  7662. * Vector3
  7663. */
  7664. Vector3 = 2,
  7665. /**
  7666. * Quaternions
  7667. */
  7668. Quaternion = 3,
  7669. /**
  7670. * Color3
  7671. */
  7672. Color3 = 4,
  7673. /**
  7674. * String
  7675. */
  7676. String = 5
  7677. }
  7678. /**
  7679. * Interface used to define custom inspectable properties.
  7680. * This interface is used by the inspector to display custom property grids
  7681. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7682. */
  7683. export interface IInspectable {
  7684. /**
  7685. * Gets the label to display
  7686. */
  7687. label: string;
  7688. /**
  7689. * Gets the name of the property to edit
  7690. */
  7691. propertyName: string;
  7692. /**
  7693. * Gets the type of the editor to use
  7694. */
  7695. type: InspectableType;
  7696. /**
  7697. * Gets the minimum value of the property when using in "slider" mode
  7698. */
  7699. min?: number;
  7700. /**
  7701. * Gets the maximum value of the property when using in "slider" mode
  7702. */
  7703. max?: number;
  7704. /**
  7705. * Gets the setp to use when using in "slider" mode
  7706. */
  7707. step?: number;
  7708. }
  7709. }
  7710. declare module BABYLON {
  7711. /**
  7712. * Class used to provide helper for timing
  7713. */
  7714. export class TimingTools {
  7715. /**
  7716. * Polyfill for setImmediate
  7717. * @param action defines the action to execute after the current execution block
  7718. */
  7719. static SetImmediate(action: () => void): void;
  7720. }
  7721. }
  7722. declare module BABYLON {
  7723. /**
  7724. * Class used to enable instatition of objects by class name
  7725. */
  7726. export class InstantiationTools {
  7727. /**
  7728. * Use this object to register external classes like custom textures or material
  7729. * to allow the laoders to instantiate them
  7730. */
  7731. static RegisteredExternalClasses: {
  7732. [key: string]: Object;
  7733. };
  7734. /**
  7735. * Tries to instantiate a new object from a given class name
  7736. * @param className defines the class name to instantiate
  7737. * @returns the new object or null if the system was not able to do the instantiation
  7738. */
  7739. static Instantiate(className: string): any;
  7740. }
  7741. }
  7742. declare module BABYLON {
  7743. /**
  7744. * Define options used to create a depth texture
  7745. */
  7746. export class DepthTextureCreationOptions {
  7747. /** Specifies whether or not a stencil should be allocated in the texture */
  7748. generateStencil?: boolean;
  7749. /** Specifies whether or not bilinear filtering is enable on the texture */
  7750. bilinearFiltering?: boolean;
  7751. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7752. comparisonFunction?: number;
  7753. /** Specifies if the created texture is a cube texture */
  7754. isCube?: boolean;
  7755. }
  7756. }
  7757. declare module BABYLON {
  7758. interface ThinEngine {
  7759. /**
  7760. * Creates a depth stencil cube texture.
  7761. * This is only available in WebGL 2.
  7762. * @param size The size of face edge in the cube texture.
  7763. * @param options The options defining the cube texture.
  7764. * @returns The cube texture
  7765. */
  7766. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7767. /**
  7768. * Creates a cube texture
  7769. * @param rootUrl defines the url where the files to load is located
  7770. * @param scene defines the current scene
  7771. * @param files defines the list of files to load (1 per face)
  7772. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7773. * @param onLoad defines an optional callback raised when the texture is loaded
  7774. * @param onError defines an optional callback raised if there is an issue to load the texture
  7775. * @param format defines the format of the data
  7776. * @param forcedExtension defines the extension to use to pick the right loader
  7777. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7778. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7779. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7780. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7781. * @returns the cube texture as an InternalTexture
  7782. */
  7783. 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;
  7784. /**
  7785. * Creates a cube texture
  7786. * @param rootUrl defines the url where the files to load is located
  7787. * @param scene defines the current scene
  7788. * @param files defines the list of files to load (1 per face)
  7789. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7790. * @param onLoad defines an optional callback raised when the texture is loaded
  7791. * @param onError defines an optional callback raised if there is an issue to load the texture
  7792. * @param format defines the format of the data
  7793. * @param forcedExtension defines the extension to use to pick the right loader
  7794. * @returns the cube texture as an InternalTexture
  7795. */
  7796. 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;
  7797. /**
  7798. * Creates a cube texture
  7799. * @param rootUrl defines the url where the files to load is located
  7800. * @param scene defines the current scene
  7801. * @param files defines the list of files to load (1 per face)
  7802. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7803. * @param onLoad defines an optional callback raised when the texture is loaded
  7804. * @param onError defines an optional callback raised if there is an issue to load the texture
  7805. * @param format defines the format of the data
  7806. * @param forcedExtension defines the extension to use to pick the right loader
  7807. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7808. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7809. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7810. * @returns the cube texture as an InternalTexture
  7811. */
  7812. 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;
  7813. /** @hidden */
  7814. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7815. /** @hidden */
  7816. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7817. /** @hidden */
  7818. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7819. /** @hidden */
  7820. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7821. /**
  7822. * @hidden
  7823. */
  7824. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7825. }
  7826. }
  7827. declare module BABYLON {
  7828. /**
  7829. * Class for creating a cube texture
  7830. */
  7831. export class CubeTexture extends BaseTexture {
  7832. private _delayedOnLoad;
  7833. /**
  7834. * Observable triggered once the texture has been loaded.
  7835. */
  7836. onLoadObservable: Observable<CubeTexture>;
  7837. /**
  7838. * The url of the texture
  7839. */
  7840. url: string;
  7841. /**
  7842. * Gets or sets the center of the bounding box associated with the cube texture.
  7843. * It must define where the camera used to render the texture was set
  7844. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7845. */
  7846. boundingBoxPosition: Vector3;
  7847. private _boundingBoxSize;
  7848. /**
  7849. * Gets or sets the size of the bounding box associated with the cube texture
  7850. * When defined, the cubemap will switch to local mode
  7851. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7852. * @example https://www.babylonjs-playground.com/#RNASML
  7853. */
  7854. set boundingBoxSize(value: Vector3);
  7855. /**
  7856. * Returns the bounding box size
  7857. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7858. */
  7859. get boundingBoxSize(): Vector3;
  7860. protected _rotationY: number;
  7861. /**
  7862. * Sets texture matrix rotation angle around Y axis in radians.
  7863. */
  7864. set rotationY(value: number);
  7865. /**
  7866. * Gets texture matrix rotation angle around Y axis radians.
  7867. */
  7868. get rotationY(): number;
  7869. /**
  7870. * Are mip maps generated for this texture or not.
  7871. */
  7872. get noMipmap(): boolean;
  7873. private _noMipmap;
  7874. private _files;
  7875. protected _forcedExtension: Nullable<string>;
  7876. private _extensions;
  7877. private _textureMatrix;
  7878. private _format;
  7879. private _createPolynomials;
  7880. /**
  7881. * Creates a cube texture from an array of image urls
  7882. * @param files defines an array of image urls
  7883. * @param scene defines the hosting scene
  7884. * @param noMipmap specifies if mip maps are not used
  7885. * @returns a cube texture
  7886. */
  7887. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7888. /**
  7889. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7890. * @param url defines the url of the prefiltered texture
  7891. * @param scene defines the scene the texture is attached to
  7892. * @param forcedExtension defines the extension of the file if different from the url
  7893. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7894. * @return the prefiltered texture
  7895. */
  7896. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7897. /**
  7898. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7899. * as prefiltered data.
  7900. * @param rootUrl defines the url of the texture or the root name of the six images
  7901. * @param null defines the scene or engine the texture is attached to
  7902. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7903. * @param noMipmap defines if mipmaps should be created or not
  7904. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7905. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7906. * @param onError defines a callback triggered in case of error during load
  7907. * @param format defines the internal format to use for the texture once loaded
  7908. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7909. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7910. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7911. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7912. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7913. * @return the cube texture
  7914. */
  7915. 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);
  7916. /**
  7917. * Get the current class name of the texture useful for serialization or dynamic coding.
  7918. * @returns "CubeTexture"
  7919. */
  7920. getClassName(): string;
  7921. /**
  7922. * Update the url (and optional buffer) of this texture if url was null during construction.
  7923. * @param url the url of the texture
  7924. * @param forcedExtension defines the extension to use
  7925. * @param onLoad callback called when the texture is loaded (defaults to null)
  7926. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7927. */
  7928. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7929. /**
  7930. * Delays loading of the cube texture
  7931. * @param forcedExtension defines the extension to use
  7932. */
  7933. delayLoad(forcedExtension?: string): void;
  7934. /**
  7935. * Returns the reflection texture matrix
  7936. * @returns the reflection texture matrix
  7937. */
  7938. getReflectionTextureMatrix(): Matrix;
  7939. /**
  7940. * Sets the reflection texture matrix
  7941. * @param value Reflection texture matrix
  7942. */
  7943. setReflectionTextureMatrix(value: Matrix): void;
  7944. /**
  7945. * Parses text to create a cube texture
  7946. * @param parsedTexture define the serialized text to read from
  7947. * @param scene defines the hosting scene
  7948. * @param rootUrl defines the root url of the cube texture
  7949. * @returns a cube texture
  7950. */
  7951. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7952. /**
  7953. * Makes a clone, or deep copy, of the cube texture
  7954. * @returns a new cube texture
  7955. */
  7956. clone(): CubeTexture;
  7957. }
  7958. }
  7959. declare module BABYLON {
  7960. /**
  7961. * Manages the defines for the Material
  7962. */
  7963. export class MaterialDefines {
  7964. /** @hidden */
  7965. protected _keys: string[];
  7966. private _isDirty;
  7967. /** @hidden */
  7968. _renderId: number;
  7969. /** @hidden */
  7970. _areLightsDirty: boolean;
  7971. /** @hidden */
  7972. _areLightsDisposed: boolean;
  7973. /** @hidden */
  7974. _areAttributesDirty: boolean;
  7975. /** @hidden */
  7976. _areTexturesDirty: boolean;
  7977. /** @hidden */
  7978. _areFresnelDirty: boolean;
  7979. /** @hidden */
  7980. _areMiscDirty: boolean;
  7981. /** @hidden */
  7982. _areImageProcessingDirty: boolean;
  7983. /** @hidden */
  7984. _normals: boolean;
  7985. /** @hidden */
  7986. _uvs: boolean;
  7987. /** @hidden */
  7988. _needNormals: boolean;
  7989. /** @hidden */
  7990. _needUVs: boolean;
  7991. [id: string]: any;
  7992. /**
  7993. * Specifies if the material needs to be re-calculated
  7994. */
  7995. get isDirty(): boolean;
  7996. /**
  7997. * Marks the material to indicate that it has been re-calculated
  7998. */
  7999. markAsProcessed(): void;
  8000. /**
  8001. * Marks the material to indicate that it needs to be re-calculated
  8002. */
  8003. markAsUnprocessed(): void;
  8004. /**
  8005. * Marks the material to indicate all of its defines need to be re-calculated
  8006. */
  8007. markAllAsDirty(): void;
  8008. /**
  8009. * Marks the material to indicate that image processing needs to be re-calculated
  8010. */
  8011. markAsImageProcessingDirty(): void;
  8012. /**
  8013. * Marks the material to indicate the lights need to be re-calculated
  8014. * @param disposed Defines whether the light is dirty due to dispose or not
  8015. */
  8016. markAsLightDirty(disposed?: boolean): void;
  8017. /**
  8018. * Marks the attribute state as changed
  8019. */
  8020. markAsAttributesDirty(): void;
  8021. /**
  8022. * Marks the texture state as changed
  8023. */
  8024. markAsTexturesDirty(): void;
  8025. /**
  8026. * Marks the fresnel state as changed
  8027. */
  8028. markAsFresnelDirty(): void;
  8029. /**
  8030. * Marks the misc state as changed
  8031. */
  8032. markAsMiscDirty(): void;
  8033. /**
  8034. * Rebuilds the material defines
  8035. */
  8036. rebuild(): void;
  8037. /**
  8038. * Specifies if two material defines are equal
  8039. * @param other - A material define instance to compare to
  8040. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8041. */
  8042. isEqual(other: MaterialDefines): boolean;
  8043. /**
  8044. * Clones this instance's defines to another instance
  8045. * @param other - material defines to clone values to
  8046. */
  8047. cloneTo(other: MaterialDefines): void;
  8048. /**
  8049. * Resets the material define values
  8050. */
  8051. reset(): void;
  8052. /**
  8053. * Converts the material define values to a string
  8054. * @returns - String of material define information
  8055. */
  8056. toString(): string;
  8057. }
  8058. }
  8059. declare module BABYLON {
  8060. /**
  8061. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8062. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8063. * 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;
  8064. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8065. */
  8066. export class ColorCurves {
  8067. private _dirty;
  8068. private _tempColor;
  8069. private _globalCurve;
  8070. private _highlightsCurve;
  8071. private _midtonesCurve;
  8072. private _shadowsCurve;
  8073. private _positiveCurve;
  8074. private _negativeCurve;
  8075. private _globalHue;
  8076. private _globalDensity;
  8077. private _globalSaturation;
  8078. private _globalExposure;
  8079. /**
  8080. * Gets the global Hue value.
  8081. * 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).
  8082. */
  8083. get globalHue(): number;
  8084. /**
  8085. * Sets the global Hue value.
  8086. * 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).
  8087. */
  8088. set globalHue(value: number);
  8089. /**
  8090. * Gets the global Density value.
  8091. * 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.
  8092. * Values less than zero provide a filter of opposite hue.
  8093. */
  8094. get globalDensity(): number;
  8095. /**
  8096. * Sets the global 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. set globalDensity(value: number);
  8101. /**
  8102. * Gets the global Saturation value.
  8103. * 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.
  8104. */
  8105. get globalSaturation(): number;
  8106. /**
  8107. * Sets the global Saturation value.
  8108. * 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.
  8109. */
  8110. set globalSaturation(value: number);
  8111. /**
  8112. * Gets the global Exposure value.
  8113. * 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.
  8114. */
  8115. get globalExposure(): number;
  8116. /**
  8117. * Sets the global Exposure value.
  8118. * 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.
  8119. */
  8120. set globalExposure(value: number);
  8121. private _highlightsHue;
  8122. private _highlightsDensity;
  8123. private _highlightsSaturation;
  8124. private _highlightsExposure;
  8125. /**
  8126. * Gets the highlights Hue value.
  8127. * 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).
  8128. */
  8129. get highlightsHue(): number;
  8130. /**
  8131. * Sets the highlights Hue value.
  8132. * 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).
  8133. */
  8134. set highlightsHue(value: number);
  8135. /**
  8136. * Gets the highlights Density value.
  8137. * 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.
  8138. * Values less than zero provide a filter of opposite hue.
  8139. */
  8140. get highlightsDensity(): number;
  8141. /**
  8142. * Sets the highlights 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. set highlightsDensity(value: number);
  8147. /**
  8148. * Gets the highlights Saturation value.
  8149. * 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.
  8150. */
  8151. get highlightsSaturation(): number;
  8152. /**
  8153. * Sets the highlights Saturation value.
  8154. * 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.
  8155. */
  8156. set highlightsSaturation(value: number);
  8157. /**
  8158. * Gets the highlights Exposure value.
  8159. * 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.
  8160. */
  8161. get highlightsExposure(): number;
  8162. /**
  8163. * Sets the highlights Exposure value.
  8164. * 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.
  8165. */
  8166. set highlightsExposure(value: number);
  8167. private _midtonesHue;
  8168. private _midtonesDensity;
  8169. private _midtonesSaturation;
  8170. private _midtonesExposure;
  8171. /**
  8172. * Gets the midtones Hue value.
  8173. * 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).
  8174. */
  8175. get midtonesHue(): number;
  8176. /**
  8177. * Sets the midtones Hue value.
  8178. * 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).
  8179. */
  8180. set midtonesHue(value: number);
  8181. /**
  8182. * Gets the midtones Density value.
  8183. * 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.
  8184. * Values less than zero provide a filter of opposite hue.
  8185. */
  8186. get midtonesDensity(): number;
  8187. /**
  8188. * Sets the midtones 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. set midtonesDensity(value: number);
  8193. /**
  8194. * Gets the midtones Saturation value.
  8195. * 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.
  8196. */
  8197. get midtonesSaturation(): number;
  8198. /**
  8199. * Sets the midtones Saturation value.
  8200. * 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.
  8201. */
  8202. set midtonesSaturation(value: number);
  8203. /**
  8204. * Gets the midtones Exposure value.
  8205. * 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.
  8206. */
  8207. get midtonesExposure(): number;
  8208. /**
  8209. * Sets the midtones Exposure value.
  8210. * 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.
  8211. */
  8212. set midtonesExposure(value: number);
  8213. private _shadowsHue;
  8214. private _shadowsDensity;
  8215. private _shadowsSaturation;
  8216. private _shadowsExposure;
  8217. /**
  8218. * Gets the shadows Hue value.
  8219. * 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).
  8220. */
  8221. get shadowsHue(): number;
  8222. /**
  8223. * Sets the shadows Hue value.
  8224. * 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).
  8225. */
  8226. set shadowsHue(value: number);
  8227. /**
  8228. * Gets the shadows Density value.
  8229. * 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.
  8230. * Values less than zero provide a filter of opposite hue.
  8231. */
  8232. get shadowsDensity(): number;
  8233. /**
  8234. * Sets the shadows Density value.
  8235. * 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.
  8236. * Values less than zero provide a filter of opposite hue.
  8237. */
  8238. set shadowsDensity(value: number);
  8239. /**
  8240. * Gets the shadows Saturation value.
  8241. * 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.
  8242. */
  8243. get shadowsSaturation(): number;
  8244. /**
  8245. * Sets the shadows Saturation value.
  8246. * 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.
  8247. */
  8248. set shadowsSaturation(value: number);
  8249. /**
  8250. * Gets the shadows Exposure value.
  8251. * 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.
  8252. */
  8253. get shadowsExposure(): number;
  8254. /**
  8255. * Sets the shadows Exposure value.
  8256. * 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.
  8257. */
  8258. set shadowsExposure(value: number);
  8259. /**
  8260. * Returns the class name
  8261. * @returns The class name
  8262. */
  8263. getClassName(): string;
  8264. /**
  8265. * Binds the color curves to the shader.
  8266. * @param colorCurves The color curve to bind
  8267. * @param effect The effect to bind to
  8268. * @param positiveUniform The positive uniform shader parameter
  8269. * @param neutralUniform The neutral uniform shader parameter
  8270. * @param negativeUniform The negative uniform shader parameter
  8271. */
  8272. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8273. /**
  8274. * Prepare the list of uniforms associated with the ColorCurves effects.
  8275. * @param uniformsList The list of uniforms used in the effect
  8276. */
  8277. static PrepareUniforms(uniformsList: string[]): void;
  8278. /**
  8279. * Returns color grading data based on a hue, density, saturation and exposure value.
  8280. * @param filterHue The hue of the color filter.
  8281. * @param filterDensity The density of the color filter.
  8282. * @param saturation The saturation.
  8283. * @param exposure The exposure.
  8284. * @param result The result data container.
  8285. */
  8286. private getColorGradingDataToRef;
  8287. /**
  8288. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8289. * @param value The input slider value in range [-100,100].
  8290. * @returns Adjusted value.
  8291. */
  8292. private static applyColorGradingSliderNonlinear;
  8293. /**
  8294. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8295. * @param hue The hue (H) input.
  8296. * @param saturation The saturation (S) input.
  8297. * @param brightness The brightness (B) input.
  8298. * @result An RGBA color represented as Vector4.
  8299. */
  8300. private static fromHSBToRef;
  8301. /**
  8302. * Returns a value clamped between min and max
  8303. * @param value The value to clamp
  8304. * @param min The minimum of value
  8305. * @param max The maximum of value
  8306. * @returns The clamped value.
  8307. */
  8308. private static clamp;
  8309. /**
  8310. * Clones the current color curve instance.
  8311. * @return The cloned curves
  8312. */
  8313. clone(): ColorCurves;
  8314. /**
  8315. * Serializes the current color curve instance to a json representation.
  8316. * @return a JSON representation
  8317. */
  8318. serialize(): any;
  8319. /**
  8320. * Parses the color curve from a json representation.
  8321. * @param source the JSON source to parse
  8322. * @return The parsed curves
  8323. */
  8324. static Parse(source: any): ColorCurves;
  8325. }
  8326. }
  8327. declare module BABYLON {
  8328. /**
  8329. * Interface to follow in your material defines to integrate easily the
  8330. * Image proccessing functions.
  8331. * @hidden
  8332. */
  8333. export interface IImageProcessingConfigurationDefines {
  8334. IMAGEPROCESSING: boolean;
  8335. VIGNETTE: boolean;
  8336. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8337. VIGNETTEBLENDMODEOPAQUE: boolean;
  8338. TONEMAPPING: boolean;
  8339. TONEMAPPING_ACES: boolean;
  8340. CONTRAST: boolean;
  8341. EXPOSURE: boolean;
  8342. COLORCURVES: boolean;
  8343. COLORGRADING: boolean;
  8344. COLORGRADING3D: boolean;
  8345. SAMPLER3DGREENDEPTH: boolean;
  8346. SAMPLER3DBGRMAP: boolean;
  8347. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8348. }
  8349. /**
  8350. * @hidden
  8351. */
  8352. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8353. IMAGEPROCESSING: boolean;
  8354. VIGNETTE: boolean;
  8355. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8356. VIGNETTEBLENDMODEOPAQUE: boolean;
  8357. TONEMAPPING: boolean;
  8358. TONEMAPPING_ACES: boolean;
  8359. CONTRAST: boolean;
  8360. COLORCURVES: boolean;
  8361. COLORGRADING: boolean;
  8362. COLORGRADING3D: boolean;
  8363. SAMPLER3DGREENDEPTH: boolean;
  8364. SAMPLER3DBGRMAP: boolean;
  8365. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8366. EXPOSURE: boolean;
  8367. constructor();
  8368. }
  8369. /**
  8370. * This groups together the common properties used for image processing either in direct forward pass
  8371. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8372. * or not.
  8373. */
  8374. export class ImageProcessingConfiguration {
  8375. /**
  8376. * Default tone mapping applied in BabylonJS.
  8377. */
  8378. static readonly TONEMAPPING_STANDARD: number;
  8379. /**
  8380. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8381. * to other engines rendering to increase portability.
  8382. */
  8383. static readonly TONEMAPPING_ACES: number;
  8384. /**
  8385. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8386. */
  8387. colorCurves: Nullable<ColorCurves>;
  8388. private _colorCurvesEnabled;
  8389. /**
  8390. * Gets wether the color curves effect is enabled.
  8391. */
  8392. get colorCurvesEnabled(): boolean;
  8393. /**
  8394. * Sets wether the color curves effect is enabled.
  8395. */
  8396. set colorCurvesEnabled(value: boolean);
  8397. private _colorGradingTexture;
  8398. /**
  8399. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8400. */
  8401. get colorGradingTexture(): Nullable<BaseTexture>;
  8402. /**
  8403. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8404. */
  8405. set colorGradingTexture(value: Nullable<BaseTexture>);
  8406. private _colorGradingEnabled;
  8407. /**
  8408. * Gets wether the color grading effect is enabled.
  8409. */
  8410. get colorGradingEnabled(): boolean;
  8411. /**
  8412. * Sets wether the color grading effect is enabled.
  8413. */
  8414. set colorGradingEnabled(value: boolean);
  8415. private _colorGradingWithGreenDepth;
  8416. /**
  8417. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8418. */
  8419. get colorGradingWithGreenDepth(): boolean;
  8420. /**
  8421. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8422. */
  8423. set colorGradingWithGreenDepth(value: boolean);
  8424. private _colorGradingBGR;
  8425. /**
  8426. * Gets wether the color grading texture contains BGR values.
  8427. */
  8428. get colorGradingBGR(): boolean;
  8429. /**
  8430. * Sets wether the color grading texture contains BGR values.
  8431. */
  8432. set colorGradingBGR(value: boolean);
  8433. /** @hidden */
  8434. _exposure: number;
  8435. /**
  8436. * Gets the Exposure used in the effect.
  8437. */
  8438. get exposure(): number;
  8439. /**
  8440. * Sets the Exposure used in the effect.
  8441. */
  8442. set exposure(value: number);
  8443. private _toneMappingEnabled;
  8444. /**
  8445. * Gets wether the tone mapping effect is enabled.
  8446. */
  8447. get toneMappingEnabled(): boolean;
  8448. /**
  8449. * Sets wether the tone mapping effect is enabled.
  8450. */
  8451. set toneMappingEnabled(value: boolean);
  8452. private _toneMappingType;
  8453. /**
  8454. * Gets the type of tone mapping effect.
  8455. */
  8456. get toneMappingType(): number;
  8457. /**
  8458. * Sets the type of tone mapping effect used in BabylonJS.
  8459. */
  8460. set toneMappingType(value: number);
  8461. protected _contrast: number;
  8462. /**
  8463. * Gets the contrast used in the effect.
  8464. */
  8465. get contrast(): number;
  8466. /**
  8467. * Sets the contrast used in the effect.
  8468. */
  8469. set contrast(value: number);
  8470. /**
  8471. * Vignette stretch size.
  8472. */
  8473. vignetteStretch: number;
  8474. /**
  8475. * Vignette centre X Offset.
  8476. */
  8477. vignetteCentreX: number;
  8478. /**
  8479. * Vignette centre Y Offset.
  8480. */
  8481. vignetteCentreY: number;
  8482. /**
  8483. * Vignette weight or intensity of the vignette effect.
  8484. */
  8485. vignetteWeight: number;
  8486. /**
  8487. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8488. * if vignetteEnabled is set to true.
  8489. */
  8490. vignetteColor: Color4;
  8491. /**
  8492. * Camera field of view used by the Vignette effect.
  8493. */
  8494. vignetteCameraFov: number;
  8495. private _vignetteBlendMode;
  8496. /**
  8497. * Gets the vignette blend mode allowing different kind of effect.
  8498. */
  8499. get vignetteBlendMode(): number;
  8500. /**
  8501. * Sets the vignette blend mode allowing different kind of effect.
  8502. */
  8503. set vignetteBlendMode(value: number);
  8504. private _vignetteEnabled;
  8505. /**
  8506. * Gets wether the vignette effect is enabled.
  8507. */
  8508. get vignetteEnabled(): boolean;
  8509. /**
  8510. * Sets wether the vignette effect is enabled.
  8511. */
  8512. set vignetteEnabled(value: boolean);
  8513. private _applyByPostProcess;
  8514. /**
  8515. * Gets wether the image processing is applied through a post process or not.
  8516. */
  8517. get applyByPostProcess(): boolean;
  8518. /**
  8519. * Sets wether the image processing is applied through a post process or not.
  8520. */
  8521. set applyByPostProcess(value: boolean);
  8522. private _isEnabled;
  8523. /**
  8524. * Gets wether the image processing is enabled or not.
  8525. */
  8526. get isEnabled(): boolean;
  8527. /**
  8528. * Sets wether the image processing is enabled or not.
  8529. */
  8530. set isEnabled(value: boolean);
  8531. /**
  8532. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8533. */
  8534. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8535. /**
  8536. * Method called each time the image processing information changes requires to recompile the effect.
  8537. */
  8538. protected _updateParameters(): void;
  8539. /**
  8540. * Gets the current class name.
  8541. * @return "ImageProcessingConfiguration"
  8542. */
  8543. getClassName(): string;
  8544. /**
  8545. * Prepare the list of uniforms associated with the Image Processing effects.
  8546. * @param uniforms The list of uniforms used in the effect
  8547. * @param defines the list of defines currently in use
  8548. */
  8549. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8550. /**
  8551. * Prepare the list of samplers associated with the Image Processing effects.
  8552. * @param samplersList The list of uniforms used in the effect
  8553. * @param defines the list of defines currently in use
  8554. */
  8555. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8556. /**
  8557. * Prepare the list of defines associated to the shader.
  8558. * @param defines the list of defines to complete
  8559. * @param forPostProcess Define if we are currently in post process mode or not
  8560. */
  8561. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8562. /**
  8563. * Returns true if all the image processing information are ready.
  8564. * @returns True if ready, otherwise, false
  8565. */
  8566. isReady(): boolean;
  8567. /**
  8568. * Binds the image processing to the shader.
  8569. * @param effect The effect to bind to
  8570. * @param overrideAspectRatio Override the aspect ratio of the effect
  8571. */
  8572. bind(effect: Effect, overrideAspectRatio?: number): void;
  8573. /**
  8574. * Clones the current image processing instance.
  8575. * @return The cloned image processing
  8576. */
  8577. clone(): ImageProcessingConfiguration;
  8578. /**
  8579. * Serializes the current image processing instance to a json representation.
  8580. * @return a JSON representation
  8581. */
  8582. serialize(): any;
  8583. /**
  8584. * Parses the image processing from a json representation.
  8585. * @param source the JSON source to parse
  8586. * @return The parsed image processing
  8587. */
  8588. static Parse(source: any): ImageProcessingConfiguration;
  8589. private static _VIGNETTEMODE_MULTIPLY;
  8590. private static _VIGNETTEMODE_OPAQUE;
  8591. /**
  8592. * Used to apply the vignette as a mix with the pixel color.
  8593. */
  8594. static get VIGNETTEMODE_MULTIPLY(): number;
  8595. /**
  8596. * Used to apply the vignette as a replacement of the pixel color.
  8597. */
  8598. static get VIGNETTEMODE_OPAQUE(): number;
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /** @hidden */
  8603. export var postprocessVertexShader: {
  8604. name: string;
  8605. shader: string;
  8606. };
  8607. }
  8608. declare module BABYLON {
  8609. /**
  8610. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8611. */
  8612. export type RenderTargetTextureSize = number | {
  8613. width: number;
  8614. height: number;
  8615. layers?: number;
  8616. };
  8617. interface ThinEngine {
  8618. /**
  8619. * Creates a new render target texture
  8620. * @param size defines the size of the texture
  8621. * @param options defines the options used to create the texture
  8622. * @returns a new render target texture stored in an InternalTexture
  8623. */
  8624. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8625. /**
  8626. * Creates a depth stencil texture.
  8627. * This is only available in WebGL 2 or with the depth texture extension available.
  8628. * @param size The size of face edge in the texture.
  8629. * @param options The options defining the texture.
  8630. * @returns The texture
  8631. */
  8632. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8633. /** @hidden */
  8634. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8635. }
  8636. }
  8637. declare module BABYLON {
  8638. /**
  8639. * Defines the kind of connection point for node based material
  8640. */
  8641. export enum NodeMaterialBlockConnectionPointTypes {
  8642. /** Float */
  8643. Float = 1,
  8644. /** Int */
  8645. Int = 2,
  8646. /** Vector2 */
  8647. Vector2 = 4,
  8648. /** Vector3 */
  8649. Vector3 = 8,
  8650. /** Vector4 */
  8651. Vector4 = 16,
  8652. /** Color3 */
  8653. Color3 = 32,
  8654. /** Color4 */
  8655. Color4 = 64,
  8656. /** Matrix */
  8657. Matrix = 128,
  8658. /** Custom object */
  8659. Object = 256,
  8660. /** Detect type based on connection */
  8661. AutoDetect = 1024,
  8662. /** Output type that will be defined by input type */
  8663. BasedOnInput = 2048
  8664. }
  8665. }
  8666. declare module BABYLON {
  8667. /**
  8668. * Enum used to define the target of a block
  8669. */
  8670. export enum NodeMaterialBlockTargets {
  8671. /** Vertex shader */
  8672. Vertex = 1,
  8673. /** Fragment shader */
  8674. Fragment = 2,
  8675. /** Neutral */
  8676. Neutral = 4,
  8677. /** Vertex and Fragment */
  8678. VertexAndFragment = 3
  8679. }
  8680. }
  8681. declare module BABYLON {
  8682. /**
  8683. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8684. */
  8685. export enum NodeMaterialBlockConnectionPointMode {
  8686. /** Value is an uniform */
  8687. Uniform = 0,
  8688. /** Value is a mesh attribute */
  8689. Attribute = 1,
  8690. /** Value is a varying between vertex and fragment shaders */
  8691. Varying = 2,
  8692. /** Mode is undefined */
  8693. Undefined = 3
  8694. }
  8695. }
  8696. declare module BABYLON {
  8697. /**
  8698. * Enum used to define system values e.g. values automatically provided by the system
  8699. */
  8700. export enum NodeMaterialSystemValues {
  8701. /** World */
  8702. World = 1,
  8703. /** View */
  8704. View = 2,
  8705. /** Projection */
  8706. Projection = 3,
  8707. /** ViewProjection */
  8708. ViewProjection = 4,
  8709. /** WorldView */
  8710. WorldView = 5,
  8711. /** WorldViewProjection */
  8712. WorldViewProjection = 6,
  8713. /** CameraPosition */
  8714. CameraPosition = 7,
  8715. /** Fog Color */
  8716. FogColor = 8,
  8717. /** Delta time */
  8718. DeltaTime = 9
  8719. }
  8720. }
  8721. declare module BABYLON {
  8722. /** Defines supported spaces */
  8723. export enum Space {
  8724. /** Local (object) space */
  8725. LOCAL = 0,
  8726. /** World space */
  8727. WORLD = 1,
  8728. /** Bone space */
  8729. BONE = 2
  8730. }
  8731. /** Defines the 3 main axes */
  8732. export class Axis {
  8733. /** X axis */
  8734. static X: Vector3;
  8735. /** Y axis */
  8736. static Y: Vector3;
  8737. /** Z axis */
  8738. static Z: Vector3;
  8739. }
  8740. }
  8741. declare module BABYLON {
  8742. /**
  8743. * Represents a camera frustum
  8744. */
  8745. export class Frustum {
  8746. /**
  8747. * Gets the planes representing the frustum
  8748. * @param transform matrix to be applied to the returned planes
  8749. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8750. */
  8751. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8752. /**
  8753. * Gets the near frustum plane transformed by the transform matrix
  8754. * @param transform transformation matrix to be applied to the resulting frustum plane
  8755. * @param frustumPlane the resuling frustum plane
  8756. */
  8757. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8758. /**
  8759. * Gets the far frustum plane transformed by the transform matrix
  8760. * @param transform transformation matrix to be applied to the resulting frustum plane
  8761. * @param frustumPlane the resuling frustum plane
  8762. */
  8763. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8764. /**
  8765. * Gets the left frustum plane transformed by the transform matrix
  8766. * @param transform transformation matrix to be applied to the resulting frustum plane
  8767. * @param frustumPlane the resuling frustum plane
  8768. */
  8769. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8770. /**
  8771. * Gets the right frustum plane transformed by the transform matrix
  8772. * @param transform transformation matrix to be applied to the resulting frustum plane
  8773. * @param frustumPlane the resuling frustum plane
  8774. */
  8775. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8776. /**
  8777. * Gets the top frustum plane transformed by the transform matrix
  8778. * @param transform transformation matrix to be applied to the resulting frustum plane
  8779. * @param frustumPlane the resuling frustum plane
  8780. */
  8781. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8782. /**
  8783. * Gets the bottom frustum plane transformed by the transform matrix
  8784. * @param transform transformation matrix to be applied to the resulting frustum plane
  8785. * @param frustumPlane the resuling frustum plane
  8786. */
  8787. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8788. /**
  8789. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8790. * @param transform transformation matrix to be applied to the resulting frustum planes
  8791. * @param frustumPlanes the resuling frustum planes
  8792. */
  8793. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8794. }
  8795. }
  8796. declare module BABYLON {
  8797. /**
  8798. * Interface for the size containing width and height
  8799. */
  8800. export interface ISize {
  8801. /**
  8802. * Width
  8803. */
  8804. width: number;
  8805. /**
  8806. * Heighht
  8807. */
  8808. height: number;
  8809. }
  8810. /**
  8811. * Size containing widht and height
  8812. */
  8813. export class Size implements ISize {
  8814. /**
  8815. * Width
  8816. */
  8817. width: number;
  8818. /**
  8819. * Height
  8820. */
  8821. height: number;
  8822. /**
  8823. * Creates a Size object from the given width and height (floats).
  8824. * @param width width of the new size
  8825. * @param height height of the new size
  8826. */
  8827. constructor(width: number, height: number);
  8828. /**
  8829. * Returns a string with the Size width and height
  8830. * @returns a string with the Size width and height
  8831. */
  8832. toString(): string;
  8833. /**
  8834. * "Size"
  8835. * @returns the string "Size"
  8836. */
  8837. getClassName(): string;
  8838. /**
  8839. * Returns the Size hash code.
  8840. * @returns a hash code for a unique width and height
  8841. */
  8842. getHashCode(): number;
  8843. /**
  8844. * Updates the current size from the given one.
  8845. * @param src the given size
  8846. */
  8847. copyFrom(src: Size): void;
  8848. /**
  8849. * Updates in place the current Size from the given floats.
  8850. * @param width width of the new size
  8851. * @param height height of the new size
  8852. * @returns the updated Size.
  8853. */
  8854. copyFromFloats(width: number, height: number): Size;
  8855. /**
  8856. * Updates in place the current Size from the given floats.
  8857. * @param width width to set
  8858. * @param height height to set
  8859. * @returns the updated Size.
  8860. */
  8861. set(width: number, height: number): Size;
  8862. /**
  8863. * Multiplies the width and height by numbers
  8864. * @param w factor to multiple the width by
  8865. * @param h factor to multiple the height by
  8866. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8867. */
  8868. multiplyByFloats(w: number, h: number): Size;
  8869. /**
  8870. * Clones the size
  8871. * @returns a new Size copied from the given one.
  8872. */
  8873. clone(): Size;
  8874. /**
  8875. * True if the current Size and the given one width and height are strictly equal.
  8876. * @param other the other size to compare against
  8877. * @returns True if the current Size and the given one width and height are strictly equal.
  8878. */
  8879. equals(other: Size): boolean;
  8880. /**
  8881. * The surface of the Size : width * height (float).
  8882. */
  8883. get surface(): number;
  8884. /**
  8885. * Create a new size of zero
  8886. * @returns a new Size set to (0.0, 0.0)
  8887. */
  8888. static Zero(): Size;
  8889. /**
  8890. * Sums the width and height of two sizes
  8891. * @param otherSize size to add to this size
  8892. * @returns a new Size set as the addition result of the current Size and the given one.
  8893. */
  8894. add(otherSize: Size): Size;
  8895. /**
  8896. * Subtracts the width and height of two
  8897. * @param otherSize size to subtract to this size
  8898. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8899. */
  8900. subtract(otherSize: Size): Size;
  8901. /**
  8902. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8903. * @param start starting size to lerp between
  8904. * @param end end size to lerp between
  8905. * @param amount amount to lerp between the start and end values
  8906. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8907. */
  8908. static Lerp(start: Size, end: Size, amount: number): Size;
  8909. }
  8910. }
  8911. declare module BABYLON {
  8912. /**
  8913. * Contains position and normal vectors for a vertex
  8914. */
  8915. export class PositionNormalVertex {
  8916. /** the position of the vertex (defaut: 0,0,0) */
  8917. position: Vector3;
  8918. /** the normal of the vertex (defaut: 0,1,0) */
  8919. normal: Vector3;
  8920. /**
  8921. * Creates a PositionNormalVertex
  8922. * @param position the position of the vertex (defaut: 0,0,0)
  8923. * @param normal the normal of the vertex (defaut: 0,1,0)
  8924. */
  8925. constructor(
  8926. /** the position of the vertex (defaut: 0,0,0) */
  8927. position?: Vector3,
  8928. /** the normal of the vertex (defaut: 0,1,0) */
  8929. normal?: Vector3);
  8930. /**
  8931. * Clones the PositionNormalVertex
  8932. * @returns the cloned PositionNormalVertex
  8933. */
  8934. clone(): PositionNormalVertex;
  8935. }
  8936. /**
  8937. * Contains position, normal and uv vectors for a vertex
  8938. */
  8939. export class PositionNormalTextureVertex {
  8940. /** the position of the vertex (defaut: 0,0,0) */
  8941. position: Vector3;
  8942. /** the normal of the vertex (defaut: 0,1,0) */
  8943. normal: Vector3;
  8944. /** the uv of the vertex (default: 0,0) */
  8945. uv: Vector2;
  8946. /**
  8947. * Creates a PositionNormalTextureVertex
  8948. * @param position the position of the vertex (defaut: 0,0,0)
  8949. * @param normal the normal of the vertex (defaut: 0,1,0)
  8950. * @param uv the uv of the vertex (default: 0,0)
  8951. */
  8952. constructor(
  8953. /** the position of the vertex (defaut: 0,0,0) */
  8954. position?: Vector3,
  8955. /** the normal of the vertex (defaut: 0,1,0) */
  8956. normal?: Vector3,
  8957. /** the uv of the vertex (default: 0,0) */
  8958. uv?: Vector2);
  8959. /**
  8960. * Clones the PositionNormalTextureVertex
  8961. * @returns the cloned PositionNormalTextureVertex
  8962. */
  8963. clone(): PositionNormalTextureVertex;
  8964. }
  8965. }
  8966. declare module BABYLON {
  8967. /**
  8968. * Enum defining the type of animations supported by InputBlock
  8969. */
  8970. export enum AnimatedInputBlockTypes {
  8971. /** No animation */
  8972. None = 0,
  8973. /** Time based animation. Will only work for floats */
  8974. Time = 1
  8975. }
  8976. }
  8977. declare module BABYLON {
  8978. /**
  8979. * Interface describing all the common properties and methods a shadow light needs to implement.
  8980. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8981. * as well as binding the different shadow properties to the effects.
  8982. */
  8983. export interface IShadowLight extends Light {
  8984. /**
  8985. * The light id in the scene (used in scene.findLighById for instance)
  8986. */
  8987. id: string;
  8988. /**
  8989. * The position the shdow will be casted from.
  8990. */
  8991. position: Vector3;
  8992. /**
  8993. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8994. */
  8995. direction: Vector3;
  8996. /**
  8997. * The transformed position. Position of the light in world space taking parenting in account.
  8998. */
  8999. transformedPosition: Vector3;
  9000. /**
  9001. * The transformed direction. Direction of the light in world space taking parenting in account.
  9002. */
  9003. transformedDirection: Vector3;
  9004. /**
  9005. * The friendly name of the light in the scene.
  9006. */
  9007. name: string;
  9008. /**
  9009. * Defines the shadow projection clipping minimum z value.
  9010. */
  9011. shadowMinZ: number;
  9012. /**
  9013. * Defines the shadow projection clipping maximum z value.
  9014. */
  9015. shadowMaxZ: number;
  9016. /**
  9017. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9018. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9019. */
  9020. computeTransformedInformation(): boolean;
  9021. /**
  9022. * Gets the scene the light belongs to.
  9023. * @returns The scene
  9024. */
  9025. getScene(): Scene;
  9026. /**
  9027. * Callback defining a custom Projection Matrix Builder.
  9028. * This can be used to override the default projection matrix computation.
  9029. */
  9030. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9031. /**
  9032. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9033. * @param matrix The materix to updated with the projection information
  9034. * @param viewMatrix The transform matrix of the light
  9035. * @param renderList The list of mesh to render in the map
  9036. * @returns The current light
  9037. */
  9038. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9039. /**
  9040. * Gets the current depth scale used in ESM.
  9041. * @returns The scale
  9042. */
  9043. getDepthScale(): number;
  9044. /**
  9045. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9046. * @returns true if a cube texture needs to be use
  9047. */
  9048. needCube(): boolean;
  9049. /**
  9050. * Detects if the projection matrix requires to be recomputed this frame.
  9051. * @returns true if it requires to be recomputed otherwise, false.
  9052. */
  9053. needProjectionMatrixCompute(): boolean;
  9054. /**
  9055. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9056. */
  9057. forceProjectionMatrixCompute(): void;
  9058. /**
  9059. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9060. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9061. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9062. */
  9063. getShadowDirection(faceIndex?: number): Vector3;
  9064. /**
  9065. * Gets the minZ used for shadow according to both the scene and the light.
  9066. * @param activeCamera The camera we are returning the min for
  9067. * @returns the depth min z
  9068. */
  9069. getDepthMinZ(activeCamera: Camera): number;
  9070. /**
  9071. * Gets the maxZ used for shadow according to both the scene and the light.
  9072. * @param activeCamera The camera we are returning the max for
  9073. * @returns the depth max z
  9074. */
  9075. getDepthMaxZ(activeCamera: Camera): number;
  9076. }
  9077. /**
  9078. * Base implementation IShadowLight
  9079. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9080. */
  9081. export abstract class ShadowLight extends Light implements IShadowLight {
  9082. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9083. protected _position: Vector3;
  9084. protected _setPosition(value: Vector3): void;
  9085. /**
  9086. * Sets the position the shadow will be casted from. Also use as the light position for both
  9087. * point and spot lights.
  9088. */
  9089. get position(): Vector3;
  9090. /**
  9091. * Sets the position the shadow will be casted from. Also use as the light position for both
  9092. * point and spot lights.
  9093. */
  9094. set position(value: Vector3);
  9095. protected _direction: Vector3;
  9096. protected _setDirection(value: Vector3): void;
  9097. /**
  9098. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9099. * Also use as the light direction on spot and directional lights.
  9100. */
  9101. get direction(): Vector3;
  9102. /**
  9103. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9104. * Also use as the light direction on spot and directional lights.
  9105. */
  9106. set direction(value: Vector3);
  9107. protected _shadowMinZ: number;
  9108. /**
  9109. * Gets the shadow projection clipping minimum z value.
  9110. */
  9111. get shadowMinZ(): number;
  9112. /**
  9113. * Sets the shadow projection clipping minimum z value.
  9114. */
  9115. set shadowMinZ(value: number);
  9116. protected _shadowMaxZ: number;
  9117. /**
  9118. * Sets the shadow projection clipping maximum z value.
  9119. */
  9120. get shadowMaxZ(): number;
  9121. /**
  9122. * Gets the shadow projection clipping maximum z value.
  9123. */
  9124. set shadowMaxZ(value: number);
  9125. /**
  9126. * Callback defining a custom Projection Matrix Builder.
  9127. * This can be used to override the default projection matrix computation.
  9128. */
  9129. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9130. /**
  9131. * The transformed position. Position of the light in world space taking parenting in account.
  9132. */
  9133. transformedPosition: Vector3;
  9134. /**
  9135. * The transformed direction. Direction of the light in world space taking parenting in account.
  9136. */
  9137. transformedDirection: Vector3;
  9138. private _needProjectionMatrixCompute;
  9139. /**
  9140. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9141. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9142. */
  9143. computeTransformedInformation(): boolean;
  9144. /**
  9145. * Return the depth scale used for the shadow map.
  9146. * @returns the depth scale.
  9147. */
  9148. getDepthScale(): number;
  9149. /**
  9150. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9151. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9152. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9153. */
  9154. getShadowDirection(faceIndex?: number): Vector3;
  9155. /**
  9156. * Returns the ShadowLight absolute position in the World.
  9157. * @returns the position vector in world space
  9158. */
  9159. getAbsolutePosition(): Vector3;
  9160. /**
  9161. * Sets the ShadowLight direction toward the passed target.
  9162. * @param target The point to target in local space
  9163. * @returns the updated ShadowLight direction
  9164. */
  9165. setDirectionToTarget(target: Vector3): Vector3;
  9166. /**
  9167. * Returns the light rotation in euler definition.
  9168. * @returns the x y z rotation in local space.
  9169. */
  9170. getRotation(): Vector3;
  9171. /**
  9172. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9173. * @returns true if a cube texture needs to be use
  9174. */
  9175. needCube(): boolean;
  9176. /**
  9177. * Detects if the projection matrix requires to be recomputed this frame.
  9178. * @returns true if it requires to be recomputed otherwise, false.
  9179. */
  9180. needProjectionMatrixCompute(): boolean;
  9181. /**
  9182. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9183. */
  9184. forceProjectionMatrixCompute(): void;
  9185. /** @hidden */
  9186. _initCache(): void;
  9187. /** @hidden */
  9188. _isSynchronized(): boolean;
  9189. /**
  9190. * Computes the world matrix of the node
  9191. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9192. * @returns the world matrix
  9193. */
  9194. computeWorldMatrix(force?: boolean): Matrix;
  9195. /**
  9196. * Gets the minZ used for shadow according to both the scene and the light.
  9197. * @param activeCamera The camera we are returning the min for
  9198. * @returns the depth min z
  9199. */
  9200. getDepthMinZ(activeCamera: Camera): number;
  9201. /**
  9202. * Gets the maxZ used for shadow according to both the scene and the light.
  9203. * @param activeCamera The camera we are returning the max for
  9204. * @returns the depth max z
  9205. */
  9206. getDepthMaxZ(activeCamera: Camera): number;
  9207. /**
  9208. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9209. * @param matrix The materix to updated with the projection information
  9210. * @param viewMatrix The transform matrix of the light
  9211. * @param renderList The list of mesh to render in the map
  9212. * @returns The current light
  9213. */
  9214. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9215. }
  9216. }
  9217. declare module BABYLON {
  9218. /** @hidden */
  9219. export var packingFunctions: {
  9220. name: string;
  9221. shader: string;
  9222. };
  9223. }
  9224. declare module BABYLON {
  9225. /** @hidden */
  9226. export var bayerDitherFunctions: {
  9227. name: string;
  9228. shader: string;
  9229. };
  9230. }
  9231. declare module BABYLON {
  9232. /** @hidden */
  9233. export var shadowMapFragmentDeclaration: {
  9234. name: string;
  9235. shader: string;
  9236. };
  9237. }
  9238. declare module BABYLON {
  9239. /** @hidden */
  9240. export var clipPlaneFragmentDeclaration: {
  9241. name: string;
  9242. shader: string;
  9243. };
  9244. }
  9245. declare module BABYLON {
  9246. /** @hidden */
  9247. export var clipPlaneFragment: {
  9248. name: string;
  9249. shader: string;
  9250. };
  9251. }
  9252. declare module BABYLON {
  9253. /** @hidden */
  9254. export var shadowMapFragment: {
  9255. name: string;
  9256. shader: string;
  9257. };
  9258. }
  9259. declare module BABYLON {
  9260. /** @hidden */
  9261. export var shadowMapPixelShader: {
  9262. name: string;
  9263. shader: string;
  9264. };
  9265. }
  9266. declare module BABYLON {
  9267. /** @hidden */
  9268. export var bonesDeclaration: {
  9269. name: string;
  9270. shader: string;
  9271. };
  9272. }
  9273. declare module BABYLON {
  9274. /** @hidden */
  9275. export var morphTargetsVertexGlobalDeclaration: {
  9276. name: string;
  9277. shader: string;
  9278. };
  9279. }
  9280. declare module BABYLON {
  9281. /** @hidden */
  9282. export var morphTargetsVertexDeclaration: {
  9283. name: string;
  9284. shader: string;
  9285. };
  9286. }
  9287. declare module BABYLON {
  9288. /** @hidden */
  9289. export var instancesDeclaration: {
  9290. name: string;
  9291. shader: string;
  9292. };
  9293. }
  9294. declare module BABYLON {
  9295. /** @hidden */
  9296. export var helperFunctions: {
  9297. name: string;
  9298. shader: string;
  9299. };
  9300. }
  9301. declare module BABYLON {
  9302. /** @hidden */
  9303. export var shadowMapVertexDeclaration: {
  9304. name: string;
  9305. shader: string;
  9306. };
  9307. }
  9308. declare module BABYLON {
  9309. /** @hidden */
  9310. export var clipPlaneVertexDeclaration: {
  9311. name: string;
  9312. shader: string;
  9313. };
  9314. }
  9315. declare module BABYLON {
  9316. /** @hidden */
  9317. export var morphTargetsVertex: {
  9318. name: string;
  9319. shader: string;
  9320. };
  9321. }
  9322. declare module BABYLON {
  9323. /** @hidden */
  9324. export var instancesVertex: {
  9325. name: string;
  9326. shader: string;
  9327. };
  9328. }
  9329. declare module BABYLON {
  9330. /** @hidden */
  9331. export var bonesVertex: {
  9332. name: string;
  9333. shader: string;
  9334. };
  9335. }
  9336. declare module BABYLON {
  9337. /** @hidden */
  9338. export var shadowMapVertexNormalBias: {
  9339. name: string;
  9340. shader: string;
  9341. };
  9342. }
  9343. declare module BABYLON {
  9344. /** @hidden */
  9345. export var shadowMapVertexMetric: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module BABYLON {
  9351. /** @hidden */
  9352. export var clipPlaneVertex: {
  9353. name: string;
  9354. shader: string;
  9355. };
  9356. }
  9357. declare module BABYLON {
  9358. /** @hidden */
  9359. export var shadowMapVertexShader: {
  9360. name: string;
  9361. shader: string;
  9362. };
  9363. }
  9364. declare module BABYLON {
  9365. /** @hidden */
  9366. export var depthBoxBlurPixelShader: {
  9367. name: string;
  9368. shader: string;
  9369. };
  9370. }
  9371. declare module BABYLON {
  9372. /** @hidden */
  9373. export var shadowMapFragmentSoftTransparentShadow: {
  9374. name: string;
  9375. shader: string;
  9376. };
  9377. }
  9378. declare module BABYLON {
  9379. /**
  9380. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9381. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9382. */
  9383. export class EffectFallbacks implements IEffectFallbacks {
  9384. private _defines;
  9385. private _currentRank;
  9386. private _maxRank;
  9387. private _mesh;
  9388. /**
  9389. * Removes the fallback from the bound mesh.
  9390. */
  9391. unBindMesh(): void;
  9392. /**
  9393. * Adds a fallback on the specified property.
  9394. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9395. * @param define The name of the define in the shader
  9396. */
  9397. addFallback(rank: number, define: string): void;
  9398. /**
  9399. * Sets the mesh to use CPU skinning when needing to fallback.
  9400. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9401. * @param mesh The mesh to use the fallbacks.
  9402. */
  9403. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9404. /**
  9405. * Checks to see if more fallbacks are still availible.
  9406. */
  9407. get hasMoreFallbacks(): boolean;
  9408. /**
  9409. * Removes the defines that should be removed when falling back.
  9410. * @param currentDefines defines the current define statements for the shader.
  9411. * @param effect defines the current effect we try to compile
  9412. * @returns The resulting defines with defines of the current rank removed.
  9413. */
  9414. reduce(currentDefines: string, effect: Effect): string;
  9415. }
  9416. }
  9417. declare module BABYLON {
  9418. /**
  9419. * Interface used to define Action
  9420. */
  9421. export interface IAction {
  9422. /**
  9423. * Trigger for the action
  9424. */
  9425. trigger: number;
  9426. /** Options of the trigger */
  9427. triggerOptions: any;
  9428. /**
  9429. * Gets the trigger parameters
  9430. * @returns the trigger parameters
  9431. */
  9432. getTriggerParameter(): any;
  9433. /**
  9434. * Internal only - executes current action event
  9435. * @hidden
  9436. */
  9437. _executeCurrent(evt?: ActionEvent): void;
  9438. /**
  9439. * Serialize placeholder for child classes
  9440. * @param parent of child
  9441. * @returns the serialized object
  9442. */
  9443. serialize(parent: any): any;
  9444. /**
  9445. * Internal only
  9446. * @hidden
  9447. */
  9448. _prepare(): void;
  9449. /**
  9450. * Internal only - manager for action
  9451. * @hidden
  9452. */
  9453. _actionManager: Nullable<AbstractActionManager>;
  9454. /**
  9455. * Adds action to chain of actions, may be a DoNothingAction
  9456. * @param action defines the next action to execute
  9457. * @returns The action passed in
  9458. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9459. */
  9460. then(action: IAction): IAction;
  9461. }
  9462. /**
  9463. * The action to be carried out following a trigger
  9464. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9465. */
  9466. export class Action implements IAction {
  9467. /** the trigger, with or without parameters, for the action */
  9468. triggerOptions: any;
  9469. /**
  9470. * Trigger for the action
  9471. */
  9472. trigger: number;
  9473. /**
  9474. * Internal only - manager for action
  9475. * @hidden
  9476. */
  9477. _actionManager: ActionManager;
  9478. private _nextActiveAction;
  9479. private _child;
  9480. private _condition?;
  9481. private _triggerParameter;
  9482. /**
  9483. * An event triggered prior to action being executed.
  9484. */
  9485. onBeforeExecuteObservable: Observable<Action>;
  9486. /**
  9487. * Creates a new Action
  9488. * @param triggerOptions the trigger, with or without parameters, for the action
  9489. * @param condition an optional determinant of action
  9490. */
  9491. constructor(
  9492. /** the trigger, with or without parameters, for the action */
  9493. triggerOptions: any, condition?: Condition);
  9494. /**
  9495. * Internal only
  9496. * @hidden
  9497. */
  9498. _prepare(): void;
  9499. /**
  9500. * Gets the trigger parameters
  9501. * @returns the trigger parameters
  9502. */
  9503. getTriggerParameter(): any;
  9504. /**
  9505. * Internal only - executes current action event
  9506. * @hidden
  9507. */
  9508. _executeCurrent(evt?: ActionEvent): void;
  9509. /**
  9510. * Execute placeholder for child classes
  9511. * @param evt optional action event
  9512. */
  9513. execute(evt?: ActionEvent): void;
  9514. /**
  9515. * Skips to next active action
  9516. */
  9517. skipToNextActiveAction(): void;
  9518. /**
  9519. * Adds action to chain of actions, may be a DoNothingAction
  9520. * @param action defines the next action to execute
  9521. * @returns The action passed in
  9522. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9523. */
  9524. then(action: Action): Action;
  9525. /**
  9526. * Internal only
  9527. * @hidden
  9528. */
  9529. _getProperty(propertyPath: string): string;
  9530. /**
  9531. * Internal only
  9532. * @hidden
  9533. */
  9534. _getEffectiveTarget(target: any, propertyPath: string): any;
  9535. /**
  9536. * Serialize placeholder for child classes
  9537. * @param parent of child
  9538. * @returns the serialized object
  9539. */
  9540. serialize(parent: any): any;
  9541. /**
  9542. * Internal only called by serialize
  9543. * @hidden
  9544. */
  9545. protected _serialize(serializedAction: any, parent?: any): any;
  9546. /**
  9547. * Internal only
  9548. * @hidden
  9549. */
  9550. static _SerializeValueAsString: (value: any) => string;
  9551. /**
  9552. * Internal only
  9553. * @hidden
  9554. */
  9555. static _GetTargetProperty: (target: Scene | Node) => {
  9556. name: string;
  9557. targetType: string;
  9558. value: string;
  9559. };
  9560. }
  9561. }
  9562. declare module BABYLON {
  9563. /**
  9564. * A Condition applied to an Action
  9565. */
  9566. export class Condition {
  9567. /**
  9568. * Internal only - manager for action
  9569. * @hidden
  9570. */
  9571. _actionManager: ActionManager;
  9572. /**
  9573. * Internal only
  9574. * @hidden
  9575. */
  9576. _evaluationId: number;
  9577. /**
  9578. * Internal only
  9579. * @hidden
  9580. */
  9581. _currentResult: boolean;
  9582. /**
  9583. * Creates a new Condition
  9584. * @param actionManager the manager of the action the condition is applied to
  9585. */
  9586. constructor(actionManager: ActionManager);
  9587. /**
  9588. * Check if the current condition is valid
  9589. * @returns a boolean
  9590. */
  9591. isValid(): boolean;
  9592. /**
  9593. * Internal only
  9594. * @hidden
  9595. */
  9596. _getProperty(propertyPath: string): string;
  9597. /**
  9598. * Internal only
  9599. * @hidden
  9600. */
  9601. _getEffectiveTarget(target: any, propertyPath: string): any;
  9602. /**
  9603. * Serialize placeholder for child classes
  9604. * @returns the serialized object
  9605. */
  9606. serialize(): any;
  9607. /**
  9608. * Internal only
  9609. * @hidden
  9610. */
  9611. protected _serialize(serializedCondition: any): any;
  9612. }
  9613. /**
  9614. * Defines specific conditional operators as extensions of Condition
  9615. */
  9616. export class ValueCondition extends Condition {
  9617. /** path to specify the property of the target the conditional operator uses */
  9618. propertyPath: string;
  9619. /** the value compared by the conditional operator against the current value of the property */
  9620. value: any;
  9621. /** the conditional operator, default ValueCondition.IsEqual */
  9622. operator: number;
  9623. /**
  9624. * Internal only
  9625. * @hidden
  9626. */
  9627. private static _IsEqual;
  9628. /**
  9629. * Internal only
  9630. * @hidden
  9631. */
  9632. private static _IsDifferent;
  9633. /**
  9634. * Internal only
  9635. * @hidden
  9636. */
  9637. private static _IsGreater;
  9638. /**
  9639. * Internal only
  9640. * @hidden
  9641. */
  9642. private static _IsLesser;
  9643. /**
  9644. * returns the number for IsEqual
  9645. */
  9646. static get IsEqual(): number;
  9647. /**
  9648. * Returns the number for IsDifferent
  9649. */
  9650. static get IsDifferent(): number;
  9651. /**
  9652. * Returns the number for IsGreater
  9653. */
  9654. static get IsGreater(): number;
  9655. /**
  9656. * Returns the number for IsLesser
  9657. */
  9658. static get IsLesser(): number;
  9659. /**
  9660. * Internal only The action manager for the condition
  9661. * @hidden
  9662. */
  9663. _actionManager: ActionManager;
  9664. /**
  9665. * Internal only
  9666. * @hidden
  9667. */
  9668. private _target;
  9669. /**
  9670. * Internal only
  9671. * @hidden
  9672. */
  9673. private _effectiveTarget;
  9674. /**
  9675. * Internal only
  9676. * @hidden
  9677. */
  9678. private _property;
  9679. /**
  9680. * Creates a new ValueCondition
  9681. * @param actionManager manager for the action the condition applies to
  9682. * @param target for the action
  9683. * @param propertyPath path to specify the property of the target the conditional operator uses
  9684. * @param value the value compared by the conditional operator against the current value of the property
  9685. * @param operator the conditional operator, default ValueCondition.IsEqual
  9686. */
  9687. constructor(actionManager: ActionManager, target: any,
  9688. /** path to specify the property of the target the conditional operator uses */
  9689. propertyPath: string,
  9690. /** the value compared by the conditional operator against the current value of the property */
  9691. value: any,
  9692. /** the conditional operator, default ValueCondition.IsEqual */
  9693. operator?: number);
  9694. /**
  9695. * Compares the given value with the property value for the specified conditional operator
  9696. * @returns the result of the comparison
  9697. */
  9698. isValid(): boolean;
  9699. /**
  9700. * Serialize the ValueCondition into a JSON compatible object
  9701. * @returns serialization object
  9702. */
  9703. serialize(): any;
  9704. /**
  9705. * Gets the name of the conditional operator for the ValueCondition
  9706. * @param operator the conditional operator
  9707. * @returns the name
  9708. */
  9709. static GetOperatorName(operator: number): string;
  9710. }
  9711. /**
  9712. * Defines a predicate condition as an extension of Condition
  9713. */
  9714. export class PredicateCondition extends Condition {
  9715. /** defines the predicate function used to validate the condition */
  9716. predicate: () => boolean;
  9717. /**
  9718. * Internal only - manager for action
  9719. * @hidden
  9720. */
  9721. _actionManager: ActionManager;
  9722. /**
  9723. * Creates a new PredicateCondition
  9724. * @param actionManager manager for the action the condition applies to
  9725. * @param predicate defines the predicate function used to validate the condition
  9726. */
  9727. constructor(actionManager: ActionManager,
  9728. /** defines the predicate function used to validate the condition */
  9729. predicate: () => boolean);
  9730. /**
  9731. * @returns the validity of the predicate condition
  9732. */
  9733. isValid(): boolean;
  9734. }
  9735. /**
  9736. * Defines a state condition as an extension of Condition
  9737. */
  9738. export class StateCondition extends Condition {
  9739. /** Value to compare with target state */
  9740. value: string;
  9741. /**
  9742. * Internal only - manager for action
  9743. * @hidden
  9744. */
  9745. _actionManager: ActionManager;
  9746. /**
  9747. * Internal only
  9748. * @hidden
  9749. */
  9750. private _target;
  9751. /**
  9752. * Creates a new StateCondition
  9753. * @param actionManager manager for the action the condition applies to
  9754. * @param target of the condition
  9755. * @param value to compare with target state
  9756. */
  9757. constructor(actionManager: ActionManager, target: any,
  9758. /** Value to compare with target state */
  9759. value: string);
  9760. /**
  9761. * Gets a boolean indicating if the current condition is met
  9762. * @returns the validity of the state
  9763. */
  9764. isValid(): boolean;
  9765. /**
  9766. * Serialize the StateCondition into a JSON compatible object
  9767. * @returns serialization object
  9768. */
  9769. serialize(): any;
  9770. }
  9771. }
  9772. declare module BABYLON {
  9773. /**
  9774. * This defines an action responsible to toggle a boolean once triggered.
  9775. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9776. */
  9777. export class SwitchBooleanAction extends Action {
  9778. /**
  9779. * The path to the boolean property in the target object
  9780. */
  9781. propertyPath: string;
  9782. private _target;
  9783. private _effectiveTarget;
  9784. private _property;
  9785. /**
  9786. * Instantiate the action
  9787. * @param triggerOptions defines the trigger options
  9788. * @param target defines the object containing the boolean
  9789. * @param propertyPath defines the path to the boolean property in the target object
  9790. * @param condition defines the trigger related conditions
  9791. */
  9792. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9793. /** @hidden */
  9794. _prepare(): void;
  9795. /**
  9796. * Execute the action toggle the boolean value.
  9797. */
  9798. execute(): void;
  9799. /**
  9800. * Serializes the actions and its related information.
  9801. * @param parent defines the object to serialize in
  9802. * @returns the serialized object
  9803. */
  9804. serialize(parent: any): any;
  9805. }
  9806. /**
  9807. * This defines an action responsible to set a the state field of the target
  9808. * to a desired value once triggered.
  9809. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9810. */
  9811. export class SetStateAction extends Action {
  9812. /**
  9813. * The value to store in the state field.
  9814. */
  9815. value: string;
  9816. private _target;
  9817. /**
  9818. * Instantiate the action
  9819. * @param triggerOptions defines the trigger options
  9820. * @param target defines the object containing the state property
  9821. * @param value defines the value to store in the state field
  9822. * @param condition defines the trigger related conditions
  9823. */
  9824. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9825. /**
  9826. * Execute the action and store the value on the target state property.
  9827. */
  9828. execute(): void;
  9829. /**
  9830. * Serializes the actions and its related information.
  9831. * @param parent defines the object to serialize in
  9832. * @returns the serialized object
  9833. */
  9834. serialize(parent: any): any;
  9835. }
  9836. /**
  9837. * This defines an action responsible to set a property of the target
  9838. * to a desired value once triggered.
  9839. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9840. */
  9841. export class SetValueAction extends Action {
  9842. /**
  9843. * The path of the property to set in the target.
  9844. */
  9845. propertyPath: string;
  9846. /**
  9847. * The value to set in the property
  9848. */
  9849. value: any;
  9850. private _target;
  9851. private _effectiveTarget;
  9852. private _property;
  9853. /**
  9854. * Instantiate the action
  9855. * @param triggerOptions defines the trigger options
  9856. * @param target defines the object containing the property
  9857. * @param propertyPath defines the path of the property to set in the target
  9858. * @param value defines the value to set in the property
  9859. * @param condition defines the trigger related conditions
  9860. */
  9861. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9862. /** @hidden */
  9863. _prepare(): void;
  9864. /**
  9865. * Execute the action and set the targetted property to the desired value.
  9866. */
  9867. execute(): void;
  9868. /**
  9869. * Serializes the actions and its related information.
  9870. * @param parent defines the object to serialize in
  9871. * @returns the serialized object
  9872. */
  9873. serialize(parent: any): any;
  9874. }
  9875. /**
  9876. * This defines an action responsible to increment the target value
  9877. * to a desired value once triggered.
  9878. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9879. */
  9880. export class IncrementValueAction extends Action {
  9881. /**
  9882. * The path of the property to increment in the target.
  9883. */
  9884. propertyPath: string;
  9885. /**
  9886. * The value we should increment the property by.
  9887. */
  9888. value: any;
  9889. private _target;
  9890. private _effectiveTarget;
  9891. private _property;
  9892. /**
  9893. * Instantiate the action
  9894. * @param triggerOptions defines the trigger options
  9895. * @param target defines the object containing the property
  9896. * @param propertyPath defines the path of the property to increment in the target
  9897. * @param value defines the value value we should increment the property by
  9898. * @param condition defines the trigger related conditions
  9899. */
  9900. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9901. /** @hidden */
  9902. _prepare(): void;
  9903. /**
  9904. * Execute the action and increment the target of the value amount.
  9905. */
  9906. execute(): void;
  9907. /**
  9908. * Serializes the actions and its related information.
  9909. * @param parent defines the object to serialize in
  9910. * @returns the serialized object
  9911. */
  9912. serialize(parent: any): any;
  9913. }
  9914. /**
  9915. * This defines an action responsible to start an animation once triggered.
  9916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9917. */
  9918. export class PlayAnimationAction extends Action {
  9919. /**
  9920. * Where the animation should start (animation frame)
  9921. */
  9922. from: number;
  9923. /**
  9924. * Where the animation should stop (animation frame)
  9925. */
  9926. to: number;
  9927. /**
  9928. * Define if the animation should loop or stop after the first play.
  9929. */
  9930. loop?: boolean;
  9931. private _target;
  9932. /**
  9933. * Instantiate the action
  9934. * @param triggerOptions defines the trigger options
  9935. * @param target defines the target animation or animation name
  9936. * @param from defines from where the animation should start (animation frame)
  9937. * @param end defines where the animation should stop (animation frame)
  9938. * @param loop defines if the animation should loop or stop after the first play
  9939. * @param condition defines the trigger related conditions
  9940. */
  9941. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9942. /** @hidden */
  9943. _prepare(): void;
  9944. /**
  9945. * Execute the action and play the animation.
  9946. */
  9947. execute(): void;
  9948. /**
  9949. * Serializes the actions and its related information.
  9950. * @param parent defines the object to serialize in
  9951. * @returns the serialized object
  9952. */
  9953. serialize(parent: any): any;
  9954. }
  9955. /**
  9956. * This defines an action responsible to stop an animation once triggered.
  9957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9958. */
  9959. export class StopAnimationAction extends Action {
  9960. private _target;
  9961. /**
  9962. * Instantiate the action
  9963. * @param triggerOptions defines the trigger options
  9964. * @param target defines the target animation or animation name
  9965. * @param condition defines the trigger related conditions
  9966. */
  9967. constructor(triggerOptions: any, target: any, condition?: Condition);
  9968. /** @hidden */
  9969. _prepare(): void;
  9970. /**
  9971. * Execute the action and stop the animation.
  9972. */
  9973. execute(): void;
  9974. /**
  9975. * Serializes the actions and its related information.
  9976. * @param parent defines the object to serialize in
  9977. * @returns the serialized object
  9978. */
  9979. serialize(parent: any): any;
  9980. }
  9981. /**
  9982. * This defines an action responsible that does nothing once triggered.
  9983. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9984. */
  9985. export class DoNothingAction extends Action {
  9986. /**
  9987. * Instantiate the action
  9988. * @param triggerOptions defines the trigger options
  9989. * @param condition defines the trigger related conditions
  9990. */
  9991. constructor(triggerOptions?: any, condition?: Condition);
  9992. /**
  9993. * Execute the action and do nothing.
  9994. */
  9995. execute(): void;
  9996. /**
  9997. * Serializes the actions and its related information.
  9998. * @param parent defines the object to serialize in
  9999. * @returns the serialized object
  10000. */
  10001. serialize(parent: any): any;
  10002. }
  10003. /**
  10004. * This defines an action responsible to trigger several actions once triggered.
  10005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10006. */
  10007. export class CombineAction extends Action {
  10008. /**
  10009. * The list of aggregated animations to run.
  10010. */
  10011. children: Action[];
  10012. /**
  10013. * Instantiate the action
  10014. * @param triggerOptions defines the trigger options
  10015. * @param children defines the list of aggregated animations to run
  10016. * @param condition defines the trigger related conditions
  10017. */
  10018. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10019. /** @hidden */
  10020. _prepare(): void;
  10021. /**
  10022. * Execute the action and executes all the aggregated actions.
  10023. */
  10024. execute(evt: ActionEvent): void;
  10025. /**
  10026. * Serializes the actions and its related information.
  10027. * @param parent defines the object to serialize in
  10028. * @returns the serialized object
  10029. */
  10030. serialize(parent: any): any;
  10031. }
  10032. /**
  10033. * This defines an action responsible to run code (external event) once triggered.
  10034. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10035. */
  10036. export class ExecuteCodeAction extends Action {
  10037. /**
  10038. * The callback function to run.
  10039. */
  10040. func: (evt: ActionEvent) => void;
  10041. /**
  10042. * Instantiate the action
  10043. * @param triggerOptions defines the trigger options
  10044. * @param func defines the callback function to run
  10045. * @param condition defines the trigger related conditions
  10046. */
  10047. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10048. /**
  10049. * Execute the action and run the attached code.
  10050. */
  10051. execute(evt: ActionEvent): void;
  10052. }
  10053. /**
  10054. * This defines an action responsible to set the parent property of the target once triggered.
  10055. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10056. */
  10057. export class SetParentAction extends Action {
  10058. private _parent;
  10059. private _target;
  10060. /**
  10061. * Instantiate the action
  10062. * @param triggerOptions defines the trigger options
  10063. * @param target defines the target containing the parent property
  10064. * @param parent defines from where the animation should start (animation frame)
  10065. * @param condition defines the trigger related conditions
  10066. */
  10067. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10068. /** @hidden */
  10069. _prepare(): void;
  10070. /**
  10071. * Execute the action and set the parent property.
  10072. */
  10073. execute(): void;
  10074. /**
  10075. * Serializes the actions and its related information.
  10076. * @param parent defines the object to serialize in
  10077. * @returns the serialized object
  10078. */
  10079. serialize(parent: any): any;
  10080. }
  10081. }
  10082. declare module BABYLON {
  10083. /**
  10084. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10085. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10086. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10087. */
  10088. export class ActionManager extends AbstractActionManager {
  10089. /**
  10090. * Nothing
  10091. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10092. */
  10093. static readonly NothingTrigger: number;
  10094. /**
  10095. * On pick
  10096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10097. */
  10098. static readonly OnPickTrigger: number;
  10099. /**
  10100. * On left pick
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10102. */
  10103. static readonly OnLeftPickTrigger: number;
  10104. /**
  10105. * On right pick
  10106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10107. */
  10108. static readonly OnRightPickTrigger: number;
  10109. /**
  10110. * On center pick
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10112. */
  10113. static readonly OnCenterPickTrigger: number;
  10114. /**
  10115. * On pick down
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10117. */
  10118. static readonly OnPickDownTrigger: number;
  10119. /**
  10120. * On double pick
  10121. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10122. */
  10123. static readonly OnDoublePickTrigger: number;
  10124. /**
  10125. * On pick up
  10126. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10127. */
  10128. static readonly OnPickUpTrigger: number;
  10129. /**
  10130. * On pick out.
  10131. * This trigger will only be raised if you also declared a OnPickDown
  10132. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10133. */
  10134. static readonly OnPickOutTrigger: number;
  10135. /**
  10136. * On long press
  10137. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10138. */
  10139. static readonly OnLongPressTrigger: number;
  10140. /**
  10141. * On pointer over
  10142. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10143. */
  10144. static readonly OnPointerOverTrigger: number;
  10145. /**
  10146. * On pointer out
  10147. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10148. */
  10149. static readonly OnPointerOutTrigger: number;
  10150. /**
  10151. * On every frame
  10152. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10153. */
  10154. static readonly OnEveryFrameTrigger: number;
  10155. /**
  10156. * On intersection enter
  10157. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10158. */
  10159. static readonly OnIntersectionEnterTrigger: number;
  10160. /**
  10161. * On intersection exit
  10162. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10163. */
  10164. static readonly OnIntersectionExitTrigger: number;
  10165. /**
  10166. * On key down
  10167. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10168. */
  10169. static readonly OnKeyDownTrigger: number;
  10170. /**
  10171. * On key up
  10172. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10173. */
  10174. static readonly OnKeyUpTrigger: number;
  10175. private _scene;
  10176. /**
  10177. * Creates a new action manager
  10178. * @param scene defines the hosting scene
  10179. */
  10180. constructor(scene: Scene);
  10181. /**
  10182. * Releases all associated resources
  10183. */
  10184. dispose(): void;
  10185. /**
  10186. * Gets hosting scene
  10187. * @returns the hosting scene
  10188. */
  10189. getScene(): Scene;
  10190. /**
  10191. * Does this action manager handles actions of any of the given triggers
  10192. * @param triggers defines the triggers to be tested
  10193. * @return a boolean indicating whether one (or more) of the triggers is handled
  10194. */
  10195. hasSpecificTriggers(triggers: number[]): boolean;
  10196. /**
  10197. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10198. * speed.
  10199. * @param triggerA defines the trigger to be tested
  10200. * @param triggerB defines the trigger to be tested
  10201. * @return a boolean indicating whether one (or more) of the triggers is handled
  10202. */
  10203. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10204. /**
  10205. * Does this action manager handles actions of a given trigger
  10206. * @param trigger defines the trigger to be tested
  10207. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10208. * @return whether the trigger is handled
  10209. */
  10210. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10211. /**
  10212. * Does this action manager has pointer triggers
  10213. */
  10214. get hasPointerTriggers(): boolean;
  10215. /**
  10216. * Does this action manager has pick triggers
  10217. */
  10218. get hasPickTriggers(): boolean;
  10219. /**
  10220. * Registers an action to this action manager
  10221. * @param action defines the action to be registered
  10222. * @return the action amended (prepared) after registration
  10223. */
  10224. registerAction(action: IAction): Nullable<IAction>;
  10225. /**
  10226. * Unregisters an action to this action manager
  10227. * @param action defines the action to be unregistered
  10228. * @return a boolean indicating whether the action has been unregistered
  10229. */
  10230. unregisterAction(action: IAction): Boolean;
  10231. /**
  10232. * Process a specific trigger
  10233. * @param trigger defines the trigger to process
  10234. * @param evt defines the event details to be processed
  10235. */
  10236. processTrigger(trigger: number, evt?: IActionEvent): void;
  10237. /** @hidden */
  10238. _getEffectiveTarget(target: any, propertyPath: string): any;
  10239. /** @hidden */
  10240. _getProperty(propertyPath: string): string;
  10241. /**
  10242. * Serialize this manager to a JSON object
  10243. * @param name defines the property name to store this manager
  10244. * @returns a JSON representation of this manager
  10245. */
  10246. serialize(name: string): any;
  10247. /**
  10248. * Creates a new ActionManager from a JSON data
  10249. * @param parsedActions defines the JSON data to read from
  10250. * @param object defines the hosting mesh
  10251. * @param scene defines the hosting scene
  10252. */
  10253. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10254. /**
  10255. * Get a trigger name by index
  10256. * @param trigger defines the trigger index
  10257. * @returns a trigger name
  10258. */
  10259. static GetTriggerName(trigger: number): string;
  10260. }
  10261. }
  10262. declare module BABYLON {
  10263. /**
  10264. * Class used to represent a sprite
  10265. * @see https://doc.babylonjs.com/babylon101/sprites
  10266. */
  10267. export class Sprite implements IAnimatable {
  10268. /** defines the name */
  10269. name: string;
  10270. /** Gets or sets the current world position */
  10271. position: Vector3;
  10272. /** Gets or sets the main color */
  10273. color: Color4;
  10274. /** Gets or sets the width */
  10275. width: number;
  10276. /** Gets or sets the height */
  10277. height: number;
  10278. /** Gets or sets rotation angle */
  10279. angle: number;
  10280. /** Gets or sets the cell index in the sprite sheet */
  10281. cellIndex: number;
  10282. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10283. cellRef: string;
  10284. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10285. invertU: boolean;
  10286. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10287. invertV: boolean;
  10288. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10289. disposeWhenFinishedAnimating: boolean;
  10290. /** Gets the list of attached animations */
  10291. animations: Nullable<Array<Animation>>;
  10292. /** Gets or sets a boolean indicating if the sprite can be picked */
  10293. isPickable: boolean;
  10294. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10295. useAlphaForPicking: boolean;
  10296. /** @hidden */
  10297. _xOffset: number;
  10298. /** @hidden */
  10299. _yOffset: number;
  10300. /** @hidden */
  10301. _xSize: number;
  10302. /** @hidden */
  10303. _ySize: number;
  10304. /**
  10305. * Gets or sets the associated action manager
  10306. */
  10307. actionManager: Nullable<ActionManager>;
  10308. /**
  10309. * An event triggered when the control has been disposed
  10310. */
  10311. onDisposeObservable: Observable<Sprite>;
  10312. private _animationStarted;
  10313. private _loopAnimation;
  10314. private _fromIndex;
  10315. private _toIndex;
  10316. private _delay;
  10317. private _direction;
  10318. private _manager;
  10319. private _time;
  10320. private _onAnimationEnd;
  10321. /**
  10322. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10323. */
  10324. isVisible: boolean;
  10325. /**
  10326. * Gets or sets the sprite size
  10327. */
  10328. get size(): number;
  10329. set size(value: number);
  10330. /**
  10331. * Returns a boolean indicating if the animation is started
  10332. */
  10333. get animationStarted(): boolean;
  10334. /**
  10335. * Gets or sets the unique id of the sprite
  10336. */
  10337. uniqueId: number;
  10338. /**
  10339. * Gets the manager of this sprite
  10340. */
  10341. get manager(): ISpriteManager;
  10342. /**
  10343. * Creates a new Sprite
  10344. * @param name defines the name
  10345. * @param manager defines the manager
  10346. */
  10347. constructor(
  10348. /** defines the name */
  10349. name: string, manager: ISpriteManager);
  10350. /**
  10351. * Returns the string "Sprite"
  10352. * @returns "Sprite"
  10353. */
  10354. getClassName(): string;
  10355. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10356. get fromIndex(): number;
  10357. set fromIndex(value: number);
  10358. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10359. get toIndex(): number;
  10360. set toIndex(value: number);
  10361. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10362. get loopAnimation(): boolean;
  10363. set loopAnimation(value: boolean);
  10364. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10365. get delay(): number;
  10366. set delay(value: number);
  10367. /**
  10368. * Starts an animation
  10369. * @param from defines the initial key
  10370. * @param to defines the end key
  10371. * @param loop defines if the animation must loop
  10372. * @param delay defines the start delay (in ms)
  10373. * @param onAnimationEnd defines a callback to call when animation ends
  10374. */
  10375. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10376. /** Stops current animation (if any) */
  10377. stopAnimation(): void;
  10378. /** @hidden */
  10379. _animate(deltaTime: number): void;
  10380. /** Release associated resources */
  10381. dispose(): void;
  10382. /**
  10383. * Serializes the sprite to a JSON object
  10384. * @returns the JSON object
  10385. */
  10386. serialize(): any;
  10387. /**
  10388. * Parses a JSON object to create a new sprite
  10389. * @param parsedSprite The JSON object to parse
  10390. * @param manager defines the hosting manager
  10391. * @returns the new sprite
  10392. */
  10393. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10394. }
  10395. }
  10396. declare module BABYLON {
  10397. /**
  10398. * Information about the result of picking within a scene
  10399. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10400. */
  10401. export class PickingInfo {
  10402. /** @hidden */
  10403. _pickingUnavailable: boolean;
  10404. /**
  10405. * If the pick collided with an object
  10406. */
  10407. hit: boolean;
  10408. /**
  10409. * Distance away where the pick collided
  10410. */
  10411. distance: number;
  10412. /**
  10413. * The location of pick collision
  10414. */
  10415. pickedPoint: Nullable<Vector3>;
  10416. /**
  10417. * The mesh corresponding the the pick collision
  10418. */
  10419. pickedMesh: Nullable<AbstractMesh>;
  10420. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10421. bu: number;
  10422. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10423. bv: number;
  10424. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10425. faceId: number;
  10426. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10427. subMeshFaceId: number;
  10428. /** Id of the the submesh that was picked */
  10429. subMeshId: number;
  10430. /** If a sprite was picked, this will be the sprite the pick collided with */
  10431. pickedSprite: Nullable<Sprite>;
  10432. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10433. thinInstanceIndex: number;
  10434. /**
  10435. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10436. */
  10437. originMesh: Nullable<AbstractMesh>;
  10438. /**
  10439. * The ray that was used to perform the picking.
  10440. */
  10441. ray: Nullable<Ray>;
  10442. /**
  10443. * Gets the normal correspodning to the face the pick collided with
  10444. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10445. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10446. * @returns The normal correspodning to the face the pick collided with
  10447. */
  10448. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10449. /**
  10450. * Gets the texture coordinates of where the pick occured
  10451. * @returns the vector containing the coordnates of the texture
  10452. */
  10453. getTextureCoordinates(): Nullable<Vector2>;
  10454. }
  10455. }
  10456. declare module BABYLON {
  10457. /**
  10458. * Class representing a ray with position and direction
  10459. */
  10460. export class Ray {
  10461. /** origin point */
  10462. origin: Vector3;
  10463. /** direction */
  10464. direction: Vector3;
  10465. /** length of the ray */
  10466. length: number;
  10467. private static readonly _TmpVector3;
  10468. private _tmpRay;
  10469. /**
  10470. * Creates a new ray
  10471. * @param origin origin point
  10472. * @param direction direction
  10473. * @param length length of the ray
  10474. */
  10475. constructor(
  10476. /** origin point */
  10477. origin: Vector3,
  10478. /** direction */
  10479. direction: Vector3,
  10480. /** length of the ray */
  10481. length?: number);
  10482. /**
  10483. * Checks if the ray intersects a box
  10484. * This does not account for the ray lenght by design to improve perfs.
  10485. * @param minimum bound of the box
  10486. * @param maximum bound of the box
  10487. * @param intersectionTreshold extra extend to be added to the box in all direction
  10488. * @returns if the box was hit
  10489. */
  10490. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10491. /**
  10492. * Checks if the ray intersects a box
  10493. * This does not account for the ray lenght by design to improve perfs.
  10494. * @param box the bounding box to check
  10495. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10496. * @returns if the box was hit
  10497. */
  10498. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10499. /**
  10500. * If the ray hits a sphere
  10501. * @param sphere the bounding sphere to check
  10502. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10503. * @returns true if it hits the sphere
  10504. */
  10505. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10506. /**
  10507. * If the ray hits a triange
  10508. * @param vertex0 triangle vertex
  10509. * @param vertex1 triangle vertex
  10510. * @param vertex2 triangle vertex
  10511. * @returns intersection information if hit
  10512. */
  10513. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10514. /**
  10515. * Checks if ray intersects a plane
  10516. * @param plane the plane to check
  10517. * @returns the distance away it was hit
  10518. */
  10519. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10520. /**
  10521. * Calculate the intercept of a ray on a given axis
  10522. * @param axis to check 'x' | 'y' | 'z'
  10523. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10524. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10525. */
  10526. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10527. /**
  10528. * Checks if ray intersects a mesh
  10529. * @param mesh the mesh to check
  10530. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10531. * @returns picking info of the intersecton
  10532. */
  10533. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10534. /**
  10535. * Checks if ray intersects a mesh
  10536. * @param meshes the meshes to check
  10537. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10538. * @param results array to store result in
  10539. * @returns Array of picking infos
  10540. */
  10541. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10542. private _comparePickingInfo;
  10543. private static smallnum;
  10544. private static rayl;
  10545. /**
  10546. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10547. * @param sega the first point of the segment to test the intersection against
  10548. * @param segb the second point of the segment to test the intersection against
  10549. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10550. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10551. */
  10552. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10553. /**
  10554. * Update the ray from viewport position
  10555. * @param x position
  10556. * @param y y position
  10557. * @param viewportWidth viewport width
  10558. * @param viewportHeight viewport height
  10559. * @param world world matrix
  10560. * @param view view matrix
  10561. * @param projection projection matrix
  10562. * @returns this ray updated
  10563. */
  10564. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10565. /**
  10566. * Creates a ray with origin and direction of 0,0,0
  10567. * @returns the new ray
  10568. */
  10569. static Zero(): Ray;
  10570. /**
  10571. * Creates a new ray from screen space and viewport
  10572. * @param x position
  10573. * @param y y position
  10574. * @param viewportWidth viewport width
  10575. * @param viewportHeight viewport height
  10576. * @param world world matrix
  10577. * @param view view matrix
  10578. * @param projection projection matrix
  10579. * @returns new ray
  10580. */
  10581. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10582. /**
  10583. * 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
  10584. * transformed to the given world matrix.
  10585. * @param origin The origin point
  10586. * @param end The end point
  10587. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10588. * @returns the new ray
  10589. */
  10590. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10591. /**
  10592. * Transforms a ray by a matrix
  10593. * @param ray ray to transform
  10594. * @param matrix matrix to apply
  10595. * @returns the resulting new ray
  10596. */
  10597. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10598. /**
  10599. * Transforms a ray by a matrix
  10600. * @param ray ray to transform
  10601. * @param matrix matrix to apply
  10602. * @param result ray to store result in
  10603. */
  10604. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10605. /**
  10606. * Unproject a ray from screen space to object space
  10607. * @param sourceX defines the screen space x coordinate to use
  10608. * @param sourceY defines the screen space y coordinate to use
  10609. * @param viewportWidth defines the current width of the viewport
  10610. * @param viewportHeight defines the current height of the viewport
  10611. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10612. * @param view defines the view matrix to use
  10613. * @param projection defines the projection matrix to use
  10614. */
  10615. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10616. }
  10617. /**
  10618. * Type used to define predicate used to select faces when a mesh intersection is detected
  10619. */
  10620. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10621. interface Scene {
  10622. /** @hidden */
  10623. _tempPickingRay: Nullable<Ray>;
  10624. /** @hidden */
  10625. _cachedRayForTransform: Ray;
  10626. /** @hidden */
  10627. _pickWithRayInverseMatrix: Matrix;
  10628. /** @hidden */
  10629. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10630. /** @hidden */
  10631. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10632. /** @hidden */
  10633. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10634. }
  10635. }
  10636. declare module BABYLON {
  10637. /**
  10638. * Groups all the scene component constants in one place to ease maintenance.
  10639. * @hidden
  10640. */
  10641. export class SceneComponentConstants {
  10642. static readonly NAME_EFFECTLAYER: string;
  10643. static readonly NAME_LAYER: string;
  10644. static readonly NAME_LENSFLARESYSTEM: string;
  10645. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10646. static readonly NAME_PARTICLESYSTEM: string;
  10647. static readonly NAME_GAMEPAD: string;
  10648. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10649. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10650. static readonly NAME_PREPASSRENDERER: string;
  10651. static readonly NAME_DEPTHRENDERER: string;
  10652. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10653. static readonly NAME_SPRITE: string;
  10654. static readonly NAME_OUTLINERENDERER: string;
  10655. static readonly NAME_PROCEDURALTEXTURE: string;
  10656. static readonly NAME_SHADOWGENERATOR: string;
  10657. static readonly NAME_OCTREE: string;
  10658. static readonly NAME_PHYSICSENGINE: string;
  10659. static readonly NAME_AUDIO: string;
  10660. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10661. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10662. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10663. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10664. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10665. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10666. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10667. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10668. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10669. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10670. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10671. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10672. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10673. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10674. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10675. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10676. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10677. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10678. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10679. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10680. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10681. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10682. static readonly STEP_AFTERRENDER_AUDIO: number;
  10683. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10684. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10685. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10686. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10687. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10688. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10689. static readonly STEP_POINTERMOVE_SPRITE: number;
  10690. static readonly STEP_POINTERDOWN_SPRITE: number;
  10691. static readonly STEP_POINTERUP_SPRITE: number;
  10692. }
  10693. /**
  10694. * This represents a scene component.
  10695. *
  10696. * This is used to decouple the dependency the scene is having on the different workloads like
  10697. * layers, post processes...
  10698. */
  10699. export interface ISceneComponent {
  10700. /**
  10701. * The name of the component. Each component must have a unique name.
  10702. */
  10703. name: string;
  10704. /**
  10705. * The scene the component belongs to.
  10706. */
  10707. scene: Scene;
  10708. /**
  10709. * Register the component to one instance of a scene.
  10710. */
  10711. register(): void;
  10712. /**
  10713. * Rebuilds the elements related to this component in case of
  10714. * context lost for instance.
  10715. */
  10716. rebuild(): void;
  10717. /**
  10718. * Disposes the component and the associated ressources.
  10719. */
  10720. dispose(): void;
  10721. }
  10722. /**
  10723. * This represents a SERIALIZABLE scene component.
  10724. *
  10725. * This extends Scene Component to add Serialization methods on top.
  10726. */
  10727. export interface ISceneSerializableComponent extends ISceneComponent {
  10728. /**
  10729. * Adds all the elements from the container to the scene
  10730. * @param container the container holding the elements
  10731. */
  10732. addFromContainer(container: AbstractScene): void;
  10733. /**
  10734. * Removes all the elements in the container from the scene
  10735. * @param container contains the elements to remove
  10736. * @param dispose if the removed element should be disposed (default: false)
  10737. */
  10738. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10739. /**
  10740. * Serializes the component data to the specified json object
  10741. * @param serializationObject The object to serialize to
  10742. */
  10743. serialize(serializationObject: any): void;
  10744. }
  10745. /**
  10746. * Strong typing of a Mesh related stage step action
  10747. */
  10748. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10749. /**
  10750. * Strong typing of a Evaluate Sub Mesh related stage step action
  10751. */
  10752. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10753. /**
  10754. * Strong typing of a Active Mesh related stage step action
  10755. */
  10756. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10757. /**
  10758. * Strong typing of a Camera related stage step action
  10759. */
  10760. export type CameraStageAction = (camera: Camera) => void;
  10761. /**
  10762. * Strong typing of a Camera Frame buffer related stage step action
  10763. */
  10764. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10765. /**
  10766. * Strong typing of a Render Target related stage step action
  10767. */
  10768. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10769. /**
  10770. * Strong typing of a RenderingGroup related stage step action
  10771. */
  10772. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10773. /**
  10774. * Strong typing of a Mesh Render related stage step action
  10775. */
  10776. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10777. /**
  10778. * Strong typing of a simple stage step action
  10779. */
  10780. export type SimpleStageAction = () => void;
  10781. /**
  10782. * Strong typing of a render target action.
  10783. */
  10784. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10785. /**
  10786. * Strong typing of a pointer move action.
  10787. */
  10788. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10789. /**
  10790. * Strong typing of a pointer up/down action.
  10791. */
  10792. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10793. /**
  10794. * Representation of a stage in the scene (Basically a list of ordered steps)
  10795. * @hidden
  10796. */
  10797. export class Stage<T extends Function> extends Array<{
  10798. index: number;
  10799. component: ISceneComponent;
  10800. action: T;
  10801. }> {
  10802. /**
  10803. * Hide ctor from the rest of the world.
  10804. * @param items The items to add.
  10805. */
  10806. private constructor();
  10807. /**
  10808. * Creates a new Stage.
  10809. * @returns A new instance of a Stage
  10810. */
  10811. static Create<T extends Function>(): Stage<T>;
  10812. /**
  10813. * Registers a step in an ordered way in the targeted stage.
  10814. * @param index Defines the position to register the step in
  10815. * @param component Defines the component attached to the step
  10816. * @param action Defines the action to launch during the step
  10817. */
  10818. registerStep(index: number, component: ISceneComponent, action: T): void;
  10819. /**
  10820. * Clears all the steps from the stage.
  10821. */
  10822. clear(): void;
  10823. }
  10824. }
  10825. declare module BABYLON {
  10826. interface Scene {
  10827. /** @hidden */
  10828. _pointerOverSprite: Nullable<Sprite>;
  10829. /** @hidden */
  10830. _pickedDownSprite: Nullable<Sprite>;
  10831. /** @hidden */
  10832. _tempSpritePickingRay: Nullable<Ray>;
  10833. /**
  10834. * All of the sprite managers added to this scene
  10835. * @see https://doc.babylonjs.com/babylon101/sprites
  10836. */
  10837. spriteManagers: Array<ISpriteManager>;
  10838. /**
  10839. * An event triggered when sprites rendering is about to start
  10840. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10841. */
  10842. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10843. /**
  10844. * An event triggered when sprites rendering is done
  10845. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10846. */
  10847. onAfterSpritesRenderingObservable: Observable<Scene>;
  10848. /** @hidden */
  10849. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10850. /** Launch a ray to try to pick a sprite in the scene
  10851. * @param x position on screen
  10852. * @param y position on screen
  10853. * @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
  10854. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10855. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10856. * @returns a PickingInfo
  10857. */
  10858. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10859. /** Use the given ray to pick a sprite in the scene
  10860. * @param ray The ray (in world space) to use to pick meshes
  10861. * @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
  10862. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10863. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10864. * @returns a PickingInfo
  10865. */
  10866. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10867. /** @hidden */
  10868. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10869. /** Launch a ray to try to pick sprites in the scene
  10870. * @param x position on screen
  10871. * @param y position on screen
  10872. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10873. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10874. * @returns a PickingInfo array
  10875. */
  10876. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10877. /** Use the given ray to pick sprites in the scene
  10878. * @param ray The ray (in world space) to use to pick meshes
  10879. * @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
  10880. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10881. * @returns a PickingInfo array
  10882. */
  10883. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10884. /**
  10885. * Force the sprite under the pointer
  10886. * @param sprite defines the sprite to use
  10887. */
  10888. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10889. /**
  10890. * Gets the sprite under the pointer
  10891. * @returns a Sprite or null if no sprite is under the pointer
  10892. */
  10893. getPointerOverSprite(): Nullable<Sprite>;
  10894. }
  10895. /**
  10896. * Defines the sprite scene component responsible to manage sprites
  10897. * in a given scene.
  10898. */
  10899. export class SpriteSceneComponent implements ISceneComponent {
  10900. /**
  10901. * The component name helpfull to identify the component in the list of scene components.
  10902. */
  10903. readonly name: string;
  10904. /**
  10905. * The scene the component belongs to.
  10906. */
  10907. scene: Scene;
  10908. /** @hidden */
  10909. private _spritePredicate;
  10910. /**
  10911. * Creates a new instance of the component for the given scene
  10912. * @param scene Defines the scene to register the component in
  10913. */
  10914. constructor(scene: Scene);
  10915. /**
  10916. * Registers the component in a given scene
  10917. */
  10918. register(): void;
  10919. /**
  10920. * Rebuilds the elements related to this component in case of
  10921. * context lost for instance.
  10922. */
  10923. rebuild(): void;
  10924. /**
  10925. * Disposes the component and the associated ressources.
  10926. */
  10927. dispose(): void;
  10928. private _pickSpriteButKeepRay;
  10929. private _pointerMove;
  10930. private _pointerDown;
  10931. private _pointerUp;
  10932. }
  10933. }
  10934. declare module BABYLON {
  10935. /** @hidden */
  10936. export var fogFragmentDeclaration: {
  10937. name: string;
  10938. shader: string;
  10939. };
  10940. }
  10941. declare module BABYLON {
  10942. /** @hidden */
  10943. export var fogFragment: {
  10944. name: string;
  10945. shader: string;
  10946. };
  10947. }
  10948. declare module BABYLON {
  10949. /** @hidden */
  10950. export var spritesPixelShader: {
  10951. name: string;
  10952. shader: string;
  10953. };
  10954. }
  10955. declare module BABYLON {
  10956. /** @hidden */
  10957. export var fogVertexDeclaration: {
  10958. name: string;
  10959. shader: string;
  10960. };
  10961. }
  10962. declare module BABYLON {
  10963. /** @hidden */
  10964. export var spritesVertexShader: {
  10965. name: string;
  10966. shader: string;
  10967. };
  10968. }
  10969. declare module BABYLON {
  10970. /**
  10971. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10972. */
  10973. export interface ISpriteManager extends IDisposable {
  10974. /**
  10975. * Gets manager's name
  10976. */
  10977. name: string;
  10978. /**
  10979. * Restricts the camera to viewing objects with the same layerMask.
  10980. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10981. */
  10982. layerMask: number;
  10983. /**
  10984. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10985. */
  10986. isPickable: boolean;
  10987. /**
  10988. * Gets the hosting scene
  10989. */
  10990. scene: Scene;
  10991. /**
  10992. * Specifies the rendering group id for this mesh (0 by default)
  10993. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10994. */
  10995. renderingGroupId: number;
  10996. /**
  10997. * Defines the list of sprites managed by the manager.
  10998. */
  10999. sprites: Array<Sprite>;
  11000. /**
  11001. * Gets or sets the spritesheet texture
  11002. */
  11003. texture: Texture;
  11004. /** Defines the default width of a cell in the spritesheet */
  11005. cellWidth: number;
  11006. /** Defines the default height of a cell in the spritesheet */
  11007. cellHeight: number;
  11008. /**
  11009. * Tests the intersection of a sprite with a specific ray.
  11010. * @param ray The ray we are sending to test the collision
  11011. * @param camera The camera space we are sending rays in
  11012. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11013. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11014. * @returns picking info or null.
  11015. */
  11016. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11017. /**
  11018. * Intersects the sprites with a ray
  11019. * @param ray defines the ray to intersect with
  11020. * @param camera defines the current active camera
  11021. * @param predicate defines a predicate used to select candidate sprites
  11022. * @returns null if no hit or a PickingInfo array
  11023. */
  11024. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11025. /**
  11026. * Renders the list of sprites on screen.
  11027. */
  11028. render(): void;
  11029. }
  11030. /**
  11031. * Class used to manage multiple sprites on the same spritesheet
  11032. * @see https://doc.babylonjs.com/babylon101/sprites
  11033. */
  11034. export class SpriteManager implements ISpriteManager {
  11035. /** defines the manager's name */
  11036. name: string;
  11037. /** Define the Url to load snippets */
  11038. static SnippetUrl: string;
  11039. /** Snippet ID if the manager was created from the snippet server */
  11040. snippetId: string;
  11041. /** Gets the list of sprites */
  11042. sprites: Sprite[];
  11043. /** Gets or sets the rendering group id (0 by default) */
  11044. renderingGroupId: number;
  11045. /** Gets or sets camera layer mask */
  11046. layerMask: number;
  11047. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11048. fogEnabled: boolean;
  11049. /** Gets or sets a boolean indicating if the sprites are pickable */
  11050. isPickable: boolean;
  11051. /** Defines the default width of a cell in the spritesheet */
  11052. cellWidth: number;
  11053. /** Defines the default height of a cell in the spritesheet */
  11054. cellHeight: number;
  11055. /** Associative array from JSON sprite data file */
  11056. private _cellData;
  11057. /** Array of sprite names from JSON sprite data file */
  11058. private _spriteMap;
  11059. /** True when packed cell data from JSON file is ready*/
  11060. private _packedAndReady;
  11061. private _textureContent;
  11062. private _useInstancing;
  11063. /**
  11064. * An event triggered when the manager is disposed.
  11065. */
  11066. onDisposeObservable: Observable<SpriteManager>;
  11067. private _onDisposeObserver;
  11068. /**
  11069. * Callback called when the manager is disposed
  11070. */
  11071. set onDispose(callback: () => void);
  11072. private _capacity;
  11073. private _fromPacked;
  11074. private _spriteTexture;
  11075. private _epsilon;
  11076. private _scene;
  11077. private _vertexData;
  11078. private _buffer;
  11079. private _vertexBuffers;
  11080. private _spriteBuffer;
  11081. private _indexBuffer;
  11082. private _effectBase;
  11083. private _effectFog;
  11084. private _vertexBufferSize;
  11085. /**
  11086. * Gets or sets the unique id of the sprite
  11087. */
  11088. uniqueId: number;
  11089. /**
  11090. * Gets the array of sprites
  11091. */
  11092. get children(): Sprite[];
  11093. /**
  11094. * Gets the hosting scene
  11095. */
  11096. get scene(): Scene;
  11097. /**
  11098. * Gets the capacity of the manager
  11099. */
  11100. get capacity(): number;
  11101. /**
  11102. * Gets or sets the spritesheet texture
  11103. */
  11104. get texture(): Texture;
  11105. set texture(value: Texture);
  11106. private _blendMode;
  11107. /**
  11108. * Blend mode use to render the particle, it can be any of
  11109. * the static Constants.ALPHA_x properties provided in this class.
  11110. * Default value is Constants.ALPHA_COMBINE
  11111. */
  11112. get blendMode(): number;
  11113. set blendMode(blendMode: number);
  11114. /** Disables writing to the depth buffer when rendering the sprites.
  11115. * It can be handy to disable depth writing when using textures without alpha channel
  11116. * and setting some specific blend modes.
  11117. */
  11118. disableDepthWrite: boolean;
  11119. /**
  11120. * Creates a new sprite manager
  11121. * @param name defines the manager's name
  11122. * @param imgUrl defines the sprite sheet url
  11123. * @param capacity defines the maximum allowed number of sprites
  11124. * @param cellSize defines the size of a sprite cell
  11125. * @param scene defines the hosting scene
  11126. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11127. * @param samplingMode defines the smapling mode to use with spritesheet
  11128. * @param fromPacked set to false; do not alter
  11129. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11130. */
  11131. constructor(
  11132. /** defines the manager's name */
  11133. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11134. /**
  11135. * Returns the string "SpriteManager"
  11136. * @returns "SpriteManager"
  11137. */
  11138. getClassName(): string;
  11139. private _makePacked;
  11140. private _appendSpriteVertex;
  11141. private _checkTextureAlpha;
  11142. /**
  11143. * Intersects the sprites with a ray
  11144. * @param ray defines the ray to intersect with
  11145. * @param camera defines the current active camera
  11146. * @param predicate defines a predicate used to select candidate sprites
  11147. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11148. * @returns null if no hit or a PickingInfo
  11149. */
  11150. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11151. /**
  11152. * Intersects the sprites with a ray
  11153. * @param ray defines the ray to intersect with
  11154. * @param camera defines the current active camera
  11155. * @param predicate defines a predicate used to select candidate sprites
  11156. * @returns null if no hit or a PickingInfo array
  11157. */
  11158. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11159. /**
  11160. * Render all child sprites
  11161. */
  11162. render(): void;
  11163. /**
  11164. * Release associated resources
  11165. */
  11166. dispose(): void;
  11167. /**
  11168. * Serializes the sprite manager to a JSON object
  11169. * @param serializeTexture defines if the texture must be serialized as well
  11170. * @returns the JSON object
  11171. */
  11172. serialize(serializeTexture?: boolean): any;
  11173. /**
  11174. * Parses a JSON object to create a new sprite manager.
  11175. * @param parsedManager The JSON object to parse
  11176. * @param scene The scene to create the sprite managerin
  11177. * @param rootUrl The root url to use to load external dependencies like texture
  11178. * @returns the new sprite manager
  11179. */
  11180. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11181. /**
  11182. * Creates a sprite manager from a snippet saved in a remote file
  11183. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11184. * @param url defines the url to load from
  11185. * @param scene defines the hosting scene
  11186. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11187. * @returns a promise that will resolve to the new sprite manager
  11188. */
  11189. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11190. /**
  11191. * Creates a sprite manager from a snippet saved by the sprite editor
  11192. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11193. * @param scene defines the hosting scene
  11194. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11195. * @returns a promise that will resolve to the new sprite manager
  11196. */
  11197. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11198. }
  11199. }
  11200. declare module BABYLON {
  11201. /** Interface used by value gradients (color, factor, ...) */
  11202. export interface IValueGradient {
  11203. /**
  11204. * Gets or sets the gradient value (between 0 and 1)
  11205. */
  11206. gradient: number;
  11207. }
  11208. /** Class used to store color4 gradient */
  11209. export class ColorGradient implements IValueGradient {
  11210. /**
  11211. * Gets or sets the gradient value (between 0 and 1)
  11212. */
  11213. gradient: number;
  11214. /**
  11215. * Gets or sets first associated color
  11216. */
  11217. color1: Color4;
  11218. /**
  11219. * Gets or sets second associated color
  11220. */
  11221. color2?: Color4 | undefined;
  11222. /**
  11223. * Creates a new color4 gradient
  11224. * @param gradient gets or sets the gradient value (between 0 and 1)
  11225. * @param color1 gets or sets first associated color
  11226. * @param color2 gets or sets first second color
  11227. */
  11228. constructor(
  11229. /**
  11230. * Gets or sets the gradient value (between 0 and 1)
  11231. */
  11232. gradient: number,
  11233. /**
  11234. * Gets or sets first associated color
  11235. */
  11236. color1: Color4,
  11237. /**
  11238. * Gets or sets second associated color
  11239. */
  11240. color2?: Color4 | undefined);
  11241. /**
  11242. * Will get a color picked randomly between color1 and color2.
  11243. * If color2 is undefined then color1 will be used
  11244. * @param result defines the target Color4 to store the result in
  11245. */
  11246. getColorToRef(result: Color4): void;
  11247. }
  11248. /** Class used to store color 3 gradient */
  11249. export class Color3Gradient implements IValueGradient {
  11250. /**
  11251. * Gets or sets the gradient value (between 0 and 1)
  11252. */
  11253. gradient: number;
  11254. /**
  11255. * Gets or sets the associated color
  11256. */
  11257. color: Color3;
  11258. /**
  11259. * Creates a new color3 gradient
  11260. * @param gradient gets or sets the gradient value (between 0 and 1)
  11261. * @param color gets or sets associated color
  11262. */
  11263. constructor(
  11264. /**
  11265. * Gets or sets the gradient value (between 0 and 1)
  11266. */
  11267. gradient: number,
  11268. /**
  11269. * Gets or sets the associated color
  11270. */
  11271. color: Color3);
  11272. }
  11273. /** Class used to store factor gradient */
  11274. export class FactorGradient implements IValueGradient {
  11275. /**
  11276. * Gets or sets the gradient value (between 0 and 1)
  11277. */
  11278. gradient: number;
  11279. /**
  11280. * Gets or sets first associated factor
  11281. */
  11282. factor1: number;
  11283. /**
  11284. * Gets or sets second associated factor
  11285. */
  11286. factor2?: number | undefined;
  11287. /**
  11288. * Creates a new factor gradient
  11289. * @param gradient gets or sets the gradient value (between 0 and 1)
  11290. * @param factor1 gets or sets first associated factor
  11291. * @param factor2 gets or sets second associated factor
  11292. */
  11293. constructor(
  11294. /**
  11295. * Gets or sets the gradient value (between 0 and 1)
  11296. */
  11297. gradient: number,
  11298. /**
  11299. * Gets or sets first associated factor
  11300. */
  11301. factor1: number,
  11302. /**
  11303. * Gets or sets second associated factor
  11304. */
  11305. factor2?: number | undefined);
  11306. /**
  11307. * Will get a number picked randomly between factor1 and factor2.
  11308. * If factor2 is undefined then factor1 will be used
  11309. * @returns the picked number
  11310. */
  11311. getFactor(): number;
  11312. }
  11313. /**
  11314. * Helper used to simplify some generic gradient tasks
  11315. */
  11316. export class GradientHelper {
  11317. /**
  11318. * Gets the current gradient from an array of IValueGradient
  11319. * @param ratio defines the current ratio to get
  11320. * @param gradients defines the array of IValueGradient
  11321. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11322. */
  11323. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11324. }
  11325. }
  11326. declare module BABYLON {
  11327. interface ThinEngine {
  11328. /**
  11329. * Creates a raw texture
  11330. * @param data defines the data to store in the texture
  11331. * @param width defines the width of the texture
  11332. * @param height defines the height of the texture
  11333. * @param format defines the format of the data
  11334. * @param generateMipMaps defines if the engine should generate the mip levels
  11335. * @param invertY defines if data must be stored with Y axis inverted
  11336. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11337. * @param compression defines the compression used (null by default)
  11338. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11339. * @returns the raw texture inside an InternalTexture
  11340. */
  11341. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11342. /**
  11343. * Update a raw texture
  11344. * @param texture defines the texture to update
  11345. * @param data defines the data to store in the texture
  11346. * @param format defines the format of the data
  11347. * @param invertY defines if data must be stored with Y axis inverted
  11348. */
  11349. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11350. /**
  11351. * Update a raw texture
  11352. * @param texture defines the texture to update
  11353. * @param data defines the data to store in the texture
  11354. * @param format defines the format of the data
  11355. * @param invertY defines if data must be stored with Y axis inverted
  11356. * @param compression defines the compression used (null by default)
  11357. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11358. */
  11359. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11360. /**
  11361. * Creates a new raw cube texture
  11362. * @param data defines the array of data to use to create each face
  11363. * @param size defines the size of the textures
  11364. * @param format defines the format of the data
  11365. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11366. * @param generateMipMaps defines if the engine should generate the mip levels
  11367. * @param invertY defines if data must be stored with Y axis inverted
  11368. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11369. * @param compression defines the compression used (null by default)
  11370. * @returns the cube texture as an InternalTexture
  11371. */
  11372. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11373. /**
  11374. * Update a raw cube texture
  11375. * @param texture defines the texture to udpdate
  11376. * @param data defines the data to store
  11377. * @param format defines the data format
  11378. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11379. * @param invertY defines if data must be stored with Y axis inverted
  11380. */
  11381. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11382. /**
  11383. * Update a raw cube texture
  11384. * @param texture defines the texture to udpdate
  11385. * @param data defines the data to store
  11386. * @param format defines the data format
  11387. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11388. * @param invertY defines if data must be stored with Y axis inverted
  11389. * @param compression defines the compression used (null by default)
  11390. */
  11391. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11392. /**
  11393. * Update a raw cube texture
  11394. * @param texture defines the texture to udpdate
  11395. * @param data defines the data to store
  11396. * @param format defines the data format
  11397. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11398. * @param invertY defines if data must be stored with Y axis inverted
  11399. * @param compression defines the compression used (null by default)
  11400. * @param level defines which level of the texture to update
  11401. */
  11402. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11403. /**
  11404. * Creates a new raw cube texture from a specified url
  11405. * @param url defines the url where the data is located
  11406. * @param scene defines the current scene
  11407. * @param size defines the size of the textures
  11408. * @param format defines the format of the data
  11409. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11410. * @param noMipmap defines if the engine should avoid generating the mip levels
  11411. * @param callback defines a callback used to extract texture data from loaded data
  11412. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11413. * @param onLoad defines a callback called when texture is loaded
  11414. * @param onError defines a callback called if there is an error
  11415. * @returns the cube texture as an InternalTexture
  11416. */
  11417. 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;
  11418. /**
  11419. * Creates a new raw cube texture from a specified url
  11420. * @param url defines the url where the data is located
  11421. * @param scene defines the current scene
  11422. * @param size defines the size of the textures
  11423. * @param format defines the format of the data
  11424. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11425. * @param noMipmap defines if the engine should avoid generating the mip levels
  11426. * @param callback defines a callback used to extract texture data from loaded data
  11427. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11428. * @param onLoad defines a callback called when texture is loaded
  11429. * @param onError defines a callback called if there is an error
  11430. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11431. * @param invertY defines if data must be stored with Y axis inverted
  11432. * @returns the cube texture as an InternalTexture
  11433. */
  11434. 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;
  11435. /**
  11436. * Creates a new raw 3D texture
  11437. * @param data defines the data used to create the texture
  11438. * @param width defines the width of the texture
  11439. * @param height defines the height of the texture
  11440. * @param depth defines the depth of the texture
  11441. * @param format defines the format of the texture
  11442. * @param generateMipMaps defines if the engine must generate mip levels
  11443. * @param invertY defines if data must be stored with Y axis inverted
  11444. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11445. * @param compression defines the compressed used (can be null)
  11446. * @param textureType defines the compressed used (can be null)
  11447. * @returns a new raw 3D texture (stored in an InternalTexture)
  11448. */
  11449. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11450. /**
  11451. * Update a raw 3D texture
  11452. * @param texture defines the texture to update
  11453. * @param data defines the data to store
  11454. * @param format defines the data format
  11455. * @param invertY defines if data must be stored with Y axis inverted
  11456. */
  11457. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11458. /**
  11459. * Update a raw 3D texture
  11460. * @param texture defines the texture to update
  11461. * @param data defines the data to store
  11462. * @param format defines the data format
  11463. * @param invertY defines if data must be stored with Y axis inverted
  11464. * @param compression defines the used compression (can be null)
  11465. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11466. */
  11467. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11468. /**
  11469. * Creates a new raw 2D array texture
  11470. * @param data defines the data used to create the texture
  11471. * @param width defines the width of the texture
  11472. * @param height defines the height of the texture
  11473. * @param depth defines the number of layers of the texture
  11474. * @param format defines the format of the texture
  11475. * @param generateMipMaps defines if the engine must generate mip levels
  11476. * @param invertY defines if data must be stored with Y axis inverted
  11477. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11478. * @param compression defines the compressed used (can be null)
  11479. * @param textureType defines the compressed used (can be null)
  11480. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11481. */
  11482. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11483. /**
  11484. * Update a raw 2D array texture
  11485. * @param texture defines the texture to update
  11486. * @param data defines the data to store
  11487. * @param format defines the data format
  11488. * @param invertY defines if data must be stored with Y axis inverted
  11489. */
  11490. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11491. /**
  11492. * Update a raw 2D array texture
  11493. * @param texture defines the texture to update
  11494. * @param data defines the data to store
  11495. * @param format defines the data format
  11496. * @param invertY defines if data must be stored with Y axis inverted
  11497. * @param compression defines the used compression (can be null)
  11498. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11499. */
  11500. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11501. }
  11502. }
  11503. declare module BABYLON {
  11504. /**
  11505. * Raw texture can help creating a texture directly from an array of data.
  11506. * This can be super useful if you either get the data from an uncompressed source or
  11507. * if you wish to create your texture pixel by pixel.
  11508. */
  11509. export class RawTexture extends Texture {
  11510. /**
  11511. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11512. */
  11513. format: number;
  11514. /**
  11515. * Instantiates a new RawTexture.
  11516. * Raw texture can help creating a texture directly from an array of data.
  11517. * This can be super useful if you either get the data from an uncompressed source or
  11518. * if you wish to create your texture pixel by pixel.
  11519. * @param data define the array of data to use to create the texture
  11520. * @param width define the width of the texture
  11521. * @param height define the height of the texture
  11522. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11523. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11524. * @param generateMipMaps define whether mip maps should be generated or not
  11525. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11526. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11527. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11528. */
  11529. constructor(data: ArrayBufferView, width: number, height: number,
  11530. /**
  11531. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11532. */
  11533. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11534. /**
  11535. * Updates the texture underlying data.
  11536. * @param data Define the new data of the texture
  11537. */
  11538. update(data: ArrayBufferView): void;
  11539. /**
  11540. * Creates a luminance 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. * @returns the luminance texture
  11549. */
  11550. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11551. /**
  11552. * Creates a luminance alpha texture from some data.
  11553. * @param data Define the texture data
  11554. * @param width Define the width of the texture
  11555. * @param height Define the height of the texture
  11556. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11560. * @returns the luminance alpha texture
  11561. */
  11562. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11563. /**
  11564. * Creates an alpha texture from some data.
  11565. * @param data Define the texture data
  11566. * @param width Define the width of the texture
  11567. * @param height Define the height of the texture
  11568. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11569. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11572. * @returns the alpha texture
  11573. */
  11574. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11575. /**
  11576. * Creates a RGB texture from some data.
  11577. * @param data Define the texture data
  11578. * @param width Define the width of the texture
  11579. * @param height Define the height of the texture
  11580. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11585. * @returns the RGB alpha texture
  11586. */
  11587. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11588. /**
  11589. * Creates a RGBA texture from some data.
  11590. * @param data Define the texture data
  11591. * @param width Define the width of the texture
  11592. * @param height Define the height of the texture
  11593. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11597. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11598. * @returns the RGBA texture
  11599. */
  11600. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11601. /**
  11602. * Creates a R texture from some data.
  11603. * @param data Define the texture data
  11604. * @param width Define the width of the texture
  11605. * @param height Define the height of the texture
  11606. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11607. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11608. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11609. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11610. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11611. * @returns the R texture
  11612. */
  11613. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11614. }
  11615. }
  11616. declare module BABYLON {
  11617. interface ThinEngine {
  11618. /**
  11619. * Update a dynamic index buffer
  11620. * @param indexBuffer defines the target index buffer
  11621. * @param indices defines the data to update
  11622. * @param offset defines the offset in the target index buffer where update should start
  11623. */
  11624. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11625. /**
  11626. * Updates a dynamic vertex buffer.
  11627. * @param vertexBuffer the vertex buffer to update
  11628. * @param data the data used to update the vertex buffer
  11629. * @param byteOffset the byte offset of the data
  11630. * @param byteLength the byte length of the data
  11631. */
  11632. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11633. }
  11634. }
  11635. declare module BABYLON {
  11636. interface AbstractScene {
  11637. /**
  11638. * The list of procedural textures added to the scene
  11639. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11640. */
  11641. proceduralTextures: Array<ProceduralTexture>;
  11642. }
  11643. /**
  11644. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11645. * in a given scene.
  11646. */
  11647. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11648. /**
  11649. * The component name helpfull to identify the component in the list of scene components.
  11650. */
  11651. readonly name: string;
  11652. /**
  11653. * The scene the component belongs to.
  11654. */
  11655. scene: Scene;
  11656. /**
  11657. * Creates a new instance of the component for the given scene
  11658. * @param scene Defines the scene to register the component in
  11659. */
  11660. constructor(scene: Scene);
  11661. /**
  11662. * Registers the component in a given scene
  11663. */
  11664. register(): void;
  11665. /**
  11666. * Rebuilds the elements related to this component in case of
  11667. * context lost for instance.
  11668. */
  11669. rebuild(): void;
  11670. /**
  11671. * Disposes the component and the associated ressources.
  11672. */
  11673. dispose(): void;
  11674. private _beforeClear;
  11675. }
  11676. }
  11677. declare module BABYLON {
  11678. interface ThinEngine {
  11679. /**
  11680. * Creates a new render target cube texture
  11681. * @param size defines the size of the texture
  11682. * @param options defines the options used to create the texture
  11683. * @returns a new render target cube texture stored in an InternalTexture
  11684. */
  11685. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11686. }
  11687. }
  11688. declare module BABYLON {
  11689. /** @hidden */
  11690. export var proceduralVertexShader: {
  11691. name: string;
  11692. shader: string;
  11693. };
  11694. }
  11695. declare module BABYLON {
  11696. /**
  11697. * 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.
  11698. * This is the base class of any Procedural texture and contains most of the shareable code.
  11699. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11700. */
  11701. export class ProceduralTexture extends Texture {
  11702. /**
  11703. * Define if the texture is enabled or not (disabled texture will not render)
  11704. */
  11705. isEnabled: boolean;
  11706. /**
  11707. * Define if the texture must be cleared before rendering (default is true)
  11708. */
  11709. autoClear: boolean;
  11710. /**
  11711. * Callback called when the texture is generated
  11712. */
  11713. onGenerated: () => void;
  11714. /**
  11715. * Event raised when the texture is generated
  11716. */
  11717. onGeneratedObservable: Observable<ProceduralTexture>;
  11718. /**
  11719. * Event raised before the texture is generated
  11720. */
  11721. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11722. /**
  11723. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11724. */
  11725. nodeMaterialSource: Nullable<NodeMaterial>;
  11726. /** @hidden */
  11727. _generateMipMaps: boolean;
  11728. /** @hidden **/
  11729. _effect: Effect;
  11730. /** @hidden */
  11731. _textures: {
  11732. [key: string]: Texture;
  11733. };
  11734. /** @hidden */
  11735. protected _fallbackTexture: Nullable<Texture>;
  11736. private _size;
  11737. private _currentRefreshId;
  11738. private _frameId;
  11739. private _refreshRate;
  11740. private _vertexBuffers;
  11741. private _indexBuffer;
  11742. private _uniforms;
  11743. private _samplers;
  11744. private _fragment;
  11745. private _floats;
  11746. private _ints;
  11747. private _floatsArrays;
  11748. private _colors3;
  11749. private _colors4;
  11750. private _vectors2;
  11751. private _vectors3;
  11752. private _matrices;
  11753. private _fallbackTextureUsed;
  11754. private _fullEngine;
  11755. private _cachedDefines;
  11756. private _contentUpdateId;
  11757. private _contentData;
  11758. /**
  11759. * Instantiates a new procedural texture.
  11760. * 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.
  11761. * This is the base class of any Procedural texture and contains most of the shareable code.
  11762. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11763. * @param name Define the name of the texture
  11764. * @param size Define the size of the texture to create
  11765. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11766. * @param scene Define the scene the texture belongs to
  11767. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11768. * @param generateMipMaps Define if the texture should creates mip maps or not
  11769. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11770. */
  11771. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11772. /**
  11773. * The effect that is created when initializing the post process.
  11774. * @returns The created effect corresponding the the postprocess.
  11775. */
  11776. getEffect(): Effect;
  11777. /**
  11778. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11779. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11780. */
  11781. getContent(): Nullable<ArrayBufferView>;
  11782. private _createIndexBuffer;
  11783. /** @hidden */
  11784. _rebuild(): void;
  11785. /**
  11786. * Resets the texture in order to recreate its associated resources.
  11787. * This can be called in case of context loss
  11788. */
  11789. reset(): void;
  11790. protected _getDefines(): string;
  11791. /**
  11792. * Is the texture ready to be used ? (rendered at least once)
  11793. * @returns true if ready, otherwise, false.
  11794. */
  11795. isReady(): boolean;
  11796. /**
  11797. * Resets the refresh counter of the texture and start bak from scratch.
  11798. * Could be useful to regenerate the texture if it is setup to render only once.
  11799. */
  11800. resetRefreshCounter(): void;
  11801. /**
  11802. * Set the fragment shader to use in order to render the texture.
  11803. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11804. */
  11805. setFragment(fragment: any): void;
  11806. /**
  11807. * Define the refresh rate of the texture or the rendering frequency.
  11808. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11809. */
  11810. get refreshRate(): number;
  11811. set refreshRate(value: number);
  11812. /** @hidden */
  11813. _shouldRender(): boolean;
  11814. /**
  11815. * Get the size the texture is rendering at.
  11816. * @returns the size (on cube texture it is always squared)
  11817. */
  11818. getRenderSize(): RenderTargetTextureSize;
  11819. /**
  11820. * Resize the texture to new value.
  11821. * @param size Define the new size the texture should have
  11822. * @param generateMipMaps Define whether the new texture should create mip maps
  11823. */
  11824. resize(size: number, generateMipMaps: boolean): void;
  11825. private _checkUniform;
  11826. /**
  11827. * Set a texture in the shader program used to render.
  11828. * @param name Define the name of the uniform samplers as defined in the shader
  11829. * @param texture Define the texture to bind to this sampler
  11830. * @return the texture itself allowing "fluent" like uniform updates
  11831. */
  11832. setTexture(name: string, texture: Texture): ProceduralTexture;
  11833. /**
  11834. * Set a float in the shader.
  11835. * @param name Define the name of the uniform as defined in the shader
  11836. * @param value Define the value to give to the uniform
  11837. * @return the texture itself allowing "fluent" like uniform updates
  11838. */
  11839. setFloat(name: string, value: number): ProceduralTexture;
  11840. /**
  11841. * Set a int in the shader.
  11842. * @param name Define the name of the uniform as defined in the shader
  11843. * @param value Define the value to give to the uniform
  11844. * @return the texture itself allowing "fluent" like uniform updates
  11845. */
  11846. setInt(name: string, value: number): ProceduralTexture;
  11847. /**
  11848. * Set an array of floats in the shader.
  11849. * @param name Define the name of the uniform as defined in the shader
  11850. * @param value Define the value to give to the uniform
  11851. * @return the texture itself allowing "fluent" like uniform updates
  11852. */
  11853. setFloats(name: string, value: number[]): ProceduralTexture;
  11854. /**
  11855. * Set a vec3 in the shader from a Color3.
  11856. * @param name Define the name of the uniform as defined in the shader
  11857. * @param value Define the value to give to the uniform
  11858. * @return the texture itself allowing "fluent" like uniform updates
  11859. */
  11860. setColor3(name: string, value: Color3): ProceduralTexture;
  11861. /**
  11862. * Set a vec4 in the shader from a Color4.
  11863. * @param name Define the name of the uniform as defined in the shader
  11864. * @param value Define the value to give to the uniform
  11865. * @return the texture itself allowing "fluent" like uniform updates
  11866. */
  11867. setColor4(name: string, value: Color4): ProceduralTexture;
  11868. /**
  11869. * Set a vec2 in the shader from a Vector2.
  11870. * @param name Define the name of the uniform as defined in the shader
  11871. * @param value Define the value to give to the uniform
  11872. * @return the texture itself allowing "fluent" like uniform updates
  11873. */
  11874. setVector2(name: string, value: Vector2): ProceduralTexture;
  11875. /**
  11876. * Set a vec3 in the shader from a Vector3.
  11877. * @param name Define the name of the uniform as defined in the shader
  11878. * @param value Define the value to give to the uniform
  11879. * @return the texture itself allowing "fluent" like uniform updates
  11880. */
  11881. setVector3(name: string, value: Vector3): ProceduralTexture;
  11882. /**
  11883. * Set a mat4 in the shader from a MAtrix.
  11884. * @param name Define the name of the uniform as defined in the shader
  11885. * @param value Define the value to give to the uniform
  11886. * @return the texture itself allowing "fluent" like uniform updates
  11887. */
  11888. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11889. /**
  11890. * Render the texture to its associated render target.
  11891. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11892. */
  11893. render(useCameraPostProcess?: boolean): void;
  11894. /**
  11895. * Clone the texture.
  11896. * @returns the cloned texture
  11897. */
  11898. clone(): ProceduralTexture;
  11899. /**
  11900. * Dispose the texture and release its asoociated resources.
  11901. */
  11902. dispose(): void;
  11903. }
  11904. }
  11905. declare module BABYLON {
  11906. /**
  11907. * This represents the base class for particle system in Babylon.
  11908. * 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.
  11909. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11910. * @example https://doc.babylonjs.com/babylon101/particles
  11911. */
  11912. export class BaseParticleSystem {
  11913. /**
  11914. * Source color is added to the destination color without alpha affecting the result
  11915. */
  11916. static BLENDMODE_ONEONE: number;
  11917. /**
  11918. * Blend current color and particle color using particle’s alpha
  11919. */
  11920. static BLENDMODE_STANDARD: number;
  11921. /**
  11922. * Add current color and particle color multiplied by particle’s alpha
  11923. */
  11924. static BLENDMODE_ADD: number;
  11925. /**
  11926. * Multiply current color with particle color
  11927. */
  11928. static BLENDMODE_MULTIPLY: number;
  11929. /**
  11930. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11931. */
  11932. static BLENDMODE_MULTIPLYADD: number;
  11933. /**
  11934. * List of animations used by the particle system.
  11935. */
  11936. animations: Animation[];
  11937. /**
  11938. * Gets or sets the unique id of the particle system
  11939. */
  11940. uniqueId: number;
  11941. /**
  11942. * The id of the Particle system.
  11943. */
  11944. id: string;
  11945. /**
  11946. * The friendly name of the Particle system.
  11947. */
  11948. name: string;
  11949. /**
  11950. * Snippet ID if the particle system was created from the snippet server
  11951. */
  11952. snippetId: string;
  11953. /**
  11954. * The rendering group used by the Particle system to chose when to render.
  11955. */
  11956. renderingGroupId: number;
  11957. /**
  11958. * The emitter represents the Mesh or position we are attaching the particle system to.
  11959. */
  11960. emitter: Nullable<AbstractMesh | Vector3>;
  11961. /**
  11962. * The maximum number of particles to emit per frame
  11963. */
  11964. emitRate: number;
  11965. /**
  11966. * If you want to launch only a few particles at once, that can be done, as well.
  11967. */
  11968. manualEmitCount: number;
  11969. /**
  11970. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11971. */
  11972. updateSpeed: number;
  11973. /**
  11974. * The amount of time the particle system is running (depends of the overall update speed).
  11975. */
  11976. targetStopDuration: number;
  11977. /**
  11978. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11979. */
  11980. disposeOnStop: boolean;
  11981. /**
  11982. * Minimum power of emitting particles.
  11983. */
  11984. minEmitPower: number;
  11985. /**
  11986. * Maximum power of emitting particles.
  11987. */
  11988. maxEmitPower: number;
  11989. /**
  11990. * Minimum life time of emitting particles.
  11991. */
  11992. minLifeTime: number;
  11993. /**
  11994. * Maximum life time of emitting particles.
  11995. */
  11996. maxLifeTime: number;
  11997. /**
  11998. * Minimum Size of emitting particles.
  11999. */
  12000. minSize: number;
  12001. /**
  12002. * Maximum Size of emitting particles.
  12003. */
  12004. maxSize: number;
  12005. /**
  12006. * Minimum scale of emitting particles on X axis.
  12007. */
  12008. minScaleX: number;
  12009. /**
  12010. * Maximum scale of emitting particles on X axis.
  12011. */
  12012. maxScaleX: number;
  12013. /**
  12014. * Minimum scale of emitting particles on Y axis.
  12015. */
  12016. minScaleY: number;
  12017. /**
  12018. * Maximum scale of emitting particles on Y axis.
  12019. */
  12020. maxScaleY: number;
  12021. /**
  12022. * Gets or sets the minimal initial rotation in radians.
  12023. */
  12024. minInitialRotation: number;
  12025. /**
  12026. * Gets or sets the maximal initial rotation in radians.
  12027. */
  12028. maxInitialRotation: number;
  12029. /**
  12030. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12031. */
  12032. minAngularSpeed: number;
  12033. /**
  12034. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12035. */
  12036. maxAngularSpeed: number;
  12037. /**
  12038. * The texture used to render each particle. (this can be a spritesheet)
  12039. */
  12040. particleTexture: Nullable<BaseTexture>;
  12041. /**
  12042. * The layer mask we are rendering the particles through.
  12043. */
  12044. layerMask: number;
  12045. /**
  12046. * This can help using your own shader to render the particle system.
  12047. * The according effect will be created
  12048. */
  12049. customShader: any;
  12050. /**
  12051. * By default particle system starts as soon as they are created. This prevents the
  12052. * automatic start to happen and let you decide when to start emitting particles.
  12053. */
  12054. preventAutoStart: boolean;
  12055. private _noiseTexture;
  12056. /**
  12057. * Gets or sets a texture used to add random noise to particle positions
  12058. */
  12059. get noiseTexture(): Nullable<ProceduralTexture>;
  12060. set noiseTexture(value: Nullable<ProceduralTexture>);
  12061. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12062. noiseStrength: Vector3;
  12063. /**
  12064. * Callback triggered when the particle animation is ending.
  12065. */
  12066. onAnimationEnd: Nullable<() => void>;
  12067. /**
  12068. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12069. */
  12070. blendMode: number;
  12071. /**
  12072. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12073. * to override the particles.
  12074. */
  12075. forceDepthWrite: boolean;
  12076. /** 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 */
  12077. preWarmCycles: number;
  12078. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12079. preWarmStepOffset: number;
  12080. /**
  12081. * 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)
  12082. */
  12083. spriteCellChangeSpeed: number;
  12084. /**
  12085. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12086. */
  12087. startSpriteCellID: number;
  12088. /**
  12089. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12090. */
  12091. endSpriteCellID: number;
  12092. /**
  12093. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12094. */
  12095. spriteCellWidth: number;
  12096. /**
  12097. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12098. */
  12099. spriteCellHeight: number;
  12100. /**
  12101. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12102. */
  12103. spriteRandomStartCell: boolean;
  12104. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12105. translationPivot: Vector2;
  12106. /** @hidden */
  12107. protected _isAnimationSheetEnabled: boolean;
  12108. /**
  12109. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12110. */
  12111. beginAnimationOnStart: boolean;
  12112. /**
  12113. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12114. */
  12115. beginAnimationFrom: number;
  12116. /**
  12117. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12118. */
  12119. beginAnimationTo: number;
  12120. /**
  12121. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12122. */
  12123. beginAnimationLoop: boolean;
  12124. /**
  12125. * Gets or sets a world offset applied to all particles
  12126. */
  12127. worldOffset: Vector3;
  12128. /**
  12129. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12130. */
  12131. get isAnimationSheetEnabled(): boolean;
  12132. set isAnimationSheetEnabled(value: boolean);
  12133. /**
  12134. * Get hosting scene
  12135. * @returns the scene
  12136. */
  12137. getScene(): Nullable<Scene>;
  12138. /**
  12139. * You can use gravity if you want to give an orientation to your particles.
  12140. */
  12141. gravity: Vector3;
  12142. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12143. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12144. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12145. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12146. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12147. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12148. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12149. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12150. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12151. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12152. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12153. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12154. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12155. /**
  12156. * Defines the delay in milliseconds before starting the system (0 by default)
  12157. */
  12158. startDelay: number;
  12159. /**
  12160. * Gets the current list of drag gradients.
  12161. * You must use addDragGradient and removeDragGradient to udpate this list
  12162. * @returns the list of drag gradients
  12163. */
  12164. getDragGradients(): Nullable<Array<FactorGradient>>;
  12165. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12166. limitVelocityDamping: number;
  12167. /**
  12168. * Gets the current list of limit velocity gradients.
  12169. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12170. * @returns the list of limit velocity gradients
  12171. */
  12172. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12173. /**
  12174. * Gets the current list of color gradients.
  12175. * You must use addColorGradient and removeColorGradient to udpate this list
  12176. * @returns the list of color gradients
  12177. */
  12178. getColorGradients(): Nullable<Array<ColorGradient>>;
  12179. /**
  12180. * Gets the current list of size gradients.
  12181. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12182. * @returns the list of size gradients
  12183. */
  12184. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12185. /**
  12186. * Gets the current list of color remap gradients.
  12187. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12188. * @returns the list of color remap gradients
  12189. */
  12190. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12191. /**
  12192. * Gets the current list of alpha remap gradients.
  12193. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12194. * @returns the list of alpha remap gradients
  12195. */
  12196. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12197. /**
  12198. * Gets the current list of life time gradients.
  12199. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12200. * @returns the list of life time gradients
  12201. */
  12202. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12203. /**
  12204. * Gets the current list of angular speed gradients.
  12205. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12206. * @returns the list of angular speed gradients
  12207. */
  12208. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12209. /**
  12210. * Gets the current list of velocity gradients.
  12211. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12212. * @returns the list of velocity gradients
  12213. */
  12214. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12215. /**
  12216. * Gets the current list of start size gradients.
  12217. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12218. * @returns the list of start size gradients
  12219. */
  12220. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12221. /**
  12222. * Gets the current list of emit rate gradients.
  12223. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12224. * @returns the list of emit rate gradients
  12225. */
  12226. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12227. /**
  12228. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12229. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12230. */
  12231. get direction1(): Vector3;
  12232. set direction1(value: Vector3);
  12233. /**
  12234. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12235. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12236. */
  12237. get direction2(): Vector3;
  12238. set direction2(value: Vector3);
  12239. /**
  12240. * 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.
  12241. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12242. */
  12243. get minEmitBox(): Vector3;
  12244. set minEmitBox(value: Vector3);
  12245. /**
  12246. * 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.
  12247. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12248. */
  12249. get maxEmitBox(): Vector3;
  12250. set maxEmitBox(value: Vector3);
  12251. /**
  12252. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12253. */
  12254. color1: Color4;
  12255. /**
  12256. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12257. */
  12258. color2: Color4;
  12259. /**
  12260. * Color the particle will have at the end of its lifetime
  12261. */
  12262. colorDead: Color4;
  12263. /**
  12264. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12265. */
  12266. textureMask: Color4;
  12267. /**
  12268. * The particle emitter type defines the emitter used by the particle system.
  12269. * It can be for example box, sphere, or cone...
  12270. */
  12271. particleEmitterType: IParticleEmitterType;
  12272. /** @hidden */
  12273. _isSubEmitter: boolean;
  12274. /**
  12275. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12276. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12277. */
  12278. billboardMode: number;
  12279. protected _isBillboardBased: boolean;
  12280. /**
  12281. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12282. */
  12283. get isBillboardBased(): boolean;
  12284. set isBillboardBased(value: boolean);
  12285. /**
  12286. * The scene the particle system belongs to.
  12287. */
  12288. protected _scene: Nullable<Scene>;
  12289. /**
  12290. * The engine the particle system belongs to.
  12291. */
  12292. protected _engine: ThinEngine;
  12293. /**
  12294. * Local cache of defines for image processing.
  12295. */
  12296. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12297. /**
  12298. * Default configuration related to image processing available in the standard Material.
  12299. */
  12300. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12301. /**
  12302. * Gets the image processing configuration used either in this material.
  12303. */
  12304. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12305. /**
  12306. * Sets the Default image processing configuration used either in the this material.
  12307. *
  12308. * If sets to null, the scene one is in use.
  12309. */
  12310. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12311. /**
  12312. * Attaches a new image processing configuration to the Standard Material.
  12313. * @param configuration
  12314. */
  12315. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12316. /** @hidden */
  12317. protected _reset(): void;
  12318. /** @hidden */
  12319. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12320. /**
  12321. * Instantiates a particle system.
  12322. * 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.
  12323. * @param name The name of the particle system
  12324. */
  12325. constructor(name: string);
  12326. /**
  12327. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12328. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12329. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12330. * @returns the emitter
  12331. */
  12332. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12333. /**
  12334. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12335. * @param radius The radius of the hemisphere to emit from
  12336. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12337. * @returns the emitter
  12338. */
  12339. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12340. /**
  12341. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12342. * @param radius The radius of the sphere to emit from
  12343. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12344. * @returns the emitter
  12345. */
  12346. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12347. /**
  12348. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12349. * @param radius The radius of the sphere to emit from
  12350. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12351. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12352. * @returns the emitter
  12353. */
  12354. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12355. /**
  12356. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12357. * @param radius The radius of the emission cylinder
  12358. * @param height The height of the emission cylinder
  12359. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12360. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12361. * @returns the emitter
  12362. */
  12363. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12364. /**
  12365. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12366. * @param radius The radius of the cylinder to emit from
  12367. * @param height The height of the emission cylinder
  12368. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12369. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12370. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12371. * @returns the emitter
  12372. */
  12373. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12374. /**
  12375. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12376. * @param radius The radius of the cone to emit from
  12377. * @param angle The base angle of the cone
  12378. * @returns the emitter
  12379. */
  12380. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12381. /**
  12382. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12383. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12384. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12385. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12386. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12387. * @returns the emitter
  12388. */
  12389. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12390. }
  12391. }
  12392. declare module BABYLON {
  12393. /**
  12394. * Type of sub emitter
  12395. */
  12396. export enum SubEmitterType {
  12397. /**
  12398. * Attached to the particle over it's lifetime
  12399. */
  12400. ATTACHED = 0,
  12401. /**
  12402. * Created when the particle dies
  12403. */
  12404. END = 1
  12405. }
  12406. /**
  12407. * Sub emitter class used to emit particles from an existing particle
  12408. */
  12409. export class SubEmitter {
  12410. /**
  12411. * the particle system to be used by the sub emitter
  12412. */
  12413. particleSystem: ParticleSystem;
  12414. /**
  12415. * Type of the submitter (Default: END)
  12416. */
  12417. type: SubEmitterType;
  12418. /**
  12419. * 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)
  12420. * Note: This only is supported when using an emitter of type Mesh
  12421. */
  12422. inheritDirection: boolean;
  12423. /**
  12424. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12425. */
  12426. inheritedVelocityAmount: number;
  12427. /**
  12428. * Creates a sub emitter
  12429. * @param particleSystem the particle system to be used by the sub emitter
  12430. */
  12431. constructor(
  12432. /**
  12433. * the particle system to be used by the sub emitter
  12434. */
  12435. particleSystem: ParticleSystem);
  12436. /**
  12437. * Clones the sub emitter
  12438. * @returns the cloned sub emitter
  12439. */
  12440. clone(): SubEmitter;
  12441. /**
  12442. * Serialize current object to a JSON object
  12443. * @returns the serialized object
  12444. */
  12445. serialize(): any;
  12446. /** @hidden */
  12447. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12448. /**
  12449. * Creates a new SubEmitter from a serialized JSON version
  12450. * @param serializationObject defines the JSON object to read from
  12451. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12452. * @param rootUrl defines the rootUrl for data loading
  12453. * @returns a new SubEmitter
  12454. */
  12455. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12456. /** Release associated resources */
  12457. dispose(): void;
  12458. }
  12459. }
  12460. declare module BABYLON {
  12461. /** @hidden */
  12462. export var imageProcessingDeclaration: {
  12463. name: string;
  12464. shader: string;
  12465. };
  12466. }
  12467. declare module BABYLON {
  12468. /** @hidden */
  12469. export var imageProcessingFunctions: {
  12470. name: string;
  12471. shader: string;
  12472. };
  12473. }
  12474. declare module BABYLON {
  12475. /** @hidden */
  12476. export var particlesPixelShader: {
  12477. name: string;
  12478. shader: string;
  12479. };
  12480. }
  12481. declare module BABYLON {
  12482. /** @hidden */
  12483. export var particlesVertexShader: {
  12484. name: string;
  12485. shader: string;
  12486. };
  12487. }
  12488. declare module BABYLON {
  12489. /**
  12490. * Interface used to define entities containing multiple clip planes
  12491. */
  12492. export interface IClipPlanesHolder {
  12493. /**
  12494. * Gets or sets the active clipplane 1
  12495. */
  12496. clipPlane: Nullable<Plane>;
  12497. /**
  12498. * Gets or sets the active clipplane 2
  12499. */
  12500. clipPlane2: Nullable<Plane>;
  12501. /**
  12502. * Gets or sets the active clipplane 3
  12503. */
  12504. clipPlane3: Nullable<Plane>;
  12505. /**
  12506. * Gets or sets the active clipplane 4
  12507. */
  12508. clipPlane4: Nullable<Plane>;
  12509. /**
  12510. * Gets or sets the active clipplane 5
  12511. */
  12512. clipPlane5: Nullable<Plane>;
  12513. /**
  12514. * Gets or sets the active clipplane 6
  12515. */
  12516. clipPlane6: Nullable<Plane>;
  12517. }
  12518. }
  12519. declare module BABYLON {
  12520. /**
  12521. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12522. *
  12523. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12524. *
  12525. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12526. */
  12527. export class ThinMaterialHelper {
  12528. /**
  12529. * Binds the clip plane information from the holder to the effect.
  12530. * @param effect The effect we are binding the data to
  12531. * @param holder The entity containing the clip plane information
  12532. */
  12533. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12534. }
  12535. }
  12536. declare module BABYLON {
  12537. interface ThinEngine {
  12538. /**
  12539. * Sets alpha constants used by some alpha blending modes
  12540. * @param r defines the red component
  12541. * @param g defines the green component
  12542. * @param b defines the blue component
  12543. * @param a defines the alpha component
  12544. */
  12545. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12546. /**
  12547. * Sets the current alpha mode
  12548. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12549. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12550. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12551. */
  12552. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12553. /**
  12554. * Gets the current alpha mode
  12555. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12556. * @returns the current alpha mode
  12557. */
  12558. getAlphaMode(): number;
  12559. /**
  12560. * Sets the current alpha equation
  12561. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12562. */
  12563. setAlphaEquation(equation: number): void;
  12564. /**
  12565. * Gets the current alpha equation.
  12566. * @returns the current alpha equation
  12567. */
  12568. getAlphaEquation(): number;
  12569. }
  12570. }
  12571. declare module BABYLON {
  12572. /**
  12573. * This represents a particle system in Babylon.
  12574. * 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.
  12575. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12576. * @example https://doc.babylonjs.com/babylon101/particles
  12577. */
  12578. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12579. /**
  12580. * Billboard mode will only apply to Y axis
  12581. */
  12582. static readonly BILLBOARDMODE_Y: number;
  12583. /**
  12584. * Billboard mode will apply to all axes
  12585. */
  12586. static readonly BILLBOARDMODE_ALL: number;
  12587. /**
  12588. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12589. */
  12590. static readonly BILLBOARDMODE_STRETCHED: number;
  12591. /**
  12592. * This function can be defined to provide custom update for active particles.
  12593. * This function will be called instead of regular update (age, position, color, etc.).
  12594. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12595. */
  12596. updateFunction: (particles: Particle[]) => void;
  12597. private _emitterWorldMatrix;
  12598. /**
  12599. * This function can be defined to specify initial direction for every new particle.
  12600. * It by default use the emitterType defined function
  12601. */
  12602. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12603. /**
  12604. * This function can be defined to specify initial position for every new particle.
  12605. * It by default use the emitterType defined function
  12606. */
  12607. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12608. /**
  12609. * @hidden
  12610. */
  12611. _inheritedVelocityOffset: Vector3;
  12612. /**
  12613. * An event triggered when the system is disposed
  12614. */
  12615. onDisposeObservable: Observable<IParticleSystem>;
  12616. private _onDisposeObserver;
  12617. /**
  12618. * Sets a callback that will be triggered when the system is disposed
  12619. */
  12620. set onDispose(callback: () => void);
  12621. private _particles;
  12622. private _epsilon;
  12623. private _capacity;
  12624. private _stockParticles;
  12625. private _newPartsExcess;
  12626. private _vertexData;
  12627. private _vertexBuffer;
  12628. private _vertexBuffers;
  12629. private _spriteBuffer;
  12630. private _indexBuffer;
  12631. private _effect;
  12632. private _customEffect;
  12633. private _cachedDefines;
  12634. private _scaledColorStep;
  12635. private _colorDiff;
  12636. private _scaledDirection;
  12637. private _scaledGravity;
  12638. private _currentRenderId;
  12639. private _alive;
  12640. private _useInstancing;
  12641. private _started;
  12642. private _stopped;
  12643. private _actualFrame;
  12644. private _scaledUpdateSpeed;
  12645. private _vertexBufferSize;
  12646. /** @hidden */
  12647. _currentEmitRateGradient: Nullable<FactorGradient>;
  12648. /** @hidden */
  12649. _currentEmitRate1: number;
  12650. /** @hidden */
  12651. _currentEmitRate2: number;
  12652. /** @hidden */
  12653. _currentStartSizeGradient: Nullable<FactorGradient>;
  12654. /** @hidden */
  12655. _currentStartSize1: number;
  12656. /** @hidden */
  12657. _currentStartSize2: number;
  12658. private readonly _rawTextureWidth;
  12659. private _rampGradientsTexture;
  12660. private _useRampGradients;
  12661. /** Gets or sets a matrix to use to compute projection */
  12662. defaultProjectionMatrix: Matrix;
  12663. /** Gets or sets a matrix to use to compute view */
  12664. defaultViewMatrix: Matrix;
  12665. /** Gets or sets a boolean indicating that ramp gradients must be used
  12666. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12667. */
  12668. get useRampGradients(): boolean;
  12669. set useRampGradients(value: boolean);
  12670. /**
  12671. * 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.
  12672. * 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: [])
  12673. */
  12674. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12675. private _subEmitters;
  12676. /**
  12677. * @hidden
  12678. * If the particle systems emitter should be disposed when the particle system is disposed
  12679. */
  12680. _disposeEmitterOnDispose: boolean;
  12681. /**
  12682. * The current active Sub-systems, this property is used by the root particle system only.
  12683. */
  12684. activeSubSystems: Array<ParticleSystem>;
  12685. /**
  12686. * Specifies if the particles are updated in emitter local space or world space
  12687. */
  12688. isLocal: boolean;
  12689. private _rootParticleSystem;
  12690. /**
  12691. * Gets the current list of active particles
  12692. */
  12693. get particles(): Particle[];
  12694. /**
  12695. * Gets the number of particles active at the same time.
  12696. * @returns The number of active particles.
  12697. */
  12698. getActiveCount(): number;
  12699. /**
  12700. * Returns the string "ParticleSystem"
  12701. * @returns a string containing the class name
  12702. */
  12703. getClassName(): string;
  12704. /**
  12705. * Gets a boolean indicating that the system is stopping
  12706. * @returns true if the system is currently stopping
  12707. */
  12708. isStopping(): boolean;
  12709. /**
  12710. * Gets the custom effect used to render the particles
  12711. * @param blendMode Blend mode for which the effect should be retrieved
  12712. * @returns The effect
  12713. */
  12714. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12715. /**
  12716. * Sets the custom effect used to render the particles
  12717. * @param effect The effect to set
  12718. * @param blendMode Blend mode for which the effect should be set
  12719. */
  12720. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12721. /** @hidden */
  12722. private _onBeforeDrawParticlesObservable;
  12723. /**
  12724. * Observable that will be called just before the particles are drawn
  12725. */
  12726. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12727. /**
  12728. * Gets the name of the particle vertex shader
  12729. */
  12730. get vertexShaderName(): string;
  12731. /**
  12732. * Instantiates a particle system.
  12733. * 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.
  12734. * @param name The name of the particle system
  12735. * @param capacity The max number of particles alive at the same time
  12736. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12737. * @param customEffect a custom effect used to change the way particles are rendered by default
  12738. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12739. * @param epsilon Offset used to render the particles
  12740. */
  12741. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12742. private _addFactorGradient;
  12743. private _removeFactorGradient;
  12744. /**
  12745. * Adds a new life time gradient
  12746. * @param gradient defines the gradient to use (between 0 and 1)
  12747. * @param factor defines the life time factor to affect to the specified gradient
  12748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12749. * @returns the current particle system
  12750. */
  12751. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12752. /**
  12753. * Remove a specific life time gradient
  12754. * @param gradient defines the gradient to remove
  12755. * @returns the current particle system
  12756. */
  12757. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12758. /**
  12759. * Adds a new size gradient
  12760. * @param gradient defines the gradient to use (between 0 and 1)
  12761. * @param factor defines the size factor to affect to the specified gradient
  12762. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12763. * @returns the current particle system
  12764. */
  12765. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12766. /**
  12767. * Remove a specific size gradient
  12768. * @param gradient defines the gradient to remove
  12769. * @returns the current particle system
  12770. */
  12771. removeSizeGradient(gradient: number): IParticleSystem;
  12772. /**
  12773. * Adds a new color remap gradient
  12774. * @param gradient defines the gradient to use (between 0 and 1)
  12775. * @param min defines the color remap minimal range
  12776. * @param max defines the color remap maximal range
  12777. * @returns the current particle system
  12778. */
  12779. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12780. /**
  12781. * Remove a specific color remap gradient
  12782. * @param gradient defines the gradient to remove
  12783. * @returns the current particle system
  12784. */
  12785. removeColorRemapGradient(gradient: number): IParticleSystem;
  12786. /**
  12787. * Adds a new alpha remap gradient
  12788. * @param gradient defines the gradient to use (between 0 and 1)
  12789. * @param min defines the alpha remap minimal range
  12790. * @param max defines the alpha remap maximal range
  12791. * @returns the current particle system
  12792. */
  12793. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12794. /**
  12795. * Remove a specific alpha remap gradient
  12796. * @param gradient defines the gradient to remove
  12797. * @returns the current particle system
  12798. */
  12799. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12800. /**
  12801. * Adds a new angular speed gradient
  12802. * @param gradient defines the gradient to use (between 0 and 1)
  12803. * @param factor defines the angular speed to affect to the specified gradient
  12804. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12805. * @returns the current particle system
  12806. */
  12807. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12808. /**
  12809. * Remove a specific angular speed gradient
  12810. * @param gradient defines the gradient to remove
  12811. * @returns the current particle system
  12812. */
  12813. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12814. /**
  12815. * Adds a new velocity gradient
  12816. * @param gradient defines the gradient to use (between 0 and 1)
  12817. * @param factor defines the velocity to affect to the specified gradient
  12818. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12819. * @returns the current particle system
  12820. */
  12821. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12822. /**
  12823. * Remove a specific velocity gradient
  12824. * @param gradient defines the gradient to remove
  12825. * @returns the current particle system
  12826. */
  12827. removeVelocityGradient(gradient: number): IParticleSystem;
  12828. /**
  12829. * Adds a new limit velocity gradient
  12830. * @param gradient defines the gradient to use (between 0 and 1)
  12831. * @param factor defines the limit velocity value to affect to the specified gradient
  12832. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12833. * @returns the current particle system
  12834. */
  12835. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12836. /**
  12837. * Remove a specific limit velocity gradient
  12838. * @param gradient defines the gradient to remove
  12839. * @returns the current particle system
  12840. */
  12841. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12842. /**
  12843. * Adds a new drag gradient
  12844. * @param gradient defines the gradient to use (between 0 and 1)
  12845. * @param factor defines the drag value to affect to the specified gradient
  12846. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12847. * @returns the current particle system
  12848. */
  12849. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12850. /**
  12851. * Remove a specific drag gradient
  12852. * @param gradient defines the gradient to remove
  12853. * @returns the current particle system
  12854. */
  12855. removeDragGradient(gradient: number): IParticleSystem;
  12856. /**
  12857. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12858. * @param gradient defines the gradient to use (between 0 and 1)
  12859. * @param factor defines the emit rate value to affect to the specified gradient
  12860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12861. * @returns the current particle system
  12862. */
  12863. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12864. /**
  12865. * Remove a specific emit rate gradient
  12866. * @param gradient defines the gradient to remove
  12867. * @returns the current particle system
  12868. */
  12869. removeEmitRateGradient(gradient: number): IParticleSystem;
  12870. /**
  12871. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12872. * @param gradient defines the gradient to use (between 0 and 1)
  12873. * @param factor defines the start size value to affect to the specified gradient
  12874. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12875. * @returns the current particle system
  12876. */
  12877. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12878. /**
  12879. * Remove a specific start size gradient
  12880. * @param gradient defines the gradient to remove
  12881. * @returns the current particle system
  12882. */
  12883. removeStartSizeGradient(gradient: number): IParticleSystem;
  12884. private _createRampGradientTexture;
  12885. /**
  12886. * Gets the current list of ramp gradients.
  12887. * You must use addRampGradient and removeRampGradient to udpate this list
  12888. * @returns the list of ramp gradients
  12889. */
  12890. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12891. /** Force the system to rebuild all gradients that need to be resync */
  12892. forceRefreshGradients(): void;
  12893. private _syncRampGradientTexture;
  12894. /**
  12895. * Adds a new ramp gradient used to remap particle colors
  12896. * @param gradient defines the gradient to use (between 0 and 1)
  12897. * @param color defines the color to affect to the specified gradient
  12898. * @returns the current particle system
  12899. */
  12900. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12901. /**
  12902. * Remove a specific ramp gradient
  12903. * @param gradient defines the gradient to remove
  12904. * @returns the current particle system
  12905. */
  12906. removeRampGradient(gradient: number): ParticleSystem;
  12907. /**
  12908. * Adds a new color gradient
  12909. * @param gradient defines the gradient to use (between 0 and 1)
  12910. * @param color1 defines the color to affect to the specified gradient
  12911. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12912. * @returns this particle system
  12913. */
  12914. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12915. /**
  12916. * Remove a specific color gradient
  12917. * @param gradient defines the gradient to remove
  12918. * @returns this particle system
  12919. */
  12920. removeColorGradient(gradient: number): IParticleSystem;
  12921. private _fetchR;
  12922. protected _reset(): void;
  12923. private _resetEffect;
  12924. private _createVertexBuffers;
  12925. private _createIndexBuffer;
  12926. /**
  12927. * Gets the maximum number of particles active at the same time.
  12928. * @returns The max number of active particles.
  12929. */
  12930. getCapacity(): number;
  12931. /**
  12932. * Gets whether there are still active particles in the system.
  12933. * @returns True if it is alive, otherwise false.
  12934. */
  12935. isAlive(): boolean;
  12936. /**
  12937. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12938. * @returns True if it has been started, otherwise false.
  12939. */
  12940. isStarted(): boolean;
  12941. private _prepareSubEmitterInternalArray;
  12942. /**
  12943. * Starts the particle system and begins to emit
  12944. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12945. */
  12946. start(delay?: number): void;
  12947. /**
  12948. * Stops the particle system.
  12949. * @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.
  12950. */
  12951. stop(stopSubEmitters?: boolean): void;
  12952. /**
  12953. * Remove all active particles
  12954. */
  12955. reset(): void;
  12956. /**
  12957. * @hidden (for internal use only)
  12958. */
  12959. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12960. /**
  12961. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12962. * Its lifetime will start back at 0.
  12963. */
  12964. recycleParticle: (particle: Particle) => void;
  12965. private _stopSubEmitters;
  12966. private _createParticle;
  12967. private _removeFromRoot;
  12968. private _emitFromParticle;
  12969. private _update;
  12970. /** @hidden */
  12971. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12972. /** @hidden */
  12973. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12974. /**
  12975. * Fill the defines array according to the current settings of the particle system
  12976. * @param defines Array to be updated
  12977. * @param blendMode blend mode to take into account when updating the array
  12978. */
  12979. fillDefines(defines: Array<string>, blendMode: number): void;
  12980. /**
  12981. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12982. * @param uniforms Uniforms array to fill
  12983. * @param attributes Attributes array to fill
  12984. * @param samplers Samplers array to fill
  12985. */
  12986. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12987. /** @hidden */
  12988. private _getEffect;
  12989. /**
  12990. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12991. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12992. */
  12993. animate(preWarmOnly?: boolean): void;
  12994. private _appendParticleVertices;
  12995. /**
  12996. * Rebuilds the particle system.
  12997. */
  12998. rebuild(): void;
  12999. /**
  13000. * Is this system ready to be used/rendered
  13001. * @return true if the system is ready
  13002. */
  13003. isReady(): boolean;
  13004. private _render;
  13005. /**
  13006. * Renders the particle system in its current state.
  13007. * @returns the current number of particles
  13008. */
  13009. render(): number;
  13010. /**
  13011. * Disposes the particle system and free the associated resources
  13012. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13013. */
  13014. dispose(disposeTexture?: boolean): void;
  13015. /**
  13016. * Clones the particle system.
  13017. * @param name The name of the cloned object
  13018. * @param newEmitter The new emitter to use
  13019. * @returns the cloned particle system
  13020. */
  13021. clone(name: string, newEmitter: any): ParticleSystem;
  13022. /**
  13023. * Serializes the particle system to a JSON object
  13024. * @param serializeTexture defines if the texture must be serialized as well
  13025. * @returns the JSON object
  13026. */
  13027. serialize(serializeTexture?: boolean): any;
  13028. /** @hidden */
  13029. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13030. /** @hidden */
  13031. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13032. /**
  13033. * Parses a JSON object to create a particle system.
  13034. * @param parsedParticleSystem The JSON object to parse
  13035. * @param sceneOrEngine The scene or the engine to create the particle system in
  13036. * @param rootUrl The root url to use to load external dependencies like texture
  13037. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13038. * @returns the Parsed particle system
  13039. */
  13040. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13041. }
  13042. }
  13043. declare module BABYLON {
  13044. /**
  13045. * A particle represents one of the element emitted by a particle system.
  13046. * This is mainly define by its coordinates, direction, velocity and age.
  13047. */
  13048. export class Particle {
  13049. /**
  13050. * The particle system the particle belongs to.
  13051. */
  13052. particleSystem: ParticleSystem;
  13053. private static _Count;
  13054. /**
  13055. * Unique ID of the particle
  13056. */
  13057. id: number;
  13058. /**
  13059. * The world position of the particle in the scene.
  13060. */
  13061. position: Vector3;
  13062. /**
  13063. * The world direction of the particle in the scene.
  13064. */
  13065. direction: Vector3;
  13066. /**
  13067. * The color of the particle.
  13068. */
  13069. color: Color4;
  13070. /**
  13071. * The color change of the particle per step.
  13072. */
  13073. colorStep: Color4;
  13074. /**
  13075. * Defines how long will the life of the particle be.
  13076. */
  13077. lifeTime: number;
  13078. /**
  13079. * The current age of the particle.
  13080. */
  13081. age: number;
  13082. /**
  13083. * The current size of the particle.
  13084. */
  13085. size: number;
  13086. /**
  13087. * The current scale of the particle.
  13088. */
  13089. scale: Vector2;
  13090. /**
  13091. * The current angle of the particle.
  13092. */
  13093. angle: number;
  13094. /**
  13095. * Defines how fast is the angle changing.
  13096. */
  13097. angularSpeed: number;
  13098. /**
  13099. * Defines the cell index used by the particle to be rendered from a sprite.
  13100. */
  13101. cellIndex: number;
  13102. /**
  13103. * The information required to support color remapping
  13104. */
  13105. remapData: Vector4;
  13106. /** @hidden */
  13107. _randomCellOffset?: number;
  13108. /** @hidden */
  13109. _initialDirection: Nullable<Vector3>;
  13110. /** @hidden */
  13111. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13112. /** @hidden */
  13113. _initialStartSpriteCellID: number;
  13114. /** @hidden */
  13115. _initialEndSpriteCellID: number;
  13116. /** @hidden */
  13117. _currentColorGradient: Nullable<ColorGradient>;
  13118. /** @hidden */
  13119. _currentColor1: Color4;
  13120. /** @hidden */
  13121. _currentColor2: Color4;
  13122. /** @hidden */
  13123. _currentSizeGradient: Nullable<FactorGradient>;
  13124. /** @hidden */
  13125. _currentSize1: number;
  13126. /** @hidden */
  13127. _currentSize2: number;
  13128. /** @hidden */
  13129. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13130. /** @hidden */
  13131. _currentAngularSpeed1: number;
  13132. /** @hidden */
  13133. _currentAngularSpeed2: number;
  13134. /** @hidden */
  13135. _currentVelocityGradient: Nullable<FactorGradient>;
  13136. /** @hidden */
  13137. _currentVelocity1: number;
  13138. /** @hidden */
  13139. _currentVelocity2: number;
  13140. /** @hidden */
  13141. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13142. /** @hidden */
  13143. _currentLimitVelocity1: number;
  13144. /** @hidden */
  13145. _currentLimitVelocity2: number;
  13146. /** @hidden */
  13147. _currentDragGradient: Nullable<FactorGradient>;
  13148. /** @hidden */
  13149. _currentDrag1: number;
  13150. /** @hidden */
  13151. _currentDrag2: number;
  13152. /** @hidden */
  13153. _randomNoiseCoordinates1: Vector3;
  13154. /** @hidden */
  13155. _randomNoiseCoordinates2: Vector3;
  13156. /** @hidden */
  13157. _localPosition?: Vector3;
  13158. /**
  13159. * Creates a new instance Particle
  13160. * @param particleSystem the particle system the particle belongs to
  13161. */
  13162. constructor(
  13163. /**
  13164. * The particle system the particle belongs to.
  13165. */
  13166. particleSystem: ParticleSystem);
  13167. private updateCellInfoFromSystem;
  13168. /**
  13169. * Defines how the sprite cell index is updated for the particle
  13170. */
  13171. updateCellIndex(): void;
  13172. /** @hidden */
  13173. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13174. /** @hidden */
  13175. _inheritParticleInfoToSubEmitters(): void;
  13176. /** @hidden */
  13177. _reset(): void;
  13178. /**
  13179. * Copy the properties of particle to another one.
  13180. * @param other the particle to copy the information to.
  13181. */
  13182. copyTo(other: Particle): void;
  13183. }
  13184. }
  13185. declare module BABYLON {
  13186. /**
  13187. * Particle emitter represents a volume emitting particles.
  13188. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13189. */
  13190. export interface IParticleEmitterType {
  13191. /**
  13192. * Called by the particle System when the direction is computed for the created particle.
  13193. * @param worldMatrix is the world matrix of the particle system
  13194. * @param directionToUpdate is the direction vector to update with the result
  13195. * @param particle is the particle we are computed the direction for
  13196. * @param isLocal defines if the direction should be set in local space
  13197. */
  13198. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13199. /**
  13200. * Called by the particle System when the position is computed for the created particle.
  13201. * @param worldMatrix is the world matrix of the particle system
  13202. * @param positionToUpdate is the position vector to update with the result
  13203. * @param particle is the particle we are computed the position for
  13204. * @param isLocal defines if the position should be set in local space
  13205. */
  13206. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13207. /**
  13208. * Clones the current emitter and returns a copy of it
  13209. * @returns the new emitter
  13210. */
  13211. clone(): IParticleEmitterType;
  13212. /**
  13213. * Called by the GPUParticleSystem to setup the update shader
  13214. * @param effect defines the update shader
  13215. */
  13216. applyToShader(effect: Effect): void;
  13217. /**
  13218. * Returns a string to use to update the GPU particles update shader
  13219. * @returns the effect defines string
  13220. */
  13221. getEffectDefines(): string;
  13222. /**
  13223. * Returns a string representing the class name
  13224. * @returns a string containing the class name
  13225. */
  13226. getClassName(): string;
  13227. /**
  13228. * Serializes the particle system to a JSON object.
  13229. * @returns the JSON object
  13230. */
  13231. serialize(): any;
  13232. /**
  13233. * Parse properties from a JSON object
  13234. * @param serializationObject defines the JSON object
  13235. * @param scene defines the hosting scene
  13236. */
  13237. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13238. }
  13239. }
  13240. declare module BABYLON {
  13241. /**
  13242. * Particle emitter emitting particles from the inside of a box.
  13243. * It emits the particles randomly between 2 given directions.
  13244. */
  13245. export class BoxParticleEmitter implements IParticleEmitterType {
  13246. /**
  13247. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13248. */
  13249. direction1: Vector3;
  13250. /**
  13251. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13252. */
  13253. direction2: Vector3;
  13254. /**
  13255. * 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.
  13256. */
  13257. minEmitBox: Vector3;
  13258. /**
  13259. * 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.
  13260. */
  13261. maxEmitBox: Vector3;
  13262. /**
  13263. * Creates a new instance BoxParticleEmitter
  13264. */
  13265. constructor();
  13266. /**
  13267. * Called by the particle System when the direction is computed for the created particle.
  13268. * @param worldMatrix is the world matrix of the particle system
  13269. * @param directionToUpdate is the direction vector to update with the result
  13270. * @param particle is the particle we are computed the direction for
  13271. * @param isLocal defines if the direction should be set in local space
  13272. */
  13273. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13274. /**
  13275. * Called by the particle System when the position is computed for the created particle.
  13276. * @param worldMatrix is the world matrix of the particle system
  13277. * @param positionToUpdate is the position vector to update with the result
  13278. * @param particle is the particle we are computed the position for
  13279. * @param isLocal defines if the position should be set in local space
  13280. */
  13281. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13282. /**
  13283. * Clones the current emitter and returns a copy of it
  13284. * @returns the new emitter
  13285. */
  13286. clone(): BoxParticleEmitter;
  13287. /**
  13288. * Called by the GPUParticleSystem to setup the update shader
  13289. * @param effect defines the update shader
  13290. */
  13291. applyToShader(effect: Effect): void;
  13292. /**
  13293. * Returns a string to use to update the GPU particles update shader
  13294. * @returns a string containng the defines string
  13295. */
  13296. getEffectDefines(): string;
  13297. /**
  13298. * Returns the string "BoxParticleEmitter"
  13299. * @returns a string containing the class name
  13300. */
  13301. getClassName(): string;
  13302. /**
  13303. * Serializes the particle system to a JSON object.
  13304. * @returns the JSON object
  13305. */
  13306. serialize(): any;
  13307. /**
  13308. * Parse properties from a JSON object
  13309. * @param serializationObject defines the JSON object
  13310. */
  13311. parse(serializationObject: any): void;
  13312. }
  13313. }
  13314. declare module BABYLON {
  13315. /**
  13316. * Particle emitter emitting particles from the inside of a cone.
  13317. * It emits the particles alongside the cone volume from the base to the particle.
  13318. * The emission direction might be randomized.
  13319. */
  13320. export class ConeParticleEmitter implements IParticleEmitterType {
  13321. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13322. directionRandomizer: number;
  13323. private _radius;
  13324. private _angle;
  13325. private _height;
  13326. /**
  13327. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13328. */
  13329. radiusRange: number;
  13330. /**
  13331. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13332. */
  13333. heightRange: number;
  13334. /**
  13335. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13336. */
  13337. emitFromSpawnPointOnly: boolean;
  13338. /**
  13339. * Gets or sets the radius of the emission cone
  13340. */
  13341. get radius(): number;
  13342. set radius(value: number);
  13343. /**
  13344. * Gets or sets the angle of the emission cone
  13345. */
  13346. get angle(): number;
  13347. set angle(value: number);
  13348. private _buildHeight;
  13349. /**
  13350. * Creates a new instance ConeParticleEmitter
  13351. * @param radius the radius of the emission cone (1 by default)
  13352. * @param angle the cone base angle (PI by default)
  13353. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13354. */
  13355. constructor(radius?: number, angle?: number,
  13356. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13357. directionRandomizer?: number);
  13358. /**
  13359. * Called by the particle System when the direction is computed for the created particle.
  13360. * @param worldMatrix is the world matrix of the particle system
  13361. * @param directionToUpdate is the direction vector to update with the result
  13362. * @param particle is the particle we are computed the direction for
  13363. * @param isLocal defines if the direction should be set in local space
  13364. */
  13365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13366. /**
  13367. * Called by the particle System when the position is computed for the created particle.
  13368. * @param worldMatrix is the world matrix of the particle system
  13369. * @param positionToUpdate is the position vector to update with the result
  13370. * @param particle is the particle we are computed the position for
  13371. * @param isLocal defines if the position should be set in local space
  13372. */
  13373. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13374. /**
  13375. * Clones the current emitter and returns a copy of it
  13376. * @returns the new emitter
  13377. */
  13378. clone(): ConeParticleEmitter;
  13379. /**
  13380. * Called by the GPUParticleSystem to setup the update shader
  13381. * @param effect defines the update shader
  13382. */
  13383. applyToShader(effect: Effect): void;
  13384. /**
  13385. * Returns a string to use to update the GPU particles update shader
  13386. * @returns a string containng the defines string
  13387. */
  13388. getEffectDefines(): string;
  13389. /**
  13390. * Returns the string "ConeParticleEmitter"
  13391. * @returns a string containing the class name
  13392. */
  13393. getClassName(): string;
  13394. /**
  13395. * Serializes the particle system to a JSON object.
  13396. * @returns the JSON object
  13397. */
  13398. serialize(): any;
  13399. /**
  13400. * Parse properties from a JSON object
  13401. * @param serializationObject defines the JSON object
  13402. */
  13403. parse(serializationObject: any): void;
  13404. }
  13405. }
  13406. declare module BABYLON {
  13407. /**
  13408. * Particle emitter emitting particles from the inside of a cylinder.
  13409. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13410. */
  13411. export class CylinderParticleEmitter implements IParticleEmitterType {
  13412. /**
  13413. * The radius of the emission cylinder.
  13414. */
  13415. radius: number;
  13416. /**
  13417. * The height of the emission cylinder.
  13418. */
  13419. height: number;
  13420. /**
  13421. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13422. */
  13423. radiusRange: number;
  13424. /**
  13425. * How much to randomize the particle direction [0-1].
  13426. */
  13427. directionRandomizer: number;
  13428. /**
  13429. * Creates a new instance CylinderParticleEmitter
  13430. * @param radius the radius of the emission cylinder (1 by default)
  13431. * @param height the height of the emission cylinder (1 by default)
  13432. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13433. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13434. */
  13435. constructor(
  13436. /**
  13437. * The radius of the emission cylinder.
  13438. */
  13439. radius?: number,
  13440. /**
  13441. * The height of the emission cylinder.
  13442. */
  13443. height?: number,
  13444. /**
  13445. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13446. */
  13447. radiusRange?: number,
  13448. /**
  13449. * How much to randomize the particle direction [0-1].
  13450. */
  13451. directionRandomizer?: number);
  13452. /**
  13453. * Called by the particle System when the direction is computed for the created particle.
  13454. * @param worldMatrix is the world matrix of the particle system
  13455. * @param directionToUpdate is the direction vector to update with the result
  13456. * @param particle is the particle we are computed the direction for
  13457. * @param isLocal defines if the direction should be set in local space
  13458. */
  13459. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13460. /**
  13461. * Called by the particle System when the position is computed for the created particle.
  13462. * @param worldMatrix is the world matrix of the particle system
  13463. * @param positionToUpdate is the position vector to update with the result
  13464. * @param particle is the particle we are computed the position for
  13465. * @param isLocal defines if the position should be set in local space
  13466. */
  13467. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13468. /**
  13469. * Clones the current emitter and returns a copy of it
  13470. * @returns the new emitter
  13471. */
  13472. clone(): CylinderParticleEmitter;
  13473. /**
  13474. * Called by the GPUParticleSystem to setup the update shader
  13475. * @param effect defines the update shader
  13476. */
  13477. applyToShader(effect: Effect): void;
  13478. /**
  13479. * Returns a string to use to update the GPU particles update shader
  13480. * @returns a string containng the defines string
  13481. */
  13482. getEffectDefines(): string;
  13483. /**
  13484. * Returns the string "CylinderParticleEmitter"
  13485. * @returns a string containing the class name
  13486. */
  13487. getClassName(): string;
  13488. /**
  13489. * Serializes the particle system to a JSON object.
  13490. * @returns the JSON object
  13491. */
  13492. serialize(): any;
  13493. /**
  13494. * Parse properties from a JSON object
  13495. * @param serializationObject defines the JSON object
  13496. */
  13497. parse(serializationObject: any): void;
  13498. }
  13499. /**
  13500. * Particle emitter emitting particles from the inside of a cylinder.
  13501. * It emits the particles randomly between two vectors.
  13502. */
  13503. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13504. /**
  13505. * The min limit of the emission direction.
  13506. */
  13507. direction1: Vector3;
  13508. /**
  13509. * The max limit of the emission direction.
  13510. */
  13511. direction2: Vector3;
  13512. /**
  13513. * Creates a new instance CylinderDirectedParticleEmitter
  13514. * @param radius the radius of the emission cylinder (1 by default)
  13515. * @param height the height of the emission cylinder (1 by default)
  13516. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13517. * @param direction1 the min limit of the emission direction (up vector by default)
  13518. * @param direction2 the max limit of the emission direction (up vector by default)
  13519. */
  13520. constructor(radius?: number, height?: number, radiusRange?: number,
  13521. /**
  13522. * The min limit of the emission direction.
  13523. */
  13524. direction1?: Vector3,
  13525. /**
  13526. * The max limit of the emission direction.
  13527. */
  13528. direction2?: Vector3);
  13529. /**
  13530. * Called by the particle System when the direction is computed for the created particle.
  13531. * @param worldMatrix is the world matrix of the particle system
  13532. * @param directionToUpdate is the direction vector to update with the result
  13533. * @param particle is the particle we are computed the direction for
  13534. */
  13535. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13536. /**
  13537. * Clones the current emitter and returns a copy of it
  13538. * @returns the new emitter
  13539. */
  13540. clone(): CylinderDirectedParticleEmitter;
  13541. /**
  13542. * Called by the GPUParticleSystem to setup the update shader
  13543. * @param effect defines the update shader
  13544. */
  13545. applyToShader(effect: Effect): void;
  13546. /**
  13547. * Returns a string to use to update the GPU particles update shader
  13548. * @returns a string containng the defines string
  13549. */
  13550. getEffectDefines(): string;
  13551. /**
  13552. * Returns the string "CylinderDirectedParticleEmitter"
  13553. * @returns a string containing the class name
  13554. */
  13555. getClassName(): string;
  13556. /**
  13557. * Serializes the particle system to a JSON object.
  13558. * @returns the JSON object
  13559. */
  13560. serialize(): any;
  13561. /**
  13562. * Parse properties from a JSON object
  13563. * @param serializationObject defines the JSON object
  13564. */
  13565. parse(serializationObject: any): void;
  13566. }
  13567. }
  13568. declare module BABYLON {
  13569. /**
  13570. * Particle emitter emitting particles from the inside of a hemisphere.
  13571. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13572. */
  13573. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13574. /**
  13575. * The radius of the emission hemisphere.
  13576. */
  13577. radius: number;
  13578. /**
  13579. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13580. */
  13581. radiusRange: number;
  13582. /**
  13583. * How much to randomize the particle direction [0-1].
  13584. */
  13585. directionRandomizer: number;
  13586. /**
  13587. * Creates a new instance HemisphericParticleEmitter
  13588. * @param radius the radius of the emission hemisphere (1 by default)
  13589. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13590. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13591. */
  13592. constructor(
  13593. /**
  13594. * The radius of the emission hemisphere.
  13595. */
  13596. radius?: number,
  13597. /**
  13598. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13599. */
  13600. radiusRange?: number,
  13601. /**
  13602. * How much to randomize the particle direction [0-1].
  13603. */
  13604. directionRandomizer?: number);
  13605. /**
  13606. * Called by the particle System when the direction is computed for the created particle.
  13607. * @param worldMatrix is the world matrix of the particle system
  13608. * @param directionToUpdate is the direction vector to update with the result
  13609. * @param particle is the particle we are computed the direction for
  13610. * @param isLocal defines if the direction should be set in local space
  13611. */
  13612. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13613. /**
  13614. * Called by the particle System when the position is computed for the created particle.
  13615. * @param worldMatrix is the world matrix of the particle system
  13616. * @param positionToUpdate is the position vector to update with the result
  13617. * @param particle is the particle we are computed the position for
  13618. * @param isLocal defines if the position should be set in local space
  13619. */
  13620. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13621. /**
  13622. * Clones the current emitter and returns a copy of it
  13623. * @returns the new emitter
  13624. */
  13625. clone(): HemisphericParticleEmitter;
  13626. /**
  13627. * Called by the GPUParticleSystem to setup the update shader
  13628. * @param effect defines the update shader
  13629. */
  13630. applyToShader(effect: Effect): void;
  13631. /**
  13632. * Returns a string to use to update the GPU particles update shader
  13633. * @returns a string containng the defines string
  13634. */
  13635. getEffectDefines(): string;
  13636. /**
  13637. * Returns the string "HemisphericParticleEmitter"
  13638. * @returns a string containing the class name
  13639. */
  13640. getClassName(): string;
  13641. /**
  13642. * Serializes the particle system to a JSON object.
  13643. * @returns the JSON object
  13644. */
  13645. serialize(): any;
  13646. /**
  13647. * Parse properties from a JSON object
  13648. * @param serializationObject defines the JSON object
  13649. */
  13650. parse(serializationObject: any): void;
  13651. }
  13652. }
  13653. declare module BABYLON {
  13654. /**
  13655. * Particle emitter emitting particles from a point.
  13656. * It emits the particles randomly between 2 given directions.
  13657. */
  13658. export class PointParticleEmitter implements IParticleEmitterType {
  13659. /**
  13660. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13661. */
  13662. direction1: Vector3;
  13663. /**
  13664. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13665. */
  13666. direction2: Vector3;
  13667. /**
  13668. * Creates a new instance PointParticleEmitter
  13669. */
  13670. constructor();
  13671. /**
  13672. * Called by the particle System when the direction is computed for the created particle.
  13673. * @param worldMatrix is the world matrix of the particle system
  13674. * @param directionToUpdate is the direction vector to update with the result
  13675. * @param particle is the particle we are computed the direction for
  13676. * @param isLocal defines if the direction should be set in local space
  13677. */
  13678. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13679. /**
  13680. * Called by the particle System when the position is computed for the created particle.
  13681. * @param worldMatrix is the world matrix of the particle system
  13682. * @param positionToUpdate is the position vector to update with the result
  13683. * @param particle is the particle we are computed the position for
  13684. * @param isLocal defines if the position should be set in local space
  13685. */
  13686. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13687. /**
  13688. * Clones the current emitter and returns a copy of it
  13689. * @returns the new emitter
  13690. */
  13691. clone(): PointParticleEmitter;
  13692. /**
  13693. * Called by the GPUParticleSystem to setup the update shader
  13694. * @param effect defines the update shader
  13695. */
  13696. applyToShader(effect: Effect): void;
  13697. /**
  13698. * Returns a string to use to update the GPU particles update shader
  13699. * @returns a string containng the defines string
  13700. */
  13701. getEffectDefines(): string;
  13702. /**
  13703. * Returns the string "PointParticleEmitter"
  13704. * @returns a string containing the class name
  13705. */
  13706. getClassName(): string;
  13707. /**
  13708. * Serializes the particle system to a JSON object.
  13709. * @returns the JSON object
  13710. */
  13711. serialize(): any;
  13712. /**
  13713. * Parse properties from a JSON object
  13714. * @param serializationObject defines the JSON object
  13715. */
  13716. parse(serializationObject: any): void;
  13717. }
  13718. }
  13719. declare module BABYLON {
  13720. /**
  13721. * Particle emitter emitting particles from the inside of a sphere.
  13722. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13723. */
  13724. export class SphereParticleEmitter implements IParticleEmitterType {
  13725. /**
  13726. * The radius of the emission sphere.
  13727. */
  13728. radius: number;
  13729. /**
  13730. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13731. */
  13732. radiusRange: number;
  13733. /**
  13734. * How much to randomize the particle direction [0-1].
  13735. */
  13736. directionRandomizer: number;
  13737. /**
  13738. * Creates a new instance SphereParticleEmitter
  13739. * @param radius the radius of the emission sphere (1 by default)
  13740. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13741. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13742. */
  13743. constructor(
  13744. /**
  13745. * The radius of the emission sphere.
  13746. */
  13747. radius?: number,
  13748. /**
  13749. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13750. */
  13751. radiusRange?: number,
  13752. /**
  13753. * How much to randomize the particle direction [0-1].
  13754. */
  13755. directionRandomizer?: number);
  13756. /**
  13757. * Called by the particle System when the direction is computed for the created particle.
  13758. * @param worldMatrix is the world matrix of the particle system
  13759. * @param directionToUpdate is the direction vector to update with the result
  13760. * @param particle is the particle we are computed the direction for
  13761. * @param isLocal defines if the direction should be set in local space
  13762. */
  13763. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13764. /**
  13765. * Called by the particle System when the position is computed for the created particle.
  13766. * @param worldMatrix is the world matrix of the particle system
  13767. * @param positionToUpdate is the position vector to update with the result
  13768. * @param particle is the particle we are computed the position for
  13769. * @param isLocal defines if the position should be set in local space
  13770. */
  13771. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13772. /**
  13773. * Clones the current emitter and returns a copy of it
  13774. * @returns the new emitter
  13775. */
  13776. clone(): SphereParticleEmitter;
  13777. /**
  13778. * Called by the GPUParticleSystem to setup the update shader
  13779. * @param effect defines the update shader
  13780. */
  13781. applyToShader(effect: Effect): void;
  13782. /**
  13783. * Returns a string to use to update the GPU particles update shader
  13784. * @returns a string containng the defines string
  13785. */
  13786. getEffectDefines(): string;
  13787. /**
  13788. * Returns the string "SphereParticleEmitter"
  13789. * @returns a string containing the class name
  13790. */
  13791. getClassName(): string;
  13792. /**
  13793. * Serializes the particle system to a JSON object.
  13794. * @returns the JSON object
  13795. */
  13796. serialize(): any;
  13797. /**
  13798. * Parse properties from a JSON object
  13799. * @param serializationObject defines the JSON object
  13800. */
  13801. parse(serializationObject: any): void;
  13802. }
  13803. /**
  13804. * Particle emitter emitting particles from the inside of a sphere.
  13805. * It emits the particles randomly between two vectors.
  13806. */
  13807. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13808. /**
  13809. * The min limit of the emission direction.
  13810. */
  13811. direction1: Vector3;
  13812. /**
  13813. * The max limit of the emission direction.
  13814. */
  13815. direction2: Vector3;
  13816. /**
  13817. * Creates a new instance SphereDirectedParticleEmitter
  13818. * @param radius the radius of the emission sphere (1 by default)
  13819. * @param direction1 the min limit of the emission direction (up vector by default)
  13820. * @param direction2 the max limit of the emission direction (up vector by default)
  13821. */
  13822. constructor(radius?: number,
  13823. /**
  13824. * The min limit of the emission direction.
  13825. */
  13826. direction1?: Vector3,
  13827. /**
  13828. * The max limit of the emission direction.
  13829. */
  13830. direction2?: Vector3);
  13831. /**
  13832. * Called by the particle System when the direction is computed for the created particle.
  13833. * @param worldMatrix is the world matrix of the particle system
  13834. * @param directionToUpdate is the direction vector to update with the result
  13835. * @param particle is the particle we are computed the direction for
  13836. */
  13837. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13838. /**
  13839. * Clones the current emitter and returns a copy of it
  13840. * @returns the new emitter
  13841. */
  13842. clone(): SphereDirectedParticleEmitter;
  13843. /**
  13844. * Called by the GPUParticleSystem to setup the update shader
  13845. * @param effect defines the update shader
  13846. */
  13847. applyToShader(effect: Effect): void;
  13848. /**
  13849. * Returns a string to use to update the GPU particles update shader
  13850. * @returns a string containng the defines string
  13851. */
  13852. getEffectDefines(): string;
  13853. /**
  13854. * Returns the string "SphereDirectedParticleEmitter"
  13855. * @returns a string containing the class name
  13856. */
  13857. getClassName(): string;
  13858. /**
  13859. * Serializes the particle system to a JSON object.
  13860. * @returns the JSON object
  13861. */
  13862. serialize(): any;
  13863. /**
  13864. * Parse properties from a JSON object
  13865. * @param serializationObject defines the JSON object
  13866. */
  13867. parse(serializationObject: any): void;
  13868. }
  13869. }
  13870. declare module BABYLON {
  13871. /**
  13872. * Particle emitter emitting particles from a custom list of positions.
  13873. */
  13874. export class CustomParticleEmitter implements IParticleEmitterType {
  13875. /**
  13876. * Gets or sets the position generator that will create the inital position of each particle.
  13877. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13878. */
  13879. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13880. /**
  13881. * Gets or sets the destination generator that will create the final destination of each particle.
  13882. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13883. */
  13884. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13885. /**
  13886. * Creates a new instance CustomParticleEmitter
  13887. */
  13888. constructor();
  13889. /**
  13890. * Called by the particle System when the direction is computed for the created particle.
  13891. * @param worldMatrix is the world matrix of the particle system
  13892. * @param directionToUpdate is the direction vector to update with the result
  13893. * @param particle is the particle we are computed the direction for
  13894. * @param isLocal defines if the direction should be set in local space
  13895. */
  13896. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13897. /**
  13898. * Called by the particle System when the position is computed for the created particle.
  13899. * @param worldMatrix is the world matrix of the particle system
  13900. * @param positionToUpdate is the position vector to update with the result
  13901. * @param particle is the particle we are computed the position for
  13902. * @param isLocal defines if the position should be set in local space
  13903. */
  13904. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13905. /**
  13906. * Clones the current emitter and returns a copy of it
  13907. * @returns the new emitter
  13908. */
  13909. clone(): CustomParticleEmitter;
  13910. /**
  13911. * Called by the GPUParticleSystem to setup the update shader
  13912. * @param effect defines the update shader
  13913. */
  13914. applyToShader(effect: Effect): void;
  13915. /**
  13916. * Returns a string to use to update the GPU particles update shader
  13917. * @returns a string containng the defines string
  13918. */
  13919. getEffectDefines(): string;
  13920. /**
  13921. * Returns the string "PointParticleEmitter"
  13922. * @returns a string containing the class name
  13923. */
  13924. getClassName(): string;
  13925. /**
  13926. * Serializes the particle system to a JSON object.
  13927. * @returns the JSON object
  13928. */
  13929. serialize(): any;
  13930. /**
  13931. * Parse properties from a JSON object
  13932. * @param serializationObject defines the JSON object
  13933. */
  13934. parse(serializationObject: any): void;
  13935. }
  13936. }
  13937. declare module BABYLON {
  13938. /**
  13939. * Particle emitter emitting particles from the inside of a box.
  13940. * It emits the particles randomly between 2 given directions.
  13941. */
  13942. export class MeshParticleEmitter implements IParticleEmitterType {
  13943. private _indices;
  13944. private _positions;
  13945. private _normals;
  13946. private _storedNormal;
  13947. private _mesh;
  13948. /**
  13949. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13950. */
  13951. direction1: Vector3;
  13952. /**
  13953. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13954. */
  13955. direction2: Vector3;
  13956. /**
  13957. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13958. */
  13959. useMeshNormalsForDirection: boolean;
  13960. /** Defines the mesh to use as source */
  13961. get mesh(): Nullable<AbstractMesh>;
  13962. set mesh(value: Nullable<AbstractMesh>);
  13963. /**
  13964. * Creates a new instance MeshParticleEmitter
  13965. * @param mesh defines the mesh to use as source
  13966. */
  13967. constructor(mesh?: Nullable<AbstractMesh>);
  13968. /**
  13969. * Called by the particle System when the direction is computed for the created particle.
  13970. * @param worldMatrix is the world matrix of the particle system
  13971. * @param directionToUpdate is the direction vector to update with the result
  13972. * @param particle is the particle we are computed the direction for
  13973. * @param isLocal defines if the direction should be set in local space
  13974. */
  13975. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13976. /**
  13977. * Called by the particle System when the position is computed for the created particle.
  13978. * @param worldMatrix is the world matrix of the particle system
  13979. * @param positionToUpdate is the position vector to update with the result
  13980. * @param particle is the particle we are computed the position for
  13981. * @param isLocal defines if the position should be set in local space
  13982. */
  13983. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13984. /**
  13985. * Clones the current emitter and returns a copy of it
  13986. * @returns the new emitter
  13987. */
  13988. clone(): MeshParticleEmitter;
  13989. /**
  13990. * Called by the GPUParticleSystem to setup the update shader
  13991. * @param effect defines the update shader
  13992. */
  13993. applyToShader(effect: Effect): void;
  13994. /**
  13995. * Returns a string to use to update the GPU particles update shader
  13996. * @returns a string containng the defines string
  13997. */
  13998. getEffectDefines(): string;
  13999. /**
  14000. * Returns the string "BoxParticleEmitter"
  14001. * @returns a string containing the class name
  14002. */
  14003. getClassName(): string;
  14004. /**
  14005. * Serializes the particle system to a JSON object.
  14006. * @returns the JSON object
  14007. */
  14008. serialize(): any;
  14009. /**
  14010. * Parse properties from a JSON object
  14011. * @param serializationObject defines the JSON object
  14012. * @param scene defines the hosting scene
  14013. */
  14014. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14015. }
  14016. }
  14017. declare module BABYLON {
  14018. /**
  14019. * Interface representing a particle system in Babylon.js.
  14020. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14021. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14022. */
  14023. export interface IParticleSystem {
  14024. /**
  14025. * List of animations used by the particle system.
  14026. */
  14027. animations: Animation[];
  14028. /**
  14029. * The id of the Particle system.
  14030. */
  14031. id: string;
  14032. /**
  14033. * The name of the Particle system.
  14034. */
  14035. name: string;
  14036. /**
  14037. * The emitter represents the Mesh or position we are attaching the particle system to.
  14038. */
  14039. emitter: Nullable<AbstractMesh | Vector3>;
  14040. /**
  14041. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14042. */
  14043. isBillboardBased: boolean;
  14044. /**
  14045. * The rendering group used by the Particle system to chose when to render.
  14046. */
  14047. renderingGroupId: number;
  14048. /**
  14049. * The layer mask we are rendering the particles through.
  14050. */
  14051. layerMask: number;
  14052. /**
  14053. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14054. */
  14055. updateSpeed: number;
  14056. /**
  14057. * The amount of time the particle system is running (depends of the overall update speed).
  14058. */
  14059. targetStopDuration: number;
  14060. /**
  14061. * The texture used to render each particle. (this can be a spritesheet)
  14062. */
  14063. particleTexture: Nullable<BaseTexture>;
  14064. /**
  14065. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14066. */
  14067. blendMode: number;
  14068. /**
  14069. * Minimum life time of emitting particles.
  14070. */
  14071. minLifeTime: number;
  14072. /**
  14073. * Maximum life time of emitting particles.
  14074. */
  14075. maxLifeTime: number;
  14076. /**
  14077. * Minimum Size of emitting particles.
  14078. */
  14079. minSize: number;
  14080. /**
  14081. * Maximum Size of emitting particles.
  14082. */
  14083. maxSize: number;
  14084. /**
  14085. * Minimum scale of emitting particles on X axis.
  14086. */
  14087. minScaleX: number;
  14088. /**
  14089. * Maximum scale of emitting particles on X axis.
  14090. */
  14091. maxScaleX: number;
  14092. /**
  14093. * Minimum scale of emitting particles on Y axis.
  14094. */
  14095. minScaleY: number;
  14096. /**
  14097. * Maximum scale of emitting particles on Y axis.
  14098. */
  14099. maxScaleY: number;
  14100. /**
  14101. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14102. */
  14103. color1: Color4;
  14104. /**
  14105. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14106. */
  14107. color2: Color4;
  14108. /**
  14109. * Color the particle will have at the end of its lifetime.
  14110. */
  14111. colorDead: Color4;
  14112. /**
  14113. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14114. */
  14115. emitRate: number;
  14116. /**
  14117. * You can use gravity if you want to give an orientation to your particles.
  14118. */
  14119. gravity: Vector3;
  14120. /**
  14121. * Minimum power of emitting particles.
  14122. */
  14123. minEmitPower: number;
  14124. /**
  14125. * Maximum power of emitting particles.
  14126. */
  14127. maxEmitPower: number;
  14128. /**
  14129. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14130. */
  14131. minAngularSpeed: number;
  14132. /**
  14133. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14134. */
  14135. maxAngularSpeed: number;
  14136. /**
  14137. * Gets or sets the minimal initial rotation in radians.
  14138. */
  14139. minInitialRotation: number;
  14140. /**
  14141. * Gets or sets the maximal initial rotation in radians.
  14142. */
  14143. maxInitialRotation: number;
  14144. /**
  14145. * The particle emitter type defines the emitter used by the particle system.
  14146. * It can be for example box, sphere, or cone...
  14147. */
  14148. particleEmitterType: Nullable<IParticleEmitterType>;
  14149. /**
  14150. * Defines the delay in milliseconds before starting the system (0 by default)
  14151. */
  14152. startDelay: number;
  14153. /**
  14154. * 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
  14155. */
  14156. preWarmCycles: number;
  14157. /**
  14158. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14159. */
  14160. preWarmStepOffset: number;
  14161. /**
  14162. * 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)
  14163. */
  14164. spriteCellChangeSpeed: number;
  14165. /**
  14166. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14167. */
  14168. startSpriteCellID: number;
  14169. /**
  14170. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14171. */
  14172. endSpriteCellID: number;
  14173. /**
  14174. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14175. */
  14176. spriteCellWidth: number;
  14177. /**
  14178. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14179. */
  14180. spriteCellHeight: number;
  14181. /**
  14182. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14183. */
  14184. spriteRandomStartCell: boolean;
  14185. /**
  14186. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14187. */
  14188. isAnimationSheetEnabled: boolean;
  14189. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14190. translationPivot: Vector2;
  14191. /**
  14192. * Gets or sets a texture used to add random noise to particle positions
  14193. */
  14194. noiseTexture: Nullable<BaseTexture>;
  14195. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14196. noiseStrength: Vector3;
  14197. /**
  14198. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14199. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14200. */
  14201. billboardMode: number;
  14202. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14203. limitVelocityDamping: number;
  14204. /**
  14205. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14206. */
  14207. beginAnimationOnStart: boolean;
  14208. /**
  14209. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14210. */
  14211. beginAnimationFrom: number;
  14212. /**
  14213. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14214. */
  14215. beginAnimationTo: number;
  14216. /**
  14217. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14218. */
  14219. beginAnimationLoop: boolean;
  14220. /**
  14221. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14222. */
  14223. disposeOnStop: boolean;
  14224. /**
  14225. * Specifies if the particles are updated in emitter local space or world space
  14226. */
  14227. isLocal: boolean;
  14228. /** Snippet ID if the particle system was created from the snippet server */
  14229. snippetId: string;
  14230. /** Gets or sets a matrix to use to compute projection */
  14231. defaultProjectionMatrix: Matrix;
  14232. /**
  14233. * Gets the maximum number of particles active at the same time.
  14234. * @returns The max number of active particles.
  14235. */
  14236. getCapacity(): number;
  14237. /**
  14238. * Gets the number of particles active at the same time.
  14239. * @returns The number of active particles.
  14240. */
  14241. getActiveCount(): number;
  14242. /**
  14243. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14244. * @returns True if it has been started, otherwise false.
  14245. */
  14246. isStarted(): boolean;
  14247. /**
  14248. * Animates the particle system for this frame.
  14249. */
  14250. animate(): void;
  14251. /**
  14252. * Renders the particle system in its current state.
  14253. * @returns the current number of particles
  14254. */
  14255. render(): number;
  14256. /**
  14257. * Dispose the particle system and frees its associated resources.
  14258. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14259. */
  14260. dispose(disposeTexture?: boolean): void;
  14261. /**
  14262. * An event triggered when the system is disposed
  14263. */
  14264. onDisposeObservable: Observable<IParticleSystem>;
  14265. /**
  14266. * Clones the particle system.
  14267. * @param name The name of the cloned object
  14268. * @param newEmitter The new emitter to use
  14269. * @returns the cloned particle system
  14270. */
  14271. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14272. /**
  14273. * Serializes the particle system to a JSON object
  14274. * @param serializeTexture defines if the texture must be serialized as well
  14275. * @returns the JSON object
  14276. */
  14277. serialize(serializeTexture: boolean): any;
  14278. /**
  14279. * Rebuild the particle system
  14280. */
  14281. rebuild(): void;
  14282. /** Force the system to rebuild all gradients that need to be resync */
  14283. forceRefreshGradients(): void;
  14284. /**
  14285. * Starts the particle system and begins to emit
  14286. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14287. */
  14288. start(delay?: number): void;
  14289. /**
  14290. * Stops the particle system.
  14291. */
  14292. stop(): void;
  14293. /**
  14294. * Remove all active particles
  14295. */
  14296. reset(): void;
  14297. /**
  14298. * Gets a boolean indicating that the system is stopping
  14299. * @returns true if the system is currently stopping
  14300. */
  14301. isStopping(): boolean;
  14302. /**
  14303. * Is this system ready to be used/rendered
  14304. * @return true if the system is ready
  14305. */
  14306. isReady(): boolean;
  14307. /**
  14308. * Returns the string "ParticleSystem"
  14309. * @returns a string containing the class name
  14310. */
  14311. getClassName(): string;
  14312. /**
  14313. * Gets the custom effect used to render the particles
  14314. * @param blendMode Blend mode for which the effect should be retrieved
  14315. * @returns The effect
  14316. */
  14317. getCustomEffect(blendMode: number): Nullable<Effect>;
  14318. /**
  14319. * Sets the custom effect used to render the particles
  14320. * @param effect The effect to set
  14321. * @param blendMode Blend mode for which the effect should be set
  14322. */
  14323. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14324. /**
  14325. * Fill the defines array according to the current settings of the particle system
  14326. * @param defines Array to be updated
  14327. * @param blendMode blend mode to take into account when updating the array
  14328. */
  14329. fillDefines(defines: Array<string>, blendMode: number): void;
  14330. /**
  14331. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14332. * @param uniforms Uniforms array to fill
  14333. * @param attributes Attributes array to fill
  14334. * @param samplers Samplers array to fill
  14335. */
  14336. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14337. /**
  14338. * Observable that will be called just before the particles are drawn
  14339. */
  14340. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14341. /**
  14342. * Gets the name of the particle vertex shader
  14343. */
  14344. vertexShaderName: string;
  14345. /**
  14346. * Adds a new color gradient
  14347. * @param gradient defines the gradient to use (between 0 and 1)
  14348. * @param color1 defines the color to affect to the specified gradient
  14349. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14350. * @returns the current particle system
  14351. */
  14352. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14353. /**
  14354. * Remove a specific color gradient
  14355. * @param gradient defines the gradient to remove
  14356. * @returns the current particle system
  14357. */
  14358. removeColorGradient(gradient: number): IParticleSystem;
  14359. /**
  14360. * Adds a new size gradient
  14361. * @param gradient defines the gradient to use (between 0 and 1)
  14362. * @param factor defines the size factor to affect to the specified gradient
  14363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14364. * @returns the current particle system
  14365. */
  14366. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14367. /**
  14368. * Remove a specific size gradient
  14369. * @param gradient defines the gradient to remove
  14370. * @returns the current particle system
  14371. */
  14372. removeSizeGradient(gradient: number): IParticleSystem;
  14373. /**
  14374. * Gets the current list of color gradients.
  14375. * You must use addColorGradient and removeColorGradient to udpate this list
  14376. * @returns the list of color gradients
  14377. */
  14378. getColorGradients(): Nullable<Array<ColorGradient>>;
  14379. /**
  14380. * Gets the current list of size gradients.
  14381. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14382. * @returns the list of size gradients
  14383. */
  14384. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14385. /**
  14386. * Gets the current list of angular speed gradients.
  14387. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14388. * @returns the list of angular speed gradients
  14389. */
  14390. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14391. /**
  14392. * Adds a new angular speed gradient
  14393. * @param gradient defines the gradient to use (between 0 and 1)
  14394. * @param factor defines the angular speed to affect to the specified gradient
  14395. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14396. * @returns the current particle system
  14397. */
  14398. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14399. /**
  14400. * Remove a specific angular speed gradient
  14401. * @param gradient defines the gradient to remove
  14402. * @returns the current particle system
  14403. */
  14404. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14405. /**
  14406. * Gets the current list of velocity gradients.
  14407. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14408. * @returns the list of velocity gradients
  14409. */
  14410. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14411. /**
  14412. * Adds a new velocity gradient
  14413. * @param gradient defines the gradient to use (between 0 and 1)
  14414. * @param factor defines the velocity to affect to the specified gradient
  14415. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14416. * @returns the current particle system
  14417. */
  14418. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14419. /**
  14420. * Remove a specific velocity gradient
  14421. * @param gradient defines the gradient to remove
  14422. * @returns the current particle system
  14423. */
  14424. removeVelocityGradient(gradient: number): IParticleSystem;
  14425. /**
  14426. * Gets the current list of limit velocity gradients.
  14427. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14428. * @returns the list of limit velocity gradients
  14429. */
  14430. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14431. /**
  14432. * Adds a new limit velocity gradient
  14433. * @param gradient defines the gradient to use (between 0 and 1)
  14434. * @param factor defines the limit velocity to affect to the specified gradient
  14435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14436. * @returns the current particle system
  14437. */
  14438. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14439. /**
  14440. * Remove a specific limit velocity gradient
  14441. * @param gradient defines the gradient to remove
  14442. * @returns the current particle system
  14443. */
  14444. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14445. /**
  14446. * Adds a new drag gradient
  14447. * @param gradient defines the gradient to use (between 0 and 1)
  14448. * @param factor defines the drag to affect to the specified gradient
  14449. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14450. * @returns the current particle system
  14451. */
  14452. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14453. /**
  14454. * Remove a specific drag gradient
  14455. * @param gradient defines the gradient to remove
  14456. * @returns the current particle system
  14457. */
  14458. removeDragGradient(gradient: number): IParticleSystem;
  14459. /**
  14460. * Gets the current list of drag gradients.
  14461. * You must use addDragGradient and removeDragGradient to udpate this list
  14462. * @returns the list of drag gradients
  14463. */
  14464. getDragGradients(): Nullable<Array<FactorGradient>>;
  14465. /**
  14466. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14467. * @param gradient defines the gradient to use (between 0 and 1)
  14468. * @param factor defines the emit rate to affect to the specified gradient
  14469. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14470. * @returns the current particle system
  14471. */
  14472. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14473. /**
  14474. * Remove a specific emit rate gradient
  14475. * @param gradient defines the gradient to remove
  14476. * @returns the current particle system
  14477. */
  14478. removeEmitRateGradient(gradient: number): IParticleSystem;
  14479. /**
  14480. * Gets the current list of emit rate gradients.
  14481. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14482. * @returns the list of emit rate gradients
  14483. */
  14484. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14485. /**
  14486. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14487. * @param gradient defines the gradient to use (between 0 and 1)
  14488. * @param factor defines the start size to affect to the specified gradient
  14489. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14490. * @returns the current particle system
  14491. */
  14492. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14493. /**
  14494. * Remove a specific start size gradient
  14495. * @param gradient defines the gradient to remove
  14496. * @returns the current particle system
  14497. */
  14498. removeStartSizeGradient(gradient: number): IParticleSystem;
  14499. /**
  14500. * Gets the current list of start size gradients.
  14501. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14502. * @returns the list of start size gradients
  14503. */
  14504. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14505. /**
  14506. * Adds a new life time gradient
  14507. * @param gradient defines the gradient to use (between 0 and 1)
  14508. * @param factor defines the life time factor to affect to the specified gradient
  14509. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14510. * @returns the current particle system
  14511. */
  14512. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14513. /**
  14514. * Remove a specific life time gradient
  14515. * @param gradient defines the gradient to remove
  14516. * @returns the current particle system
  14517. */
  14518. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14519. /**
  14520. * Gets the current list of life time gradients.
  14521. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14522. * @returns the list of life time gradients
  14523. */
  14524. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14525. /**
  14526. * Gets the current list of color gradients.
  14527. * You must use addColorGradient and removeColorGradient to udpate this list
  14528. * @returns the list of color gradients
  14529. */
  14530. getColorGradients(): Nullable<Array<ColorGradient>>;
  14531. /**
  14532. * Adds a new ramp gradient used to remap particle colors
  14533. * @param gradient defines the gradient to use (between 0 and 1)
  14534. * @param color defines the color to affect to the specified gradient
  14535. * @returns the current particle system
  14536. */
  14537. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14538. /**
  14539. * Gets the current list of ramp gradients.
  14540. * You must use addRampGradient and removeRampGradient to udpate this list
  14541. * @returns the list of ramp gradients
  14542. */
  14543. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14544. /** Gets or sets a boolean indicating that ramp gradients must be used
  14545. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14546. */
  14547. useRampGradients: boolean;
  14548. /**
  14549. * Adds a new color remap gradient
  14550. * @param gradient defines the gradient to use (between 0 and 1)
  14551. * @param min defines the color remap minimal range
  14552. * @param max defines the color remap maximal range
  14553. * @returns the current particle system
  14554. */
  14555. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14556. /**
  14557. * Gets the current list of color remap gradients.
  14558. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14559. * @returns the list of color remap gradients
  14560. */
  14561. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14562. /**
  14563. * Adds a new alpha remap gradient
  14564. * @param gradient defines the gradient to use (between 0 and 1)
  14565. * @param min defines the alpha remap minimal range
  14566. * @param max defines the alpha remap maximal range
  14567. * @returns the current particle system
  14568. */
  14569. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14570. /**
  14571. * Gets the current list of alpha remap gradients.
  14572. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14573. * @returns the list of alpha remap gradients
  14574. */
  14575. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14576. /**
  14577. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14578. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14579. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14580. * @returns the emitter
  14581. */
  14582. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14583. /**
  14584. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14585. * @param radius The radius of the hemisphere to emit from
  14586. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14587. * @returns the emitter
  14588. */
  14589. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14590. /**
  14591. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14592. * @param radius The radius of the sphere to emit from
  14593. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14594. * @returns the emitter
  14595. */
  14596. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14597. /**
  14598. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14599. * @param radius The radius of the sphere to emit from
  14600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14602. * @returns the emitter
  14603. */
  14604. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14605. /**
  14606. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14607. * @param radius The radius of the emission cylinder
  14608. * @param height The height of the emission cylinder
  14609. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14610. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14611. * @returns the emitter
  14612. */
  14613. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14614. /**
  14615. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14616. * @param radius The radius of the cylinder to emit from
  14617. * @param height The height of the emission cylinder
  14618. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14621. * @returns the emitter
  14622. */
  14623. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14624. /**
  14625. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14626. * @param radius The radius of the cone to emit from
  14627. * @param angle The base angle of the cone
  14628. * @returns the emitter
  14629. */
  14630. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14631. /**
  14632. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14633. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14634. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14635. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14636. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14637. * @returns the emitter
  14638. */
  14639. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14640. /**
  14641. * Get hosting scene
  14642. * @returns the scene
  14643. */
  14644. getScene(): Nullable<Scene>;
  14645. }
  14646. }
  14647. declare module BABYLON {
  14648. /**
  14649. * 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.
  14650. * @see https://doc.babylonjs.com/how_to/transformnode
  14651. */
  14652. export class TransformNode extends Node {
  14653. /**
  14654. * Object will not rotate to face the camera
  14655. */
  14656. static BILLBOARDMODE_NONE: number;
  14657. /**
  14658. * Object will rotate to face the camera but only on the x axis
  14659. */
  14660. static BILLBOARDMODE_X: number;
  14661. /**
  14662. * Object will rotate to face the camera but only on the y axis
  14663. */
  14664. static BILLBOARDMODE_Y: number;
  14665. /**
  14666. * Object will rotate to face the camera but only on the z axis
  14667. */
  14668. static BILLBOARDMODE_Z: number;
  14669. /**
  14670. * Object will rotate to face the camera
  14671. */
  14672. static BILLBOARDMODE_ALL: number;
  14673. /**
  14674. * Object will rotate to face the camera's position instead of orientation
  14675. */
  14676. static BILLBOARDMODE_USE_POSITION: number;
  14677. private static _TmpRotation;
  14678. private static _TmpScaling;
  14679. private static _TmpTranslation;
  14680. private _forward;
  14681. private _forwardInverted;
  14682. private _up;
  14683. private _right;
  14684. private _rightInverted;
  14685. private _position;
  14686. private _rotation;
  14687. private _rotationQuaternion;
  14688. protected _scaling: Vector3;
  14689. protected _isDirty: boolean;
  14690. private _transformToBoneReferal;
  14691. private _isAbsoluteSynced;
  14692. private _billboardMode;
  14693. /**
  14694. * Gets or sets the billboard mode. Default is 0.
  14695. *
  14696. * | Value | Type | Description |
  14697. * | --- | --- | --- |
  14698. * | 0 | BILLBOARDMODE_NONE | |
  14699. * | 1 | BILLBOARDMODE_X | |
  14700. * | 2 | BILLBOARDMODE_Y | |
  14701. * | 4 | BILLBOARDMODE_Z | |
  14702. * | 7 | BILLBOARDMODE_ALL | |
  14703. *
  14704. */
  14705. get billboardMode(): number;
  14706. set billboardMode(value: number);
  14707. private _preserveParentRotationForBillboard;
  14708. /**
  14709. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14710. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14711. */
  14712. get preserveParentRotationForBillboard(): boolean;
  14713. set preserveParentRotationForBillboard(value: boolean);
  14714. /**
  14715. * 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
  14716. */
  14717. scalingDeterminant: number;
  14718. private _infiniteDistance;
  14719. /**
  14720. * Gets or sets the distance of the object to max, often used by skybox
  14721. */
  14722. get infiniteDistance(): boolean;
  14723. set infiniteDistance(value: boolean);
  14724. /**
  14725. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14726. * By default the system will update normals to compensate
  14727. */
  14728. ignoreNonUniformScaling: boolean;
  14729. /**
  14730. * 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
  14731. */
  14732. reIntegrateRotationIntoRotationQuaternion: boolean;
  14733. /** @hidden */
  14734. _poseMatrix: Nullable<Matrix>;
  14735. /** @hidden */
  14736. _localMatrix: Matrix;
  14737. private _usePivotMatrix;
  14738. private _absolutePosition;
  14739. private _absoluteScaling;
  14740. private _absoluteRotationQuaternion;
  14741. private _pivotMatrix;
  14742. private _pivotMatrixInverse;
  14743. /** @hidden */
  14744. _postMultiplyPivotMatrix: boolean;
  14745. protected _isWorldMatrixFrozen: boolean;
  14746. /** @hidden */
  14747. _indexInSceneTransformNodesArray: number;
  14748. /**
  14749. * An event triggered after the world matrix is updated
  14750. */
  14751. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14752. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14753. /**
  14754. * Gets a string identifying the name of the class
  14755. * @returns "TransformNode" string
  14756. */
  14757. getClassName(): string;
  14758. /**
  14759. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14760. */
  14761. get position(): Vector3;
  14762. set position(newPosition: Vector3);
  14763. /**
  14764. * 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)).
  14765. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14766. */
  14767. get rotation(): Vector3;
  14768. set rotation(newRotation: Vector3);
  14769. /**
  14770. * 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)).
  14771. */
  14772. get scaling(): Vector3;
  14773. set scaling(newScaling: Vector3);
  14774. /**
  14775. * 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).
  14776. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14777. */
  14778. get rotationQuaternion(): Nullable<Quaternion>;
  14779. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14780. /**
  14781. * The forward direction of that transform in world space.
  14782. */
  14783. get forward(): Vector3;
  14784. /**
  14785. * The up direction of that transform in world space.
  14786. */
  14787. get up(): Vector3;
  14788. /**
  14789. * The right direction of that transform in world space.
  14790. */
  14791. get right(): Vector3;
  14792. /**
  14793. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14794. * @param matrix the matrix to copy the pose from
  14795. * @returns this TransformNode.
  14796. */
  14797. updatePoseMatrix(matrix: Matrix): TransformNode;
  14798. /**
  14799. * Returns the mesh Pose matrix.
  14800. * @returns the pose matrix
  14801. */
  14802. getPoseMatrix(): Matrix;
  14803. /** @hidden */
  14804. _isSynchronized(): boolean;
  14805. /** @hidden */
  14806. _initCache(): void;
  14807. /**
  14808. * Flag the transform node as dirty (Forcing it to update everything)
  14809. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14810. * @returns this transform node
  14811. */
  14812. markAsDirty(property: string): TransformNode;
  14813. /**
  14814. * Returns the current mesh absolute position.
  14815. * Returns a Vector3.
  14816. */
  14817. get absolutePosition(): Vector3;
  14818. /**
  14819. * Returns the current mesh absolute scaling.
  14820. * Returns a Vector3.
  14821. */
  14822. get absoluteScaling(): Vector3;
  14823. /**
  14824. * Returns the current mesh absolute rotation.
  14825. * Returns a Quaternion.
  14826. */
  14827. get absoluteRotationQuaternion(): Quaternion;
  14828. /**
  14829. * Sets a new matrix to apply before all other transformation
  14830. * @param matrix defines the transform matrix
  14831. * @returns the current TransformNode
  14832. */
  14833. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14834. /**
  14835. * Sets a new pivot matrix to the current node
  14836. * @param matrix defines the new pivot matrix to use
  14837. * @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
  14838. * @returns the current TransformNode
  14839. */
  14840. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14841. /**
  14842. * Returns the mesh pivot matrix.
  14843. * Default : Identity.
  14844. * @returns the matrix
  14845. */
  14846. getPivotMatrix(): Matrix;
  14847. /**
  14848. * Instantiate (when possible) or clone that node with its hierarchy
  14849. * @param newParent defines the new parent to use for the instance (or clone)
  14850. * @param options defines options to configure how copy is done
  14851. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14852. * @returns an instance (or a clone) of the current node with its hiearchy
  14853. */
  14854. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14855. doNotInstantiate: boolean;
  14856. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14857. /**
  14858. * Prevents the World matrix to be computed any longer
  14859. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14860. * @returns the TransformNode.
  14861. */
  14862. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14863. /**
  14864. * Allows back the World matrix computation.
  14865. * @returns the TransformNode.
  14866. */
  14867. unfreezeWorldMatrix(): this;
  14868. /**
  14869. * True if the World matrix has been frozen.
  14870. */
  14871. get isWorldMatrixFrozen(): boolean;
  14872. /**
  14873. * Retuns the mesh absolute position in the World.
  14874. * @returns a Vector3.
  14875. */
  14876. getAbsolutePosition(): Vector3;
  14877. /**
  14878. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14879. * @param absolutePosition the absolute position to set
  14880. * @returns the TransformNode.
  14881. */
  14882. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14883. /**
  14884. * Sets the mesh position in its local space.
  14885. * @param vector3 the position to set in localspace
  14886. * @returns the TransformNode.
  14887. */
  14888. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14889. /**
  14890. * Returns the mesh position in the local space from the current World matrix values.
  14891. * @returns a new Vector3.
  14892. */
  14893. getPositionExpressedInLocalSpace(): Vector3;
  14894. /**
  14895. * Translates the mesh along the passed Vector3 in its local space.
  14896. * @param vector3 the distance to translate in localspace
  14897. * @returns the TransformNode.
  14898. */
  14899. locallyTranslate(vector3: Vector3): TransformNode;
  14900. private static _lookAtVectorCache;
  14901. /**
  14902. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14903. * @param targetPoint the position (must be in same space as current mesh) to look at
  14904. * @param yawCor optional yaw (y-axis) correction in radians
  14905. * @param pitchCor optional pitch (x-axis) correction in radians
  14906. * @param rollCor optional roll (z-axis) correction in radians
  14907. * @param space the choosen space of the target
  14908. * @returns the TransformNode.
  14909. */
  14910. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14911. /**
  14912. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14913. * This Vector3 is expressed in the World space.
  14914. * @param localAxis axis to rotate
  14915. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14916. */
  14917. getDirection(localAxis: Vector3): Vector3;
  14918. /**
  14919. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14920. * localAxis is expressed in the mesh local space.
  14921. * result is computed in the Wordl space from the mesh World matrix.
  14922. * @param localAxis axis to rotate
  14923. * @param result the resulting transformnode
  14924. * @returns this TransformNode.
  14925. */
  14926. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14927. /**
  14928. * Sets this transform node rotation to the given local axis.
  14929. * @param localAxis the axis in local space
  14930. * @param yawCor optional yaw (y-axis) correction in radians
  14931. * @param pitchCor optional pitch (x-axis) correction in radians
  14932. * @param rollCor optional roll (z-axis) correction in radians
  14933. * @returns this TransformNode
  14934. */
  14935. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14936. /**
  14937. * Sets a new pivot point to the current node
  14938. * @param point defines the new pivot point to use
  14939. * @param space defines if the point is in world or local space (local by default)
  14940. * @returns the current TransformNode
  14941. */
  14942. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14943. /**
  14944. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14945. * @returns the pivot point
  14946. */
  14947. getPivotPoint(): Vector3;
  14948. /**
  14949. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14950. * @param result the vector3 to store the result
  14951. * @returns this TransformNode.
  14952. */
  14953. getPivotPointToRef(result: Vector3): TransformNode;
  14954. /**
  14955. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14956. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14957. */
  14958. getAbsolutePivotPoint(): Vector3;
  14959. /**
  14960. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14961. * @param result vector3 to store the result
  14962. * @returns this TransformNode.
  14963. */
  14964. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14965. /**
  14966. * Defines the passed node as the parent of the current node.
  14967. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14968. * @see https://doc.babylonjs.com/how_to/parenting
  14969. * @param node the node ot set as the parent
  14970. * @returns this TransformNode.
  14971. */
  14972. setParent(node: Nullable<Node>): TransformNode;
  14973. private _nonUniformScaling;
  14974. /**
  14975. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14976. */
  14977. get nonUniformScaling(): boolean;
  14978. /** @hidden */
  14979. _updateNonUniformScalingState(value: boolean): boolean;
  14980. /**
  14981. * Attach the current TransformNode to another TransformNode associated with a bone
  14982. * @param bone Bone affecting the TransformNode
  14983. * @param affectedTransformNode TransformNode associated with the bone
  14984. * @returns this object
  14985. */
  14986. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14987. /**
  14988. * Detach the transform node if its associated with a bone
  14989. * @returns this object
  14990. */
  14991. detachFromBone(): TransformNode;
  14992. private static _rotationAxisCache;
  14993. /**
  14994. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14995. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14996. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14997. * The passed axis is also normalized.
  14998. * @param axis the axis to rotate around
  14999. * @param amount the amount to rotate in radians
  15000. * @param space Space to rotate in (Default: local)
  15001. * @returns the TransformNode.
  15002. */
  15003. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15004. /**
  15005. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15006. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15007. * The passed axis is also normalized. .
  15008. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15009. * @param point the point to rotate around
  15010. * @param axis the axis to rotate around
  15011. * @param amount the amount to rotate in radians
  15012. * @returns the TransformNode
  15013. */
  15014. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15015. /**
  15016. * Translates the mesh along the axis vector for the passed distance in the given space.
  15017. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15018. * @param axis the axis to translate in
  15019. * @param distance the distance to translate
  15020. * @param space Space to rotate in (Default: local)
  15021. * @returns the TransformNode.
  15022. */
  15023. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15024. /**
  15025. * Adds a rotation step to the mesh current rotation.
  15026. * x, y, z are Euler angles expressed in radians.
  15027. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15028. * This means this rotation is made in the mesh local space only.
  15029. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15030. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15031. * ```javascript
  15032. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15033. * ```
  15034. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15035. * 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.
  15036. * @param x Rotation to add
  15037. * @param y Rotation to add
  15038. * @param z Rotation to add
  15039. * @returns the TransformNode.
  15040. */
  15041. addRotation(x: number, y: number, z: number): TransformNode;
  15042. /**
  15043. * @hidden
  15044. */
  15045. protected _getEffectiveParent(): Nullable<Node>;
  15046. /**
  15047. * Computes the world matrix of the node
  15048. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15049. * @returns the world matrix
  15050. */
  15051. computeWorldMatrix(force?: boolean): Matrix;
  15052. /**
  15053. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15054. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15055. */
  15056. resetLocalMatrix(independentOfChildren?: boolean): void;
  15057. protected _afterComputeWorldMatrix(): void;
  15058. /**
  15059. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15060. * @param func callback function to add
  15061. *
  15062. * @returns the TransformNode.
  15063. */
  15064. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15065. /**
  15066. * Removes a registered callback function.
  15067. * @param func callback function to remove
  15068. * @returns the TransformNode.
  15069. */
  15070. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15071. /**
  15072. * Gets the position of the current mesh in camera space
  15073. * @param camera defines the camera to use
  15074. * @returns a position
  15075. */
  15076. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15077. /**
  15078. * Returns the distance from the mesh to the active camera
  15079. * @param camera defines the camera to use
  15080. * @returns the distance
  15081. */
  15082. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15083. /**
  15084. * Clone the current transform node
  15085. * @param name Name of the new clone
  15086. * @param newParent New parent for the clone
  15087. * @param doNotCloneChildren Do not clone children hierarchy
  15088. * @returns the new transform node
  15089. */
  15090. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15091. /**
  15092. * Serializes the objects information.
  15093. * @param currentSerializationObject defines the object to serialize in
  15094. * @returns the serialized object
  15095. */
  15096. serialize(currentSerializationObject?: any): any;
  15097. /**
  15098. * Returns a new TransformNode object parsed from the source provided.
  15099. * @param parsedTransformNode is the source.
  15100. * @param scene the scne the object belongs to
  15101. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15102. * @returns a new TransformNode object parsed from the source provided.
  15103. */
  15104. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15105. /**
  15106. * Get all child-transformNodes of this node
  15107. * @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
  15108. * @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
  15109. * @returns an array of TransformNode
  15110. */
  15111. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15112. /**
  15113. * Releases resources associated with this transform node.
  15114. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15115. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15116. */
  15117. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15118. /**
  15119. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15120. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15121. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15122. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15123. * @returns the current mesh
  15124. */
  15125. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15126. private _syncAbsoluteScalingAndRotation;
  15127. }
  15128. }
  15129. declare module BABYLON {
  15130. /**
  15131. * Class used to override all child animations of a given target
  15132. */
  15133. export class AnimationPropertiesOverride {
  15134. /**
  15135. * Gets or sets a value indicating if animation blending must be used
  15136. */
  15137. enableBlending: boolean;
  15138. /**
  15139. * Gets or sets the blending speed to use when enableBlending is true
  15140. */
  15141. blendingSpeed: number;
  15142. /**
  15143. * Gets or sets the default loop mode to use
  15144. */
  15145. loopMode: number;
  15146. }
  15147. }
  15148. declare module BABYLON {
  15149. /**
  15150. * Class used to store bone information
  15151. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15152. */
  15153. export class Bone extends Node {
  15154. /**
  15155. * defines the bone name
  15156. */
  15157. name: string;
  15158. private static _tmpVecs;
  15159. private static _tmpQuat;
  15160. private static _tmpMats;
  15161. /**
  15162. * Gets the list of child bones
  15163. */
  15164. children: Bone[];
  15165. /** Gets the animations associated with this bone */
  15166. animations: Animation[];
  15167. /**
  15168. * Gets or sets bone length
  15169. */
  15170. length: number;
  15171. /**
  15172. * @hidden Internal only
  15173. * Set this value to map this bone to a different index in the transform matrices
  15174. * Set this value to -1 to exclude the bone from the transform matrices
  15175. */
  15176. _index: Nullable<number>;
  15177. private _skeleton;
  15178. private _localMatrix;
  15179. private _restPose;
  15180. private _bindPose;
  15181. private _baseMatrix;
  15182. private _absoluteTransform;
  15183. private _invertedAbsoluteTransform;
  15184. private _parent;
  15185. private _scalingDeterminant;
  15186. private _worldTransform;
  15187. private _localScaling;
  15188. private _localRotation;
  15189. private _localPosition;
  15190. private _needToDecompose;
  15191. private _needToCompose;
  15192. /** @hidden */
  15193. _linkedTransformNode: Nullable<TransformNode>;
  15194. /** @hidden */
  15195. _waitingTransformNodeId: Nullable<string>;
  15196. /** @hidden */
  15197. get _matrix(): Matrix;
  15198. /** @hidden */
  15199. set _matrix(value: Matrix);
  15200. /**
  15201. * Create a new bone
  15202. * @param name defines the bone name
  15203. * @param skeleton defines the parent skeleton
  15204. * @param parentBone defines the parent (can be null if the bone is the root)
  15205. * @param localMatrix defines the local matrix
  15206. * @param restPose defines the rest pose matrix
  15207. * @param baseMatrix defines the base matrix
  15208. * @param index defines index of the bone in the hiearchy
  15209. */
  15210. constructor(
  15211. /**
  15212. * defines the bone name
  15213. */
  15214. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15215. /**
  15216. * Gets the current object class name.
  15217. * @return the class name
  15218. */
  15219. getClassName(): string;
  15220. /**
  15221. * Gets the parent skeleton
  15222. * @returns a skeleton
  15223. */
  15224. getSkeleton(): Skeleton;
  15225. /**
  15226. * Gets parent bone
  15227. * @returns a bone or null if the bone is the root of the bone hierarchy
  15228. */
  15229. getParent(): Nullable<Bone>;
  15230. /**
  15231. * Returns an array containing the root bones
  15232. * @returns an array containing the root bones
  15233. */
  15234. getChildren(): Array<Bone>;
  15235. /**
  15236. * Gets the node index in matrix array generated for rendering
  15237. * @returns the node index
  15238. */
  15239. getIndex(): number;
  15240. /**
  15241. * Sets the parent bone
  15242. * @param parent defines the parent (can be null if the bone is the root)
  15243. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15244. */
  15245. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15246. /**
  15247. * Gets the local matrix
  15248. * @returns a matrix
  15249. */
  15250. getLocalMatrix(): Matrix;
  15251. /**
  15252. * Gets the base matrix (initial matrix which remains unchanged)
  15253. * @returns a matrix
  15254. */
  15255. getBaseMatrix(): Matrix;
  15256. /**
  15257. * Gets the rest pose matrix
  15258. * @returns a matrix
  15259. */
  15260. getRestPose(): Matrix;
  15261. /**
  15262. * Sets the rest pose matrix
  15263. * @param matrix the local-space rest pose to set for this bone
  15264. */
  15265. setRestPose(matrix: Matrix): void;
  15266. /**
  15267. * Gets the bind pose matrix
  15268. * @returns the bind pose matrix
  15269. */
  15270. getBindPose(): Matrix;
  15271. /**
  15272. * Sets the bind pose matrix
  15273. * @param matrix the local-space bind pose to set for this bone
  15274. */
  15275. setBindPose(matrix: Matrix): void;
  15276. /**
  15277. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15278. */
  15279. getWorldMatrix(): Matrix;
  15280. /**
  15281. * Sets the local matrix to rest pose matrix
  15282. */
  15283. returnToRest(): void;
  15284. /**
  15285. * Gets the inverse of the absolute transform matrix.
  15286. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15287. * @returns a matrix
  15288. */
  15289. getInvertedAbsoluteTransform(): Matrix;
  15290. /**
  15291. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15292. * @returns a matrix
  15293. */
  15294. getAbsoluteTransform(): Matrix;
  15295. /**
  15296. * Links with the given transform node.
  15297. * The local matrix of this bone is copied from the transform node every frame.
  15298. * @param transformNode defines the transform node to link to
  15299. */
  15300. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15301. /**
  15302. * Gets the node used to drive the bone's transformation
  15303. * @returns a transform node or null
  15304. */
  15305. getTransformNode(): Nullable<TransformNode>;
  15306. /** Gets or sets current position (in local space) */
  15307. get position(): Vector3;
  15308. set position(newPosition: Vector3);
  15309. /** Gets or sets current rotation (in local space) */
  15310. get rotation(): Vector3;
  15311. set rotation(newRotation: Vector3);
  15312. /** Gets or sets current rotation quaternion (in local space) */
  15313. get rotationQuaternion(): Quaternion;
  15314. set rotationQuaternion(newRotation: Quaternion);
  15315. /** Gets or sets current scaling (in local space) */
  15316. get scaling(): Vector3;
  15317. set scaling(newScaling: Vector3);
  15318. /**
  15319. * Gets the animation properties override
  15320. */
  15321. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15322. private _decompose;
  15323. private _compose;
  15324. /**
  15325. * Update the base and local matrices
  15326. * @param matrix defines the new base or local matrix
  15327. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15328. * @param updateLocalMatrix defines if the local matrix should be updated
  15329. */
  15330. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15331. /** @hidden */
  15332. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15333. /**
  15334. * Flag the bone as dirty (Forcing it to update everything)
  15335. */
  15336. markAsDirty(): void;
  15337. /** @hidden */
  15338. _markAsDirtyAndCompose(): void;
  15339. private _markAsDirtyAndDecompose;
  15340. /**
  15341. * Translate the bone in local or world space
  15342. * @param vec The amount to translate the bone
  15343. * @param space The space that the translation is in
  15344. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15345. */
  15346. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15347. /**
  15348. * Set the postion of the bone in local or world space
  15349. * @param position The position to set the bone
  15350. * @param space The space that the position is in
  15351. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15352. */
  15353. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15354. /**
  15355. * Set the absolute position of the bone (world space)
  15356. * @param position The position to set the bone
  15357. * @param mesh The mesh that this bone is attached to
  15358. */
  15359. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15360. /**
  15361. * Scale the bone on the x, y and z axes (in local space)
  15362. * @param x The amount to scale the bone on the x axis
  15363. * @param y The amount to scale the bone on the y axis
  15364. * @param z The amount to scale the bone on the z axis
  15365. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15366. */
  15367. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15368. /**
  15369. * Set the bone scaling in local space
  15370. * @param scale defines the scaling vector
  15371. */
  15372. setScale(scale: Vector3): void;
  15373. /**
  15374. * Gets the current scaling in local space
  15375. * @returns the current scaling vector
  15376. */
  15377. getScale(): Vector3;
  15378. /**
  15379. * Gets the current scaling in local space and stores it in a target vector
  15380. * @param result defines the target vector
  15381. */
  15382. getScaleToRef(result: Vector3): void;
  15383. /**
  15384. * Set the yaw, pitch, and roll of the bone in local or world space
  15385. * @param yaw The rotation of the bone on the y axis
  15386. * @param pitch The rotation of the bone on the x axis
  15387. * @param roll The rotation of the bone on the z axis
  15388. * @param space The space that the axes of rotation are in
  15389. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15390. */
  15391. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15392. /**
  15393. * Add a rotation to the bone on an axis in local or world space
  15394. * @param axis The axis to rotate the bone on
  15395. * @param amount The amount to rotate the bone
  15396. * @param space The space that the axis is in
  15397. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15398. */
  15399. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15400. /**
  15401. * Set the rotation of the bone to a particular axis angle in local or world space
  15402. * @param axis The axis to rotate the bone on
  15403. * @param angle The angle that the bone should be rotated to
  15404. * @param space The space that the axis is in
  15405. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15406. */
  15407. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15408. /**
  15409. * Set the euler rotation of the bone in local of world space
  15410. * @param rotation The euler rotation that the bone should be set to
  15411. * @param space The space that the rotation is in
  15412. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15413. */
  15414. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15415. /**
  15416. * Set the quaternion rotation of the bone in local of world space
  15417. * @param quat The quaternion rotation that the bone should be set to
  15418. * @param space The space that the rotation is in
  15419. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15420. */
  15421. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15422. /**
  15423. * Set the rotation matrix of the bone in local of world space
  15424. * @param rotMat The rotation matrix that the bone should be set to
  15425. * @param space The space that the rotation is in
  15426. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15427. */
  15428. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15429. private _rotateWithMatrix;
  15430. private _getNegativeRotationToRef;
  15431. /**
  15432. * Get the position of the bone in local or world space
  15433. * @param space The space that the returned position is in
  15434. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15435. * @returns The position of the bone
  15436. */
  15437. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15438. /**
  15439. * Copy the position of the bone to a vector3 in local or world space
  15440. * @param space The space that the returned position is in
  15441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15442. * @param result The vector3 to copy the position to
  15443. */
  15444. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15445. /**
  15446. * Get the absolute position of the bone (world space)
  15447. * @param mesh The mesh that this bone is attached to
  15448. * @returns The absolute position of the bone
  15449. */
  15450. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15451. /**
  15452. * Copy the absolute position of the bone (world space) to the result param
  15453. * @param mesh The mesh that this bone is attached to
  15454. * @param result The vector3 to copy the absolute position to
  15455. */
  15456. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15457. /**
  15458. * Compute the absolute transforms of this bone and its children
  15459. */
  15460. computeAbsoluteTransforms(): void;
  15461. /**
  15462. * Get the world direction from an axis that is in the local space of the bone
  15463. * @param localAxis The local direction that is used to compute the world direction
  15464. * @param mesh The mesh that this bone is attached to
  15465. * @returns The world direction
  15466. */
  15467. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15468. /**
  15469. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15470. * @param localAxis The local direction that is used to compute the world direction
  15471. * @param mesh The mesh that this bone is attached to
  15472. * @param result The vector3 that the world direction will be copied to
  15473. */
  15474. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15475. /**
  15476. * Get the euler rotation of the bone in local or world space
  15477. * @param space The space that the rotation should be in
  15478. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15479. * @returns The euler rotation
  15480. */
  15481. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15482. /**
  15483. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15484. * @param space The space that the rotation should be in
  15485. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15486. * @param result The vector3 that the rotation should be copied to
  15487. */
  15488. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15489. /**
  15490. * Get the quaternion rotation of the bone in either local or world space
  15491. * @param space The space that the rotation should be in
  15492. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15493. * @returns The quaternion rotation
  15494. */
  15495. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15496. /**
  15497. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15498. * @param space The space that the rotation should be in
  15499. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15500. * @param result The quaternion that the rotation should be copied to
  15501. */
  15502. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15503. /**
  15504. * Get the rotation matrix of the bone in local or world space
  15505. * @param space The space that the rotation should be in
  15506. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15507. * @returns The rotation matrix
  15508. */
  15509. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15510. /**
  15511. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15512. * @param space The space that the rotation should be in
  15513. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15514. * @param result The quaternion that the rotation should be copied to
  15515. */
  15516. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15517. /**
  15518. * Get the world position of a point that is in the local space of the bone
  15519. * @param position The local position
  15520. * @param mesh The mesh that this bone is attached to
  15521. * @returns The world position
  15522. */
  15523. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15524. /**
  15525. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15526. * @param position The local position
  15527. * @param mesh The mesh that this bone is attached to
  15528. * @param result The vector3 that the world position should be copied to
  15529. */
  15530. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15531. /**
  15532. * Get the local position of a point that is in world space
  15533. * @param position The world position
  15534. * @param mesh The mesh that this bone is attached to
  15535. * @returns The local position
  15536. */
  15537. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15538. /**
  15539. * Get the local position of a point that is in world space and copy it to the result param
  15540. * @param position The world position
  15541. * @param mesh The mesh that this bone is attached to
  15542. * @param result The vector3 that the local position should be copied to
  15543. */
  15544. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15545. }
  15546. }
  15547. declare module BABYLON {
  15548. /**
  15549. * Defines a runtime animation
  15550. */
  15551. export class RuntimeAnimation {
  15552. private _events;
  15553. /**
  15554. * The current frame of the runtime animation
  15555. */
  15556. private _currentFrame;
  15557. /**
  15558. * The animation used by the runtime animation
  15559. */
  15560. private _animation;
  15561. /**
  15562. * The target of the runtime animation
  15563. */
  15564. private _target;
  15565. /**
  15566. * The initiating animatable
  15567. */
  15568. private _host;
  15569. /**
  15570. * The original value of the runtime animation
  15571. */
  15572. private _originalValue;
  15573. /**
  15574. * The original blend value of the runtime animation
  15575. */
  15576. private _originalBlendValue;
  15577. /**
  15578. * The offsets cache of the runtime animation
  15579. */
  15580. private _offsetsCache;
  15581. /**
  15582. * The high limits cache of the runtime animation
  15583. */
  15584. private _highLimitsCache;
  15585. /**
  15586. * Specifies if the runtime animation has been stopped
  15587. */
  15588. private _stopped;
  15589. /**
  15590. * The blending factor of the runtime animation
  15591. */
  15592. private _blendingFactor;
  15593. /**
  15594. * The BabylonJS scene
  15595. */
  15596. private _scene;
  15597. /**
  15598. * The current value of the runtime animation
  15599. */
  15600. private _currentValue;
  15601. /** @hidden */
  15602. _animationState: _IAnimationState;
  15603. /**
  15604. * The active target of the runtime animation
  15605. */
  15606. private _activeTargets;
  15607. private _currentActiveTarget;
  15608. private _directTarget;
  15609. /**
  15610. * The target path of the runtime animation
  15611. */
  15612. private _targetPath;
  15613. /**
  15614. * The weight of the runtime animation
  15615. */
  15616. private _weight;
  15617. /**
  15618. * The ratio offset of the runtime animation
  15619. */
  15620. private _ratioOffset;
  15621. /**
  15622. * The previous delay of the runtime animation
  15623. */
  15624. private _previousDelay;
  15625. /**
  15626. * The previous ratio of the runtime animation
  15627. */
  15628. private _previousRatio;
  15629. private _enableBlending;
  15630. private _keys;
  15631. private _minFrame;
  15632. private _maxFrame;
  15633. private _minValue;
  15634. private _maxValue;
  15635. private _targetIsArray;
  15636. /**
  15637. * Gets the current frame of the runtime animation
  15638. */
  15639. get currentFrame(): number;
  15640. /**
  15641. * Gets the weight of the runtime animation
  15642. */
  15643. get weight(): number;
  15644. /**
  15645. * Gets the current value of the runtime animation
  15646. */
  15647. get currentValue(): any;
  15648. /**
  15649. * Gets the target path of the runtime animation
  15650. */
  15651. get targetPath(): string;
  15652. /**
  15653. * Gets the actual target of the runtime animation
  15654. */
  15655. get target(): any;
  15656. /**
  15657. * Gets the additive state of the runtime animation
  15658. */
  15659. get isAdditive(): boolean;
  15660. /** @hidden */
  15661. _onLoop: () => void;
  15662. /**
  15663. * Create a new RuntimeAnimation object
  15664. * @param target defines the target of the animation
  15665. * @param animation defines the source animation object
  15666. * @param scene defines the hosting scene
  15667. * @param host defines the initiating Animatable
  15668. */
  15669. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15670. private _preparePath;
  15671. /**
  15672. * Gets the animation from the runtime animation
  15673. */
  15674. get animation(): Animation;
  15675. /**
  15676. * Resets the runtime animation to the beginning
  15677. * @param restoreOriginal defines whether to restore the target property to the original value
  15678. */
  15679. reset(restoreOriginal?: boolean): void;
  15680. /**
  15681. * Specifies if the runtime animation is stopped
  15682. * @returns Boolean specifying if the runtime animation is stopped
  15683. */
  15684. isStopped(): boolean;
  15685. /**
  15686. * Disposes of the runtime animation
  15687. */
  15688. dispose(): void;
  15689. /**
  15690. * Apply the interpolated value to the target
  15691. * @param currentValue defines the value computed by the animation
  15692. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15693. */
  15694. setValue(currentValue: any, weight: number): void;
  15695. private _getOriginalValues;
  15696. private _setValue;
  15697. /**
  15698. * Gets the loop pmode of the runtime animation
  15699. * @returns Loop Mode
  15700. */
  15701. private _getCorrectLoopMode;
  15702. /**
  15703. * Move the current animation to a given frame
  15704. * @param frame defines the frame to move to
  15705. */
  15706. goToFrame(frame: number): void;
  15707. /**
  15708. * @hidden Internal use only
  15709. */
  15710. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15711. /**
  15712. * Execute the current animation
  15713. * @param delay defines the delay to add to the current frame
  15714. * @param from defines the lower bound of the animation range
  15715. * @param to defines the upper bound of the animation range
  15716. * @param loop defines if the current animation must loop
  15717. * @param speedRatio defines the current speed ratio
  15718. * @param weight defines the weight of the animation (default is -1 so no weight)
  15719. * @param onLoop optional callback called when animation loops
  15720. * @returns a boolean indicating if the animation is running
  15721. */
  15722. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15723. }
  15724. }
  15725. declare module BABYLON {
  15726. /**
  15727. * Class used to store an actual running animation
  15728. */
  15729. export class Animatable {
  15730. /** defines the target object */
  15731. target: any;
  15732. /** defines the starting frame number (default is 0) */
  15733. fromFrame: number;
  15734. /** defines the ending frame number (default is 100) */
  15735. toFrame: number;
  15736. /** defines if the animation must loop (default is false) */
  15737. loopAnimation: boolean;
  15738. /** defines a callback to call when animation ends if it is not looping */
  15739. onAnimationEnd?: (() => void) | null | undefined;
  15740. /** defines a callback to call when animation loops */
  15741. onAnimationLoop?: (() => void) | null | undefined;
  15742. /** defines whether the animation should be evaluated additively */
  15743. isAdditive: boolean;
  15744. private _localDelayOffset;
  15745. private _pausedDelay;
  15746. private _runtimeAnimations;
  15747. private _paused;
  15748. private _scene;
  15749. private _speedRatio;
  15750. private _weight;
  15751. private _syncRoot;
  15752. /**
  15753. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15754. * This will only apply for non looping animation (default is true)
  15755. */
  15756. disposeOnEnd: boolean;
  15757. /**
  15758. * Gets a boolean indicating if the animation has started
  15759. */
  15760. animationStarted: boolean;
  15761. /**
  15762. * Observer raised when the animation ends
  15763. */
  15764. onAnimationEndObservable: Observable<Animatable>;
  15765. /**
  15766. * Observer raised when the animation loops
  15767. */
  15768. onAnimationLoopObservable: Observable<Animatable>;
  15769. /**
  15770. * Gets the root Animatable used to synchronize and normalize animations
  15771. */
  15772. get syncRoot(): Nullable<Animatable>;
  15773. /**
  15774. * Gets the current frame of the first RuntimeAnimation
  15775. * Used to synchronize Animatables
  15776. */
  15777. get masterFrame(): number;
  15778. /**
  15779. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15780. */
  15781. get weight(): number;
  15782. set weight(value: number);
  15783. /**
  15784. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15785. */
  15786. get speedRatio(): number;
  15787. set speedRatio(value: number);
  15788. /**
  15789. * Creates a new Animatable
  15790. * @param scene defines the hosting scene
  15791. * @param target defines the target object
  15792. * @param fromFrame defines the starting frame number (default is 0)
  15793. * @param toFrame defines the ending frame number (default is 100)
  15794. * @param loopAnimation defines if the animation must loop (default is false)
  15795. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15796. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15797. * @param animations defines a group of animation to add to the new Animatable
  15798. * @param onAnimationLoop defines a callback to call when animation loops
  15799. * @param isAdditive defines whether the animation should be evaluated additively
  15800. */
  15801. constructor(scene: Scene,
  15802. /** defines the target object */
  15803. target: any,
  15804. /** defines the starting frame number (default is 0) */
  15805. fromFrame?: number,
  15806. /** defines the ending frame number (default is 100) */
  15807. toFrame?: number,
  15808. /** defines if the animation must loop (default is false) */
  15809. loopAnimation?: boolean, speedRatio?: number,
  15810. /** defines a callback to call when animation ends if it is not looping */
  15811. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15812. /** defines a callback to call when animation loops */
  15813. onAnimationLoop?: (() => void) | null | undefined,
  15814. /** defines whether the animation should be evaluated additively */
  15815. isAdditive?: boolean);
  15816. /**
  15817. * Synchronize and normalize current Animatable with a source Animatable
  15818. * This is useful when using animation weights and when animations are not of the same length
  15819. * @param root defines the root Animatable to synchronize with
  15820. * @returns the current Animatable
  15821. */
  15822. syncWith(root: Animatable): Animatable;
  15823. /**
  15824. * Gets the list of runtime animations
  15825. * @returns an array of RuntimeAnimation
  15826. */
  15827. getAnimations(): RuntimeAnimation[];
  15828. /**
  15829. * Adds more animations to the current animatable
  15830. * @param target defines the target of the animations
  15831. * @param animations defines the new animations to add
  15832. */
  15833. appendAnimations(target: any, animations: Animation[]): void;
  15834. /**
  15835. * Gets the source animation for a specific property
  15836. * @param property defines the propertyu to look for
  15837. * @returns null or the source animation for the given property
  15838. */
  15839. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15840. /**
  15841. * Gets the runtime animation for a specific property
  15842. * @param property defines the propertyu to look for
  15843. * @returns null or the runtime animation for the given property
  15844. */
  15845. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15846. /**
  15847. * Resets the animatable to its original state
  15848. */
  15849. reset(): void;
  15850. /**
  15851. * Allows the animatable to blend with current running animations
  15852. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15853. * @param blendingSpeed defines the blending speed to use
  15854. */
  15855. enableBlending(blendingSpeed: number): void;
  15856. /**
  15857. * Disable animation blending
  15858. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15859. */
  15860. disableBlending(): void;
  15861. /**
  15862. * Jump directly to a given frame
  15863. * @param frame defines the frame to jump to
  15864. */
  15865. goToFrame(frame: number): void;
  15866. /**
  15867. * Pause the animation
  15868. */
  15869. pause(): void;
  15870. /**
  15871. * Restart the animation
  15872. */
  15873. restart(): void;
  15874. private _raiseOnAnimationEnd;
  15875. /**
  15876. * Stop and delete the current animation
  15877. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15878. * @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)
  15879. */
  15880. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15881. /**
  15882. * Wait asynchronously for the animation to end
  15883. * @returns a promise which will be fullfilled when the animation ends
  15884. */
  15885. waitAsync(): Promise<Animatable>;
  15886. /** @hidden */
  15887. _animate(delay: number): boolean;
  15888. }
  15889. interface Scene {
  15890. /** @hidden */
  15891. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15892. /** @hidden */
  15893. _processLateAnimationBindingsForMatrices(holder: {
  15894. totalWeight: number;
  15895. totalAdditiveWeight: number;
  15896. animations: RuntimeAnimation[];
  15897. additiveAnimations: RuntimeAnimation[];
  15898. originalValue: Matrix;
  15899. }): any;
  15900. /** @hidden */
  15901. _processLateAnimationBindingsForQuaternions(holder: {
  15902. totalWeight: number;
  15903. totalAdditiveWeight: number;
  15904. animations: RuntimeAnimation[];
  15905. additiveAnimations: RuntimeAnimation[];
  15906. originalValue: Quaternion;
  15907. }, refQuaternion: Quaternion): Quaternion;
  15908. /** @hidden */
  15909. _processLateAnimationBindings(): void;
  15910. /**
  15911. * Will start the animation sequence of a given target
  15912. * @param target defines the target
  15913. * @param from defines from which frame should animation start
  15914. * @param to defines until which frame should animation run.
  15915. * @param weight defines the weight to apply to the animation (1.0 by default)
  15916. * @param loop defines if the animation loops
  15917. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15918. * @param onAnimationEnd defines the function to be executed when the animation ends
  15919. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15920. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15921. * @param onAnimationLoop defines the callback to call when an animation loops
  15922. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15923. * @returns the animatable object created for this animation
  15924. */
  15925. 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;
  15926. /**
  15927. * Will start the animation sequence of a given target
  15928. * @param target defines the target
  15929. * @param from defines from which frame should animation start
  15930. * @param to defines until which frame should animation run.
  15931. * @param loop defines if the animation loops
  15932. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15933. * @param onAnimationEnd defines the function to be executed when the animation ends
  15934. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15935. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15936. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15937. * @param onAnimationLoop defines the callback to call when an animation loops
  15938. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15939. * @returns the animatable object created for this animation
  15940. */
  15941. 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;
  15942. /**
  15943. * Will start the animation sequence of a given target and its hierarchy
  15944. * @param target defines the target
  15945. * @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.
  15946. * @param from defines from which frame should animation start
  15947. * @param to defines until which frame should animation run.
  15948. * @param loop defines if the animation loops
  15949. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15950. * @param onAnimationEnd defines the function to be executed when the animation ends
  15951. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15952. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15953. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15954. * @param onAnimationLoop defines the callback to call when an animation loops
  15955. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15956. * @returns the list of created animatables
  15957. */
  15958. 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[];
  15959. /**
  15960. * Begin a new animation on a given node
  15961. * @param target defines the target where the animation will take place
  15962. * @param animations defines the list of animations to start
  15963. * @param from defines the initial value
  15964. * @param to defines the final value
  15965. * @param loop defines if you want animation to loop (off by default)
  15966. * @param speedRatio defines the speed ratio to apply to all animations
  15967. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15968. * @param onAnimationLoop defines the callback to call when an animation loops
  15969. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15970. * @returns the list of created animatables
  15971. */
  15972. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15973. /**
  15974. * Begin a new animation on a given node and its hierarchy
  15975. * @param target defines the root node where the animation will take place
  15976. * @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.
  15977. * @param animations defines the list of animations to start
  15978. * @param from defines the initial value
  15979. * @param to defines the final value
  15980. * @param loop defines if you want animation to loop (off by default)
  15981. * @param speedRatio defines the speed ratio to apply to all animations
  15982. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15983. * @param onAnimationLoop defines the callback to call when an animation loops
  15984. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15985. * @returns the list of animatables created for all nodes
  15986. */
  15987. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15988. /**
  15989. * Gets the animatable associated with a specific target
  15990. * @param target defines the target of the animatable
  15991. * @returns the required animatable if found
  15992. */
  15993. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15994. /**
  15995. * Gets all animatables associated with a given target
  15996. * @param target defines the target to look animatables for
  15997. * @returns an array of Animatables
  15998. */
  15999. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16000. /**
  16001. * Stops and removes all animations that have been applied to the scene
  16002. */
  16003. stopAllAnimations(): void;
  16004. /**
  16005. * Gets the current delta time used by animation engine
  16006. */
  16007. deltaTime: number;
  16008. }
  16009. interface Bone {
  16010. /**
  16011. * Copy an animation range from another bone
  16012. * @param source defines the source bone
  16013. * @param rangeName defines the range name to copy
  16014. * @param frameOffset defines the frame offset
  16015. * @param rescaleAsRequired defines if rescaling must be applied if required
  16016. * @param skelDimensionsRatio defines the scaling ratio
  16017. * @returns true if operation was successful
  16018. */
  16019. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16020. }
  16021. }
  16022. declare module BABYLON {
  16023. /**
  16024. * Class used to handle skinning animations
  16025. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16026. */
  16027. export class Skeleton implements IAnimatable {
  16028. /** defines the skeleton name */
  16029. name: string;
  16030. /** defines the skeleton Id */
  16031. id: string;
  16032. /**
  16033. * Defines the list of child bones
  16034. */
  16035. bones: Bone[];
  16036. /**
  16037. * Defines an estimate of the dimension of the skeleton at rest
  16038. */
  16039. dimensionsAtRest: Vector3;
  16040. /**
  16041. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16042. */
  16043. needInitialSkinMatrix: boolean;
  16044. /**
  16045. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16046. */
  16047. overrideMesh: Nullable<AbstractMesh>;
  16048. /**
  16049. * Gets the list of animations attached to this skeleton
  16050. */
  16051. animations: Array<Animation>;
  16052. private _scene;
  16053. private _isDirty;
  16054. private _transformMatrices;
  16055. private _transformMatrixTexture;
  16056. private _meshesWithPoseMatrix;
  16057. private _animatables;
  16058. private _identity;
  16059. private _synchronizedWithMesh;
  16060. private _ranges;
  16061. private _lastAbsoluteTransformsUpdateId;
  16062. private _canUseTextureForBones;
  16063. private _uniqueId;
  16064. /** @hidden */
  16065. _numBonesWithLinkedTransformNode: number;
  16066. /** @hidden */
  16067. _hasWaitingData: Nullable<boolean>;
  16068. /** @hidden */
  16069. _waitingOverrideMeshId: Nullable<string>;
  16070. /**
  16071. * Specifies if the skeleton should be serialized
  16072. */
  16073. doNotSerialize: boolean;
  16074. private _useTextureToStoreBoneMatrices;
  16075. /**
  16076. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16077. * Please note that this option is not available if the hardware does not support it
  16078. */
  16079. get useTextureToStoreBoneMatrices(): boolean;
  16080. set useTextureToStoreBoneMatrices(value: boolean);
  16081. private _animationPropertiesOverride;
  16082. /**
  16083. * Gets or sets the animation properties override
  16084. */
  16085. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16086. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16087. /**
  16088. * List of inspectable custom properties (used by the Inspector)
  16089. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16090. */
  16091. inspectableCustomProperties: IInspectable[];
  16092. /**
  16093. * An observable triggered before computing the skeleton's matrices
  16094. */
  16095. onBeforeComputeObservable: Observable<Skeleton>;
  16096. /**
  16097. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16098. */
  16099. get isUsingTextureForMatrices(): boolean;
  16100. /**
  16101. * Gets the unique ID of this skeleton
  16102. */
  16103. get uniqueId(): number;
  16104. /**
  16105. * Creates a new skeleton
  16106. * @param name defines the skeleton name
  16107. * @param id defines the skeleton Id
  16108. * @param scene defines the hosting scene
  16109. */
  16110. constructor(
  16111. /** defines the skeleton name */
  16112. name: string,
  16113. /** defines the skeleton Id */
  16114. id: string, scene: Scene);
  16115. /**
  16116. * Gets the current object class name.
  16117. * @return the class name
  16118. */
  16119. getClassName(): string;
  16120. /**
  16121. * Returns an array containing the root bones
  16122. * @returns an array containing the root bones
  16123. */
  16124. getChildren(): Array<Bone>;
  16125. /**
  16126. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16127. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16128. * @returns a Float32Array containing matrices data
  16129. */
  16130. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16131. /**
  16132. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16133. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16134. * @returns a raw texture containing the data
  16135. */
  16136. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16137. /**
  16138. * Gets the current hosting scene
  16139. * @returns a scene object
  16140. */
  16141. getScene(): Scene;
  16142. /**
  16143. * Gets a string representing the current skeleton data
  16144. * @param fullDetails defines a boolean indicating if we want a verbose version
  16145. * @returns a string representing the current skeleton data
  16146. */
  16147. toString(fullDetails?: boolean): string;
  16148. /**
  16149. * Get bone's index searching by name
  16150. * @param name defines bone's name to search for
  16151. * @return the indice of the bone. Returns -1 if not found
  16152. */
  16153. getBoneIndexByName(name: string): number;
  16154. /**
  16155. * Creater a new animation range
  16156. * @param name defines the name of the range
  16157. * @param from defines the start key
  16158. * @param to defines the end key
  16159. */
  16160. createAnimationRange(name: string, from: number, to: number): void;
  16161. /**
  16162. * Delete a specific animation range
  16163. * @param name defines the name of the range
  16164. * @param deleteFrames defines if frames must be removed as well
  16165. */
  16166. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16167. /**
  16168. * Gets a specific animation range
  16169. * @param name defines the name of the range to look for
  16170. * @returns the requested animation range or null if not found
  16171. */
  16172. getAnimationRange(name: string): Nullable<AnimationRange>;
  16173. /**
  16174. * Gets the list of all animation ranges defined on this skeleton
  16175. * @returns an array
  16176. */
  16177. getAnimationRanges(): Nullable<AnimationRange>[];
  16178. /**
  16179. * Copy animation range from a source skeleton.
  16180. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16181. * @param source defines the source skeleton
  16182. * @param name defines the name of the range to copy
  16183. * @param rescaleAsRequired defines if rescaling must be applied if required
  16184. * @returns true if operation was successful
  16185. */
  16186. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16187. /**
  16188. * Forces the skeleton to go to rest pose
  16189. */
  16190. returnToRest(): void;
  16191. private _getHighestAnimationFrame;
  16192. /**
  16193. * Begin a specific animation range
  16194. * @param name defines the name of the range to start
  16195. * @param loop defines if looping must be turned on (false by default)
  16196. * @param speedRatio defines the speed ratio to apply (1 by default)
  16197. * @param onAnimationEnd defines a callback which will be called when animation will end
  16198. * @returns a new animatable
  16199. */
  16200. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16201. /**
  16202. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16203. * @param skeleton defines the Skeleton containing the animation range to convert
  16204. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16205. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16206. * @returns the original skeleton
  16207. */
  16208. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16209. /** @hidden */
  16210. _markAsDirty(): void;
  16211. /** @hidden */
  16212. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16213. /** @hidden */
  16214. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16215. private _computeTransformMatrices;
  16216. /**
  16217. * Build all resources required to render a skeleton
  16218. */
  16219. prepare(): void;
  16220. /**
  16221. * Gets the list of animatables currently running for this skeleton
  16222. * @returns an array of animatables
  16223. */
  16224. getAnimatables(): IAnimatable[];
  16225. /**
  16226. * Clone the current skeleton
  16227. * @param name defines the name of the new skeleton
  16228. * @param id defines the id of the new skeleton
  16229. * @returns the new skeleton
  16230. */
  16231. clone(name: string, id?: string): Skeleton;
  16232. /**
  16233. * Enable animation blending for this skeleton
  16234. * @param blendingSpeed defines the blending speed to apply
  16235. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16236. */
  16237. enableBlending(blendingSpeed?: number): void;
  16238. /**
  16239. * Releases all resources associated with the current skeleton
  16240. */
  16241. dispose(): void;
  16242. /**
  16243. * Serialize the skeleton in a JSON object
  16244. * @returns a JSON object
  16245. */
  16246. serialize(): any;
  16247. /**
  16248. * Creates a new skeleton from serialized data
  16249. * @param parsedSkeleton defines the serialized data
  16250. * @param scene defines the hosting scene
  16251. * @returns a new skeleton
  16252. */
  16253. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16254. /**
  16255. * Compute all node absolute transforms
  16256. * @param forceUpdate defines if computation must be done even if cache is up to date
  16257. */
  16258. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16259. /**
  16260. * Gets the root pose matrix
  16261. * @returns a matrix
  16262. */
  16263. getPoseMatrix(): Nullable<Matrix>;
  16264. /**
  16265. * Sorts bones per internal index
  16266. */
  16267. sortBones(): void;
  16268. private _sortBones;
  16269. }
  16270. }
  16271. declare module BABYLON {
  16272. /**
  16273. * Creates an instance based on a source mesh.
  16274. */
  16275. export class InstancedMesh extends AbstractMesh {
  16276. private _sourceMesh;
  16277. private _currentLOD;
  16278. /** @hidden */
  16279. _indexInSourceMeshInstanceArray: number;
  16280. constructor(name: string, source: Mesh);
  16281. /**
  16282. * Returns the string "InstancedMesh".
  16283. */
  16284. getClassName(): string;
  16285. /** Gets the list of lights affecting that mesh */
  16286. get lightSources(): Light[];
  16287. _resyncLightSources(): void;
  16288. _resyncLightSource(light: Light): void;
  16289. _removeLightSource(light: Light, dispose: boolean): void;
  16290. /**
  16291. * If the source mesh receives shadows
  16292. */
  16293. get receiveShadows(): boolean;
  16294. /**
  16295. * The material of the source mesh
  16296. */
  16297. get material(): Nullable<Material>;
  16298. /**
  16299. * Visibility of the source mesh
  16300. */
  16301. get visibility(): number;
  16302. /**
  16303. * Skeleton of the source mesh
  16304. */
  16305. get skeleton(): Nullable<Skeleton>;
  16306. /**
  16307. * Rendering ground id of the source mesh
  16308. */
  16309. get renderingGroupId(): number;
  16310. set renderingGroupId(value: number);
  16311. /**
  16312. * Returns the total number of vertices (integer).
  16313. */
  16314. getTotalVertices(): number;
  16315. /**
  16316. * Returns a positive integer : the total number of indices in this mesh geometry.
  16317. * @returns the numner of indices or zero if the mesh has no geometry.
  16318. */
  16319. getTotalIndices(): number;
  16320. /**
  16321. * The source mesh of the instance
  16322. */
  16323. get sourceMesh(): Mesh;
  16324. /**
  16325. * Creates a new InstancedMesh object from the mesh model.
  16326. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16327. * @param name defines the name of the new instance
  16328. * @returns a new InstancedMesh
  16329. */
  16330. createInstance(name: string): InstancedMesh;
  16331. /**
  16332. * Is this node ready to be used/rendered
  16333. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16334. * @return {boolean} is it ready
  16335. */
  16336. isReady(completeCheck?: boolean): boolean;
  16337. /**
  16338. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16339. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16340. * @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.
  16341. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16342. */
  16343. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16344. /**
  16345. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16346. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16347. * The `data` are either a numeric array either a Float32Array.
  16348. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16349. * 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).
  16350. * Note that a new underlying VertexBuffer object is created each call.
  16351. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16352. *
  16353. * Possible `kind` values :
  16354. * - VertexBuffer.PositionKind
  16355. * - VertexBuffer.UVKind
  16356. * - VertexBuffer.UV2Kind
  16357. * - VertexBuffer.UV3Kind
  16358. * - VertexBuffer.UV4Kind
  16359. * - VertexBuffer.UV5Kind
  16360. * - VertexBuffer.UV6Kind
  16361. * - VertexBuffer.ColorKind
  16362. * - VertexBuffer.MatricesIndicesKind
  16363. * - VertexBuffer.MatricesIndicesExtraKind
  16364. * - VertexBuffer.MatricesWeightsKind
  16365. * - VertexBuffer.MatricesWeightsExtraKind
  16366. *
  16367. * Returns the Mesh.
  16368. */
  16369. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16370. /**
  16371. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16372. * If the mesh has no geometry, it is simply returned as it is.
  16373. * The `data` are either a numeric array either a Float32Array.
  16374. * No new underlying VertexBuffer object is created.
  16375. * 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.
  16376. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16377. *
  16378. * Possible `kind` values :
  16379. * - VertexBuffer.PositionKind
  16380. * - VertexBuffer.UVKind
  16381. * - VertexBuffer.UV2Kind
  16382. * - VertexBuffer.UV3Kind
  16383. * - VertexBuffer.UV4Kind
  16384. * - VertexBuffer.UV5Kind
  16385. * - VertexBuffer.UV6Kind
  16386. * - VertexBuffer.ColorKind
  16387. * - VertexBuffer.MatricesIndicesKind
  16388. * - VertexBuffer.MatricesIndicesExtraKind
  16389. * - VertexBuffer.MatricesWeightsKind
  16390. * - VertexBuffer.MatricesWeightsExtraKind
  16391. *
  16392. * Returns the Mesh.
  16393. */
  16394. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16395. /**
  16396. * Sets the mesh indices.
  16397. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16398. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16399. * This method creates a new index buffer each call.
  16400. * Returns the Mesh.
  16401. */
  16402. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16403. /**
  16404. * Boolean : True if the mesh owns the requested kind of data.
  16405. */
  16406. isVerticesDataPresent(kind: string): boolean;
  16407. /**
  16408. * Returns an array of indices (IndicesArray).
  16409. */
  16410. getIndices(): Nullable<IndicesArray>;
  16411. get _positions(): Nullable<Vector3[]>;
  16412. /**
  16413. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16414. * This means the mesh underlying bounding box and sphere are recomputed.
  16415. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16416. * @returns the current mesh
  16417. */
  16418. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16419. /** @hidden */
  16420. _preActivate(): InstancedMesh;
  16421. /** @hidden */
  16422. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16423. /** @hidden */
  16424. _postActivate(): void;
  16425. getWorldMatrix(): Matrix;
  16426. get isAnInstance(): boolean;
  16427. /**
  16428. * Returns the current associated LOD AbstractMesh.
  16429. */
  16430. getLOD(camera: Camera): AbstractMesh;
  16431. /** @hidden */
  16432. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16433. /** @hidden */
  16434. _syncSubMeshes(): InstancedMesh;
  16435. /** @hidden */
  16436. _generatePointsArray(): boolean;
  16437. /** @hidden */
  16438. _updateBoundingInfo(): AbstractMesh;
  16439. /**
  16440. * Creates a new InstancedMesh from the current mesh.
  16441. * - name (string) : the cloned mesh name
  16442. * - newParent (optional Node) : the optional Node to parent the clone to.
  16443. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16444. *
  16445. * Returns the clone.
  16446. */
  16447. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16448. /**
  16449. * Disposes the InstancedMesh.
  16450. * Returns nothing.
  16451. */
  16452. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16453. }
  16454. interface Mesh {
  16455. /**
  16456. * Register a custom buffer that will be instanced
  16457. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16458. * @param kind defines the buffer kind
  16459. * @param stride defines the stride in floats
  16460. */
  16461. registerInstancedBuffer(kind: string, stride: number): void;
  16462. /**
  16463. * true to use the edge renderer for all instances of this mesh
  16464. */
  16465. edgesShareWithInstances: boolean;
  16466. /** @hidden */
  16467. _userInstancedBuffersStorage: {
  16468. data: {
  16469. [key: string]: Float32Array;
  16470. };
  16471. sizes: {
  16472. [key: string]: number;
  16473. };
  16474. vertexBuffers: {
  16475. [key: string]: Nullable<VertexBuffer>;
  16476. };
  16477. strides: {
  16478. [key: string]: number;
  16479. };
  16480. };
  16481. }
  16482. interface AbstractMesh {
  16483. /**
  16484. * Object used to store instanced buffers defined by user
  16485. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16486. */
  16487. instancedBuffers: {
  16488. [key: string]: any;
  16489. };
  16490. }
  16491. }
  16492. declare module BABYLON {
  16493. /**
  16494. * Defines the options associated with the creation of a shader material.
  16495. */
  16496. export interface IShaderMaterialOptions {
  16497. /**
  16498. * Does the material work in alpha blend mode
  16499. */
  16500. needAlphaBlending: boolean;
  16501. /**
  16502. * Does the material work in alpha test mode
  16503. */
  16504. needAlphaTesting: boolean;
  16505. /**
  16506. * The list of attribute names used in the shader
  16507. */
  16508. attributes: string[];
  16509. /**
  16510. * The list of unifrom names used in the shader
  16511. */
  16512. uniforms: string[];
  16513. /**
  16514. * The list of UBO names used in the shader
  16515. */
  16516. uniformBuffers: string[];
  16517. /**
  16518. * The list of sampler names used in the shader
  16519. */
  16520. samplers: string[];
  16521. /**
  16522. * The list of defines used in the shader
  16523. */
  16524. defines: string[];
  16525. }
  16526. /**
  16527. * 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.
  16528. *
  16529. * This returned material effects how the mesh will look based on the code in the shaders.
  16530. *
  16531. * @see https://doc.babylonjs.com/how_to/shader_material
  16532. */
  16533. export class ShaderMaterial extends Material {
  16534. private _shaderPath;
  16535. private _options;
  16536. private _textures;
  16537. private _textureArrays;
  16538. private _floats;
  16539. private _ints;
  16540. private _floatsArrays;
  16541. private _colors3;
  16542. private _colors3Arrays;
  16543. private _colors4;
  16544. private _colors4Arrays;
  16545. private _vectors2;
  16546. private _vectors3;
  16547. private _vectors4;
  16548. private _matrices;
  16549. private _matrixArrays;
  16550. private _matrices3x3;
  16551. private _matrices2x2;
  16552. private _vectors2Arrays;
  16553. private _vectors3Arrays;
  16554. private _vectors4Arrays;
  16555. private _cachedWorldViewMatrix;
  16556. private _cachedWorldViewProjectionMatrix;
  16557. private _renderId;
  16558. private _multiview;
  16559. private _cachedDefines;
  16560. /** Define the Url to load snippets */
  16561. static SnippetUrl: string;
  16562. /** Snippet ID if the material was created from the snippet server */
  16563. snippetId: string;
  16564. /**
  16565. * Instantiate a new shader material.
  16566. * 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.
  16567. * This returned material effects how the mesh will look based on the code in the shaders.
  16568. * @see https://doc.babylonjs.com/how_to/shader_material
  16569. * @param name Define the name of the material in the scene
  16570. * @param scene Define the scene the material belongs to
  16571. * @param shaderPath Defines the route to the shader code in one of three ways:
  16572. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16573. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16574. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16575. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16576. * @param options Define the options used to create the shader
  16577. */
  16578. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16579. /**
  16580. * Gets the shader path used to define the shader code
  16581. * It can be modified to trigger a new compilation
  16582. */
  16583. get shaderPath(): any;
  16584. /**
  16585. * Sets the shader path used to define the shader code
  16586. * It can be modified to trigger a new compilation
  16587. */
  16588. set shaderPath(shaderPath: any);
  16589. /**
  16590. * Gets the options used to compile the shader.
  16591. * They can be modified to trigger a new compilation
  16592. */
  16593. get options(): IShaderMaterialOptions;
  16594. /**
  16595. * Gets the current class name of the material e.g. "ShaderMaterial"
  16596. * Mainly use in serialization.
  16597. * @returns the class name
  16598. */
  16599. getClassName(): string;
  16600. /**
  16601. * Specifies if the material will require alpha blending
  16602. * @returns a boolean specifying if alpha blending is needed
  16603. */
  16604. needAlphaBlending(): boolean;
  16605. /**
  16606. * Specifies if this material should be rendered in alpha test mode
  16607. * @returns a boolean specifying if an alpha test is needed.
  16608. */
  16609. needAlphaTesting(): boolean;
  16610. private _checkUniform;
  16611. /**
  16612. * Set a texture in the shader.
  16613. * @param name Define the name of the uniform samplers as defined in the shader
  16614. * @param texture Define the texture to bind to this sampler
  16615. * @return the material itself allowing "fluent" like uniform updates
  16616. */
  16617. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16618. /**
  16619. * Set a texture array in the shader.
  16620. * @param name Define the name of the uniform sampler array as defined in the shader
  16621. * @param textures Define the list of textures to bind to this sampler
  16622. * @return the material itself allowing "fluent" like uniform updates
  16623. */
  16624. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16625. /**
  16626. * Set a float in the shader.
  16627. * @param name Define the name of the uniform as defined in the shader
  16628. * @param value Define the value to give to the uniform
  16629. * @return the material itself allowing "fluent" like uniform updates
  16630. */
  16631. setFloat(name: string, value: number): ShaderMaterial;
  16632. /**
  16633. * Set a int in the shader.
  16634. * @param name Define the name of the uniform as defined in the shader
  16635. * @param value Define the value to give to the uniform
  16636. * @return the material itself allowing "fluent" like uniform updates
  16637. */
  16638. setInt(name: string, value: number): ShaderMaterial;
  16639. /**
  16640. * Set an array of floats in the shader.
  16641. * @param name Define the name of the uniform as defined in the shader
  16642. * @param value Define the value to give to the uniform
  16643. * @return the material itself allowing "fluent" like uniform updates
  16644. */
  16645. setFloats(name: string, value: number[]): ShaderMaterial;
  16646. /**
  16647. * Set a vec3 in the shader from a Color3.
  16648. * @param name Define the name of the uniform as defined in the shader
  16649. * @param value Define the value to give to the uniform
  16650. * @return the material itself allowing "fluent" like uniform updates
  16651. */
  16652. setColor3(name: string, value: Color3): ShaderMaterial;
  16653. /**
  16654. * Set a vec3 array in the shader from a Color3 array.
  16655. * @param name Define the name of the uniform as defined in the shader
  16656. * @param value Define the value to give to the uniform
  16657. * @return the material itself allowing "fluent" like uniform updates
  16658. */
  16659. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16660. /**
  16661. * Set a vec4 in the shader from a Color4.
  16662. * @param name Define the name of the uniform as defined in the shader
  16663. * @param value Define the value to give to the uniform
  16664. * @return the material itself allowing "fluent" like uniform updates
  16665. */
  16666. setColor4(name: string, value: Color4): ShaderMaterial;
  16667. /**
  16668. * Set a vec4 array in the shader from a Color4 array.
  16669. * @param name Define the name of the uniform as defined in the shader
  16670. * @param value Define the value to give to the uniform
  16671. * @return the material itself allowing "fluent" like uniform updates
  16672. */
  16673. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16674. /**
  16675. * Set a vec2 in the shader from a Vector2.
  16676. * @param name Define the name of the uniform as defined in the shader
  16677. * @param value Define the value to give to the uniform
  16678. * @return the material itself allowing "fluent" like uniform updates
  16679. */
  16680. setVector2(name: string, value: Vector2): ShaderMaterial;
  16681. /**
  16682. * Set a vec3 in the shader from a Vector3.
  16683. * @param name Define the name of the uniform as defined in the shader
  16684. * @param value Define the value to give to the uniform
  16685. * @return the material itself allowing "fluent" like uniform updates
  16686. */
  16687. setVector3(name: string, value: Vector3): ShaderMaterial;
  16688. /**
  16689. * Set a vec4 in the shader from a Vector4.
  16690. * @param name Define the name of the uniform as defined in the shader
  16691. * @param value Define the value to give to the uniform
  16692. * @return the material itself allowing "fluent" like uniform updates
  16693. */
  16694. setVector4(name: string, value: Vector4): ShaderMaterial;
  16695. /**
  16696. * Set a mat4 in the shader from a Matrix.
  16697. * @param name Define the name of the uniform as defined in the shader
  16698. * @param value Define the value to give to the uniform
  16699. * @return the material itself allowing "fluent" like uniform updates
  16700. */
  16701. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16702. /**
  16703. * Set a float32Array in the shader from a matrix array.
  16704. * @param name Define the name of the uniform as defined in the shader
  16705. * @param value Define the value to give to the uniform
  16706. * @return the material itself allowing "fluent" like uniform updates
  16707. */
  16708. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16709. /**
  16710. * Set a mat3 in the shader from a Float32Array.
  16711. * @param name Define the name of the uniform as defined in the shader
  16712. * @param value Define the value to give to the uniform
  16713. * @return the material itself allowing "fluent" like uniform updates
  16714. */
  16715. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16716. /**
  16717. * Set a mat2 in the shader from a Float32Array.
  16718. * @param name Define the name of the uniform as defined in the shader
  16719. * @param value Define the value to give to the uniform
  16720. * @return the material itself allowing "fluent" like uniform updates
  16721. */
  16722. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16723. /**
  16724. * Set a vec2 array in the shader from a number array.
  16725. * @param name Define the name of the uniform as defined in the shader
  16726. * @param value Define the value to give to the uniform
  16727. * @return the material itself allowing "fluent" like uniform updates
  16728. */
  16729. setArray2(name: string, value: number[]): ShaderMaterial;
  16730. /**
  16731. * Set a vec3 array in the shader from a number array.
  16732. * @param name Define the name of the uniform as defined in the shader
  16733. * @param value Define the value to give to the uniform
  16734. * @return the material itself allowing "fluent" like uniform updates
  16735. */
  16736. setArray3(name: string, value: number[]): ShaderMaterial;
  16737. /**
  16738. * Set a vec4 array in the shader from a number array.
  16739. * @param name Define the name of the uniform as defined in the shader
  16740. * @param value Define the value to give to the uniform
  16741. * @return the material itself allowing "fluent" like uniform updates
  16742. */
  16743. setArray4(name: string, value: number[]): ShaderMaterial;
  16744. private _checkCache;
  16745. /**
  16746. * Specifies that the submesh is ready to be used
  16747. * @param mesh defines the mesh to check
  16748. * @param subMesh defines which submesh to check
  16749. * @param useInstances specifies that instances should be used
  16750. * @returns a boolean indicating that the submesh is ready or not
  16751. */
  16752. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16753. /**
  16754. * Checks if the material is ready to render the requested mesh
  16755. * @param mesh Define the mesh to render
  16756. * @param useInstances Define whether or not the material is used with instances
  16757. * @returns true if ready, otherwise false
  16758. */
  16759. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16760. /**
  16761. * Binds the world matrix to the material
  16762. * @param world defines the world transformation matrix
  16763. * @param effectOverride - If provided, use this effect instead of internal effect
  16764. */
  16765. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16766. /**
  16767. * Binds the submesh to this material by preparing the effect and shader to draw
  16768. * @param world defines the world transformation matrix
  16769. * @param mesh defines the mesh containing the submesh
  16770. * @param subMesh defines the submesh to bind the material to
  16771. */
  16772. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16773. /**
  16774. * Binds the material to the mesh
  16775. * @param world defines the world transformation matrix
  16776. * @param mesh defines the mesh to bind the material to
  16777. * @param effectOverride - If provided, use this effect instead of internal effect
  16778. */
  16779. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16780. protected _afterBind(mesh?: Mesh): void;
  16781. /**
  16782. * Gets the active textures from the material
  16783. * @returns an array of textures
  16784. */
  16785. getActiveTextures(): BaseTexture[];
  16786. /**
  16787. * Specifies if the material uses a texture
  16788. * @param texture defines the texture to check against the material
  16789. * @returns a boolean specifying if the material uses the texture
  16790. */
  16791. hasTexture(texture: BaseTexture): boolean;
  16792. /**
  16793. * Makes a duplicate of the material, and gives it a new name
  16794. * @param name defines the new name for the duplicated material
  16795. * @returns the cloned material
  16796. */
  16797. clone(name: string): ShaderMaterial;
  16798. /**
  16799. * Disposes the material
  16800. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16801. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16802. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16803. */
  16804. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16805. /**
  16806. * Serializes this material in a JSON representation
  16807. * @returns the serialized material object
  16808. */
  16809. serialize(): any;
  16810. /**
  16811. * Creates a shader material from parsed shader material data
  16812. * @param source defines the JSON represnetation of the material
  16813. * @param scene defines the hosting scene
  16814. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16815. * @returns a new material
  16816. */
  16817. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16818. /**
  16819. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16820. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16821. * @param url defines the url to load from
  16822. * @param scene defines the hosting scene
  16823. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16824. * @returns a promise that will resolve to the new ShaderMaterial
  16825. */
  16826. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16827. /**
  16828. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16829. * @param snippetId defines the snippet to load
  16830. * @param scene defines the hosting scene
  16831. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16832. * @returns a promise that will resolve to the new ShaderMaterial
  16833. */
  16834. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16835. }
  16836. }
  16837. declare module BABYLON {
  16838. /** @hidden */
  16839. export var colorPixelShader: {
  16840. name: string;
  16841. shader: string;
  16842. };
  16843. }
  16844. declare module BABYLON {
  16845. /** @hidden */
  16846. export var colorVertexShader: {
  16847. name: string;
  16848. shader: string;
  16849. };
  16850. }
  16851. declare module BABYLON {
  16852. /**
  16853. * Line mesh
  16854. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16855. */
  16856. export class LinesMesh extends Mesh {
  16857. /**
  16858. * If vertex color should be applied to the mesh
  16859. */
  16860. readonly useVertexColor?: boolean | undefined;
  16861. /**
  16862. * If vertex alpha should be applied to the mesh
  16863. */
  16864. readonly useVertexAlpha?: boolean | undefined;
  16865. /**
  16866. * Color of the line (Default: White)
  16867. */
  16868. color: Color3;
  16869. /**
  16870. * Alpha of the line (Default: 1)
  16871. */
  16872. alpha: number;
  16873. /**
  16874. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16875. * This margin is expressed in world space coordinates, so its value may vary.
  16876. * Default value is 0.1
  16877. */
  16878. intersectionThreshold: number;
  16879. private _colorShader;
  16880. private color4;
  16881. /**
  16882. * Creates a new LinesMesh
  16883. * @param name defines the name
  16884. * @param scene defines the hosting scene
  16885. * @param parent defines the parent mesh if any
  16886. * @param source defines the optional source LinesMesh used to clone data from
  16887. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16888. * When false, achieved by calling a clone(), also passing False.
  16889. * This will make creation of children, recursive.
  16890. * @param useVertexColor defines if this LinesMesh supports vertex color
  16891. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16892. */
  16893. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16894. /**
  16895. * If vertex color should be applied to the mesh
  16896. */
  16897. useVertexColor?: boolean | undefined,
  16898. /**
  16899. * If vertex alpha should be applied to the mesh
  16900. */
  16901. useVertexAlpha?: boolean | undefined);
  16902. private _addClipPlaneDefine;
  16903. private _removeClipPlaneDefine;
  16904. isReady(): boolean;
  16905. /**
  16906. * Returns the string "LineMesh"
  16907. */
  16908. getClassName(): string;
  16909. /**
  16910. * @hidden
  16911. */
  16912. get material(): Material;
  16913. /**
  16914. * @hidden
  16915. */
  16916. set material(value: Material);
  16917. /**
  16918. * @hidden
  16919. */
  16920. get checkCollisions(): boolean;
  16921. /** @hidden */
  16922. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16923. /** @hidden */
  16924. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16925. /**
  16926. * Disposes of the line mesh
  16927. * @param doNotRecurse If children should be disposed
  16928. */
  16929. dispose(doNotRecurse?: boolean): void;
  16930. /**
  16931. * Returns a new LineMesh object cloned from the current one.
  16932. */
  16933. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16934. /**
  16935. * Creates a new InstancedLinesMesh object from the mesh model.
  16936. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16937. * @param name defines the name of the new instance
  16938. * @returns a new InstancedLinesMesh
  16939. */
  16940. createInstance(name: string): InstancedLinesMesh;
  16941. }
  16942. /**
  16943. * Creates an instance based on a source LinesMesh
  16944. */
  16945. export class InstancedLinesMesh extends InstancedMesh {
  16946. /**
  16947. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16948. * This margin is expressed in world space coordinates, so its value may vary.
  16949. * Initilized with the intersectionThreshold value of the source LinesMesh
  16950. */
  16951. intersectionThreshold: number;
  16952. constructor(name: string, source: LinesMesh);
  16953. /**
  16954. * Returns the string "InstancedLinesMesh".
  16955. */
  16956. getClassName(): string;
  16957. }
  16958. }
  16959. declare module BABYLON {
  16960. /** @hidden */
  16961. export var linePixelShader: {
  16962. name: string;
  16963. shader: string;
  16964. };
  16965. }
  16966. declare module BABYLON {
  16967. /** @hidden */
  16968. export var lineVertexShader: {
  16969. name: string;
  16970. shader: string;
  16971. };
  16972. }
  16973. declare module BABYLON {
  16974. interface Scene {
  16975. /** @hidden */
  16976. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16977. }
  16978. interface AbstractMesh {
  16979. /**
  16980. * Gets the edgesRenderer associated with the mesh
  16981. */
  16982. edgesRenderer: Nullable<EdgesRenderer>;
  16983. }
  16984. interface LinesMesh {
  16985. /**
  16986. * Enables the edge rendering mode on the mesh.
  16987. * This mode makes the mesh edges visible
  16988. * @param epsilon defines the maximal distance between two angles to detect a face
  16989. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16990. * @returns the currentAbstractMesh
  16991. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16992. */
  16993. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16994. }
  16995. interface InstancedLinesMesh {
  16996. /**
  16997. * Enables the edge rendering mode on the mesh.
  16998. * This mode makes the mesh edges visible
  16999. * @param epsilon defines the maximal distance between two angles to detect a face
  17000. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17001. * @returns the current InstancedLinesMesh
  17002. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17003. */
  17004. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17005. }
  17006. /**
  17007. * Defines the minimum contract an Edges renderer should follow.
  17008. */
  17009. export interface IEdgesRenderer extends IDisposable {
  17010. /**
  17011. * Gets or sets a boolean indicating if the edgesRenderer is active
  17012. */
  17013. isEnabled: boolean;
  17014. /**
  17015. * Renders the edges of the attached mesh,
  17016. */
  17017. render(): void;
  17018. /**
  17019. * Checks wether or not the edges renderer is ready to render.
  17020. * @return true if ready, otherwise false.
  17021. */
  17022. isReady(): boolean;
  17023. /**
  17024. * List of instances to render in case the source mesh has instances
  17025. */
  17026. customInstances: SmartArray<Matrix>;
  17027. }
  17028. /**
  17029. * Defines the additional options of the edges renderer
  17030. */
  17031. export interface IEdgesRendererOptions {
  17032. /**
  17033. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17034. * If not defined, the default value is true
  17035. */
  17036. useAlternateEdgeFinder?: boolean;
  17037. /**
  17038. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17039. * If not defined, the default value is true.
  17040. * 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)
  17041. * This option is used only if useAlternateEdgeFinder = true
  17042. */
  17043. useFastVertexMerger?: boolean;
  17044. /**
  17045. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17046. * The default value is 1e-6
  17047. * This option is used only if useAlternateEdgeFinder = true
  17048. */
  17049. epsilonVertexMerge?: number;
  17050. /**
  17051. * 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
  17052. * 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.
  17053. * This option is used only if useAlternateEdgeFinder = true
  17054. */
  17055. applyTessellation?: boolean;
  17056. /**
  17057. * 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
  17058. * The default value is 1e-6
  17059. * This option is used only if useAlternateEdgeFinder = true
  17060. */
  17061. epsilonVertexAligned?: number;
  17062. }
  17063. /**
  17064. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17065. */
  17066. export class EdgesRenderer implements IEdgesRenderer {
  17067. /**
  17068. * Define the size of the edges with an orthographic camera
  17069. */
  17070. edgesWidthScalerForOrthographic: number;
  17071. /**
  17072. * Define the size of the edges with a perspective camera
  17073. */
  17074. edgesWidthScalerForPerspective: number;
  17075. protected _source: AbstractMesh;
  17076. protected _linesPositions: number[];
  17077. protected _linesNormals: number[];
  17078. protected _linesIndices: number[];
  17079. protected _epsilon: number;
  17080. protected _indicesCount: number;
  17081. protected _lineShader: ShaderMaterial;
  17082. protected _ib: DataBuffer;
  17083. protected _buffers: {
  17084. [key: string]: Nullable<VertexBuffer>;
  17085. };
  17086. protected _buffersForInstances: {
  17087. [key: string]: Nullable<VertexBuffer>;
  17088. };
  17089. protected _checkVerticesInsteadOfIndices: boolean;
  17090. protected _options: Nullable<IEdgesRendererOptions>;
  17091. private _meshRebuildObserver;
  17092. private _meshDisposeObserver;
  17093. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17094. isEnabled: boolean;
  17095. /**
  17096. * List of instances to render in case the source mesh has instances
  17097. */
  17098. customInstances: SmartArray<Matrix>;
  17099. private static GetShader;
  17100. /**
  17101. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17102. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17103. * @param source Mesh used to create edges
  17104. * @param epsilon sum of angles in adjacency to check for edge
  17105. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17106. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17107. * @param options The options to apply when generating the edges
  17108. */
  17109. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17110. protected _prepareRessources(): void;
  17111. /** @hidden */
  17112. _rebuild(): void;
  17113. /**
  17114. * Releases the required resources for the edges renderer
  17115. */
  17116. dispose(): void;
  17117. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17118. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17119. /**
  17120. * Checks if the pair of p0 and p1 is en edge
  17121. * @param faceIndex
  17122. * @param edge
  17123. * @param faceNormals
  17124. * @param p0
  17125. * @param p1
  17126. * @private
  17127. */
  17128. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17129. /**
  17130. * push line into the position, normal and index buffer
  17131. * @protected
  17132. */
  17133. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17134. /**
  17135. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17136. */
  17137. private _tessellateTriangle;
  17138. private _generateEdgesLinesAlternate;
  17139. /**
  17140. * Generates lines edges from adjacencjes
  17141. * @private
  17142. */
  17143. _generateEdgesLines(): void;
  17144. /**
  17145. * Checks wether or not the edges renderer is ready to render.
  17146. * @return true if ready, otherwise false.
  17147. */
  17148. isReady(): boolean;
  17149. /**
  17150. * Renders the edges of the attached mesh,
  17151. */
  17152. render(): void;
  17153. }
  17154. /**
  17155. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17156. */
  17157. export class LineEdgesRenderer extends EdgesRenderer {
  17158. /**
  17159. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17160. * @param source LineMesh used to generate edges
  17161. * @param epsilon not important (specified angle for edge detection)
  17162. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17163. */
  17164. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17165. /**
  17166. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17167. */
  17168. _generateEdgesLines(): void;
  17169. }
  17170. }
  17171. declare module BABYLON {
  17172. /**
  17173. * This represents the object necessary to create a rendering group.
  17174. * This is exclusively used and created by the rendering manager.
  17175. * To modify the behavior, you use the available helpers in your scene or meshes.
  17176. * @hidden
  17177. */
  17178. export class RenderingGroup {
  17179. index: number;
  17180. private static _zeroVector;
  17181. private _scene;
  17182. private _opaqueSubMeshes;
  17183. private _transparentSubMeshes;
  17184. private _alphaTestSubMeshes;
  17185. private _depthOnlySubMeshes;
  17186. private _particleSystems;
  17187. private _spriteManagers;
  17188. private _opaqueSortCompareFn;
  17189. private _alphaTestSortCompareFn;
  17190. private _transparentSortCompareFn;
  17191. private _renderOpaque;
  17192. private _renderAlphaTest;
  17193. private _renderTransparent;
  17194. /** @hidden */
  17195. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17196. onBeforeTransparentRendering: () => void;
  17197. /**
  17198. * Set the opaque sort comparison function.
  17199. * If null the sub meshes will be render in the order they were created
  17200. */
  17201. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17202. /**
  17203. * Set the alpha test sort comparison function.
  17204. * If null the sub meshes will be render in the order they were created
  17205. */
  17206. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17207. /**
  17208. * Set the transparent sort comparison function.
  17209. * If null the sub meshes will be render in the order they were created
  17210. */
  17211. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17212. /**
  17213. * Creates a new rendering group.
  17214. * @param index The rendering group index
  17215. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17216. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17217. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17218. */
  17219. 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>);
  17220. /**
  17221. * Render all the sub meshes contained in the group.
  17222. * @param customRenderFunction Used to override the default render behaviour of the group.
  17223. * @returns true if rendered some submeshes.
  17224. */
  17225. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17226. /**
  17227. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17228. * @param subMeshes The submeshes to render
  17229. */
  17230. private renderOpaqueSorted;
  17231. /**
  17232. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17233. * @param subMeshes The submeshes to render
  17234. */
  17235. private renderAlphaTestSorted;
  17236. /**
  17237. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17238. * @param subMeshes The submeshes to render
  17239. */
  17240. private renderTransparentSorted;
  17241. /**
  17242. * Renders the submeshes in a specified order.
  17243. * @param subMeshes The submeshes to sort before render
  17244. * @param sortCompareFn The comparison function use to sort
  17245. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17246. * @param transparent Specifies to activate blending if true
  17247. */
  17248. private static renderSorted;
  17249. /**
  17250. * Renders the submeshes in the order they were dispatched (no sort applied).
  17251. * @param subMeshes The submeshes to render
  17252. */
  17253. private static renderUnsorted;
  17254. /**
  17255. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17256. * are rendered back to front if in the same alpha index.
  17257. *
  17258. * @param a The first submesh
  17259. * @param b The second submesh
  17260. * @returns The result of the comparison
  17261. */
  17262. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17263. /**
  17264. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17265. * are rendered back to front.
  17266. *
  17267. * @param a The first submesh
  17268. * @param b The second submesh
  17269. * @returns The result of the comparison
  17270. */
  17271. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17272. /**
  17273. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17274. * are rendered front to back (prevent overdraw).
  17275. *
  17276. * @param a The first submesh
  17277. * @param b The second submesh
  17278. * @returns The result of the comparison
  17279. */
  17280. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17281. /**
  17282. * Resets the different lists of submeshes to prepare a new frame.
  17283. */
  17284. prepare(): void;
  17285. dispose(): void;
  17286. /**
  17287. * Inserts the submesh in its correct queue depending on its material.
  17288. * @param subMesh The submesh to dispatch
  17289. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17290. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17291. */
  17292. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17293. dispatchSprites(spriteManager: ISpriteManager): void;
  17294. dispatchParticles(particleSystem: IParticleSystem): void;
  17295. private _renderParticles;
  17296. private _renderSprites;
  17297. }
  17298. }
  17299. declare module BABYLON {
  17300. /**
  17301. * Interface describing the different options available in the rendering manager
  17302. * regarding Auto Clear between groups.
  17303. */
  17304. export interface IRenderingManagerAutoClearSetup {
  17305. /**
  17306. * Defines whether or not autoclear is enable.
  17307. */
  17308. autoClear: boolean;
  17309. /**
  17310. * Defines whether or not to autoclear the depth buffer.
  17311. */
  17312. depth: boolean;
  17313. /**
  17314. * Defines whether or not to autoclear the stencil buffer.
  17315. */
  17316. stencil: boolean;
  17317. }
  17318. /**
  17319. * This class is used by the onRenderingGroupObservable
  17320. */
  17321. export class RenderingGroupInfo {
  17322. /**
  17323. * The Scene that being rendered
  17324. */
  17325. scene: Scene;
  17326. /**
  17327. * The camera currently used for the rendering pass
  17328. */
  17329. camera: Nullable<Camera>;
  17330. /**
  17331. * The ID of the renderingGroup being processed
  17332. */
  17333. renderingGroupId: number;
  17334. }
  17335. /**
  17336. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17337. * It is enable to manage the different groups as well as the different necessary sort functions.
  17338. * This should not be used directly aside of the few static configurations
  17339. */
  17340. export class RenderingManager {
  17341. /**
  17342. * The max id used for rendering groups (not included)
  17343. */
  17344. static MAX_RENDERINGGROUPS: number;
  17345. /**
  17346. * The min id used for rendering groups (included)
  17347. */
  17348. static MIN_RENDERINGGROUPS: number;
  17349. /**
  17350. * Used to globally prevent autoclearing scenes.
  17351. */
  17352. static AUTOCLEAR: boolean;
  17353. /**
  17354. * @hidden
  17355. */
  17356. _useSceneAutoClearSetup: boolean;
  17357. private _scene;
  17358. private _renderingGroups;
  17359. private _depthStencilBufferAlreadyCleaned;
  17360. private _autoClearDepthStencil;
  17361. private _customOpaqueSortCompareFn;
  17362. private _customAlphaTestSortCompareFn;
  17363. private _customTransparentSortCompareFn;
  17364. private _renderingGroupInfo;
  17365. /**
  17366. * Instantiates a new rendering group for a particular scene
  17367. * @param scene Defines the scene the groups belongs to
  17368. */
  17369. constructor(scene: Scene);
  17370. private _clearDepthStencilBuffer;
  17371. /**
  17372. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17373. * @hidden
  17374. */
  17375. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17376. /**
  17377. * Resets the different information of the group to prepare a new frame
  17378. * @hidden
  17379. */
  17380. reset(): void;
  17381. /**
  17382. * Dispose and release the group and its associated resources.
  17383. * @hidden
  17384. */
  17385. dispose(): void;
  17386. /**
  17387. * Clear the info related to rendering groups preventing retention points during dispose.
  17388. */
  17389. freeRenderingGroups(): void;
  17390. private _prepareRenderingGroup;
  17391. /**
  17392. * Add a sprite manager to the rendering manager in order to render it this frame.
  17393. * @param spriteManager Define the sprite manager to render
  17394. */
  17395. dispatchSprites(spriteManager: ISpriteManager): void;
  17396. /**
  17397. * Add a particle system to the rendering manager in order to render it this frame.
  17398. * @param particleSystem Define the particle system to render
  17399. */
  17400. dispatchParticles(particleSystem: IParticleSystem): void;
  17401. /**
  17402. * Add a submesh to the manager in order to render it this frame
  17403. * @param subMesh The submesh to dispatch
  17404. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17405. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17406. */
  17407. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17408. /**
  17409. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17410. * This allowed control for front to back rendering or reversly depending of the special needs.
  17411. *
  17412. * @param renderingGroupId The rendering group id corresponding to its index
  17413. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17414. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17415. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17416. */
  17417. 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;
  17418. /**
  17419. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17420. *
  17421. * @param renderingGroupId The rendering group id corresponding to its index
  17422. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17423. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17424. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17425. */
  17426. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17427. /**
  17428. * Gets the current auto clear configuration for one rendering group of the rendering
  17429. * manager.
  17430. * @param index the rendering group index to get the information for
  17431. * @returns The auto clear setup for the requested rendering group
  17432. */
  17433. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17434. }
  17435. }
  17436. declare module BABYLON {
  17437. /**
  17438. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17439. */
  17440. export interface ICustomShaderOptions {
  17441. /**
  17442. * Gets or sets the custom shader name to use
  17443. */
  17444. shaderName: string;
  17445. /**
  17446. * The list of attribute names used in the shader
  17447. */
  17448. attributes?: string[];
  17449. /**
  17450. * The list of unifrom names used in the shader
  17451. */
  17452. uniforms?: string[];
  17453. /**
  17454. * The list of sampler names used in the shader
  17455. */
  17456. samplers?: string[];
  17457. /**
  17458. * The list of defines used in the shader
  17459. */
  17460. defines?: string[];
  17461. }
  17462. /**
  17463. * Interface to implement to create a shadow generator compatible with BJS.
  17464. */
  17465. export interface IShadowGenerator {
  17466. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17467. id: string;
  17468. /**
  17469. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17470. * @returns The render target texture if present otherwise, null
  17471. */
  17472. getShadowMap(): Nullable<RenderTargetTexture>;
  17473. /**
  17474. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17475. * @param subMesh The submesh we want to render in the shadow map
  17476. * @param useInstances Defines wether will draw in the map using instances
  17477. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17478. * @returns true if ready otherwise, false
  17479. */
  17480. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17481. /**
  17482. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17483. * @param defines Defines of the material we want to update
  17484. * @param lightIndex Index of the light in the enabled light list of the material
  17485. */
  17486. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17487. /**
  17488. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17489. * defined in the generator but impacting the effect).
  17490. * It implies the unifroms available on the materials are the standard BJS ones.
  17491. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17492. * @param effect The effect we are binfing the information for
  17493. */
  17494. bindShadowLight(lightIndex: string, effect: Effect): void;
  17495. /**
  17496. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17497. * (eq to shadow prjection matrix * light transform matrix)
  17498. * @returns The transform matrix used to create the shadow map
  17499. */
  17500. getTransformMatrix(): Matrix;
  17501. /**
  17502. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17503. * Cube and 2D textures for instance.
  17504. */
  17505. recreateShadowMap(): void;
  17506. /**
  17507. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17508. * @param onCompiled Callback triggered at the and of the effects compilation
  17509. * @param options Sets of optional options forcing the compilation with different modes
  17510. */
  17511. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17512. useInstances: boolean;
  17513. }>): void;
  17514. /**
  17515. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17516. * @param options Sets of optional options forcing the compilation with different modes
  17517. * @returns A promise that resolves when the compilation completes
  17518. */
  17519. forceCompilationAsync(options?: Partial<{
  17520. useInstances: boolean;
  17521. }>): Promise<void>;
  17522. /**
  17523. * Serializes the shadow generator setup to a json object.
  17524. * @returns The serialized JSON object
  17525. */
  17526. serialize(): any;
  17527. /**
  17528. * Disposes the Shadow map and related Textures and effects.
  17529. */
  17530. dispose(): void;
  17531. }
  17532. /**
  17533. * Default implementation IShadowGenerator.
  17534. * This is the main object responsible of generating shadows in the framework.
  17535. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17536. */
  17537. export class ShadowGenerator implements IShadowGenerator {
  17538. /**
  17539. * Name of the shadow generator class
  17540. */
  17541. static CLASSNAME: string;
  17542. /**
  17543. * Shadow generator mode None: no filtering applied.
  17544. */
  17545. static readonly FILTER_NONE: number;
  17546. /**
  17547. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17548. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17549. */
  17550. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17551. /**
  17552. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17553. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17554. */
  17555. static readonly FILTER_POISSONSAMPLING: number;
  17556. /**
  17557. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17558. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17559. */
  17560. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17561. /**
  17562. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17563. * edge artifacts on steep falloff.
  17564. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17565. */
  17566. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17567. /**
  17568. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17569. * edge artifacts on steep falloff.
  17570. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17571. */
  17572. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17573. /**
  17574. * Shadow generator mode PCF: Percentage Closer Filtering
  17575. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17576. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17577. */
  17578. static readonly FILTER_PCF: number;
  17579. /**
  17580. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17581. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17582. * Contact Hardening
  17583. */
  17584. static readonly FILTER_PCSS: number;
  17585. /**
  17586. * Reserved for PCF and PCSS
  17587. * Highest Quality.
  17588. *
  17589. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17590. *
  17591. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17592. */
  17593. static readonly QUALITY_HIGH: number;
  17594. /**
  17595. * Reserved for PCF and PCSS
  17596. * Good tradeoff for quality/perf cross devices
  17597. *
  17598. * Execute PCF on a 3*3 kernel.
  17599. *
  17600. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17601. */
  17602. static readonly QUALITY_MEDIUM: number;
  17603. /**
  17604. * Reserved for PCF and PCSS
  17605. * The lowest quality but the fastest.
  17606. *
  17607. * Execute PCF on a 1*1 kernel.
  17608. *
  17609. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17610. */
  17611. static readonly QUALITY_LOW: number;
  17612. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17613. id: string;
  17614. /** Gets or sets the custom shader name to use */
  17615. customShaderOptions: ICustomShaderOptions;
  17616. /**
  17617. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17618. */
  17619. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17620. /**
  17621. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17622. */
  17623. onAfterShadowMapRenderObservable: Observable<Effect>;
  17624. /**
  17625. * Observable triggered before a mesh is rendered in the shadow map.
  17626. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17627. */
  17628. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17629. /**
  17630. * Observable triggered after a mesh is rendered in the shadow map.
  17631. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17632. */
  17633. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17634. protected _bias: number;
  17635. /**
  17636. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17637. */
  17638. get bias(): number;
  17639. /**
  17640. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17641. */
  17642. set bias(bias: number);
  17643. protected _normalBias: number;
  17644. /**
  17645. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17646. */
  17647. get normalBias(): number;
  17648. /**
  17649. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17650. */
  17651. set normalBias(normalBias: number);
  17652. protected _blurBoxOffset: number;
  17653. /**
  17654. * Gets the blur box offset: offset applied during the blur pass.
  17655. * Only useful if useKernelBlur = false
  17656. */
  17657. get blurBoxOffset(): number;
  17658. /**
  17659. * Sets the blur box offset: offset applied during the blur pass.
  17660. * Only useful if useKernelBlur = false
  17661. */
  17662. set blurBoxOffset(value: number);
  17663. protected _blurScale: number;
  17664. /**
  17665. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17666. * 2 means half of the size.
  17667. */
  17668. get blurScale(): number;
  17669. /**
  17670. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17671. * 2 means half of the size.
  17672. */
  17673. set blurScale(value: number);
  17674. protected _blurKernel: number;
  17675. /**
  17676. * Gets the blur kernel: kernel size of the blur pass.
  17677. * Only useful if useKernelBlur = true
  17678. */
  17679. get blurKernel(): number;
  17680. /**
  17681. * Sets the blur kernel: kernel size of the blur pass.
  17682. * Only useful if useKernelBlur = true
  17683. */
  17684. set blurKernel(value: number);
  17685. protected _useKernelBlur: boolean;
  17686. /**
  17687. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17688. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17689. */
  17690. get useKernelBlur(): boolean;
  17691. /**
  17692. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17693. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17694. */
  17695. set useKernelBlur(value: boolean);
  17696. protected _depthScale: number;
  17697. /**
  17698. * Gets the depth scale used in ESM mode.
  17699. */
  17700. get depthScale(): number;
  17701. /**
  17702. * Sets the depth scale used in ESM mode.
  17703. * This can override the scale stored on the light.
  17704. */
  17705. set depthScale(value: number);
  17706. protected _validateFilter(filter: number): number;
  17707. protected _filter: number;
  17708. /**
  17709. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17710. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17711. */
  17712. get filter(): number;
  17713. /**
  17714. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17715. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17716. */
  17717. set filter(value: number);
  17718. /**
  17719. * Gets if the current filter is set to Poisson Sampling.
  17720. */
  17721. get usePoissonSampling(): boolean;
  17722. /**
  17723. * Sets the current filter to Poisson Sampling.
  17724. */
  17725. set usePoissonSampling(value: boolean);
  17726. /**
  17727. * Gets if the current filter is set to ESM.
  17728. */
  17729. get useExponentialShadowMap(): boolean;
  17730. /**
  17731. * Sets the current filter is to ESM.
  17732. */
  17733. set useExponentialShadowMap(value: boolean);
  17734. /**
  17735. * Gets if the current filter is set to filtered ESM.
  17736. */
  17737. get useBlurExponentialShadowMap(): boolean;
  17738. /**
  17739. * Gets if the current filter is set to filtered ESM.
  17740. */
  17741. set useBlurExponentialShadowMap(value: boolean);
  17742. /**
  17743. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17744. * exponential to prevent steep falloff artifacts).
  17745. */
  17746. get useCloseExponentialShadowMap(): boolean;
  17747. /**
  17748. * Sets the current filter to "close ESM" (using the inverse of the
  17749. * exponential to prevent steep falloff artifacts).
  17750. */
  17751. set useCloseExponentialShadowMap(value: boolean);
  17752. /**
  17753. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17754. * exponential to prevent steep falloff artifacts).
  17755. */
  17756. get useBlurCloseExponentialShadowMap(): boolean;
  17757. /**
  17758. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17759. * exponential to prevent steep falloff artifacts).
  17760. */
  17761. set useBlurCloseExponentialShadowMap(value: boolean);
  17762. /**
  17763. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17764. */
  17765. get usePercentageCloserFiltering(): boolean;
  17766. /**
  17767. * Sets the current filter to "PCF" (percentage closer filtering).
  17768. */
  17769. set usePercentageCloserFiltering(value: boolean);
  17770. protected _filteringQuality: number;
  17771. /**
  17772. * Gets the PCF or PCSS Quality.
  17773. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17774. */
  17775. get filteringQuality(): number;
  17776. /**
  17777. * Sets the PCF or PCSS Quality.
  17778. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17779. */
  17780. set filteringQuality(filteringQuality: number);
  17781. /**
  17782. * Gets if the current filter is set to "PCSS" (contact hardening).
  17783. */
  17784. get useContactHardeningShadow(): boolean;
  17785. /**
  17786. * Sets the current filter to "PCSS" (contact hardening).
  17787. */
  17788. set useContactHardeningShadow(value: boolean);
  17789. protected _contactHardeningLightSizeUVRatio: number;
  17790. /**
  17791. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17792. * Using a ratio helps keeping shape stability independently of the map size.
  17793. *
  17794. * It does not account for the light projection as it was having too much
  17795. * instability during the light setup or during light position changes.
  17796. *
  17797. * Only valid if useContactHardeningShadow is true.
  17798. */
  17799. get contactHardeningLightSizeUVRatio(): number;
  17800. /**
  17801. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17802. * Using a ratio helps keeping shape stability independently of the map size.
  17803. *
  17804. * It does not account for the light projection as it was having too much
  17805. * instability during the light setup or during light position changes.
  17806. *
  17807. * Only valid if useContactHardeningShadow is true.
  17808. */
  17809. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17810. protected _darkness: number;
  17811. /** Gets or sets the actual darkness of a shadow */
  17812. get darkness(): number;
  17813. set darkness(value: number);
  17814. /**
  17815. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17816. * 0 means strongest and 1 would means no shadow.
  17817. * @returns the darkness.
  17818. */
  17819. getDarkness(): number;
  17820. /**
  17821. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17822. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17823. * @returns the shadow generator allowing fluent coding.
  17824. */
  17825. setDarkness(darkness: number): ShadowGenerator;
  17826. protected _transparencyShadow: boolean;
  17827. /** Gets or sets the ability to have transparent shadow */
  17828. get transparencyShadow(): boolean;
  17829. set transparencyShadow(value: boolean);
  17830. /**
  17831. * Sets the ability to have transparent shadow (boolean).
  17832. * @param transparent True if transparent else False
  17833. * @returns the shadow generator allowing fluent coding
  17834. */
  17835. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17836. /**
  17837. * Enables or disables shadows with varying strength based on the transparency
  17838. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17839. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17840. * mesh.visibility * alphaTexture.a
  17841. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17842. */
  17843. enableSoftTransparentShadow: boolean;
  17844. protected _shadowMap: Nullable<RenderTargetTexture>;
  17845. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17846. /**
  17847. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17848. * @returns The render target texture if present otherwise, null
  17849. */
  17850. getShadowMap(): Nullable<RenderTargetTexture>;
  17851. /**
  17852. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17853. * @returns The render target texture if the shadow map is present otherwise, null
  17854. */
  17855. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17856. /**
  17857. * Gets the class name of that object
  17858. * @returns "ShadowGenerator"
  17859. */
  17860. getClassName(): string;
  17861. /**
  17862. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17863. * @param mesh Mesh to add
  17864. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17865. * @returns the Shadow Generator itself
  17866. */
  17867. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17868. /**
  17869. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17870. * @param mesh Mesh to remove
  17871. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17872. * @returns the Shadow Generator itself
  17873. */
  17874. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17875. /**
  17876. * Controls the extent to which the shadows fade out at the edge of the frustum
  17877. */
  17878. frustumEdgeFalloff: number;
  17879. protected _light: IShadowLight;
  17880. /**
  17881. * Returns the associated light object.
  17882. * @returns the light generating the shadow
  17883. */
  17884. getLight(): IShadowLight;
  17885. /**
  17886. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17887. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17888. * It might on the other hand introduce peter panning.
  17889. */
  17890. forceBackFacesOnly: boolean;
  17891. protected _scene: Scene;
  17892. protected _lightDirection: Vector3;
  17893. protected _effect: Effect;
  17894. protected _viewMatrix: Matrix;
  17895. protected _projectionMatrix: Matrix;
  17896. protected _transformMatrix: Matrix;
  17897. protected _cachedPosition: Vector3;
  17898. protected _cachedDirection: Vector3;
  17899. protected _cachedDefines: string;
  17900. protected _currentRenderID: number;
  17901. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17902. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17903. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17904. protected _blurPostProcesses: PostProcess[];
  17905. protected _mapSize: number;
  17906. protected _currentFaceIndex: number;
  17907. protected _currentFaceIndexCache: number;
  17908. protected _textureType: number;
  17909. protected _defaultTextureMatrix: Matrix;
  17910. protected _storedUniqueId: Nullable<number>;
  17911. /** @hidden */
  17912. static _SceneComponentInitialization: (scene: Scene) => void;
  17913. /**
  17914. * Creates a ShadowGenerator object.
  17915. * A ShadowGenerator is the required tool to use the shadows.
  17916. * Each light casting shadows needs to use its own ShadowGenerator.
  17917. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17918. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17919. * @param light The light object generating the shadows.
  17920. * @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.
  17921. */
  17922. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17923. protected _initializeGenerator(): void;
  17924. protected _createTargetRenderTexture(): void;
  17925. protected _initializeShadowMap(): void;
  17926. protected _initializeBlurRTTAndPostProcesses(): void;
  17927. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17928. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17929. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17930. protected _applyFilterValues(): void;
  17931. /**
  17932. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17933. * @param onCompiled Callback triggered at the and of the effects compilation
  17934. * @param options Sets of optional options forcing the compilation with different modes
  17935. */
  17936. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17937. useInstances: boolean;
  17938. }>): void;
  17939. /**
  17940. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17941. * @param options Sets of optional options forcing the compilation with different modes
  17942. * @returns A promise that resolves when the compilation completes
  17943. */
  17944. forceCompilationAsync(options?: Partial<{
  17945. useInstances: boolean;
  17946. }>): Promise<void>;
  17947. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17948. private _prepareShadowDefines;
  17949. /**
  17950. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17951. * @param subMesh The submesh we want to render in the shadow map
  17952. * @param useInstances Defines wether will draw in the map using instances
  17953. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17954. * @returns true if ready otherwise, false
  17955. */
  17956. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17957. /**
  17958. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17959. * @param defines Defines of the material we want to update
  17960. * @param lightIndex Index of the light in the enabled light list of the material
  17961. */
  17962. prepareDefines(defines: any, lightIndex: number): void;
  17963. /**
  17964. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17965. * defined in the generator but impacting the effect).
  17966. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17967. * @param effect The effect we are binfing the information for
  17968. */
  17969. bindShadowLight(lightIndex: string, effect: Effect): void;
  17970. /**
  17971. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17972. * (eq to shadow prjection matrix * light transform matrix)
  17973. * @returns The transform matrix used to create the shadow map
  17974. */
  17975. getTransformMatrix(): Matrix;
  17976. /**
  17977. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17978. * Cube and 2D textures for instance.
  17979. */
  17980. recreateShadowMap(): void;
  17981. protected _disposeBlurPostProcesses(): void;
  17982. protected _disposeRTTandPostProcesses(): void;
  17983. /**
  17984. * Disposes the ShadowGenerator.
  17985. * Returns nothing.
  17986. */
  17987. dispose(): void;
  17988. /**
  17989. * Serializes the shadow generator setup to a json object.
  17990. * @returns The serialized JSON object
  17991. */
  17992. serialize(): any;
  17993. /**
  17994. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17995. * @param parsedShadowGenerator The JSON object to parse
  17996. * @param scene The scene to create the shadow map for
  17997. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17998. * @returns The parsed shadow generator
  17999. */
  18000. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18001. }
  18002. }
  18003. declare module BABYLON {
  18004. /**
  18005. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18006. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18007. * 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.
  18008. */
  18009. export abstract class Light extends Node {
  18010. /**
  18011. * Falloff Default: light is falling off following the material specification:
  18012. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18013. */
  18014. static readonly FALLOFF_DEFAULT: number;
  18015. /**
  18016. * Falloff Physical: light is falling off following the inverse squared distance law.
  18017. */
  18018. static readonly FALLOFF_PHYSICAL: number;
  18019. /**
  18020. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18021. * to enhance interoperability with other engines.
  18022. */
  18023. static readonly FALLOFF_GLTF: number;
  18024. /**
  18025. * Falloff Standard: light is falling off like in the standard material
  18026. * to enhance interoperability with other materials.
  18027. */
  18028. static readonly FALLOFF_STANDARD: number;
  18029. /**
  18030. * If every light affecting the material is in this lightmapMode,
  18031. * material.lightmapTexture adds or multiplies
  18032. * (depends on material.useLightmapAsShadowmap)
  18033. * after every other light calculations.
  18034. */
  18035. static readonly LIGHTMAP_DEFAULT: number;
  18036. /**
  18037. * material.lightmapTexture as only diffuse lighting from this light
  18038. * adds only specular lighting from this light
  18039. * adds dynamic shadows
  18040. */
  18041. static readonly LIGHTMAP_SPECULAR: number;
  18042. /**
  18043. * material.lightmapTexture as only lighting
  18044. * no light calculation from this light
  18045. * only adds dynamic shadows from this light
  18046. */
  18047. static readonly LIGHTMAP_SHADOWSONLY: number;
  18048. /**
  18049. * Each light type uses the default quantity according to its type:
  18050. * point/spot lights use luminous intensity
  18051. * directional lights use illuminance
  18052. */
  18053. static readonly INTENSITYMODE_AUTOMATIC: number;
  18054. /**
  18055. * lumen (lm)
  18056. */
  18057. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18058. /**
  18059. * candela (lm/sr)
  18060. */
  18061. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18062. /**
  18063. * lux (lm/m^2)
  18064. */
  18065. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18066. /**
  18067. * nit (cd/m^2)
  18068. */
  18069. static readonly INTENSITYMODE_LUMINANCE: number;
  18070. /**
  18071. * Light type const id of the point light.
  18072. */
  18073. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18074. /**
  18075. * Light type const id of the directional light.
  18076. */
  18077. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18078. /**
  18079. * Light type const id of the spot light.
  18080. */
  18081. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18082. /**
  18083. * Light type const id of the hemispheric light.
  18084. */
  18085. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18086. /**
  18087. * Diffuse gives the basic color to an object.
  18088. */
  18089. diffuse: Color3;
  18090. /**
  18091. * Specular produces a highlight color on an object.
  18092. * Note: This is note affecting PBR materials.
  18093. */
  18094. specular: Color3;
  18095. /**
  18096. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18097. * falling off base on range or angle.
  18098. * This can be set to any values in Light.FALLOFF_x.
  18099. *
  18100. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18101. * other types of materials.
  18102. */
  18103. falloffType: number;
  18104. /**
  18105. * Strength of the light.
  18106. * Note: By default it is define in the framework own unit.
  18107. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18108. */
  18109. intensity: number;
  18110. private _range;
  18111. protected _inverseSquaredRange: number;
  18112. /**
  18113. * Defines how far from the source the light is impacting in scene units.
  18114. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18115. */
  18116. get range(): number;
  18117. /**
  18118. * Defines how far from the source the light is impacting in scene units.
  18119. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18120. */
  18121. set range(value: number);
  18122. /**
  18123. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18124. * of light.
  18125. */
  18126. private _photometricScale;
  18127. private _intensityMode;
  18128. /**
  18129. * Gets the photometric scale used to interpret the intensity.
  18130. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18131. */
  18132. get intensityMode(): number;
  18133. /**
  18134. * Sets the photometric scale used to interpret the intensity.
  18135. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18136. */
  18137. set intensityMode(value: number);
  18138. private _radius;
  18139. /**
  18140. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18141. */
  18142. get radius(): number;
  18143. /**
  18144. * sets the light radius used by PBR Materials to simulate soft area lights.
  18145. */
  18146. set radius(value: number);
  18147. private _renderPriority;
  18148. /**
  18149. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18150. * exceeding the number allowed of the materials.
  18151. */
  18152. renderPriority: number;
  18153. private _shadowEnabled;
  18154. /**
  18155. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18156. * the current shadow generator.
  18157. */
  18158. get shadowEnabled(): boolean;
  18159. /**
  18160. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18161. * the current shadow generator.
  18162. */
  18163. set shadowEnabled(value: boolean);
  18164. private _includedOnlyMeshes;
  18165. /**
  18166. * Gets the only meshes impacted by this light.
  18167. */
  18168. get includedOnlyMeshes(): AbstractMesh[];
  18169. /**
  18170. * Sets the only meshes impacted by this light.
  18171. */
  18172. set includedOnlyMeshes(value: AbstractMesh[]);
  18173. private _excludedMeshes;
  18174. /**
  18175. * Gets the meshes not impacted by this light.
  18176. */
  18177. get excludedMeshes(): AbstractMesh[];
  18178. /**
  18179. * Sets the meshes not impacted by this light.
  18180. */
  18181. set excludedMeshes(value: AbstractMesh[]);
  18182. private _excludeWithLayerMask;
  18183. /**
  18184. * Gets the layer id use to find what meshes are not impacted by the light.
  18185. * Inactive if 0
  18186. */
  18187. get excludeWithLayerMask(): number;
  18188. /**
  18189. * Sets the layer id use to find what meshes are not impacted by the light.
  18190. * Inactive if 0
  18191. */
  18192. set excludeWithLayerMask(value: number);
  18193. private _includeOnlyWithLayerMask;
  18194. /**
  18195. * Gets the layer id use to find what meshes are impacted by the light.
  18196. * Inactive if 0
  18197. */
  18198. get includeOnlyWithLayerMask(): number;
  18199. /**
  18200. * Sets the layer id use to find what meshes are impacted by the light.
  18201. * Inactive if 0
  18202. */
  18203. set includeOnlyWithLayerMask(value: number);
  18204. private _lightmapMode;
  18205. /**
  18206. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18207. */
  18208. get lightmapMode(): number;
  18209. /**
  18210. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18211. */
  18212. set lightmapMode(value: number);
  18213. /**
  18214. * Shadow generator associted to the light.
  18215. * @hidden Internal use only.
  18216. */
  18217. _shadowGenerator: Nullable<IShadowGenerator>;
  18218. /**
  18219. * @hidden Internal use only.
  18220. */
  18221. _excludedMeshesIds: string[];
  18222. /**
  18223. * @hidden Internal use only.
  18224. */
  18225. _includedOnlyMeshesIds: string[];
  18226. /**
  18227. * The current light unifom buffer.
  18228. * @hidden Internal use only.
  18229. */
  18230. _uniformBuffer: UniformBuffer;
  18231. /** @hidden */
  18232. _renderId: number;
  18233. /**
  18234. * Creates a Light object in the scene.
  18235. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18236. * @param name The firendly name of the light
  18237. * @param scene The scene the light belongs too
  18238. */
  18239. constructor(name: string, scene: Scene);
  18240. protected abstract _buildUniformLayout(): void;
  18241. /**
  18242. * Sets the passed Effect "effect" with the Light information.
  18243. * @param effect The effect to update
  18244. * @param lightIndex The index of the light in the effect to update
  18245. * @returns The light
  18246. */
  18247. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18248. /**
  18249. * Sets the passed Effect "effect" with the Light textures.
  18250. * @param effect The effect to update
  18251. * @param lightIndex The index of the light in the effect to update
  18252. * @returns The light
  18253. */
  18254. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18255. /**
  18256. * Binds the lights information from the scene to the effect for the given mesh.
  18257. * @param lightIndex Light index
  18258. * @param scene The scene where the light belongs to
  18259. * @param effect The effect we are binding the data to
  18260. * @param useSpecular Defines if specular is supported
  18261. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18262. */
  18263. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18264. /**
  18265. * Sets the passed Effect "effect" with the Light information.
  18266. * @param effect The effect to update
  18267. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18268. * @returns The light
  18269. */
  18270. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18271. /**
  18272. * Returns the string "Light".
  18273. * @returns the class name
  18274. */
  18275. getClassName(): string;
  18276. /** @hidden */
  18277. readonly _isLight: boolean;
  18278. /**
  18279. * Converts the light information to a readable string for debug purpose.
  18280. * @param fullDetails Supports for multiple levels of logging within scene loading
  18281. * @returns the human readable light info
  18282. */
  18283. toString(fullDetails?: boolean): string;
  18284. /** @hidden */
  18285. protected _syncParentEnabledState(): void;
  18286. /**
  18287. * Set the enabled state of this node.
  18288. * @param value - the new enabled state
  18289. */
  18290. setEnabled(value: boolean): void;
  18291. /**
  18292. * Returns the Light associated shadow generator if any.
  18293. * @return the associated shadow generator.
  18294. */
  18295. getShadowGenerator(): Nullable<IShadowGenerator>;
  18296. /**
  18297. * Returns a Vector3, the absolute light position in the World.
  18298. * @returns the world space position of the light
  18299. */
  18300. getAbsolutePosition(): Vector3;
  18301. /**
  18302. * Specifies if the light will affect the passed mesh.
  18303. * @param mesh The mesh to test against the light
  18304. * @return true the mesh is affected otherwise, false.
  18305. */
  18306. canAffectMesh(mesh: AbstractMesh): boolean;
  18307. /**
  18308. * Sort function to order lights for rendering.
  18309. * @param a First Light object to compare to second.
  18310. * @param b Second Light object to compare first.
  18311. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18312. */
  18313. static CompareLightsPriority(a: Light, b: Light): number;
  18314. /**
  18315. * Releases resources associated with this node.
  18316. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18317. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18318. */
  18319. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18320. /**
  18321. * Returns the light type ID (integer).
  18322. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18323. */
  18324. getTypeID(): number;
  18325. /**
  18326. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18327. * @returns the scaled intensity in intensity mode unit
  18328. */
  18329. getScaledIntensity(): number;
  18330. /**
  18331. * Returns a new Light object, named "name", from the current one.
  18332. * @param name The name of the cloned light
  18333. * @param newParent The parent of this light, if it has one
  18334. * @returns the new created light
  18335. */
  18336. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18337. /**
  18338. * Serializes the current light into a Serialization object.
  18339. * @returns the serialized object.
  18340. */
  18341. serialize(): any;
  18342. /**
  18343. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18344. * This new light is named "name" and added to the passed scene.
  18345. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18346. * @param name The friendly name of the light
  18347. * @param scene The scene the new light will belong to
  18348. * @returns the constructor function
  18349. */
  18350. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18351. /**
  18352. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18353. * @param parsedLight The JSON representation of the light
  18354. * @param scene The scene to create the parsed light in
  18355. * @returns the created light after parsing
  18356. */
  18357. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18358. private _hookArrayForExcluded;
  18359. private _hookArrayForIncludedOnly;
  18360. private _resyncMeshes;
  18361. /**
  18362. * Forces the meshes to update their light related information in their rendering used effects
  18363. * @hidden Internal Use Only
  18364. */
  18365. _markMeshesAsLightDirty(): void;
  18366. /**
  18367. * Recomputes the cached photometric scale if needed.
  18368. */
  18369. private _computePhotometricScale;
  18370. /**
  18371. * Returns the Photometric Scale according to the light type and intensity mode.
  18372. */
  18373. private _getPhotometricScale;
  18374. /**
  18375. * Reorder the light in the scene according to their defined priority.
  18376. * @hidden Internal Use Only
  18377. */
  18378. _reorderLightsInScene(): void;
  18379. /**
  18380. * Prepares the list of defines specific to the light type.
  18381. * @param defines the list of defines
  18382. * @param lightIndex defines the index of the light for the effect
  18383. */
  18384. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18385. }
  18386. }
  18387. declare module BABYLON {
  18388. /**
  18389. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18390. * This is the base of the follow, arc rotate cameras and Free camera
  18391. * @see https://doc.babylonjs.com/features/cameras
  18392. */
  18393. export class TargetCamera extends Camera {
  18394. private static _RigCamTransformMatrix;
  18395. private static _TargetTransformMatrix;
  18396. private static _TargetFocalPoint;
  18397. private _tmpUpVector;
  18398. private _tmpTargetVector;
  18399. /**
  18400. * Define the current direction the camera is moving to
  18401. */
  18402. cameraDirection: Vector3;
  18403. /**
  18404. * Define the current rotation the camera is rotating to
  18405. */
  18406. cameraRotation: Vector2;
  18407. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18408. ignoreParentScaling: boolean;
  18409. /**
  18410. * When set, the up vector of the camera will be updated by the rotation of the camera
  18411. */
  18412. updateUpVectorFromRotation: boolean;
  18413. private _tmpQuaternion;
  18414. /**
  18415. * Define the current rotation of the camera
  18416. */
  18417. rotation: Vector3;
  18418. /**
  18419. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18420. */
  18421. rotationQuaternion: Quaternion;
  18422. /**
  18423. * Define the current speed of the camera
  18424. */
  18425. speed: number;
  18426. /**
  18427. * Add constraint to the camera to prevent it to move freely in all directions and
  18428. * around all axis.
  18429. */
  18430. noRotationConstraint: boolean;
  18431. /**
  18432. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18433. * panning
  18434. */
  18435. invertRotation: boolean;
  18436. /**
  18437. * Speed multiplier for inverse camera panning
  18438. */
  18439. inverseRotationSpeed: number;
  18440. /**
  18441. * Define the current target of the camera as an object or a position.
  18442. */
  18443. lockedTarget: any;
  18444. /** @hidden */
  18445. _currentTarget: Vector3;
  18446. /** @hidden */
  18447. _initialFocalDistance: number;
  18448. /** @hidden */
  18449. _viewMatrix: Matrix;
  18450. /** @hidden */
  18451. _camMatrix: Matrix;
  18452. /** @hidden */
  18453. _cameraTransformMatrix: Matrix;
  18454. /** @hidden */
  18455. _cameraRotationMatrix: Matrix;
  18456. /** @hidden */
  18457. _referencePoint: Vector3;
  18458. /** @hidden */
  18459. _transformedReferencePoint: Vector3;
  18460. /** @hidden */
  18461. _reset: () => void;
  18462. private _defaultUp;
  18463. /**
  18464. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18465. * This is the base of the follow, arc rotate cameras and Free camera
  18466. * @see https://doc.babylonjs.com/features/cameras
  18467. * @param name Defines the name of the camera in the scene
  18468. * @param position Defines the start position of the camera in the scene
  18469. * @param scene Defines the scene the camera belongs to
  18470. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18471. */
  18472. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18473. /**
  18474. * Gets the position in front of the camera at a given distance.
  18475. * @param distance The distance from the camera we want the position to be
  18476. * @returns the position
  18477. */
  18478. getFrontPosition(distance: number): Vector3;
  18479. /** @hidden */
  18480. _getLockedTargetPosition(): Nullable<Vector3>;
  18481. private _storedPosition;
  18482. private _storedRotation;
  18483. private _storedRotationQuaternion;
  18484. /**
  18485. * Store current camera state of the camera (fov, position, rotation, etc..)
  18486. * @returns the camera
  18487. */
  18488. storeState(): Camera;
  18489. /**
  18490. * Restored camera state. You must call storeState() first
  18491. * @returns whether it was successful or not
  18492. * @hidden
  18493. */
  18494. _restoreStateValues(): boolean;
  18495. /** @hidden */
  18496. _initCache(): void;
  18497. /** @hidden */
  18498. _updateCache(ignoreParentClass?: boolean): void;
  18499. /** @hidden */
  18500. _isSynchronizedViewMatrix(): boolean;
  18501. /** @hidden */
  18502. _computeLocalCameraSpeed(): number;
  18503. /**
  18504. * Defines the target the camera should look at.
  18505. * @param target Defines the new target as a Vector or a mesh
  18506. */
  18507. setTarget(target: Vector3): void;
  18508. /**
  18509. * Defines the target point of the camera.
  18510. * The camera looks towards it form the radius distance.
  18511. */
  18512. get target(): Vector3;
  18513. set target(value: Vector3);
  18514. /**
  18515. * Return the current target position of the camera. This value is expressed in local space.
  18516. * @returns the target position
  18517. */
  18518. getTarget(): Vector3;
  18519. /** @hidden */
  18520. _decideIfNeedsToMove(): boolean;
  18521. /** @hidden */
  18522. _updatePosition(): void;
  18523. /** @hidden */
  18524. _checkInputs(): void;
  18525. protected _updateCameraRotationMatrix(): void;
  18526. /**
  18527. * 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)
  18528. * @returns the current camera
  18529. */
  18530. private _rotateUpVectorWithCameraRotationMatrix;
  18531. private _cachedRotationZ;
  18532. private _cachedQuaternionRotationZ;
  18533. /** @hidden */
  18534. _getViewMatrix(): Matrix;
  18535. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18536. /**
  18537. * @hidden
  18538. */
  18539. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18540. /**
  18541. * @hidden
  18542. */
  18543. _updateRigCameras(): void;
  18544. private _getRigCamPositionAndTarget;
  18545. /**
  18546. * Gets the current object class name.
  18547. * @return the class name
  18548. */
  18549. getClassName(): string;
  18550. }
  18551. }
  18552. declare module BABYLON {
  18553. /**
  18554. * Gather the list of keyboard event types as constants.
  18555. */
  18556. export class KeyboardEventTypes {
  18557. /**
  18558. * The keydown event is fired when a key becomes active (pressed).
  18559. */
  18560. static readonly KEYDOWN: number;
  18561. /**
  18562. * The keyup event is fired when a key has been released.
  18563. */
  18564. static readonly KEYUP: number;
  18565. }
  18566. /**
  18567. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18568. */
  18569. export class KeyboardInfo {
  18570. /**
  18571. * Defines the type of event (KeyboardEventTypes)
  18572. */
  18573. type: number;
  18574. /**
  18575. * Defines the related dom event
  18576. */
  18577. event: KeyboardEvent;
  18578. /**
  18579. * Instantiates a new keyboard info.
  18580. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18581. * @param type Defines the type of event (KeyboardEventTypes)
  18582. * @param event Defines the related dom event
  18583. */
  18584. constructor(
  18585. /**
  18586. * Defines the type of event (KeyboardEventTypes)
  18587. */
  18588. type: number,
  18589. /**
  18590. * Defines the related dom event
  18591. */
  18592. event: KeyboardEvent);
  18593. }
  18594. /**
  18595. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18596. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18597. */
  18598. export class KeyboardInfoPre extends KeyboardInfo {
  18599. /**
  18600. * Defines the type of event (KeyboardEventTypes)
  18601. */
  18602. type: number;
  18603. /**
  18604. * Defines the related dom event
  18605. */
  18606. event: KeyboardEvent;
  18607. /**
  18608. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18609. */
  18610. skipOnPointerObservable: boolean;
  18611. /**
  18612. * Instantiates a new keyboard pre info.
  18613. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18614. * @param type Defines the type of event (KeyboardEventTypes)
  18615. * @param event Defines the related dom event
  18616. */
  18617. constructor(
  18618. /**
  18619. * Defines the type of event (KeyboardEventTypes)
  18620. */
  18621. type: number,
  18622. /**
  18623. * Defines the related dom event
  18624. */
  18625. event: KeyboardEvent);
  18626. }
  18627. }
  18628. declare module BABYLON {
  18629. /**
  18630. * Manage the keyboard inputs to control the movement of a free camera.
  18631. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18632. */
  18633. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18634. /**
  18635. * Defines the camera the input is attached to.
  18636. */
  18637. camera: FreeCamera;
  18638. /**
  18639. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18640. */
  18641. keysUp: number[];
  18642. /**
  18643. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18644. */
  18645. keysUpward: number[];
  18646. /**
  18647. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18648. */
  18649. keysDown: number[];
  18650. /**
  18651. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18652. */
  18653. keysDownward: number[];
  18654. /**
  18655. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18656. */
  18657. keysLeft: number[];
  18658. /**
  18659. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18660. */
  18661. keysRight: number[];
  18662. private _keys;
  18663. private _onCanvasBlurObserver;
  18664. private _onKeyboardObserver;
  18665. private _engine;
  18666. private _scene;
  18667. /**
  18668. * Attach the input controls to a specific dom element to get the input from.
  18669. * @param element Defines the element the controls should be listened from
  18670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18671. */
  18672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18673. /**
  18674. * Detach the current controls from the specified dom element.
  18675. * @param element Defines the element to stop listening the inputs from
  18676. */
  18677. detachControl(element: Nullable<HTMLElement>): void;
  18678. /**
  18679. * Update the current camera state depending on the inputs that have been used this frame.
  18680. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18681. */
  18682. checkInputs(): void;
  18683. /**
  18684. * Gets the class name of the current intput.
  18685. * @returns the class name
  18686. */
  18687. getClassName(): string;
  18688. /** @hidden */
  18689. _onLostFocus(): void;
  18690. /**
  18691. * Get the friendly name associated with the input class.
  18692. * @returns the input friendly name
  18693. */
  18694. getSimpleName(): string;
  18695. }
  18696. }
  18697. declare module BABYLON {
  18698. /**
  18699. * Gather the list of pointer event types as constants.
  18700. */
  18701. export class PointerEventTypes {
  18702. /**
  18703. * 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.
  18704. */
  18705. static readonly POINTERDOWN: number;
  18706. /**
  18707. * The pointerup event is fired when a pointer is no longer active.
  18708. */
  18709. static readonly POINTERUP: number;
  18710. /**
  18711. * The pointermove event is fired when a pointer changes coordinates.
  18712. */
  18713. static readonly POINTERMOVE: number;
  18714. /**
  18715. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18716. */
  18717. static readonly POINTERWHEEL: number;
  18718. /**
  18719. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18720. */
  18721. static readonly POINTERPICK: number;
  18722. /**
  18723. * The pointertap event is fired when a the object has been touched and released without drag.
  18724. */
  18725. static readonly POINTERTAP: number;
  18726. /**
  18727. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18728. */
  18729. static readonly POINTERDOUBLETAP: number;
  18730. }
  18731. /**
  18732. * Base class of pointer info types.
  18733. */
  18734. export class PointerInfoBase {
  18735. /**
  18736. * Defines the type of event (PointerEventTypes)
  18737. */
  18738. type: number;
  18739. /**
  18740. * Defines the related dom event
  18741. */
  18742. event: PointerEvent | MouseWheelEvent;
  18743. /**
  18744. * Instantiates the base class of pointers info.
  18745. * @param type Defines the type of event (PointerEventTypes)
  18746. * @param event Defines the related dom event
  18747. */
  18748. constructor(
  18749. /**
  18750. * Defines the type of event (PointerEventTypes)
  18751. */
  18752. type: number,
  18753. /**
  18754. * Defines the related dom event
  18755. */
  18756. event: PointerEvent | MouseWheelEvent);
  18757. }
  18758. /**
  18759. * This class is used to store pointer related info for the onPrePointerObservable event.
  18760. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18761. */
  18762. export class PointerInfoPre extends PointerInfoBase {
  18763. /**
  18764. * Ray from a pointer if availible (eg. 6dof controller)
  18765. */
  18766. ray: Nullable<Ray>;
  18767. /**
  18768. * Defines the local position of the pointer on the canvas.
  18769. */
  18770. localPosition: Vector2;
  18771. /**
  18772. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18773. */
  18774. skipOnPointerObservable: boolean;
  18775. /**
  18776. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18777. * @param type Defines the type of event (PointerEventTypes)
  18778. * @param event Defines the related dom event
  18779. * @param localX Defines the local x coordinates of the pointer when the event occured
  18780. * @param localY Defines the local y coordinates of the pointer when the event occured
  18781. */
  18782. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18783. }
  18784. /**
  18785. * This type contains all the data related to a pointer event in Babylon.js.
  18786. * 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.
  18787. */
  18788. export class PointerInfo extends PointerInfoBase {
  18789. /**
  18790. * Defines the picking info associated to the info (if any)\
  18791. */
  18792. pickInfo: Nullable<PickingInfo>;
  18793. /**
  18794. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18795. * @param type Defines the type of event (PointerEventTypes)
  18796. * @param event Defines the related dom event
  18797. * @param pickInfo Defines the picking info associated to the info (if any)\
  18798. */
  18799. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18800. /**
  18801. * Defines the picking info associated to the info (if any)\
  18802. */
  18803. pickInfo: Nullable<PickingInfo>);
  18804. }
  18805. /**
  18806. * Data relating to a touch event on the screen.
  18807. */
  18808. export interface PointerTouch {
  18809. /**
  18810. * X coordinate of touch.
  18811. */
  18812. x: number;
  18813. /**
  18814. * Y coordinate of touch.
  18815. */
  18816. y: number;
  18817. /**
  18818. * Id of touch. Unique for each finger.
  18819. */
  18820. pointerId: number;
  18821. /**
  18822. * Event type passed from DOM.
  18823. */
  18824. type: any;
  18825. }
  18826. }
  18827. declare module BABYLON {
  18828. /**
  18829. * Manage the mouse inputs to control the movement of a free camera.
  18830. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18831. */
  18832. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18833. /**
  18834. * Define if touch is enabled in the mouse input
  18835. */
  18836. touchEnabled: boolean;
  18837. /**
  18838. * Defines the camera the input is attached to.
  18839. */
  18840. camera: FreeCamera;
  18841. /**
  18842. * Defines the buttons associated with the input to handle camera move.
  18843. */
  18844. buttons: number[];
  18845. /**
  18846. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18847. */
  18848. angularSensibility: number;
  18849. private _pointerInput;
  18850. private _onMouseMove;
  18851. private _observer;
  18852. private previousPosition;
  18853. /**
  18854. * Observable for when a pointer move event occurs containing the move offset
  18855. */
  18856. onPointerMovedObservable: Observable<{
  18857. offsetX: number;
  18858. offsetY: number;
  18859. }>;
  18860. /**
  18861. * @hidden
  18862. * If the camera should be rotated automatically based on pointer movement
  18863. */
  18864. _allowCameraRotation: boolean;
  18865. /**
  18866. * Manage the mouse inputs to control the movement of a free camera.
  18867. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18868. * @param touchEnabled Defines if touch is enabled or not
  18869. */
  18870. constructor(
  18871. /**
  18872. * Define if touch is enabled in the mouse input
  18873. */
  18874. touchEnabled?: boolean);
  18875. /**
  18876. * Attach the input controls to a specific dom element to get the input from.
  18877. * @param element Defines the element the controls should be listened from
  18878. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18879. */
  18880. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18881. /**
  18882. * Called on JS contextmenu event.
  18883. * Override this method to provide functionality.
  18884. */
  18885. protected onContextMenu(evt: PointerEvent): void;
  18886. /**
  18887. * Detach the current controls from the specified dom element.
  18888. * @param element Defines the element to stop listening the inputs from
  18889. */
  18890. detachControl(element: Nullable<HTMLElement>): void;
  18891. /**
  18892. * Gets the class name of the current intput.
  18893. * @returns the class name
  18894. */
  18895. getClassName(): string;
  18896. /**
  18897. * Get the friendly name associated with the input class.
  18898. * @returns the input friendly name
  18899. */
  18900. getSimpleName(): string;
  18901. }
  18902. }
  18903. declare module BABYLON {
  18904. /**
  18905. * Manage the touch inputs to control the movement of a free camera.
  18906. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18907. */
  18908. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18909. /**
  18910. * Define if mouse events can be treated as touch events
  18911. */
  18912. allowMouse: boolean;
  18913. /**
  18914. * Defines the camera the input is attached to.
  18915. */
  18916. camera: FreeCamera;
  18917. /**
  18918. * Defines the touch sensibility for rotation.
  18919. * The higher the faster.
  18920. */
  18921. touchAngularSensibility: number;
  18922. /**
  18923. * Defines the touch sensibility for move.
  18924. * The higher the faster.
  18925. */
  18926. touchMoveSensibility: number;
  18927. private _offsetX;
  18928. private _offsetY;
  18929. private _pointerPressed;
  18930. private _pointerInput;
  18931. private _observer;
  18932. private _onLostFocus;
  18933. /**
  18934. * Manage the touch inputs to control the movement of a free camera.
  18935. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18936. * @param allowMouse Defines if mouse events can be treated as touch events
  18937. */
  18938. constructor(
  18939. /**
  18940. * Define if mouse events can be treated as touch events
  18941. */
  18942. allowMouse?: boolean);
  18943. /**
  18944. * Attach the input controls to a specific dom element to get the input from.
  18945. * @param element Defines the element the controls should be listened from
  18946. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18947. */
  18948. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18949. /**
  18950. * Detach the current controls from the specified dom element.
  18951. * @param element Defines the element to stop listening the inputs from
  18952. */
  18953. detachControl(element: Nullable<HTMLElement>): void;
  18954. /**
  18955. * Update the current camera state depending on the inputs that have been used this frame.
  18956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18957. */
  18958. checkInputs(): void;
  18959. /**
  18960. * Gets the class name of the current intput.
  18961. * @returns the class name
  18962. */
  18963. getClassName(): string;
  18964. /**
  18965. * Get the friendly name associated with the input class.
  18966. * @returns the input friendly name
  18967. */
  18968. getSimpleName(): string;
  18969. }
  18970. }
  18971. declare module BABYLON {
  18972. /**
  18973. * Default Inputs manager for the FreeCamera.
  18974. * It groups all the default supported inputs for ease of use.
  18975. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18976. */
  18977. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18978. /**
  18979. * @hidden
  18980. */
  18981. _mouseInput: Nullable<FreeCameraMouseInput>;
  18982. /**
  18983. * Instantiates a new FreeCameraInputsManager.
  18984. * @param camera Defines the camera the inputs belong to
  18985. */
  18986. constructor(camera: FreeCamera);
  18987. /**
  18988. * Add keyboard input support to the input manager.
  18989. * @returns the current input manager
  18990. */
  18991. addKeyboard(): FreeCameraInputsManager;
  18992. /**
  18993. * Add mouse input support to the input manager.
  18994. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18995. * @returns the current input manager
  18996. */
  18997. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18998. /**
  18999. * Removes the mouse input support from the manager
  19000. * @returns the current input manager
  19001. */
  19002. removeMouse(): FreeCameraInputsManager;
  19003. /**
  19004. * Add touch input support to the input manager.
  19005. * @returns the current input manager
  19006. */
  19007. addTouch(): FreeCameraInputsManager;
  19008. /**
  19009. * Remove all attached input methods from a camera
  19010. */
  19011. clear(): void;
  19012. }
  19013. }
  19014. declare module BABYLON {
  19015. /**
  19016. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19017. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19018. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19019. */
  19020. export class FreeCamera extends TargetCamera {
  19021. /**
  19022. * Define the collision ellipsoid of the camera.
  19023. * This is helpful to simulate a camera body like the player body around the camera
  19024. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19025. */
  19026. ellipsoid: Vector3;
  19027. /**
  19028. * Define an offset for the position of the ellipsoid around the camera.
  19029. * This can be helpful to determine the center of the body near the gravity center of the body
  19030. * instead of its head.
  19031. */
  19032. ellipsoidOffset: Vector3;
  19033. /**
  19034. * Enable or disable collisions of the camera with the rest of the scene objects.
  19035. */
  19036. checkCollisions: boolean;
  19037. /**
  19038. * Enable or disable gravity on the camera.
  19039. */
  19040. applyGravity: boolean;
  19041. /**
  19042. * Define the input manager associated to the camera.
  19043. */
  19044. inputs: FreeCameraInputsManager;
  19045. /**
  19046. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19047. * Higher values reduce sensitivity.
  19048. */
  19049. get angularSensibility(): number;
  19050. /**
  19051. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19052. * Higher values reduce sensitivity.
  19053. */
  19054. set angularSensibility(value: number);
  19055. /**
  19056. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19057. */
  19058. get keysUp(): number[];
  19059. set keysUp(value: number[]);
  19060. /**
  19061. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19062. */
  19063. get keysUpward(): number[];
  19064. set keysUpward(value: number[]);
  19065. /**
  19066. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19067. */
  19068. get keysDown(): number[];
  19069. set keysDown(value: number[]);
  19070. /**
  19071. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19072. */
  19073. get keysDownward(): number[];
  19074. set keysDownward(value: number[]);
  19075. /**
  19076. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19077. */
  19078. get keysLeft(): number[];
  19079. set keysLeft(value: number[]);
  19080. /**
  19081. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19082. */
  19083. get keysRight(): number[];
  19084. set keysRight(value: number[]);
  19085. /**
  19086. * Event raised when the camera collide with a mesh in the scene.
  19087. */
  19088. onCollide: (collidedMesh: AbstractMesh) => void;
  19089. private _collider;
  19090. private _needMoveForGravity;
  19091. private _oldPosition;
  19092. private _diffPosition;
  19093. private _newPosition;
  19094. /** @hidden */
  19095. _localDirection: Vector3;
  19096. /** @hidden */
  19097. _transformedDirection: Vector3;
  19098. /**
  19099. * Instantiates a Free Camera.
  19100. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19101. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19102. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19103. * @param name Define the name of the camera in the scene
  19104. * @param position Define the start position of the camera in the scene
  19105. * @param scene Define the scene the camera belongs to
  19106. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19107. */
  19108. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19109. /**
  19110. * Attached controls to the current camera.
  19111. * @param element Defines the element the controls should be listened from
  19112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19113. */
  19114. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19115. /**
  19116. * Detach the current controls from the camera.
  19117. * The camera will stop reacting to inputs.
  19118. * @param element Defines the element to stop listening the inputs from
  19119. */
  19120. detachControl(element: HTMLElement): void;
  19121. private _collisionMask;
  19122. /**
  19123. * Define a collision mask to limit the list of object the camera can collide with
  19124. */
  19125. get collisionMask(): number;
  19126. set collisionMask(mask: number);
  19127. /** @hidden */
  19128. _collideWithWorld(displacement: Vector3): void;
  19129. private _onCollisionPositionChange;
  19130. /** @hidden */
  19131. _checkInputs(): void;
  19132. /** @hidden */
  19133. _decideIfNeedsToMove(): boolean;
  19134. /** @hidden */
  19135. _updatePosition(): void;
  19136. /**
  19137. * Destroy the camera and release the current resources hold by it.
  19138. */
  19139. dispose(): void;
  19140. /**
  19141. * Gets the current object class name.
  19142. * @return the class name
  19143. */
  19144. getClassName(): string;
  19145. }
  19146. }
  19147. declare module BABYLON {
  19148. /**
  19149. * Represents a gamepad control stick position
  19150. */
  19151. export class StickValues {
  19152. /**
  19153. * The x component of the control stick
  19154. */
  19155. x: number;
  19156. /**
  19157. * The y component of the control stick
  19158. */
  19159. y: number;
  19160. /**
  19161. * Initializes the gamepad x and y control stick values
  19162. * @param x The x component of the gamepad control stick value
  19163. * @param y The y component of the gamepad control stick value
  19164. */
  19165. constructor(
  19166. /**
  19167. * The x component of the control stick
  19168. */
  19169. x: number,
  19170. /**
  19171. * The y component of the control stick
  19172. */
  19173. y: number);
  19174. }
  19175. /**
  19176. * An interface which manages callbacks for gamepad button changes
  19177. */
  19178. export interface GamepadButtonChanges {
  19179. /**
  19180. * Called when a gamepad has been changed
  19181. */
  19182. changed: boolean;
  19183. /**
  19184. * Called when a gamepad press event has been triggered
  19185. */
  19186. pressChanged: boolean;
  19187. /**
  19188. * Called when a touch event has been triggered
  19189. */
  19190. touchChanged: boolean;
  19191. /**
  19192. * Called when a value has changed
  19193. */
  19194. valueChanged: boolean;
  19195. }
  19196. /**
  19197. * Represents a gamepad
  19198. */
  19199. export class Gamepad {
  19200. /**
  19201. * The id of the gamepad
  19202. */
  19203. id: string;
  19204. /**
  19205. * The index of the gamepad
  19206. */
  19207. index: number;
  19208. /**
  19209. * The browser gamepad
  19210. */
  19211. browserGamepad: any;
  19212. /**
  19213. * Specifies what type of gamepad this represents
  19214. */
  19215. type: number;
  19216. private _leftStick;
  19217. private _rightStick;
  19218. /** @hidden */
  19219. _isConnected: boolean;
  19220. private _leftStickAxisX;
  19221. private _leftStickAxisY;
  19222. private _rightStickAxisX;
  19223. private _rightStickAxisY;
  19224. /**
  19225. * Triggered when the left control stick has been changed
  19226. */
  19227. private _onleftstickchanged;
  19228. /**
  19229. * Triggered when the right control stick has been changed
  19230. */
  19231. private _onrightstickchanged;
  19232. /**
  19233. * Represents a gamepad controller
  19234. */
  19235. static GAMEPAD: number;
  19236. /**
  19237. * Represents a generic controller
  19238. */
  19239. static GENERIC: number;
  19240. /**
  19241. * Represents an XBox controller
  19242. */
  19243. static XBOX: number;
  19244. /**
  19245. * Represents a pose-enabled controller
  19246. */
  19247. static POSE_ENABLED: number;
  19248. /**
  19249. * Represents an Dual Shock controller
  19250. */
  19251. static DUALSHOCK: number;
  19252. /**
  19253. * Specifies whether the left control stick should be Y-inverted
  19254. */
  19255. protected _invertLeftStickY: boolean;
  19256. /**
  19257. * Specifies if the gamepad has been connected
  19258. */
  19259. get isConnected(): boolean;
  19260. /**
  19261. * Initializes the gamepad
  19262. * @param id The id of the gamepad
  19263. * @param index The index of the gamepad
  19264. * @param browserGamepad The browser gamepad
  19265. * @param leftStickX The x component of the left joystick
  19266. * @param leftStickY The y component of the left joystick
  19267. * @param rightStickX The x component of the right joystick
  19268. * @param rightStickY The y component of the right joystick
  19269. */
  19270. constructor(
  19271. /**
  19272. * The id of the gamepad
  19273. */
  19274. id: string,
  19275. /**
  19276. * The index of the gamepad
  19277. */
  19278. index: number,
  19279. /**
  19280. * The browser gamepad
  19281. */
  19282. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19283. /**
  19284. * Callback triggered when the left joystick has changed
  19285. * @param callback
  19286. */
  19287. onleftstickchanged(callback: (values: StickValues) => void): void;
  19288. /**
  19289. * Callback triggered when the right joystick has changed
  19290. * @param callback
  19291. */
  19292. onrightstickchanged(callback: (values: StickValues) => void): void;
  19293. /**
  19294. * Gets the left joystick
  19295. */
  19296. get leftStick(): StickValues;
  19297. /**
  19298. * Sets the left joystick values
  19299. */
  19300. set leftStick(newValues: StickValues);
  19301. /**
  19302. * Gets the right joystick
  19303. */
  19304. get rightStick(): StickValues;
  19305. /**
  19306. * Sets the right joystick value
  19307. */
  19308. set rightStick(newValues: StickValues);
  19309. /**
  19310. * Updates the gamepad joystick positions
  19311. */
  19312. update(): void;
  19313. /**
  19314. * Disposes the gamepad
  19315. */
  19316. dispose(): void;
  19317. }
  19318. /**
  19319. * Represents a generic gamepad
  19320. */
  19321. export class GenericPad extends Gamepad {
  19322. private _buttons;
  19323. private _onbuttondown;
  19324. private _onbuttonup;
  19325. /**
  19326. * Observable triggered when a button has been pressed
  19327. */
  19328. onButtonDownObservable: Observable<number>;
  19329. /**
  19330. * Observable triggered when a button has been released
  19331. */
  19332. onButtonUpObservable: Observable<number>;
  19333. /**
  19334. * Callback triggered when a button has been pressed
  19335. * @param callback Called when a button has been pressed
  19336. */
  19337. onbuttondown(callback: (buttonPressed: number) => void): void;
  19338. /**
  19339. * Callback triggered when a button has been released
  19340. * @param callback Called when a button has been released
  19341. */
  19342. onbuttonup(callback: (buttonReleased: number) => void): void;
  19343. /**
  19344. * Initializes the generic gamepad
  19345. * @param id The id of the generic gamepad
  19346. * @param index The index of the generic gamepad
  19347. * @param browserGamepad The browser gamepad
  19348. */
  19349. constructor(id: string, index: number, browserGamepad: any);
  19350. private _setButtonValue;
  19351. /**
  19352. * Updates the generic gamepad
  19353. */
  19354. update(): void;
  19355. /**
  19356. * Disposes the generic gamepad
  19357. */
  19358. dispose(): void;
  19359. }
  19360. }
  19361. declare module BABYLON {
  19362. /**
  19363. * Defines the types of pose enabled controllers that are supported
  19364. */
  19365. export enum PoseEnabledControllerType {
  19366. /**
  19367. * HTC Vive
  19368. */
  19369. VIVE = 0,
  19370. /**
  19371. * Oculus Rift
  19372. */
  19373. OCULUS = 1,
  19374. /**
  19375. * Windows mixed reality
  19376. */
  19377. WINDOWS = 2,
  19378. /**
  19379. * Samsung gear VR
  19380. */
  19381. GEAR_VR = 3,
  19382. /**
  19383. * Google Daydream
  19384. */
  19385. DAYDREAM = 4,
  19386. /**
  19387. * Generic
  19388. */
  19389. GENERIC = 5
  19390. }
  19391. /**
  19392. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19393. */
  19394. export interface MutableGamepadButton {
  19395. /**
  19396. * Value of the button/trigger
  19397. */
  19398. value: number;
  19399. /**
  19400. * If the button/trigger is currently touched
  19401. */
  19402. touched: boolean;
  19403. /**
  19404. * If the button/trigger is currently pressed
  19405. */
  19406. pressed: boolean;
  19407. }
  19408. /**
  19409. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19410. * @hidden
  19411. */
  19412. export interface ExtendedGamepadButton extends GamepadButton {
  19413. /**
  19414. * If the button/trigger is currently pressed
  19415. */
  19416. readonly pressed: boolean;
  19417. /**
  19418. * If the button/trigger is currently touched
  19419. */
  19420. readonly touched: boolean;
  19421. /**
  19422. * Value of the button/trigger
  19423. */
  19424. readonly value: number;
  19425. }
  19426. /** @hidden */
  19427. export interface _GamePadFactory {
  19428. /**
  19429. * Returns whether or not the current gamepad can be created for this type of controller.
  19430. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19431. * @returns true if it can be created, otherwise false
  19432. */
  19433. canCreate(gamepadInfo: any): boolean;
  19434. /**
  19435. * Creates a new instance of the Gamepad.
  19436. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19437. * @returns the new gamepad instance
  19438. */
  19439. create(gamepadInfo: any): Gamepad;
  19440. }
  19441. /**
  19442. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19443. */
  19444. export class PoseEnabledControllerHelper {
  19445. /** @hidden */
  19446. static _ControllerFactories: _GamePadFactory[];
  19447. /** @hidden */
  19448. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19449. /**
  19450. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19451. * @param vrGamepad the gamepad to initialized
  19452. * @returns a vr controller of the type the gamepad identified as
  19453. */
  19454. static InitiateController(vrGamepad: any): Gamepad;
  19455. }
  19456. /**
  19457. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19458. */
  19459. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19460. /**
  19461. * If the controller is used in a webXR session
  19462. */
  19463. isXR: boolean;
  19464. private _deviceRoomPosition;
  19465. private _deviceRoomRotationQuaternion;
  19466. /**
  19467. * The device position in babylon space
  19468. */
  19469. devicePosition: Vector3;
  19470. /**
  19471. * The device rotation in babylon space
  19472. */
  19473. deviceRotationQuaternion: Quaternion;
  19474. /**
  19475. * The scale factor of the device in babylon space
  19476. */
  19477. deviceScaleFactor: number;
  19478. /**
  19479. * (Likely devicePosition should be used instead) The device position in its room space
  19480. */
  19481. position: Vector3;
  19482. /**
  19483. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19484. */
  19485. rotationQuaternion: Quaternion;
  19486. /**
  19487. * The type of controller (Eg. Windows mixed reality)
  19488. */
  19489. controllerType: PoseEnabledControllerType;
  19490. protected _calculatedPosition: Vector3;
  19491. private _calculatedRotation;
  19492. /**
  19493. * The raw pose from the device
  19494. */
  19495. rawPose: DevicePose;
  19496. private _trackPosition;
  19497. private _maxRotationDistFromHeadset;
  19498. private _draggedRoomRotation;
  19499. /**
  19500. * @hidden
  19501. */
  19502. _disableTrackPosition(fixedPosition: Vector3): void;
  19503. /**
  19504. * Internal, the mesh attached to the controller
  19505. * @hidden
  19506. */
  19507. _mesh: Nullable<AbstractMesh>;
  19508. private _poseControlledCamera;
  19509. private _leftHandSystemQuaternion;
  19510. /**
  19511. * Internal, matrix used to convert room space to babylon space
  19512. * @hidden
  19513. */
  19514. _deviceToWorld: Matrix;
  19515. /**
  19516. * Node to be used when casting a ray from the controller
  19517. * @hidden
  19518. */
  19519. _pointingPoseNode: Nullable<TransformNode>;
  19520. /**
  19521. * Name of the child mesh that can be used to cast a ray from the controller
  19522. */
  19523. static readonly POINTING_POSE: string;
  19524. /**
  19525. * Creates a new PoseEnabledController from a gamepad
  19526. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19527. */
  19528. constructor(browserGamepad: any);
  19529. private _workingMatrix;
  19530. /**
  19531. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19532. */
  19533. update(): void;
  19534. /**
  19535. * Updates only the pose device and mesh without doing any button event checking
  19536. */
  19537. protected _updatePoseAndMesh(): void;
  19538. /**
  19539. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19540. * @param poseData raw pose fromthe device
  19541. */
  19542. updateFromDevice(poseData: DevicePose): void;
  19543. /**
  19544. * @hidden
  19545. */
  19546. _meshAttachedObservable: Observable<AbstractMesh>;
  19547. /**
  19548. * Attaches a mesh to the controller
  19549. * @param mesh the mesh to be attached
  19550. */
  19551. attachToMesh(mesh: AbstractMesh): void;
  19552. /**
  19553. * Attaches the controllers mesh to a camera
  19554. * @param camera the camera the mesh should be attached to
  19555. */
  19556. attachToPoseControlledCamera(camera: TargetCamera): void;
  19557. /**
  19558. * Disposes of the controller
  19559. */
  19560. dispose(): void;
  19561. /**
  19562. * The mesh that is attached to the controller
  19563. */
  19564. get mesh(): Nullable<AbstractMesh>;
  19565. /**
  19566. * Gets the ray of the controller in the direction the controller is pointing
  19567. * @param length the length the resulting ray should be
  19568. * @returns a ray in the direction the controller is pointing
  19569. */
  19570. getForwardRay(length?: number): Ray;
  19571. }
  19572. }
  19573. declare module BABYLON {
  19574. /**
  19575. * Defines the WebVRController object that represents controllers tracked in 3D space
  19576. */
  19577. export abstract class WebVRController extends PoseEnabledController {
  19578. /**
  19579. * Internal, the default controller model for the controller
  19580. */
  19581. protected _defaultModel: Nullable<AbstractMesh>;
  19582. /**
  19583. * Fired when the trigger state has changed
  19584. */
  19585. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19586. /**
  19587. * Fired when the main button state has changed
  19588. */
  19589. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19590. /**
  19591. * Fired when the secondary button state has changed
  19592. */
  19593. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19594. /**
  19595. * Fired when the pad state has changed
  19596. */
  19597. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19598. /**
  19599. * Fired when controllers stick values have changed
  19600. */
  19601. onPadValuesChangedObservable: Observable<StickValues>;
  19602. /**
  19603. * Array of button availible on the controller
  19604. */
  19605. protected _buttons: Array<MutableGamepadButton>;
  19606. private _onButtonStateChange;
  19607. /**
  19608. * Fired when a controller button's state has changed
  19609. * @param callback the callback containing the button that was modified
  19610. */
  19611. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19612. /**
  19613. * X and Y axis corresponding to the controllers joystick
  19614. */
  19615. pad: StickValues;
  19616. /**
  19617. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19618. */
  19619. hand: string;
  19620. /**
  19621. * The default controller model for the controller
  19622. */
  19623. get defaultModel(): Nullable<AbstractMesh>;
  19624. /**
  19625. * Creates a new WebVRController from a gamepad
  19626. * @param vrGamepad the gamepad that the WebVRController should be created from
  19627. */
  19628. constructor(vrGamepad: any);
  19629. /**
  19630. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19631. */
  19632. update(): void;
  19633. /**
  19634. * Function to be called when a button is modified
  19635. */
  19636. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19637. /**
  19638. * Loads a mesh and attaches it to the controller
  19639. * @param scene the scene the mesh should be added to
  19640. * @param meshLoaded callback for when the mesh has been loaded
  19641. */
  19642. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19643. private _setButtonValue;
  19644. private _changes;
  19645. private _checkChanges;
  19646. /**
  19647. * Disposes of th webVRCOntroller
  19648. */
  19649. dispose(): void;
  19650. }
  19651. }
  19652. declare module BABYLON {
  19653. /**
  19654. * The HemisphericLight simulates the ambient environment light,
  19655. * so the passed direction is the light reflection direction, not the incoming direction.
  19656. */
  19657. export class HemisphericLight extends Light {
  19658. /**
  19659. * The groundColor is the light in the opposite direction to the one specified during creation.
  19660. * 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.
  19661. */
  19662. groundColor: Color3;
  19663. /**
  19664. * The light reflection direction, not the incoming direction.
  19665. */
  19666. direction: Vector3;
  19667. /**
  19668. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19669. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19670. * The HemisphericLight can't cast shadows.
  19671. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19672. * @param name The friendly name of the light
  19673. * @param direction The direction of the light reflection
  19674. * @param scene The scene the light belongs to
  19675. */
  19676. constructor(name: string, direction: Vector3, scene: Scene);
  19677. protected _buildUniformLayout(): void;
  19678. /**
  19679. * Returns the string "HemisphericLight".
  19680. * @return The class name
  19681. */
  19682. getClassName(): string;
  19683. /**
  19684. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19685. * Returns the updated direction.
  19686. * @param target The target the direction should point to
  19687. * @return The computed direction
  19688. */
  19689. setDirectionToTarget(target: Vector3): Vector3;
  19690. /**
  19691. * Returns the shadow generator associated to the light.
  19692. * @returns Always null for hemispheric lights because it does not support shadows.
  19693. */
  19694. getShadowGenerator(): Nullable<IShadowGenerator>;
  19695. /**
  19696. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19697. * @param effect The effect to update
  19698. * @param lightIndex The index of the light in the effect to update
  19699. * @returns The hemispheric light
  19700. */
  19701. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19702. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19703. /**
  19704. * Computes the world matrix of the node
  19705. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19706. * @param useWasUpdatedFlag defines a reserved property
  19707. * @returns the world matrix
  19708. */
  19709. computeWorldMatrix(): Matrix;
  19710. /**
  19711. * Returns the integer 3.
  19712. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19713. */
  19714. getTypeID(): number;
  19715. /**
  19716. * Prepares the list of defines specific to the light type.
  19717. * @param defines the list of defines
  19718. * @param lightIndex defines the index of the light for the effect
  19719. */
  19720. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19721. }
  19722. }
  19723. declare module BABYLON {
  19724. /** @hidden */
  19725. export var vrMultiviewToSingleviewPixelShader: {
  19726. name: string;
  19727. shader: string;
  19728. };
  19729. }
  19730. declare module BABYLON {
  19731. /**
  19732. * Renders to multiple views with a single draw call
  19733. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19734. */
  19735. export class MultiviewRenderTarget extends RenderTargetTexture {
  19736. /**
  19737. * Creates a multiview render target
  19738. * @param scene scene used with the render target
  19739. * @param size the size of the render target (used for each view)
  19740. */
  19741. constructor(scene: Scene, size?: number | {
  19742. width: number;
  19743. height: number;
  19744. } | {
  19745. ratio: number;
  19746. });
  19747. /**
  19748. * @hidden
  19749. * @param faceIndex the face index, if its a cube texture
  19750. */
  19751. _bindFrameBuffer(faceIndex?: number): void;
  19752. /**
  19753. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19754. * @returns the view count
  19755. */
  19756. getViewCount(): number;
  19757. }
  19758. }
  19759. declare module BABYLON {
  19760. interface Engine {
  19761. /**
  19762. * Creates a new multiview render target
  19763. * @param width defines the width of the texture
  19764. * @param height defines the height of the texture
  19765. * @returns the created multiview texture
  19766. */
  19767. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19768. /**
  19769. * Binds a multiview framebuffer to be drawn to
  19770. * @param multiviewTexture texture to bind
  19771. */
  19772. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19773. }
  19774. interface Camera {
  19775. /**
  19776. * @hidden
  19777. * 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)
  19778. */
  19779. _useMultiviewToSingleView: boolean;
  19780. /**
  19781. * @hidden
  19782. * 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)
  19783. */
  19784. _multiviewTexture: Nullable<RenderTargetTexture>;
  19785. /**
  19786. * @hidden
  19787. * ensures the multiview texture of the camera exists and has the specified width/height
  19788. * @param width height to set on the multiview texture
  19789. * @param height width to set on the multiview texture
  19790. */
  19791. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19792. }
  19793. interface Scene {
  19794. /** @hidden */
  19795. _transformMatrixR: Matrix;
  19796. /** @hidden */
  19797. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19798. /** @hidden */
  19799. _createMultiviewUbo(): void;
  19800. /** @hidden */
  19801. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19802. /** @hidden */
  19803. _renderMultiviewToSingleView(camera: Camera): void;
  19804. }
  19805. }
  19806. declare module BABYLON {
  19807. /**
  19808. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19809. * This will not be used for webXR as it supports displaying texture arrays directly
  19810. */
  19811. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19812. /**
  19813. * Gets a string identifying the name of the class
  19814. * @returns "VRMultiviewToSingleviewPostProcess" string
  19815. */
  19816. getClassName(): string;
  19817. /**
  19818. * Initializes a VRMultiviewToSingleview
  19819. * @param name name of the post process
  19820. * @param camera camera to be applied to
  19821. * @param scaleFactor scaling factor to the size of the output texture
  19822. */
  19823. constructor(name: string, camera: Camera, scaleFactor: number);
  19824. }
  19825. }
  19826. declare module BABYLON {
  19827. /**
  19828. * Interface used to define additional presentation attributes
  19829. */
  19830. export interface IVRPresentationAttributes {
  19831. /**
  19832. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19833. */
  19834. highRefreshRate: boolean;
  19835. /**
  19836. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19837. */
  19838. foveationLevel: number;
  19839. }
  19840. interface Engine {
  19841. /** @hidden */
  19842. _vrDisplay: any;
  19843. /** @hidden */
  19844. _vrSupported: boolean;
  19845. /** @hidden */
  19846. _oldSize: Size;
  19847. /** @hidden */
  19848. _oldHardwareScaleFactor: number;
  19849. /** @hidden */
  19850. _vrExclusivePointerMode: boolean;
  19851. /** @hidden */
  19852. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19853. /** @hidden */
  19854. _onVRDisplayPointerRestricted: () => void;
  19855. /** @hidden */
  19856. _onVRDisplayPointerUnrestricted: () => void;
  19857. /** @hidden */
  19858. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19859. /** @hidden */
  19860. _onVrDisplayDisconnect: Nullable<() => void>;
  19861. /** @hidden */
  19862. _onVrDisplayPresentChange: Nullable<() => void>;
  19863. /**
  19864. * Observable signaled when VR display mode changes
  19865. */
  19866. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19867. /**
  19868. * Observable signaled when VR request present is complete
  19869. */
  19870. onVRRequestPresentComplete: Observable<boolean>;
  19871. /**
  19872. * Observable signaled when VR request present starts
  19873. */
  19874. onVRRequestPresentStart: Observable<Engine>;
  19875. /**
  19876. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19877. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19878. */
  19879. isInVRExclusivePointerMode: boolean;
  19880. /**
  19881. * Gets a boolean indicating if a webVR device was detected
  19882. * @returns true if a webVR device was detected
  19883. */
  19884. isVRDevicePresent(): boolean;
  19885. /**
  19886. * Gets the current webVR device
  19887. * @returns the current webVR device (or null)
  19888. */
  19889. getVRDevice(): any;
  19890. /**
  19891. * Initializes a webVR display and starts listening to display change events
  19892. * The onVRDisplayChangedObservable will be notified upon these changes
  19893. * @returns A promise containing a VRDisplay and if vr is supported
  19894. */
  19895. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19896. /** @hidden */
  19897. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19898. /**
  19899. * Gets or sets the presentation attributes used to configure VR rendering
  19900. */
  19901. vrPresentationAttributes?: IVRPresentationAttributes;
  19902. /**
  19903. * Call this function to switch to webVR mode
  19904. * Will do nothing if webVR is not supported or if there is no webVR device
  19905. * @param options the webvr options provided to the camera. mainly used for multiview
  19906. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19907. */
  19908. enableVR(options: WebVROptions): void;
  19909. /** @hidden */
  19910. _onVRFullScreenTriggered(): void;
  19911. }
  19912. }
  19913. declare module BABYLON {
  19914. /**
  19915. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19916. * IMPORTANT!! The data is right-hand data.
  19917. * @export
  19918. * @interface DevicePose
  19919. */
  19920. export interface DevicePose {
  19921. /**
  19922. * The position of the device, values in array are [x,y,z].
  19923. */
  19924. readonly position: Nullable<Float32Array>;
  19925. /**
  19926. * The linearVelocity of the device, values in array are [x,y,z].
  19927. */
  19928. readonly linearVelocity: Nullable<Float32Array>;
  19929. /**
  19930. * The linearAcceleration of the device, values in array are [x,y,z].
  19931. */
  19932. readonly linearAcceleration: Nullable<Float32Array>;
  19933. /**
  19934. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19935. */
  19936. readonly orientation: Nullable<Float32Array>;
  19937. /**
  19938. * The angularVelocity of the device, values in array are [x,y,z].
  19939. */
  19940. readonly angularVelocity: Nullable<Float32Array>;
  19941. /**
  19942. * The angularAcceleration of the device, values in array are [x,y,z].
  19943. */
  19944. readonly angularAcceleration: Nullable<Float32Array>;
  19945. }
  19946. /**
  19947. * Interface representing a pose controlled object in Babylon.
  19948. * A pose controlled object has both regular pose values as well as pose values
  19949. * from an external device such as a VR head mounted display
  19950. */
  19951. export interface PoseControlled {
  19952. /**
  19953. * The position of the object in babylon space.
  19954. */
  19955. position: Vector3;
  19956. /**
  19957. * The rotation quaternion of the object in babylon space.
  19958. */
  19959. rotationQuaternion: Quaternion;
  19960. /**
  19961. * The position of the device in babylon space.
  19962. */
  19963. devicePosition?: Vector3;
  19964. /**
  19965. * The rotation quaternion of the device in babylon space.
  19966. */
  19967. deviceRotationQuaternion: Quaternion;
  19968. /**
  19969. * The raw pose coming from the device.
  19970. */
  19971. rawPose: Nullable<DevicePose>;
  19972. /**
  19973. * The scale of the device to be used when translating from device space to babylon space.
  19974. */
  19975. deviceScaleFactor: number;
  19976. /**
  19977. * Updates the poseControlled values based on the input device pose.
  19978. * @param poseData the pose data to update the object with
  19979. */
  19980. updateFromDevice(poseData: DevicePose): void;
  19981. }
  19982. /**
  19983. * Set of options to customize the webVRCamera
  19984. */
  19985. export interface WebVROptions {
  19986. /**
  19987. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19988. */
  19989. trackPosition?: boolean;
  19990. /**
  19991. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19992. */
  19993. positionScale?: number;
  19994. /**
  19995. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19996. */
  19997. displayName?: string;
  19998. /**
  19999. * Should the native controller meshes be initialized. (default: true)
  20000. */
  20001. controllerMeshes?: boolean;
  20002. /**
  20003. * Creating a default HemiLight only on controllers. (default: true)
  20004. */
  20005. defaultLightingOnControllers?: boolean;
  20006. /**
  20007. * If you don't want to use the default VR button of the helper. (default: false)
  20008. */
  20009. useCustomVRButton?: boolean;
  20010. /**
  20011. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20012. */
  20013. customVRButton?: HTMLButtonElement;
  20014. /**
  20015. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20016. */
  20017. rayLength?: number;
  20018. /**
  20019. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20020. */
  20021. defaultHeight?: number;
  20022. /**
  20023. * If multiview should be used if availible (default: false)
  20024. */
  20025. useMultiview?: boolean;
  20026. }
  20027. /**
  20028. * This represents a WebVR camera.
  20029. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20030. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20031. */
  20032. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20033. private webVROptions;
  20034. /**
  20035. * @hidden
  20036. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20037. */
  20038. _vrDevice: any;
  20039. /**
  20040. * The rawPose of the vrDevice.
  20041. */
  20042. rawPose: Nullable<DevicePose>;
  20043. private _onVREnabled;
  20044. private _specsVersion;
  20045. private _attached;
  20046. private _frameData;
  20047. protected _descendants: Array<Node>;
  20048. private _deviceRoomPosition;
  20049. /** @hidden */
  20050. _deviceRoomRotationQuaternion: Quaternion;
  20051. private _standingMatrix;
  20052. /**
  20053. * Represents device position in babylon space.
  20054. */
  20055. devicePosition: Vector3;
  20056. /**
  20057. * Represents device rotation in babylon space.
  20058. */
  20059. deviceRotationQuaternion: Quaternion;
  20060. /**
  20061. * The scale of the device to be used when translating from device space to babylon space.
  20062. */
  20063. deviceScaleFactor: number;
  20064. private _deviceToWorld;
  20065. private _worldToDevice;
  20066. /**
  20067. * References to the webVR controllers for the vrDevice.
  20068. */
  20069. controllers: Array<WebVRController>;
  20070. /**
  20071. * Emits an event when a controller is attached.
  20072. */
  20073. onControllersAttachedObservable: Observable<WebVRController[]>;
  20074. /**
  20075. * Emits an event when a controller's mesh has been loaded;
  20076. */
  20077. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20078. /**
  20079. * Emits an event when the HMD's pose has been updated.
  20080. */
  20081. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20082. private _poseSet;
  20083. /**
  20084. * If the rig cameras be used as parent instead of this camera.
  20085. */
  20086. rigParenting: boolean;
  20087. private _lightOnControllers;
  20088. private _defaultHeight?;
  20089. /**
  20090. * Instantiates a WebVRFreeCamera.
  20091. * @param name The name of the WebVRFreeCamera
  20092. * @param position The starting anchor position for the camera
  20093. * @param scene The scene the camera belongs to
  20094. * @param webVROptions a set of customizable options for the webVRCamera
  20095. */
  20096. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20097. /**
  20098. * Gets the device distance from the ground in meters.
  20099. * @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.
  20100. */
  20101. deviceDistanceToRoomGround(): number;
  20102. /**
  20103. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20104. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20105. */
  20106. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20107. /**
  20108. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20109. * @returns A promise with a boolean set to if the standing matrix is supported.
  20110. */
  20111. useStandingMatrixAsync(): Promise<boolean>;
  20112. /**
  20113. * Disposes the camera
  20114. */
  20115. dispose(): void;
  20116. /**
  20117. * Gets a vrController by name.
  20118. * @param name The name of the controller to retreive
  20119. * @returns the controller matching the name specified or null if not found
  20120. */
  20121. getControllerByName(name: string): Nullable<WebVRController>;
  20122. private _leftController;
  20123. /**
  20124. * The controller corresponding to the users left hand.
  20125. */
  20126. get leftController(): Nullable<WebVRController>;
  20127. private _rightController;
  20128. /**
  20129. * The controller corresponding to the users right hand.
  20130. */
  20131. get rightController(): Nullable<WebVRController>;
  20132. /**
  20133. * Casts a ray forward from the vrCamera's gaze.
  20134. * @param length Length of the ray (default: 100)
  20135. * @returns the ray corresponding to the gaze
  20136. */
  20137. getForwardRay(length?: number): Ray;
  20138. /**
  20139. * @hidden
  20140. * Updates the camera based on device's frame data
  20141. */
  20142. _checkInputs(): void;
  20143. /**
  20144. * Updates the poseControlled values based on the input device pose.
  20145. * @param poseData Pose coming from the device
  20146. */
  20147. updateFromDevice(poseData: DevicePose): void;
  20148. private _htmlElementAttached;
  20149. private _detachIfAttached;
  20150. /**
  20151. * WebVR's attach control will start broadcasting frames to the device.
  20152. * Note that in certain browsers (chrome for example) this function must be called
  20153. * within a user-interaction callback. Example:
  20154. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20155. *
  20156. * @param element html element to attach the vrDevice to
  20157. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20158. */
  20159. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20160. /**
  20161. * Detaches the camera from the html element and disables VR
  20162. *
  20163. * @param element html element to detach from
  20164. */
  20165. detachControl(element: HTMLElement): void;
  20166. /**
  20167. * @returns the name of this class
  20168. */
  20169. getClassName(): string;
  20170. /**
  20171. * Calls resetPose on the vrDisplay
  20172. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20173. */
  20174. resetToCurrentRotation(): void;
  20175. /**
  20176. * @hidden
  20177. * Updates the rig cameras (left and right eye)
  20178. */
  20179. _updateRigCameras(): void;
  20180. private _workingVector;
  20181. private _oneVector;
  20182. private _workingMatrix;
  20183. private updateCacheCalled;
  20184. private _correctPositionIfNotTrackPosition;
  20185. /**
  20186. * @hidden
  20187. * Updates the cached values of the camera
  20188. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20189. */
  20190. _updateCache(ignoreParentClass?: boolean): void;
  20191. /**
  20192. * @hidden
  20193. * Get current device position in babylon world
  20194. */
  20195. _computeDevicePosition(): void;
  20196. /**
  20197. * Updates the current device position and rotation in the babylon world
  20198. */
  20199. update(): void;
  20200. /**
  20201. * @hidden
  20202. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20203. * @returns an identity matrix
  20204. */
  20205. _getViewMatrix(): Matrix;
  20206. private _tmpMatrix;
  20207. /**
  20208. * This function is called by the two RIG cameras.
  20209. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20210. * @hidden
  20211. */
  20212. _getWebVRViewMatrix(): Matrix;
  20213. /** @hidden */
  20214. _getWebVRProjectionMatrix(): Matrix;
  20215. private _onGamepadConnectedObserver;
  20216. private _onGamepadDisconnectedObserver;
  20217. private _updateCacheWhenTrackingDisabledObserver;
  20218. /**
  20219. * Initializes the controllers and their meshes
  20220. */
  20221. initControllers(): void;
  20222. }
  20223. }
  20224. declare module BABYLON {
  20225. /**
  20226. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20227. *
  20228. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20229. *
  20230. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20231. */
  20232. export class MaterialHelper {
  20233. /**
  20234. * Bind the current view position to an effect.
  20235. * @param effect The effect to be bound
  20236. * @param scene The scene the eyes position is used from
  20237. * @param variableName name of the shader variable that will hold the eye position
  20238. */
  20239. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20240. /**
  20241. * Helps preparing the defines values about the UVs in used in the effect.
  20242. * UVs are shared as much as we can accross channels in the shaders.
  20243. * @param texture The texture we are preparing the UVs for
  20244. * @param defines The defines to update
  20245. * @param key The channel key "diffuse", "specular"... used in the shader
  20246. */
  20247. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20248. /**
  20249. * Binds a texture matrix value to its corrsponding uniform
  20250. * @param texture The texture to bind the matrix for
  20251. * @param uniformBuffer The uniform buffer receivin the data
  20252. * @param key The channel key "diffuse", "specular"... used in the shader
  20253. */
  20254. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20255. /**
  20256. * Gets the current status of the fog (should it be enabled?)
  20257. * @param mesh defines the mesh to evaluate for fog support
  20258. * @param scene defines the hosting scene
  20259. * @returns true if fog must be enabled
  20260. */
  20261. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20262. /**
  20263. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20264. * @param mesh defines the current mesh
  20265. * @param scene defines the current scene
  20266. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20267. * @param pointsCloud defines if point cloud rendering has to be turned on
  20268. * @param fogEnabled defines if fog has to be turned on
  20269. * @param alphaTest defines if alpha testing has to be turned on
  20270. * @param defines defines the current list of defines
  20271. */
  20272. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20273. /**
  20274. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20275. * @param scene defines the current scene
  20276. * @param engine defines the current engine
  20277. * @param defines specifies the list of active defines
  20278. * @param useInstances defines if instances have to be turned on
  20279. * @param useClipPlane defines if clip plane have to be turned on
  20280. * @param useInstances defines if instances have to be turned on
  20281. * @param useThinInstances defines if thin instances have to be turned on
  20282. */
  20283. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20284. /**
  20285. * Prepares the defines for bones
  20286. * @param mesh The mesh containing the geometry data we will draw
  20287. * @param defines The defines to update
  20288. */
  20289. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20290. /**
  20291. * Prepares the defines for morph targets
  20292. * @param mesh The mesh containing the geometry data we will draw
  20293. * @param defines The defines to update
  20294. */
  20295. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20296. /**
  20297. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20298. * @param mesh The mesh containing the geometry data we will draw
  20299. * @param defines The defines to update
  20300. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20301. * @param useBones Precise whether bones should be used or not (override mesh info)
  20302. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20303. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20304. * @returns false if defines are considered not dirty and have not been checked
  20305. */
  20306. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20307. /**
  20308. * Prepares the defines related to multiview
  20309. * @param scene The scene we are intending to draw
  20310. * @param defines The defines to update
  20311. */
  20312. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20313. /**
  20314. * Prepares the defines related to the prepass
  20315. * @param scene The scene we are intending to draw
  20316. * @param defines The defines to update
  20317. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20318. */
  20319. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20320. /**
  20321. * Prepares the defines related to the light information passed in parameter
  20322. * @param scene The scene we are intending to draw
  20323. * @param mesh The mesh the effect is compiling for
  20324. * @param light The light the effect is compiling for
  20325. * @param lightIndex The index of the light
  20326. * @param defines The defines to update
  20327. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20328. * @param state Defines the current state regarding what is needed (normals, etc...)
  20329. */
  20330. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20331. needNormals: boolean;
  20332. needRebuild: boolean;
  20333. shadowEnabled: boolean;
  20334. specularEnabled: boolean;
  20335. lightmapMode: boolean;
  20336. }): void;
  20337. /**
  20338. * Prepares the defines related to the light information passed in parameter
  20339. * @param scene The scene we are intending to draw
  20340. * @param mesh The mesh the effect is compiling for
  20341. * @param defines The defines to update
  20342. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20343. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20344. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20345. * @returns true if normals will be required for the rest of the effect
  20346. */
  20347. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20348. /**
  20349. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20350. * @param lightIndex defines the light index
  20351. * @param uniformsList The uniform list
  20352. * @param samplersList The sampler list
  20353. * @param projectedLightTexture defines if projected texture must be used
  20354. * @param uniformBuffersList defines an optional list of uniform buffers
  20355. */
  20356. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20357. /**
  20358. * Prepares the uniforms and samplers list to be used in the effect
  20359. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20360. * @param samplersList The sampler list
  20361. * @param defines The defines helping in the list generation
  20362. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20363. */
  20364. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20365. /**
  20366. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20367. * @param defines The defines to update while falling back
  20368. * @param fallbacks The authorized effect fallbacks
  20369. * @param maxSimultaneousLights The maximum number of lights allowed
  20370. * @param rank the current rank of the Effect
  20371. * @returns The newly affected rank
  20372. */
  20373. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20374. private static _TmpMorphInfluencers;
  20375. /**
  20376. * Prepares the list of attributes required for morph targets according to the effect defines.
  20377. * @param attribs The current list of supported attribs
  20378. * @param mesh The mesh to prepare the morph targets attributes for
  20379. * @param influencers The number of influencers
  20380. */
  20381. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20382. /**
  20383. * Prepares the list of attributes required for morph targets according to the effect defines.
  20384. * @param attribs The current list of supported attribs
  20385. * @param mesh The mesh to prepare the morph targets attributes for
  20386. * @param defines The current Defines of the effect
  20387. */
  20388. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20389. /**
  20390. * Prepares the list of attributes required for bones according to the effect defines.
  20391. * @param attribs The current list of supported attribs
  20392. * @param mesh The mesh to prepare the bones attributes for
  20393. * @param defines The current Defines of the effect
  20394. * @param fallbacks The current efffect fallback strategy
  20395. */
  20396. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20397. /**
  20398. * Check and prepare the list of attributes required for instances according to the effect defines.
  20399. * @param attribs The current list of supported attribs
  20400. * @param defines The current MaterialDefines of the effect
  20401. */
  20402. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20403. /**
  20404. * Add the list of attributes required for instances to the attribs array.
  20405. * @param attribs The current list of supported attribs
  20406. */
  20407. static PushAttributesForInstances(attribs: string[]): void;
  20408. /**
  20409. * Binds the light information to the effect.
  20410. * @param light The light containing the generator
  20411. * @param effect The effect we are binding the data to
  20412. * @param lightIndex The light index in the effect used to render
  20413. */
  20414. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20415. /**
  20416. * Binds the lights information from the scene to the effect for the given mesh.
  20417. * @param light Light to bind
  20418. * @param lightIndex Light index
  20419. * @param scene The scene where the light belongs to
  20420. * @param effect The effect we are binding the data to
  20421. * @param useSpecular Defines if specular is supported
  20422. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20423. */
  20424. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20425. /**
  20426. * Binds the lights information from the scene to the effect for the given mesh.
  20427. * @param scene The scene the lights belongs to
  20428. * @param mesh The mesh we are binding the information to render
  20429. * @param effect The effect we are binding the data to
  20430. * @param defines The generated defines for the effect
  20431. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20432. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20433. */
  20434. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20435. private static _tempFogColor;
  20436. /**
  20437. * Binds the fog information from the scene to the effect for the given mesh.
  20438. * @param scene The scene the lights belongs to
  20439. * @param mesh The mesh we are binding the information to render
  20440. * @param effect The effect we are binding the data to
  20441. * @param linearSpace Defines if the fog effect is applied in linear space
  20442. */
  20443. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20444. /**
  20445. * Binds the bones information from the mesh to the effect.
  20446. * @param mesh The mesh we are binding the information to render
  20447. * @param effect The effect we are binding the data to
  20448. */
  20449. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20450. /**
  20451. * Binds the morph targets information from the mesh to the effect.
  20452. * @param abstractMesh The mesh we are binding the information to render
  20453. * @param effect The effect we are binding the data to
  20454. */
  20455. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20456. /**
  20457. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20458. * @param defines The generated defines used in the effect
  20459. * @param effect The effect we are binding the data to
  20460. * @param scene The scene we are willing to render with logarithmic scale for
  20461. */
  20462. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20463. /**
  20464. * Binds the clip plane information from the scene to the effect.
  20465. * @param scene The scene the clip plane information are extracted from
  20466. * @param effect The effect we are binding the data to
  20467. */
  20468. static BindClipPlane(effect: Effect, scene: Scene): void;
  20469. }
  20470. }
  20471. declare module BABYLON {
  20472. /**
  20473. * Block used to expose an input value
  20474. */
  20475. export class InputBlock extends NodeMaterialBlock {
  20476. private _mode;
  20477. private _associatedVariableName;
  20478. private _storedValue;
  20479. private _valueCallback;
  20480. private _type;
  20481. private _animationType;
  20482. /** Gets or set a value used to limit the range of float values */
  20483. min: number;
  20484. /** Gets or set a value used to limit the range of float values */
  20485. max: number;
  20486. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20487. isBoolean: boolean;
  20488. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20489. matrixMode: number;
  20490. /** @hidden */
  20491. _systemValue: Nullable<NodeMaterialSystemValues>;
  20492. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20493. isConstant: boolean;
  20494. /** Gets or sets the group to use to display this block in the Inspector */
  20495. groupInInspector: string;
  20496. /** Gets an observable raised when the value is changed */
  20497. onValueChangedObservable: Observable<InputBlock>;
  20498. /**
  20499. * Gets or sets the connection point type (default is float)
  20500. */
  20501. get type(): NodeMaterialBlockConnectionPointTypes;
  20502. /**
  20503. * Creates a new InputBlock
  20504. * @param name defines the block name
  20505. * @param target defines the target of that block (Vertex by default)
  20506. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20507. */
  20508. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20509. /**
  20510. * Validates if a name is a reserve word.
  20511. * @param newName the new name to be given to the node.
  20512. * @returns false if the name is a reserve word, else true.
  20513. */
  20514. validateBlockName(newName: string): boolean;
  20515. /**
  20516. * Gets the output component
  20517. */
  20518. get output(): NodeMaterialConnectionPoint;
  20519. /**
  20520. * Set the source of this connection point to a vertex attribute
  20521. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20522. * @returns the current connection point
  20523. */
  20524. setAsAttribute(attributeName?: string): InputBlock;
  20525. /**
  20526. * Set the source of this connection point to a system value
  20527. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20528. * @returns the current connection point
  20529. */
  20530. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20531. /**
  20532. * Gets or sets the value of that point.
  20533. * Please note that this value will be ignored if valueCallback is defined
  20534. */
  20535. get value(): any;
  20536. set value(value: any);
  20537. /**
  20538. * Gets or sets a callback used to get the value of that point.
  20539. * Please note that setting this value will force the connection point to ignore the value property
  20540. */
  20541. get valueCallback(): () => any;
  20542. set valueCallback(value: () => any);
  20543. /**
  20544. * Gets or sets the associated variable name in the shader
  20545. */
  20546. get associatedVariableName(): string;
  20547. set associatedVariableName(value: string);
  20548. /** Gets or sets the type of animation applied to the input */
  20549. get animationType(): AnimatedInputBlockTypes;
  20550. set animationType(value: AnimatedInputBlockTypes);
  20551. /**
  20552. * Gets a boolean indicating that this connection point not defined yet
  20553. */
  20554. get isUndefined(): boolean;
  20555. /**
  20556. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20557. * In this case the connection point name must be the name of the uniform to use.
  20558. * Can only be set on inputs
  20559. */
  20560. get isUniform(): boolean;
  20561. set isUniform(value: boolean);
  20562. /**
  20563. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20564. * In this case the connection point name must be the name of the attribute to use
  20565. * Can only be set on inputs
  20566. */
  20567. get isAttribute(): boolean;
  20568. set isAttribute(value: boolean);
  20569. /**
  20570. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20571. * Can only be set on exit points
  20572. */
  20573. get isVarying(): boolean;
  20574. set isVarying(value: boolean);
  20575. /**
  20576. * Gets a boolean indicating that the current connection point is a system value
  20577. */
  20578. get isSystemValue(): boolean;
  20579. /**
  20580. * Gets or sets the current well known value or null if not defined as a system value
  20581. */
  20582. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20583. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20584. /**
  20585. * Gets the current class name
  20586. * @returns the class name
  20587. */
  20588. getClassName(): string;
  20589. /**
  20590. * Animate the input if animationType !== None
  20591. * @param scene defines the rendering scene
  20592. */
  20593. animate(scene: Scene): void;
  20594. private _emitDefine;
  20595. initialize(state: NodeMaterialBuildState): void;
  20596. /**
  20597. * Set the input block to its default value (based on its type)
  20598. */
  20599. setDefaultValue(): void;
  20600. private _emitConstant;
  20601. /** @hidden */
  20602. get _noContextSwitch(): boolean;
  20603. private _emit;
  20604. /** @hidden */
  20605. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20606. /** @hidden */
  20607. _transmit(effect: Effect, scene: Scene): void;
  20608. protected _buildBlock(state: NodeMaterialBuildState): void;
  20609. protected _dumpPropertiesCode(): string;
  20610. dispose(): void;
  20611. serialize(): any;
  20612. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20613. }
  20614. }
  20615. declare module BABYLON {
  20616. /**
  20617. * Enum used to define the compatibility state between two connection points
  20618. */
  20619. export enum NodeMaterialConnectionPointCompatibilityStates {
  20620. /** Points are compatibles */
  20621. Compatible = 0,
  20622. /** Points are incompatible because of their types */
  20623. TypeIncompatible = 1,
  20624. /** Points are incompatible because of their targets (vertex vs fragment) */
  20625. TargetIncompatible = 2
  20626. }
  20627. /**
  20628. * Defines the direction of a connection point
  20629. */
  20630. export enum NodeMaterialConnectionPointDirection {
  20631. /** Input */
  20632. Input = 0,
  20633. /** Output */
  20634. Output = 1
  20635. }
  20636. /**
  20637. * Defines a connection point for a block
  20638. */
  20639. export class NodeMaterialConnectionPoint {
  20640. /** @hidden */
  20641. _ownerBlock: NodeMaterialBlock;
  20642. /** @hidden */
  20643. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20644. private _endpoints;
  20645. private _associatedVariableName;
  20646. private _direction;
  20647. /** @hidden */
  20648. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20649. /** @hidden */
  20650. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20651. private _type;
  20652. /** @hidden */
  20653. _enforceAssociatedVariableName: boolean;
  20654. /** Gets the direction of the point */
  20655. get direction(): NodeMaterialConnectionPointDirection;
  20656. /** Indicates that this connection point needs dual validation before being connected to another point */
  20657. needDualDirectionValidation: boolean;
  20658. /**
  20659. * Gets or sets the additional types supported by this connection point
  20660. */
  20661. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20662. /**
  20663. * Gets or sets the additional types excluded by this connection point
  20664. */
  20665. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20666. /**
  20667. * Observable triggered when this point is connected
  20668. */
  20669. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20670. /**
  20671. * Gets or sets the associated variable name in the shader
  20672. */
  20673. get associatedVariableName(): string;
  20674. set associatedVariableName(value: string);
  20675. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20676. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20677. /**
  20678. * Gets or sets the connection point type (default is float)
  20679. */
  20680. get type(): NodeMaterialBlockConnectionPointTypes;
  20681. set type(value: NodeMaterialBlockConnectionPointTypes);
  20682. /**
  20683. * Gets or sets the connection point name
  20684. */
  20685. name: string;
  20686. /**
  20687. * Gets or sets the connection point name
  20688. */
  20689. displayName: string;
  20690. /**
  20691. * Gets or sets a boolean indicating that this connection point can be omitted
  20692. */
  20693. isOptional: boolean;
  20694. /**
  20695. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20696. */
  20697. isExposedOnFrame: boolean;
  20698. /**
  20699. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20700. */
  20701. define: string;
  20702. /** @hidden */
  20703. _prioritizeVertex: boolean;
  20704. private _target;
  20705. /** Gets or sets the target of that connection point */
  20706. get target(): NodeMaterialBlockTargets;
  20707. set target(value: NodeMaterialBlockTargets);
  20708. /**
  20709. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20710. */
  20711. get isConnected(): boolean;
  20712. /**
  20713. * Gets a boolean indicating that the current point is connected to an input block
  20714. */
  20715. get isConnectedToInputBlock(): boolean;
  20716. /**
  20717. * Gets a the connected input block (if any)
  20718. */
  20719. get connectInputBlock(): Nullable<InputBlock>;
  20720. /** Get the other side of the connection (if any) */
  20721. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20722. /** Get the block that owns this connection point */
  20723. get ownerBlock(): NodeMaterialBlock;
  20724. /** Get the block connected on the other side of this connection (if any) */
  20725. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20726. /** Get the block connected on the endpoints of this connection (if any) */
  20727. get connectedBlocks(): Array<NodeMaterialBlock>;
  20728. /** Gets the list of connected endpoints */
  20729. get endpoints(): NodeMaterialConnectionPoint[];
  20730. /** Gets a boolean indicating if that output point is connected to at least one input */
  20731. get hasEndpoints(): boolean;
  20732. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20733. get isConnectedInVertexShader(): boolean;
  20734. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20735. get isConnectedInFragmentShader(): boolean;
  20736. /**
  20737. * Creates a block suitable to be used as an input for this input point.
  20738. * If null is returned, a block based on the point type will be created.
  20739. * @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
  20740. */
  20741. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20742. /**
  20743. * Creates a new connection point
  20744. * @param name defines the connection point name
  20745. * @param ownerBlock defines the block hosting this connection point
  20746. * @param direction defines the direction of the connection point
  20747. */
  20748. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20749. /**
  20750. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20751. * @returns the class name
  20752. */
  20753. getClassName(): string;
  20754. /**
  20755. * Gets a boolean indicating if the current point can be connected to another point
  20756. * @param connectionPoint defines the other connection point
  20757. * @returns a boolean
  20758. */
  20759. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20760. /**
  20761. * Gets a number indicating if the current point can be connected to another point
  20762. * @param connectionPoint defines the other connection point
  20763. * @returns a number defining the compatibility state
  20764. */
  20765. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20766. /**
  20767. * Connect this point to another connection point
  20768. * @param connectionPoint defines the other connection point
  20769. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20770. * @returns the current connection point
  20771. */
  20772. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20773. /**
  20774. * Disconnect this point from one of his endpoint
  20775. * @param endpoint defines the other connection point
  20776. * @returns the current connection point
  20777. */
  20778. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20779. /**
  20780. * Serializes this point in a JSON representation
  20781. * @param isInput defines if the connection point is an input (default is true)
  20782. * @returns the serialized point object
  20783. */
  20784. serialize(isInput?: boolean): any;
  20785. /**
  20786. * Release resources
  20787. */
  20788. dispose(): void;
  20789. }
  20790. }
  20791. declare module BABYLON {
  20792. /**
  20793. * Enum used to define the material modes
  20794. */
  20795. export enum NodeMaterialModes {
  20796. /** Regular material */
  20797. Material = 0,
  20798. /** For post process */
  20799. PostProcess = 1,
  20800. /** For particle system */
  20801. Particle = 2,
  20802. /** For procedural texture */
  20803. ProceduralTexture = 3
  20804. }
  20805. }
  20806. declare module BABYLON {
  20807. /**
  20808. * Block used to read a texture from a sampler
  20809. */
  20810. export class TextureBlock extends NodeMaterialBlock {
  20811. private _defineName;
  20812. private _linearDefineName;
  20813. private _gammaDefineName;
  20814. private _tempTextureRead;
  20815. private _samplerName;
  20816. private _transformedUVName;
  20817. private _textureTransformName;
  20818. private _textureInfoName;
  20819. private _mainUVName;
  20820. private _mainUVDefineName;
  20821. private _fragmentOnly;
  20822. /**
  20823. * Gets or sets the texture associated with the node
  20824. */
  20825. texture: Nullable<Texture>;
  20826. /**
  20827. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20828. */
  20829. convertToGammaSpace: boolean;
  20830. /**
  20831. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20832. */
  20833. convertToLinearSpace: boolean;
  20834. /**
  20835. * Create a new TextureBlock
  20836. * @param name defines the block name
  20837. */
  20838. constructor(name: string, fragmentOnly?: boolean);
  20839. /**
  20840. * Gets the current class name
  20841. * @returns the class name
  20842. */
  20843. getClassName(): string;
  20844. /**
  20845. * Gets the uv input component
  20846. */
  20847. get uv(): NodeMaterialConnectionPoint;
  20848. /**
  20849. * Gets the rgba output component
  20850. */
  20851. get rgba(): NodeMaterialConnectionPoint;
  20852. /**
  20853. * Gets the rgb output component
  20854. */
  20855. get rgb(): NodeMaterialConnectionPoint;
  20856. /**
  20857. * Gets the r output component
  20858. */
  20859. get r(): NodeMaterialConnectionPoint;
  20860. /**
  20861. * Gets the g output component
  20862. */
  20863. get g(): NodeMaterialConnectionPoint;
  20864. /**
  20865. * Gets the b output component
  20866. */
  20867. get b(): NodeMaterialConnectionPoint;
  20868. /**
  20869. * Gets the a output component
  20870. */
  20871. get a(): NodeMaterialConnectionPoint;
  20872. get target(): NodeMaterialBlockTargets;
  20873. autoConfigure(material: NodeMaterial): void;
  20874. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20875. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20876. isReady(): boolean;
  20877. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20878. private get _isMixed();
  20879. private _injectVertexCode;
  20880. private _writeTextureRead;
  20881. private _writeOutput;
  20882. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20883. protected _dumpPropertiesCode(): string;
  20884. serialize(): any;
  20885. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20886. }
  20887. }
  20888. declare module BABYLON {
  20889. /** @hidden */
  20890. export var reflectionFunction: {
  20891. name: string;
  20892. shader: string;
  20893. };
  20894. }
  20895. declare module BABYLON {
  20896. /**
  20897. * Base block used to read a reflection texture from a sampler
  20898. */
  20899. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20900. /** @hidden */
  20901. _define3DName: string;
  20902. /** @hidden */
  20903. _defineCubicName: string;
  20904. /** @hidden */
  20905. _defineExplicitName: string;
  20906. /** @hidden */
  20907. _defineProjectionName: string;
  20908. /** @hidden */
  20909. _defineLocalCubicName: string;
  20910. /** @hidden */
  20911. _defineSphericalName: string;
  20912. /** @hidden */
  20913. _definePlanarName: string;
  20914. /** @hidden */
  20915. _defineEquirectangularName: string;
  20916. /** @hidden */
  20917. _defineMirroredEquirectangularFixedName: string;
  20918. /** @hidden */
  20919. _defineEquirectangularFixedName: string;
  20920. /** @hidden */
  20921. _defineSkyboxName: string;
  20922. /** @hidden */
  20923. _defineOppositeZ: string;
  20924. /** @hidden */
  20925. _cubeSamplerName: string;
  20926. /** @hidden */
  20927. _2DSamplerName: string;
  20928. protected _positionUVWName: string;
  20929. protected _directionWName: string;
  20930. protected _reflectionVectorName: string;
  20931. /** @hidden */
  20932. _reflectionCoordsName: string;
  20933. /** @hidden */
  20934. _reflectionMatrixName: string;
  20935. protected _reflectionColorName: string;
  20936. /**
  20937. * Gets or sets the texture associated with the node
  20938. */
  20939. texture: Nullable<BaseTexture>;
  20940. /**
  20941. * Create a new ReflectionTextureBaseBlock
  20942. * @param name defines the block name
  20943. */
  20944. constructor(name: string);
  20945. /**
  20946. * Gets the current class name
  20947. * @returns the class name
  20948. */
  20949. getClassName(): string;
  20950. /**
  20951. * Gets the world position input component
  20952. */
  20953. abstract get position(): NodeMaterialConnectionPoint;
  20954. /**
  20955. * Gets the world position input component
  20956. */
  20957. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20958. /**
  20959. * Gets the world normal input component
  20960. */
  20961. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20962. /**
  20963. * Gets the world input component
  20964. */
  20965. abstract get world(): NodeMaterialConnectionPoint;
  20966. /**
  20967. * Gets the camera (or eye) position component
  20968. */
  20969. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20970. /**
  20971. * Gets the view input component
  20972. */
  20973. abstract get view(): NodeMaterialConnectionPoint;
  20974. protected _getTexture(): Nullable<BaseTexture>;
  20975. autoConfigure(material: NodeMaterial): void;
  20976. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20977. isReady(): boolean;
  20978. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20979. /**
  20980. * Gets the code to inject in the vertex shader
  20981. * @param state current state of the node material building
  20982. * @returns the shader code
  20983. */
  20984. handleVertexSide(state: NodeMaterialBuildState): string;
  20985. /**
  20986. * Handles the inits for the fragment code path
  20987. * @param state node material build state
  20988. */
  20989. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20990. /**
  20991. * Generates the reflection coords code for the fragment code path
  20992. * @param worldNormalVarName name of the world normal variable
  20993. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20994. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20995. * @returns the shader code
  20996. */
  20997. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20998. /**
  20999. * Generates the reflection color code for the fragment code path
  21000. * @param lodVarName name of the lod variable
  21001. * @param swizzleLookupTexture swizzle to use for the final color variable
  21002. * @returns the shader code
  21003. */
  21004. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21005. /**
  21006. * Generates the code corresponding to the connected output points
  21007. * @param state node material build state
  21008. * @param varName name of the variable to output
  21009. * @returns the shader code
  21010. */
  21011. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21012. protected _buildBlock(state: NodeMaterialBuildState): this;
  21013. protected _dumpPropertiesCode(): string;
  21014. serialize(): any;
  21015. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21016. }
  21017. }
  21018. declare module BABYLON {
  21019. /**
  21020. * Defines a connection point to be used for points with a custom object type
  21021. */
  21022. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21023. private _blockType;
  21024. private _blockName;
  21025. private _nameForCheking?;
  21026. /**
  21027. * Creates a new connection point
  21028. * @param name defines the connection point name
  21029. * @param ownerBlock defines the block hosting this connection point
  21030. * @param direction defines the direction of the connection point
  21031. */
  21032. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21033. /**
  21034. * Gets a number indicating if the current point can be connected to another point
  21035. * @param connectionPoint defines the other connection point
  21036. * @returns a number defining the compatibility state
  21037. */
  21038. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21039. /**
  21040. * Creates a block suitable to be used as an input for this input point.
  21041. * If null is returned, a block based on the point type will be created.
  21042. * @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
  21043. */
  21044. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21045. }
  21046. }
  21047. declare module BABYLON {
  21048. /**
  21049. * Enum defining the type of properties that can be edited in the property pages in the NME
  21050. */
  21051. export enum PropertyTypeForEdition {
  21052. /** property is a boolean */
  21053. Boolean = 0,
  21054. /** property is a float */
  21055. Float = 1,
  21056. /** property is a Vector2 */
  21057. Vector2 = 2,
  21058. /** property is a list of values */
  21059. List = 3
  21060. }
  21061. /**
  21062. * Interface that defines an option in a variable of type list
  21063. */
  21064. export interface IEditablePropertyListOption {
  21065. /** label of the option */
  21066. "label": string;
  21067. /** value of the option */
  21068. "value": number;
  21069. }
  21070. /**
  21071. * Interface that defines the options available for an editable property
  21072. */
  21073. export interface IEditablePropertyOption {
  21074. /** min value */
  21075. "min"?: number;
  21076. /** max value */
  21077. "max"?: number;
  21078. /** notifiers: indicates which actions to take when the property is changed */
  21079. "notifiers"?: {
  21080. /** the material should be rebuilt */
  21081. "rebuild"?: boolean;
  21082. /** the preview should be updated */
  21083. "update"?: boolean;
  21084. };
  21085. /** list of the options for a variable of type list */
  21086. "options"?: IEditablePropertyListOption[];
  21087. }
  21088. /**
  21089. * Interface that describes an editable property
  21090. */
  21091. export interface IPropertyDescriptionForEdition {
  21092. /** name of the property */
  21093. "propertyName": string;
  21094. /** display name of the property */
  21095. "displayName": string;
  21096. /** type of the property */
  21097. "type": PropertyTypeForEdition;
  21098. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21099. "groupName": string;
  21100. /** options for the property */
  21101. "options": IEditablePropertyOption;
  21102. }
  21103. /**
  21104. * Decorator that flags a property in a node material block as being editable
  21105. */
  21106. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21107. }
  21108. declare module BABYLON {
  21109. /**
  21110. * Block used to implement the refraction part of the sub surface module of the PBR material
  21111. */
  21112. export class RefractionBlock extends NodeMaterialBlock {
  21113. /** @hidden */
  21114. _define3DName: string;
  21115. /** @hidden */
  21116. _refractionMatrixName: string;
  21117. /** @hidden */
  21118. _defineLODRefractionAlpha: string;
  21119. /** @hidden */
  21120. _defineLinearSpecularRefraction: string;
  21121. /** @hidden */
  21122. _defineOppositeZ: string;
  21123. /** @hidden */
  21124. _cubeSamplerName: string;
  21125. /** @hidden */
  21126. _2DSamplerName: string;
  21127. /** @hidden */
  21128. _vRefractionMicrosurfaceInfosName: string;
  21129. /** @hidden */
  21130. _vRefractionInfosName: string;
  21131. private _scene;
  21132. /**
  21133. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21134. * Materials half opaque for instance using refraction could benefit from this control.
  21135. */
  21136. linkRefractionWithTransparency: boolean;
  21137. /**
  21138. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21139. */
  21140. invertRefractionY: boolean;
  21141. /**
  21142. * Gets or sets the texture associated with the node
  21143. */
  21144. texture: Nullable<BaseTexture>;
  21145. /**
  21146. * Create a new RefractionBlock
  21147. * @param name defines the block name
  21148. */
  21149. constructor(name: string);
  21150. /**
  21151. * Gets the current class name
  21152. * @returns the class name
  21153. */
  21154. getClassName(): string;
  21155. /**
  21156. * Gets the intensity input component
  21157. */
  21158. get intensity(): NodeMaterialConnectionPoint;
  21159. /**
  21160. * Gets the index of refraction input component
  21161. */
  21162. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21163. /**
  21164. * Gets the tint at distance input component
  21165. */
  21166. get tintAtDistance(): NodeMaterialConnectionPoint;
  21167. /**
  21168. * Gets the view input component
  21169. */
  21170. get view(): NodeMaterialConnectionPoint;
  21171. /**
  21172. * Gets the refraction object output component
  21173. */
  21174. get refraction(): NodeMaterialConnectionPoint;
  21175. /**
  21176. * Returns true if the block has a texture
  21177. */
  21178. get hasTexture(): boolean;
  21179. protected _getTexture(): Nullable<BaseTexture>;
  21180. autoConfigure(material: NodeMaterial): void;
  21181. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21182. isReady(): boolean;
  21183. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21184. /**
  21185. * Gets the main code of the block (fragment side)
  21186. * @param state current state of the node material building
  21187. * @returns the shader code
  21188. */
  21189. getCode(state: NodeMaterialBuildState): string;
  21190. protected _buildBlock(state: NodeMaterialBuildState): this;
  21191. protected _dumpPropertiesCode(): string;
  21192. serialize(): any;
  21193. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21194. }
  21195. }
  21196. declare module BABYLON {
  21197. /**
  21198. * Base block used as input for post process
  21199. */
  21200. export class CurrentScreenBlock extends NodeMaterialBlock {
  21201. private _samplerName;
  21202. private _linearDefineName;
  21203. private _gammaDefineName;
  21204. private _mainUVName;
  21205. private _tempTextureRead;
  21206. /**
  21207. * Gets or sets the texture associated with the node
  21208. */
  21209. texture: Nullable<BaseTexture>;
  21210. /**
  21211. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21212. */
  21213. convertToGammaSpace: boolean;
  21214. /**
  21215. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21216. */
  21217. convertToLinearSpace: boolean;
  21218. /**
  21219. * Create a new CurrentScreenBlock
  21220. * @param name defines the block name
  21221. */
  21222. constructor(name: string);
  21223. /**
  21224. * Gets the current class name
  21225. * @returns the class name
  21226. */
  21227. getClassName(): string;
  21228. /**
  21229. * Gets the uv input component
  21230. */
  21231. get uv(): NodeMaterialConnectionPoint;
  21232. /**
  21233. * Gets the rgba output component
  21234. */
  21235. get rgba(): NodeMaterialConnectionPoint;
  21236. /**
  21237. * Gets the rgb output component
  21238. */
  21239. get rgb(): NodeMaterialConnectionPoint;
  21240. /**
  21241. * Gets the r output component
  21242. */
  21243. get r(): NodeMaterialConnectionPoint;
  21244. /**
  21245. * Gets the g output component
  21246. */
  21247. get g(): NodeMaterialConnectionPoint;
  21248. /**
  21249. * Gets the b output component
  21250. */
  21251. get b(): NodeMaterialConnectionPoint;
  21252. /**
  21253. * Gets the a output component
  21254. */
  21255. get a(): NodeMaterialConnectionPoint;
  21256. /**
  21257. * Initialize the block and prepare the context for build
  21258. * @param state defines the state that will be used for the build
  21259. */
  21260. initialize(state: NodeMaterialBuildState): void;
  21261. get target(): NodeMaterialBlockTargets;
  21262. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21263. isReady(): boolean;
  21264. private _injectVertexCode;
  21265. private _writeTextureRead;
  21266. private _writeOutput;
  21267. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21268. serialize(): any;
  21269. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21270. }
  21271. }
  21272. declare module BABYLON {
  21273. /**
  21274. * Base block used for the particle texture
  21275. */
  21276. export class ParticleTextureBlock extends NodeMaterialBlock {
  21277. private _samplerName;
  21278. private _linearDefineName;
  21279. private _gammaDefineName;
  21280. private _tempTextureRead;
  21281. /**
  21282. * Gets or sets the texture associated with the node
  21283. */
  21284. texture: Nullable<BaseTexture>;
  21285. /**
  21286. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21287. */
  21288. convertToGammaSpace: boolean;
  21289. /**
  21290. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21291. */
  21292. convertToLinearSpace: boolean;
  21293. /**
  21294. * Create a new ParticleTextureBlock
  21295. * @param name defines the block name
  21296. */
  21297. constructor(name: string);
  21298. /**
  21299. * Gets the current class name
  21300. * @returns the class name
  21301. */
  21302. getClassName(): string;
  21303. /**
  21304. * Gets the uv input component
  21305. */
  21306. get uv(): NodeMaterialConnectionPoint;
  21307. /**
  21308. * Gets the rgba output component
  21309. */
  21310. get rgba(): NodeMaterialConnectionPoint;
  21311. /**
  21312. * Gets the rgb output component
  21313. */
  21314. get rgb(): NodeMaterialConnectionPoint;
  21315. /**
  21316. * Gets the r output component
  21317. */
  21318. get r(): NodeMaterialConnectionPoint;
  21319. /**
  21320. * Gets the g output component
  21321. */
  21322. get g(): NodeMaterialConnectionPoint;
  21323. /**
  21324. * Gets the b output component
  21325. */
  21326. get b(): NodeMaterialConnectionPoint;
  21327. /**
  21328. * Gets the a output component
  21329. */
  21330. get a(): NodeMaterialConnectionPoint;
  21331. /**
  21332. * Initialize the block and prepare the context for build
  21333. * @param state defines the state that will be used for the build
  21334. */
  21335. initialize(state: NodeMaterialBuildState): void;
  21336. autoConfigure(material: NodeMaterial): void;
  21337. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21338. isReady(): boolean;
  21339. private _writeOutput;
  21340. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21341. serialize(): any;
  21342. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21343. }
  21344. }
  21345. declare module BABYLON {
  21346. /**
  21347. * Class used to store shared data between 2 NodeMaterialBuildState
  21348. */
  21349. export class NodeMaterialBuildStateSharedData {
  21350. /**
  21351. * Gets the list of emitted varyings
  21352. */
  21353. temps: string[];
  21354. /**
  21355. * Gets the list of emitted varyings
  21356. */
  21357. varyings: string[];
  21358. /**
  21359. * Gets the varying declaration string
  21360. */
  21361. varyingDeclaration: string;
  21362. /**
  21363. * Input blocks
  21364. */
  21365. inputBlocks: InputBlock[];
  21366. /**
  21367. * Input blocks
  21368. */
  21369. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21370. /**
  21371. * Bindable blocks (Blocks that need to set data to the effect)
  21372. */
  21373. bindableBlocks: NodeMaterialBlock[];
  21374. /**
  21375. * List of blocks that can provide a compilation fallback
  21376. */
  21377. blocksWithFallbacks: NodeMaterialBlock[];
  21378. /**
  21379. * List of blocks that can provide a define update
  21380. */
  21381. blocksWithDefines: NodeMaterialBlock[];
  21382. /**
  21383. * List of blocks that can provide a repeatable content
  21384. */
  21385. repeatableContentBlocks: NodeMaterialBlock[];
  21386. /**
  21387. * List of blocks that can provide a dynamic list of uniforms
  21388. */
  21389. dynamicUniformBlocks: NodeMaterialBlock[];
  21390. /**
  21391. * List of blocks that can block the isReady function for the material
  21392. */
  21393. blockingBlocks: NodeMaterialBlock[];
  21394. /**
  21395. * Gets the list of animated inputs
  21396. */
  21397. animatedInputs: InputBlock[];
  21398. /**
  21399. * Build Id used to avoid multiple recompilations
  21400. */
  21401. buildId: number;
  21402. /** List of emitted variables */
  21403. variableNames: {
  21404. [key: string]: number;
  21405. };
  21406. /** List of emitted defines */
  21407. defineNames: {
  21408. [key: string]: number;
  21409. };
  21410. /** Should emit comments? */
  21411. emitComments: boolean;
  21412. /** Emit build activity */
  21413. verbose: boolean;
  21414. /** Gets or sets the hosting scene */
  21415. scene: Scene;
  21416. /**
  21417. * Gets the compilation hints emitted at compilation time
  21418. */
  21419. hints: {
  21420. needWorldViewMatrix: boolean;
  21421. needWorldViewProjectionMatrix: boolean;
  21422. needAlphaBlending: boolean;
  21423. needAlphaTesting: boolean;
  21424. };
  21425. /**
  21426. * List of compilation checks
  21427. */
  21428. checks: {
  21429. emitVertex: boolean;
  21430. emitFragment: boolean;
  21431. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21432. };
  21433. /**
  21434. * Is vertex program allowed to be empty?
  21435. */
  21436. allowEmptyVertexProgram: boolean;
  21437. /** Creates a new shared data */
  21438. constructor();
  21439. /**
  21440. * Emits console errors and exceptions if there is a failing check
  21441. */
  21442. emitErrors(): void;
  21443. }
  21444. }
  21445. declare module BABYLON {
  21446. /**
  21447. * Class used to store node based material build state
  21448. */
  21449. export class NodeMaterialBuildState {
  21450. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21451. supportUniformBuffers: boolean;
  21452. /**
  21453. * Gets the list of emitted attributes
  21454. */
  21455. attributes: string[];
  21456. /**
  21457. * Gets the list of emitted uniforms
  21458. */
  21459. uniforms: string[];
  21460. /**
  21461. * Gets the list of emitted constants
  21462. */
  21463. constants: string[];
  21464. /**
  21465. * Gets the list of emitted samplers
  21466. */
  21467. samplers: string[];
  21468. /**
  21469. * Gets the list of emitted functions
  21470. */
  21471. functions: {
  21472. [key: string]: string;
  21473. };
  21474. /**
  21475. * Gets the list of emitted extensions
  21476. */
  21477. extensions: {
  21478. [key: string]: string;
  21479. };
  21480. /**
  21481. * Gets the target of the compilation state
  21482. */
  21483. target: NodeMaterialBlockTargets;
  21484. /**
  21485. * Gets the list of emitted counters
  21486. */
  21487. counters: {
  21488. [key: string]: number;
  21489. };
  21490. /**
  21491. * Shared data between multiple NodeMaterialBuildState instances
  21492. */
  21493. sharedData: NodeMaterialBuildStateSharedData;
  21494. /** @hidden */
  21495. _vertexState: NodeMaterialBuildState;
  21496. /** @hidden */
  21497. _attributeDeclaration: string;
  21498. /** @hidden */
  21499. _uniformDeclaration: string;
  21500. /** @hidden */
  21501. _constantDeclaration: string;
  21502. /** @hidden */
  21503. _samplerDeclaration: string;
  21504. /** @hidden */
  21505. _varyingTransfer: string;
  21506. /** @hidden */
  21507. _injectAtEnd: string;
  21508. private _repeatableContentAnchorIndex;
  21509. /** @hidden */
  21510. _builtCompilationString: string;
  21511. /**
  21512. * Gets the emitted compilation strings
  21513. */
  21514. compilationString: string;
  21515. /**
  21516. * Finalize the compilation strings
  21517. * @param state defines the current compilation state
  21518. */
  21519. finalize(state: NodeMaterialBuildState): void;
  21520. /** @hidden */
  21521. get _repeatableContentAnchor(): string;
  21522. /** @hidden */
  21523. _getFreeVariableName(prefix: string): string;
  21524. /** @hidden */
  21525. _getFreeDefineName(prefix: string): string;
  21526. /** @hidden */
  21527. _excludeVariableName(name: string): void;
  21528. /** @hidden */
  21529. _emit2DSampler(name: string): void;
  21530. /** @hidden */
  21531. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21532. /** @hidden */
  21533. _emitExtension(name: string, extension: string, define?: string): void;
  21534. /** @hidden */
  21535. _emitFunction(name: string, code: string, comments: string): void;
  21536. /** @hidden */
  21537. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21538. replaceStrings?: {
  21539. search: RegExp;
  21540. replace: string;
  21541. }[];
  21542. repeatKey?: string;
  21543. }): string;
  21544. /** @hidden */
  21545. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21546. repeatKey?: string;
  21547. removeAttributes?: boolean;
  21548. removeUniforms?: boolean;
  21549. removeVaryings?: boolean;
  21550. removeIfDef?: boolean;
  21551. replaceStrings?: {
  21552. search: RegExp;
  21553. replace: string;
  21554. }[];
  21555. }, storeKey?: string): void;
  21556. /** @hidden */
  21557. _registerTempVariable(name: string): boolean;
  21558. /** @hidden */
  21559. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21560. /** @hidden */
  21561. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21562. /** @hidden */
  21563. _emitFloat(value: number): string;
  21564. }
  21565. }
  21566. declare module BABYLON {
  21567. /**
  21568. * Helper class used to generate session unique ID
  21569. */
  21570. export class UniqueIdGenerator {
  21571. private static _UniqueIdCounter;
  21572. /**
  21573. * Gets an unique (relatively to the current scene) Id
  21574. */
  21575. static get UniqueId(): number;
  21576. }
  21577. }
  21578. declare module BABYLON {
  21579. /**
  21580. * Defines a block that can be used inside a node based material
  21581. */
  21582. export class NodeMaterialBlock {
  21583. private _buildId;
  21584. private _buildTarget;
  21585. private _target;
  21586. private _isFinalMerger;
  21587. private _isInput;
  21588. private _name;
  21589. protected _isUnique: boolean;
  21590. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21591. inputsAreExclusive: boolean;
  21592. /** @hidden */
  21593. _codeVariableName: string;
  21594. /** @hidden */
  21595. _inputs: NodeMaterialConnectionPoint[];
  21596. /** @hidden */
  21597. _outputs: NodeMaterialConnectionPoint[];
  21598. /** @hidden */
  21599. _preparationId: number;
  21600. /**
  21601. * Gets the name of the block
  21602. */
  21603. get name(): string;
  21604. /**
  21605. * Sets the name of the block. Will check if the name is valid.
  21606. */
  21607. set name(newName: string);
  21608. /**
  21609. * Gets or sets the unique id of the node
  21610. */
  21611. uniqueId: number;
  21612. /**
  21613. * Gets or sets the comments associated with this block
  21614. */
  21615. comments: string;
  21616. /**
  21617. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21618. */
  21619. get isUnique(): boolean;
  21620. /**
  21621. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21622. */
  21623. get isFinalMerger(): boolean;
  21624. /**
  21625. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21626. */
  21627. get isInput(): boolean;
  21628. /**
  21629. * Gets or sets the build Id
  21630. */
  21631. get buildId(): number;
  21632. set buildId(value: number);
  21633. /**
  21634. * Gets or sets the target of the block
  21635. */
  21636. get target(): NodeMaterialBlockTargets;
  21637. set target(value: NodeMaterialBlockTargets);
  21638. /**
  21639. * Gets the list of input points
  21640. */
  21641. get inputs(): NodeMaterialConnectionPoint[];
  21642. /** Gets the list of output points */
  21643. get outputs(): NodeMaterialConnectionPoint[];
  21644. /**
  21645. * Find an input by its name
  21646. * @param name defines the name of the input to look for
  21647. * @returns the input or null if not found
  21648. */
  21649. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21650. /**
  21651. * Find an output by its name
  21652. * @param name defines the name of the outputto look for
  21653. * @returns the output or null if not found
  21654. */
  21655. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21656. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21657. visibleInInspector: boolean;
  21658. /**
  21659. * Creates a new NodeMaterialBlock
  21660. * @param name defines the block name
  21661. * @param target defines the target of that block (Vertex by default)
  21662. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21663. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21664. */
  21665. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21666. /**
  21667. * Initialize the block and prepare the context for build
  21668. * @param state defines the state that will be used for the build
  21669. */
  21670. initialize(state: NodeMaterialBuildState): void;
  21671. /**
  21672. * Bind data to effect. Will only be called for blocks with isBindable === true
  21673. * @param effect defines the effect to bind data to
  21674. * @param nodeMaterial defines the hosting NodeMaterial
  21675. * @param mesh defines the mesh that will be rendered
  21676. * @param subMesh defines the submesh that will be rendered
  21677. */
  21678. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21679. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21680. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21681. protected _writeFloat(value: number): string;
  21682. /**
  21683. * Gets the current class name e.g. "NodeMaterialBlock"
  21684. * @returns the class name
  21685. */
  21686. getClassName(): string;
  21687. /**
  21688. * Register a new input. Must be called inside a block constructor
  21689. * @param name defines the connection point name
  21690. * @param type defines the connection point type
  21691. * @param isOptional defines a boolean indicating that this input can be omitted
  21692. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21693. * @param point an already created connection point. If not provided, create a new one
  21694. * @returns the current block
  21695. */
  21696. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21697. /**
  21698. * Register a new output. Must be called inside a block constructor
  21699. * @param name defines the connection point name
  21700. * @param type defines the connection point type
  21701. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21702. * @param point an already created connection point. If not provided, create a new one
  21703. * @returns the current block
  21704. */
  21705. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21706. /**
  21707. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21708. * @param forOutput defines an optional connection point to check compatibility with
  21709. * @returns the first available input or null
  21710. */
  21711. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21712. /**
  21713. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21714. * @param forBlock defines an optional block to check compatibility with
  21715. * @returns the first available input or null
  21716. */
  21717. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21718. /**
  21719. * Gets the sibling of the given output
  21720. * @param current defines the current output
  21721. * @returns the next output in the list or null
  21722. */
  21723. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21724. /**
  21725. * Connect current block with another block
  21726. * @param other defines the block to connect with
  21727. * @param options define the various options to help pick the right connections
  21728. * @returns the current block
  21729. */
  21730. connectTo(other: NodeMaterialBlock, options?: {
  21731. input?: string;
  21732. output?: string;
  21733. outputSwizzle?: string;
  21734. }): this | undefined;
  21735. protected _buildBlock(state: NodeMaterialBuildState): void;
  21736. /**
  21737. * Add uniforms, samplers and uniform buffers at compilation time
  21738. * @param state defines the state to update
  21739. * @param nodeMaterial defines the node material requesting the update
  21740. * @param defines defines the material defines to update
  21741. * @param uniformBuffers defines the list of uniform buffer names
  21742. */
  21743. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21744. /**
  21745. * Add potential fallbacks if shader compilation fails
  21746. * @param mesh defines the mesh to be rendered
  21747. * @param fallbacks defines the current prioritized list of fallbacks
  21748. */
  21749. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21750. /**
  21751. * Initialize defines for shader compilation
  21752. * @param mesh defines the mesh to be rendered
  21753. * @param nodeMaterial defines the node material requesting the update
  21754. * @param defines defines the material defines to update
  21755. * @param useInstances specifies that instances should be used
  21756. */
  21757. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21758. /**
  21759. * Update defines for shader compilation
  21760. * @param mesh defines the mesh to be rendered
  21761. * @param nodeMaterial defines the node material requesting the update
  21762. * @param defines defines the material defines to update
  21763. * @param useInstances specifies that instances should be used
  21764. * @param subMesh defines which submesh to render
  21765. */
  21766. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21767. /**
  21768. * Lets the block try to connect some inputs automatically
  21769. * @param material defines the hosting NodeMaterial
  21770. */
  21771. autoConfigure(material: NodeMaterial): void;
  21772. /**
  21773. * Function called when a block is declared as repeatable content generator
  21774. * @param vertexShaderState defines the current compilation state for the vertex shader
  21775. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21776. * @param mesh defines the mesh to be rendered
  21777. * @param defines defines the material defines to update
  21778. */
  21779. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21780. /**
  21781. * Checks if the block is ready
  21782. * @param mesh defines the mesh to be rendered
  21783. * @param nodeMaterial defines the node material requesting the update
  21784. * @param defines defines the material defines to update
  21785. * @param useInstances specifies that instances should be used
  21786. * @returns true if the block is ready
  21787. */
  21788. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21789. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21790. private _processBuild;
  21791. /**
  21792. * Validates the new name for the block node.
  21793. * @param newName the new name to be given to the node.
  21794. * @returns false if the name is a reserve word, else true.
  21795. */
  21796. validateBlockName(newName: string): boolean;
  21797. /**
  21798. * Compile the current node and generate the shader code
  21799. * @param state defines the current compilation state (uniforms, samplers, current string)
  21800. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21801. * @returns true if already built
  21802. */
  21803. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21804. protected _inputRename(name: string): string;
  21805. protected _outputRename(name: string): string;
  21806. protected _dumpPropertiesCode(): string;
  21807. /** @hidden */
  21808. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21809. /** @hidden */
  21810. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21811. /**
  21812. * Clone the current block to a new identical block
  21813. * @param scene defines the hosting scene
  21814. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21815. * @returns a copy of the current block
  21816. */
  21817. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21818. /**
  21819. * Serializes this block in a JSON representation
  21820. * @returns the serialized block object
  21821. */
  21822. serialize(): any;
  21823. /** @hidden */
  21824. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21825. private _deserializePortDisplayNamesAndExposedOnFrame;
  21826. /**
  21827. * Release resources
  21828. */
  21829. dispose(): void;
  21830. }
  21831. }
  21832. declare module BABYLON {
  21833. /**
  21834. * Base class of materials working in push mode in babylon JS
  21835. * @hidden
  21836. */
  21837. export class PushMaterial extends Material {
  21838. protected _activeEffect: Effect;
  21839. protected _normalMatrix: Matrix;
  21840. constructor(name: string, scene: Scene);
  21841. getEffect(): Effect;
  21842. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21843. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21844. /**
  21845. * Binds the given world matrix to the active effect
  21846. *
  21847. * @param world the matrix to bind
  21848. */
  21849. bindOnlyWorldMatrix(world: Matrix): void;
  21850. /**
  21851. * Binds the given normal matrix to the active effect
  21852. *
  21853. * @param normalMatrix the matrix to bind
  21854. */
  21855. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21856. bind(world: Matrix, mesh?: Mesh): void;
  21857. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21858. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21859. }
  21860. }
  21861. declare module BABYLON {
  21862. /**
  21863. * Root class for all node material optimizers
  21864. */
  21865. export class NodeMaterialOptimizer {
  21866. /**
  21867. * Function used to optimize a NodeMaterial graph
  21868. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21869. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21870. */
  21871. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21872. }
  21873. }
  21874. declare module BABYLON {
  21875. /**
  21876. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21877. */
  21878. export class TransformBlock extends NodeMaterialBlock {
  21879. /**
  21880. * Defines the value to use to complement W value to transform it to a Vector4
  21881. */
  21882. complementW: number;
  21883. /**
  21884. * Defines the value to use to complement z value to transform it to a Vector4
  21885. */
  21886. complementZ: number;
  21887. /**
  21888. * Creates a new TransformBlock
  21889. * @param name defines the block name
  21890. */
  21891. constructor(name: string);
  21892. /**
  21893. * Gets the current class name
  21894. * @returns the class name
  21895. */
  21896. getClassName(): string;
  21897. /**
  21898. * Gets the vector input
  21899. */
  21900. get vector(): NodeMaterialConnectionPoint;
  21901. /**
  21902. * Gets the output component
  21903. */
  21904. get output(): NodeMaterialConnectionPoint;
  21905. /**
  21906. * Gets the xyz output component
  21907. */
  21908. get xyz(): NodeMaterialConnectionPoint;
  21909. /**
  21910. * Gets the matrix transform input
  21911. */
  21912. get transform(): NodeMaterialConnectionPoint;
  21913. protected _buildBlock(state: NodeMaterialBuildState): this;
  21914. /**
  21915. * Update defines for shader compilation
  21916. * @param mesh defines the mesh to be rendered
  21917. * @param nodeMaterial defines the node material requesting the update
  21918. * @param defines defines the material defines to update
  21919. * @param useInstances specifies that instances should be used
  21920. * @param subMesh defines which submesh to render
  21921. */
  21922. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21923. serialize(): any;
  21924. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21925. protected _dumpPropertiesCode(): string;
  21926. }
  21927. }
  21928. declare module BABYLON {
  21929. /**
  21930. * Block used to output the vertex position
  21931. */
  21932. export class VertexOutputBlock extends NodeMaterialBlock {
  21933. /**
  21934. * Creates a new VertexOutputBlock
  21935. * @param name defines the block name
  21936. */
  21937. constructor(name: string);
  21938. /**
  21939. * Gets the current class name
  21940. * @returns the class name
  21941. */
  21942. getClassName(): string;
  21943. /**
  21944. * Gets the vector input component
  21945. */
  21946. get vector(): NodeMaterialConnectionPoint;
  21947. protected _buildBlock(state: NodeMaterialBuildState): this;
  21948. }
  21949. }
  21950. declare module BABYLON {
  21951. /**
  21952. * Block used to output the final color
  21953. */
  21954. export class FragmentOutputBlock extends NodeMaterialBlock {
  21955. /**
  21956. * Create a new FragmentOutputBlock
  21957. * @param name defines the block name
  21958. */
  21959. constructor(name: string);
  21960. /**
  21961. * Gets the current class name
  21962. * @returns the class name
  21963. */
  21964. getClassName(): string;
  21965. /**
  21966. * Gets the rgba input component
  21967. */
  21968. get rgba(): NodeMaterialConnectionPoint;
  21969. /**
  21970. * Gets the rgb input component
  21971. */
  21972. get rgb(): NodeMaterialConnectionPoint;
  21973. /**
  21974. * Gets the a input component
  21975. */
  21976. get a(): NodeMaterialConnectionPoint;
  21977. protected _buildBlock(state: NodeMaterialBuildState): this;
  21978. }
  21979. }
  21980. declare module BABYLON {
  21981. /**
  21982. * Block used for the particle ramp gradient section
  21983. */
  21984. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21985. /**
  21986. * Create a new ParticleRampGradientBlock
  21987. * @param name defines the block name
  21988. */
  21989. constructor(name: string);
  21990. /**
  21991. * Gets the current class name
  21992. * @returns the class name
  21993. */
  21994. getClassName(): string;
  21995. /**
  21996. * Gets the color input component
  21997. */
  21998. get color(): NodeMaterialConnectionPoint;
  21999. /**
  22000. * Gets the rampColor output component
  22001. */
  22002. get rampColor(): NodeMaterialConnectionPoint;
  22003. /**
  22004. * Initialize the block and prepare the context for build
  22005. * @param state defines the state that will be used for the build
  22006. */
  22007. initialize(state: NodeMaterialBuildState): void;
  22008. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22009. }
  22010. }
  22011. declare module BABYLON {
  22012. /**
  22013. * Block used for the particle blend multiply section
  22014. */
  22015. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22016. /**
  22017. * Create a new ParticleBlendMultiplyBlock
  22018. * @param name defines the block name
  22019. */
  22020. constructor(name: string);
  22021. /**
  22022. * Gets the current class name
  22023. * @returns the class name
  22024. */
  22025. getClassName(): string;
  22026. /**
  22027. * Gets the color input component
  22028. */
  22029. get color(): NodeMaterialConnectionPoint;
  22030. /**
  22031. * Gets the alphaTexture input component
  22032. */
  22033. get alphaTexture(): NodeMaterialConnectionPoint;
  22034. /**
  22035. * Gets the alphaColor input component
  22036. */
  22037. get alphaColor(): NodeMaterialConnectionPoint;
  22038. /**
  22039. * Gets the blendColor output component
  22040. */
  22041. get blendColor(): NodeMaterialConnectionPoint;
  22042. /**
  22043. * Initialize the block and prepare the context for build
  22044. * @param state defines the state that will be used for the build
  22045. */
  22046. initialize(state: NodeMaterialBuildState): void;
  22047. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22048. }
  22049. }
  22050. declare module BABYLON {
  22051. /**
  22052. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22053. */
  22054. export class VectorMergerBlock extends NodeMaterialBlock {
  22055. /**
  22056. * Create a new VectorMergerBlock
  22057. * @param name defines the block name
  22058. */
  22059. constructor(name: string);
  22060. /**
  22061. * Gets the current class name
  22062. * @returns the class name
  22063. */
  22064. getClassName(): string;
  22065. /**
  22066. * Gets the xyz component (input)
  22067. */
  22068. get xyzIn(): NodeMaterialConnectionPoint;
  22069. /**
  22070. * Gets the xy component (input)
  22071. */
  22072. get xyIn(): NodeMaterialConnectionPoint;
  22073. /**
  22074. * Gets the x component (input)
  22075. */
  22076. get x(): NodeMaterialConnectionPoint;
  22077. /**
  22078. * Gets the y component (input)
  22079. */
  22080. get y(): NodeMaterialConnectionPoint;
  22081. /**
  22082. * Gets the z component (input)
  22083. */
  22084. get z(): NodeMaterialConnectionPoint;
  22085. /**
  22086. * Gets the w component (input)
  22087. */
  22088. get w(): NodeMaterialConnectionPoint;
  22089. /**
  22090. * Gets the xyzw component (output)
  22091. */
  22092. get xyzw(): NodeMaterialConnectionPoint;
  22093. /**
  22094. * Gets the xyz component (output)
  22095. */
  22096. get xyzOut(): NodeMaterialConnectionPoint;
  22097. /**
  22098. * Gets the xy component (output)
  22099. */
  22100. get xyOut(): NodeMaterialConnectionPoint;
  22101. /**
  22102. * Gets the xy component (output)
  22103. * @deprecated Please use xyOut instead.
  22104. */
  22105. get xy(): NodeMaterialConnectionPoint;
  22106. /**
  22107. * Gets the xyz component (output)
  22108. * @deprecated Please use xyzOut instead.
  22109. */
  22110. get xyz(): NodeMaterialConnectionPoint;
  22111. protected _buildBlock(state: NodeMaterialBuildState): this;
  22112. }
  22113. }
  22114. declare module BABYLON {
  22115. /**
  22116. * Block used to remap a float from a range to a new one
  22117. */
  22118. export class RemapBlock extends NodeMaterialBlock {
  22119. /**
  22120. * Gets or sets the source range
  22121. */
  22122. sourceRange: Vector2;
  22123. /**
  22124. * Gets or sets the target range
  22125. */
  22126. targetRange: Vector2;
  22127. /**
  22128. * Creates a new RemapBlock
  22129. * @param name defines the block name
  22130. */
  22131. constructor(name: string);
  22132. /**
  22133. * Gets the current class name
  22134. * @returns the class name
  22135. */
  22136. getClassName(): string;
  22137. /**
  22138. * Gets the input component
  22139. */
  22140. get input(): NodeMaterialConnectionPoint;
  22141. /**
  22142. * Gets the source min input component
  22143. */
  22144. get sourceMin(): NodeMaterialConnectionPoint;
  22145. /**
  22146. * Gets the source max input component
  22147. */
  22148. get sourceMax(): NodeMaterialConnectionPoint;
  22149. /**
  22150. * Gets the target min input component
  22151. */
  22152. get targetMin(): NodeMaterialConnectionPoint;
  22153. /**
  22154. * Gets the target max input component
  22155. */
  22156. get targetMax(): NodeMaterialConnectionPoint;
  22157. /**
  22158. * Gets the output component
  22159. */
  22160. get output(): NodeMaterialConnectionPoint;
  22161. protected _buildBlock(state: NodeMaterialBuildState): this;
  22162. protected _dumpPropertiesCode(): string;
  22163. serialize(): any;
  22164. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22165. }
  22166. }
  22167. declare module BABYLON {
  22168. /**
  22169. * Block used to multiply 2 values
  22170. */
  22171. export class MultiplyBlock extends NodeMaterialBlock {
  22172. /**
  22173. * Creates a new MultiplyBlock
  22174. * @param name defines the block name
  22175. */
  22176. constructor(name: string);
  22177. /**
  22178. * Gets the current class name
  22179. * @returns the class name
  22180. */
  22181. getClassName(): string;
  22182. /**
  22183. * Gets the left operand input component
  22184. */
  22185. get left(): NodeMaterialConnectionPoint;
  22186. /**
  22187. * Gets the right operand input component
  22188. */
  22189. get right(): NodeMaterialConnectionPoint;
  22190. /**
  22191. * Gets the output component
  22192. */
  22193. get output(): NodeMaterialConnectionPoint;
  22194. protected _buildBlock(state: NodeMaterialBuildState): this;
  22195. }
  22196. }
  22197. declare module BABYLON {
  22198. /**
  22199. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22200. */
  22201. export class ColorSplitterBlock extends NodeMaterialBlock {
  22202. /**
  22203. * Create a new ColorSplitterBlock
  22204. * @param name defines the block name
  22205. */
  22206. constructor(name: string);
  22207. /**
  22208. * Gets the current class name
  22209. * @returns the class name
  22210. */
  22211. getClassName(): string;
  22212. /**
  22213. * Gets the rgba component (input)
  22214. */
  22215. get rgba(): NodeMaterialConnectionPoint;
  22216. /**
  22217. * Gets the rgb component (input)
  22218. */
  22219. get rgbIn(): NodeMaterialConnectionPoint;
  22220. /**
  22221. * Gets the rgb component (output)
  22222. */
  22223. get rgbOut(): NodeMaterialConnectionPoint;
  22224. /**
  22225. * Gets the r component (output)
  22226. */
  22227. get r(): NodeMaterialConnectionPoint;
  22228. /**
  22229. * Gets the g component (output)
  22230. */
  22231. get g(): NodeMaterialConnectionPoint;
  22232. /**
  22233. * Gets the b component (output)
  22234. */
  22235. get b(): NodeMaterialConnectionPoint;
  22236. /**
  22237. * Gets the a component (output)
  22238. */
  22239. get a(): NodeMaterialConnectionPoint;
  22240. protected _inputRename(name: string): string;
  22241. protected _outputRename(name: string): string;
  22242. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22243. }
  22244. }
  22245. declare module BABYLON {
  22246. /**
  22247. * Operations supported by the Trigonometry block
  22248. */
  22249. export enum TrigonometryBlockOperations {
  22250. /** Cos */
  22251. Cos = 0,
  22252. /** Sin */
  22253. Sin = 1,
  22254. /** Abs */
  22255. Abs = 2,
  22256. /** Exp */
  22257. Exp = 3,
  22258. /** Exp2 */
  22259. Exp2 = 4,
  22260. /** Round */
  22261. Round = 5,
  22262. /** Floor */
  22263. Floor = 6,
  22264. /** Ceiling */
  22265. Ceiling = 7,
  22266. /** Square root */
  22267. Sqrt = 8,
  22268. /** Log */
  22269. Log = 9,
  22270. /** Tangent */
  22271. Tan = 10,
  22272. /** Arc tangent */
  22273. ArcTan = 11,
  22274. /** Arc cosinus */
  22275. ArcCos = 12,
  22276. /** Arc sinus */
  22277. ArcSin = 13,
  22278. /** Fraction */
  22279. Fract = 14,
  22280. /** Sign */
  22281. Sign = 15,
  22282. /** To radians (from degrees) */
  22283. Radians = 16,
  22284. /** To degrees (from radians) */
  22285. Degrees = 17
  22286. }
  22287. /**
  22288. * Block used to apply trigonometry operation to floats
  22289. */
  22290. export class TrigonometryBlock extends NodeMaterialBlock {
  22291. /**
  22292. * Gets or sets the operation applied by the block
  22293. */
  22294. operation: TrigonometryBlockOperations;
  22295. /**
  22296. * Creates a new TrigonometryBlock
  22297. * @param name defines the block name
  22298. */
  22299. constructor(name: string);
  22300. /**
  22301. * Gets the current class name
  22302. * @returns the class name
  22303. */
  22304. getClassName(): string;
  22305. /**
  22306. * Gets the input component
  22307. */
  22308. get input(): NodeMaterialConnectionPoint;
  22309. /**
  22310. * Gets the output component
  22311. */
  22312. get output(): NodeMaterialConnectionPoint;
  22313. protected _buildBlock(state: NodeMaterialBuildState): this;
  22314. serialize(): any;
  22315. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22316. protected _dumpPropertiesCode(): string;
  22317. }
  22318. }
  22319. declare module BABYLON {
  22320. /**
  22321. * Interface used to configure the node material editor
  22322. */
  22323. export interface INodeMaterialEditorOptions {
  22324. /** Define the URl to load node editor script */
  22325. editorURL?: string;
  22326. }
  22327. /** @hidden */
  22328. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22329. NORMAL: boolean;
  22330. TANGENT: boolean;
  22331. UV1: boolean;
  22332. /** BONES */
  22333. NUM_BONE_INFLUENCERS: number;
  22334. BonesPerMesh: number;
  22335. BONETEXTURE: boolean;
  22336. /** MORPH TARGETS */
  22337. MORPHTARGETS: boolean;
  22338. MORPHTARGETS_NORMAL: boolean;
  22339. MORPHTARGETS_TANGENT: boolean;
  22340. MORPHTARGETS_UV: boolean;
  22341. NUM_MORPH_INFLUENCERS: number;
  22342. /** IMAGE PROCESSING */
  22343. IMAGEPROCESSING: boolean;
  22344. VIGNETTE: boolean;
  22345. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22346. VIGNETTEBLENDMODEOPAQUE: boolean;
  22347. TONEMAPPING: boolean;
  22348. TONEMAPPING_ACES: boolean;
  22349. CONTRAST: boolean;
  22350. EXPOSURE: boolean;
  22351. COLORCURVES: boolean;
  22352. COLORGRADING: boolean;
  22353. COLORGRADING3D: boolean;
  22354. SAMPLER3DGREENDEPTH: boolean;
  22355. SAMPLER3DBGRMAP: boolean;
  22356. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22357. /** MISC. */
  22358. BUMPDIRECTUV: number;
  22359. constructor();
  22360. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22361. }
  22362. /**
  22363. * Class used to configure NodeMaterial
  22364. */
  22365. export interface INodeMaterialOptions {
  22366. /**
  22367. * Defines if blocks should emit comments
  22368. */
  22369. emitComments: boolean;
  22370. }
  22371. /**
  22372. * Class used to create a node based material built by assembling shader blocks
  22373. */
  22374. export class NodeMaterial extends PushMaterial {
  22375. private static _BuildIdGenerator;
  22376. private _options;
  22377. private _vertexCompilationState;
  22378. private _fragmentCompilationState;
  22379. private _sharedData;
  22380. private _buildId;
  22381. private _buildWasSuccessful;
  22382. private _cachedWorldViewMatrix;
  22383. private _cachedWorldViewProjectionMatrix;
  22384. private _optimizers;
  22385. private _animationFrame;
  22386. /** Define the Url to load node editor script */
  22387. static EditorURL: string;
  22388. /** Define the Url to load snippets */
  22389. static SnippetUrl: string;
  22390. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22391. static IgnoreTexturesAtLoadTime: boolean;
  22392. private BJSNODEMATERIALEDITOR;
  22393. /** Get the inspector from bundle or global */
  22394. private _getGlobalNodeMaterialEditor;
  22395. /**
  22396. * Snippet ID if the material was created from the snippet server
  22397. */
  22398. snippetId: string;
  22399. /**
  22400. * Gets or sets data used by visual editor
  22401. * @see https://nme.babylonjs.com
  22402. */
  22403. editorData: any;
  22404. /**
  22405. * 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)
  22406. */
  22407. ignoreAlpha: boolean;
  22408. /**
  22409. * Defines the maximum number of lights that can be used in the material
  22410. */
  22411. maxSimultaneousLights: number;
  22412. /**
  22413. * Observable raised when the material is built
  22414. */
  22415. onBuildObservable: Observable<NodeMaterial>;
  22416. /**
  22417. * Gets or sets the root nodes of the material vertex shader
  22418. */
  22419. _vertexOutputNodes: NodeMaterialBlock[];
  22420. /**
  22421. * Gets or sets the root nodes of the material fragment (pixel) shader
  22422. */
  22423. _fragmentOutputNodes: NodeMaterialBlock[];
  22424. /** Gets or sets options to control the node material overall behavior */
  22425. get options(): INodeMaterialOptions;
  22426. set options(options: INodeMaterialOptions);
  22427. /**
  22428. * Default configuration related to image processing available in the standard Material.
  22429. */
  22430. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22431. /**
  22432. * Gets the image processing configuration used either in this material.
  22433. */
  22434. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22435. /**
  22436. * Sets the Default image processing configuration used either in the this material.
  22437. *
  22438. * If sets to null, the scene one is in use.
  22439. */
  22440. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22441. /**
  22442. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22443. */
  22444. attachedBlocks: NodeMaterialBlock[];
  22445. /**
  22446. * Specifies the mode of the node material
  22447. * @hidden
  22448. */
  22449. _mode: NodeMaterialModes;
  22450. /**
  22451. * Gets the mode property
  22452. */
  22453. get mode(): NodeMaterialModes;
  22454. /**
  22455. * Create a new node based material
  22456. * @param name defines the material name
  22457. * @param scene defines the hosting scene
  22458. * @param options defines creation option
  22459. */
  22460. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22461. /**
  22462. * Gets the current class name of the material e.g. "NodeMaterial"
  22463. * @returns the class name
  22464. */
  22465. getClassName(): string;
  22466. /**
  22467. * Keep track of the image processing observer to allow dispose and replace.
  22468. */
  22469. private _imageProcessingObserver;
  22470. /**
  22471. * Attaches a new image processing configuration to the Standard Material.
  22472. * @param configuration
  22473. */
  22474. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22475. /**
  22476. * Get a block by its name
  22477. * @param name defines the name of the block to retrieve
  22478. * @returns the required block or null if not found
  22479. */
  22480. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22481. /**
  22482. * Get a block by its name
  22483. * @param predicate defines the predicate used to find the good candidate
  22484. * @returns the required block or null if not found
  22485. */
  22486. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22487. /**
  22488. * Get an input block by its name
  22489. * @param predicate defines the predicate used to find the good candidate
  22490. * @returns the required input block or null if not found
  22491. */
  22492. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22493. /**
  22494. * Gets the list of input blocks attached to this material
  22495. * @returns an array of InputBlocks
  22496. */
  22497. getInputBlocks(): InputBlock[];
  22498. /**
  22499. * Adds a new optimizer to the list of optimizers
  22500. * @param optimizer defines the optimizers to add
  22501. * @returns the current material
  22502. */
  22503. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22504. /**
  22505. * Remove an optimizer from the list of optimizers
  22506. * @param optimizer defines the optimizers to remove
  22507. * @returns the current material
  22508. */
  22509. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22510. /**
  22511. * Add a new block to the list of output nodes
  22512. * @param node defines the node to add
  22513. * @returns the current material
  22514. */
  22515. addOutputNode(node: NodeMaterialBlock): this;
  22516. /**
  22517. * Remove a block from the list of root nodes
  22518. * @param node defines the node to remove
  22519. * @returns the current material
  22520. */
  22521. removeOutputNode(node: NodeMaterialBlock): this;
  22522. private _addVertexOutputNode;
  22523. private _removeVertexOutputNode;
  22524. private _addFragmentOutputNode;
  22525. private _removeFragmentOutputNode;
  22526. /**
  22527. * Specifies if the material will require alpha blending
  22528. * @returns a boolean specifying if alpha blending is needed
  22529. */
  22530. needAlphaBlending(): boolean;
  22531. /**
  22532. * Specifies if this material should be rendered in alpha test mode
  22533. * @returns a boolean specifying if an alpha test is needed.
  22534. */
  22535. needAlphaTesting(): boolean;
  22536. private _initializeBlock;
  22537. private _resetDualBlocks;
  22538. /**
  22539. * Remove a block from the current node material
  22540. * @param block defines the block to remove
  22541. */
  22542. removeBlock(block: NodeMaterialBlock): void;
  22543. /**
  22544. * Build the material and generates the inner effect
  22545. * @param verbose defines if the build should log activity
  22546. */
  22547. build(verbose?: boolean): void;
  22548. /**
  22549. * Runs an otpimization phase to try to improve the shader code
  22550. */
  22551. optimize(): void;
  22552. private _prepareDefinesForAttributes;
  22553. /**
  22554. * Create a post process from the material
  22555. * @param camera The camera to apply the render pass to.
  22556. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22558. * @param engine The engine which the post process will be applied. (default: current engine)
  22559. * @param reusable If the post process can be reused on the same frame. (default: false)
  22560. * @param textureType Type of textures used when performing the post process. (default: 0)
  22561. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22562. * @returns the post process created
  22563. */
  22564. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22565. /**
  22566. * Create the post process effect from the material
  22567. * @param postProcess The post process to create the effect for
  22568. */
  22569. createEffectForPostProcess(postProcess: PostProcess): void;
  22570. private _createEffectForPostProcess;
  22571. /**
  22572. * Create a new procedural texture based on this node material
  22573. * @param size defines the size of the texture
  22574. * @param scene defines the hosting scene
  22575. * @returns the new procedural texture attached to this node material
  22576. */
  22577. createProceduralTexture(size: number | {
  22578. width: number;
  22579. height: number;
  22580. layers?: number;
  22581. }, scene: Scene): ProceduralTexture;
  22582. private _createEffectForParticles;
  22583. private _checkInternals;
  22584. /**
  22585. * Create the effect to be used as the custom effect for a particle system
  22586. * @param particleSystem Particle system to create the effect for
  22587. * @param onCompiled defines a function to call when the effect creation is successful
  22588. * @param onError defines a function to call when the effect creation has failed
  22589. */
  22590. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22591. private _processDefines;
  22592. /**
  22593. * Get if the submesh is ready to be used and all its information available.
  22594. * Child classes can use it to update shaders
  22595. * @param mesh defines the mesh to check
  22596. * @param subMesh defines which submesh to check
  22597. * @param useInstances specifies that instances should be used
  22598. * @returns a boolean indicating that the submesh is ready or not
  22599. */
  22600. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22601. /**
  22602. * Get a string representing the shaders built by the current node graph
  22603. */
  22604. get compiledShaders(): string;
  22605. /**
  22606. * Binds the world matrix to the material
  22607. * @param world defines the world transformation matrix
  22608. */
  22609. bindOnlyWorldMatrix(world: Matrix): void;
  22610. /**
  22611. * Binds the submesh to this material by preparing the effect and shader to draw
  22612. * @param world defines the world transformation matrix
  22613. * @param mesh defines the mesh containing the submesh
  22614. * @param subMesh defines the submesh to bind the material to
  22615. */
  22616. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22617. /**
  22618. * Gets the active textures from the material
  22619. * @returns an array of textures
  22620. */
  22621. getActiveTextures(): BaseTexture[];
  22622. /**
  22623. * Gets the list of texture blocks
  22624. * @returns an array of texture blocks
  22625. */
  22626. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22627. /**
  22628. * Specifies if the material uses a texture
  22629. * @param texture defines the texture to check against the material
  22630. * @returns a boolean specifying if the material uses the texture
  22631. */
  22632. hasTexture(texture: BaseTexture): boolean;
  22633. /**
  22634. * Disposes the material
  22635. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22636. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22637. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22638. */
  22639. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22640. /** Creates the node editor window. */
  22641. private _createNodeEditor;
  22642. /**
  22643. * Launch the node material editor
  22644. * @param config Define the configuration of the editor
  22645. * @return a promise fulfilled when the node editor is visible
  22646. */
  22647. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22648. /**
  22649. * Clear the current material
  22650. */
  22651. clear(): void;
  22652. /**
  22653. * Clear the current material and set it to a default state
  22654. */
  22655. setToDefault(): void;
  22656. /**
  22657. * Clear the current material and set it to a default state for post process
  22658. */
  22659. setToDefaultPostProcess(): void;
  22660. /**
  22661. * Clear the current material and set it to a default state for procedural texture
  22662. */
  22663. setToDefaultProceduralTexture(): void;
  22664. /**
  22665. * Clear the current material and set it to a default state for particle
  22666. */
  22667. setToDefaultParticle(): void;
  22668. /**
  22669. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22670. * @param url defines the url to load from
  22671. * @returns a promise that will fullfil when the material is fully loaded
  22672. */
  22673. loadAsync(url: string): Promise<void>;
  22674. private _gatherBlocks;
  22675. /**
  22676. * Generate a string containing the code declaration required to create an equivalent of this material
  22677. * @returns a string
  22678. */
  22679. generateCode(): string;
  22680. /**
  22681. * Serializes this material in a JSON representation
  22682. * @returns the serialized material object
  22683. */
  22684. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22685. private _restoreConnections;
  22686. /**
  22687. * Clear the current graph and load a new one from a serialization object
  22688. * @param source defines the JSON representation of the material
  22689. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22690. * @param merge defines whether or not the source must be merged or replace the current content
  22691. */
  22692. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22693. /**
  22694. * Makes a duplicate of the current material.
  22695. * @param name - name to use for the new material.
  22696. */
  22697. clone(name: string): NodeMaterial;
  22698. /**
  22699. * Creates a node material from parsed material data
  22700. * @param source defines the JSON representation of the material
  22701. * @param scene defines the hosting scene
  22702. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22703. * @returns a new node material
  22704. */
  22705. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22706. /**
  22707. * Creates a node material from a snippet saved in a remote file
  22708. * @param name defines the name of the material to create
  22709. * @param url defines the url to load from
  22710. * @param scene defines the hosting scene
  22711. * @returns a promise that will resolve to the new node material
  22712. */
  22713. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22714. /**
  22715. * Creates a node material from a snippet saved by the node material editor
  22716. * @param snippetId defines the snippet to load
  22717. * @param scene defines the hosting scene
  22718. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22719. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22720. * @returns a promise that will resolve to the new node material
  22721. */
  22722. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22723. /**
  22724. * Creates a new node material set to default basic configuration
  22725. * @param name defines the name of the material
  22726. * @param scene defines the hosting scene
  22727. * @returns a new NodeMaterial
  22728. */
  22729. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22730. }
  22731. }
  22732. declare module BABYLON {
  22733. /**
  22734. * Size options for a post process
  22735. */
  22736. export type PostProcessOptions = {
  22737. width: number;
  22738. height: number;
  22739. };
  22740. /**
  22741. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22742. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22743. */
  22744. export class PostProcess {
  22745. /**
  22746. * Gets or sets the unique id of the post process
  22747. */
  22748. uniqueId: number;
  22749. /** Name of the PostProcess. */
  22750. name: string;
  22751. /**
  22752. * Width of the texture to apply the post process on
  22753. */
  22754. width: number;
  22755. /**
  22756. * Height of the texture to apply the post process on
  22757. */
  22758. height: number;
  22759. /**
  22760. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22761. */
  22762. nodeMaterialSource: Nullable<NodeMaterial>;
  22763. /**
  22764. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22765. * @hidden
  22766. */
  22767. _outputTexture: Nullable<InternalTexture>;
  22768. /**
  22769. * Sampling mode used by the shader
  22770. * See https://doc.babylonjs.com/classes/3.1/texture
  22771. */
  22772. renderTargetSamplingMode: number;
  22773. /**
  22774. * Clear color to use when screen clearing
  22775. */
  22776. clearColor: Color4;
  22777. /**
  22778. * If the buffer needs to be cleared before applying the post process. (default: true)
  22779. * Should be set to false if shader will overwrite all previous pixels.
  22780. */
  22781. autoClear: boolean;
  22782. /**
  22783. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22784. */
  22785. alphaMode: number;
  22786. /**
  22787. * Sets the setAlphaBlendConstants of the babylon engine
  22788. */
  22789. alphaConstants: Color4;
  22790. /**
  22791. * Animations to be used for the post processing
  22792. */
  22793. animations: Animation[];
  22794. /**
  22795. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22796. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22797. */
  22798. enablePixelPerfectMode: boolean;
  22799. /**
  22800. * Force the postprocess to be applied without taking in account viewport
  22801. */
  22802. forceFullscreenViewport: boolean;
  22803. /**
  22804. * List of inspectable custom properties (used by the Inspector)
  22805. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22806. */
  22807. inspectableCustomProperties: IInspectable[];
  22808. /**
  22809. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22810. *
  22811. * | Value | Type | Description |
  22812. * | ----- | ----------------------------------- | ----------- |
  22813. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22814. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22815. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22816. *
  22817. */
  22818. scaleMode: number;
  22819. /**
  22820. * Force textures to be a power of two (default: false)
  22821. */
  22822. alwaysForcePOT: boolean;
  22823. private _samples;
  22824. /**
  22825. * Number of sample textures (default: 1)
  22826. */
  22827. get samples(): number;
  22828. set samples(n: number);
  22829. /**
  22830. * Modify the scale of the post process to be the same as the viewport (default: false)
  22831. */
  22832. adaptScaleToCurrentViewport: boolean;
  22833. private _camera;
  22834. protected _scene: Scene;
  22835. private _engine;
  22836. private _options;
  22837. private _reusable;
  22838. private _textureType;
  22839. private _textureFormat;
  22840. /**
  22841. * Smart array of input and output textures for the post process.
  22842. * @hidden
  22843. */
  22844. _textures: SmartArray<InternalTexture>;
  22845. /**
  22846. * The index in _textures that corresponds to the output texture.
  22847. * @hidden
  22848. */
  22849. _currentRenderTextureInd: number;
  22850. private _effect;
  22851. private _samplers;
  22852. private _fragmentUrl;
  22853. private _vertexUrl;
  22854. private _parameters;
  22855. private _scaleRatio;
  22856. protected _indexParameters: any;
  22857. private _shareOutputWithPostProcess;
  22858. private _texelSize;
  22859. private _forcedOutputTexture;
  22860. /**
  22861. * Returns the fragment url or shader name used in the post process.
  22862. * @returns the fragment url or name in the shader store.
  22863. */
  22864. getEffectName(): string;
  22865. /**
  22866. * An event triggered when the postprocess is activated.
  22867. */
  22868. onActivateObservable: Observable<Camera>;
  22869. private _onActivateObserver;
  22870. /**
  22871. * A function that is added to the onActivateObservable
  22872. */
  22873. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22874. /**
  22875. * An event triggered when the postprocess changes its size.
  22876. */
  22877. onSizeChangedObservable: Observable<PostProcess>;
  22878. private _onSizeChangedObserver;
  22879. /**
  22880. * A function that is added to the onSizeChangedObservable
  22881. */
  22882. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22883. /**
  22884. * An event triggered when the postprocess applies its effect.
  22885. */
  22886. onApplyObservable: Observable<Effect>;
  22887. private _onApplyObserver;
  22888. /**
  22889. * A function that is added to the onApplyObservable
  22890. */
  22891. set onApply(callback: (effect: Effect) => void);
  22892. /**
  22893. * An event triggered before rendering the postprocess
  22894. */
  22895. onBeforeRenderObservable: Observable<Effect>;
  22896. private _onBeforeRenderObserver;
  22897. /**
  22898. * A function that is added to the onBeforeRenderObservable
  22899. */
  22900. set onBeforeRender(callback: (effect: Effect) => void);
  22901. /**
  22902. * An event triggered after rendering the postprocess
  22903. */
  22904. onAfterRenderObservable: Observable<Effect>;
  22905. private _onAfterRenderObserver;
  22906. /**
  22907. * A function that is added to the onAfterRenderObservable
  22908. */
  22909. set onAfterRender(callback: (efect: Effect) => void);
  22910. /**
  22911. * 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
  22912. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22913. */
  22914. get inputTexture(): InternalTexture;
  22915. set inputTexture(value: InternalTexture);
  22916. /**
  22917. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22918. * the only way to unset it is to use this function to restore its internal state
  22919. */
  22920. restoreDefaultInputTexture(): void;
  22921. /**
  22922. * Gets the camera which post process is applied to.
  22923. * @returns The camera the post process is applied to.
  22924. */
  22925. getCamera(): Camera;
  22926. /**
  22927. * Gets the texel size of the postprocess.
  22928. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22929. */
  22930. get texelSize(): Vector2;
  22931. /**
  22932. * Creates a new instance PostProcess
  22933. * @param name The name of the PostProcess.
  22934. * @param fragmentUrl The url of the fragment shader to be used.
  22935. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22936. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22937. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22938. * @param camera The camera to apply the render pass to.
  22939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22940. * @param engine The engine which the post process will be applied. (default: current engine)
  22941. * @param reusable If the post process can be reused on the same frame. (default: false)
  22942. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22943. * @param textureType Type of textures used when performing the post process. (default: 0)
  22944. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22945. * @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
  22946. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  22947. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22948. */
  22949. 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);
  22950. /**
  22951. * Gets a string identifying the name of the class
  22952. * @returns "PostProcess" string
  22953. */
  22954. getClassName(): string;
  22955. /**
  22956. * Gets the engine which this post process belongs to.
  22957. * @returns The engine the post process was enabled with.
  22958. */
  22959. getEngine(): Engine;
  22960. /**
  22961. * The effect that is created when initializing the post process.
  22962. * @returns The created effect corresponding the the postprocess.
  22963. */
  22964. getEffect(): Effect;
  22965. /**
  22966. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22967. * @param postProcess The post process to share the output with.
  22968. * @returns This post process.
  22969. */
  22970. shareOutputWith(postProcess: PostProcess): PostProcess;
  22971. /**
  22972. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22973. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22974. */
  22975. useOwnOutput(): void;
  22976. /**
  22977. * Updates the effect with the current post process compile time values and recompiles the shader.
  22978. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22979. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22980. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22981. * @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
  22982. * @param onCompiled Called when the shader has been compiled.
  22983. * @param onError Called if there is an error when compiling a shader.
  22984. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22985. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22986. */
  22987. 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;
  22988. /**
  22989. * The post process is reusable if it can be used multiple times within one frame.
  22990. * @returns If the post process is reusable
  22991. */
  22992. isReusable(): boolean;
  22993. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22994. markTextureDirty(): void;
  22995. /**
  22996. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22997. * 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.
  22998. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22999. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23000. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23001. * @returns The target texture that was bound to be written to.
  23002. */
  23003. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23004. /**
  23005. * If the post process is supported.
  23006. */
  23007. get isSupported(): boolean;
  23008. /**
  23009. * The aspect ratio of the output texture.
  23010. */
  23011. get aspectRatio(): number;
  23012. /**
  23013. * Get a value indicating if the post-process is ready to be used
  23014. * @returns true if the post-process is ready (shader is compiled)
  23015. */
  23016. isReady(): boolean;
  23017. /**
  23018. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23019. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23020. */
  23021. apply(): Nullable<Effect>;
  23022. private _disposeTextures;
  23023. /**
  23024. * Disposes the post process.
  23025. * @param camera The camera to dispose the post process on.
  23026. */
  23027. dispose(camera?: Camera): void;
  23028. /**
  23029. * Serializes the particle system to a JSON object
  23030. * @returns the JSON object
  23031. */
  23032. serialize(): any;
  23033. /**
  23034. * Creates a material from parsed material data
  23035. * @param parsedPostProcess defines parsed post process data
  23036. * @param scene defines the hosting scene
  23037. * @param rootUrl defines the root URL to use to load textures
  23038. * @returns a new post process
  23039. */
  23040. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23041. }
  23042. }
  23043. declare module BABYLON {
  23044. /** @hidden */
  23045. export var kernelBlurVaryingDeclaration: {
  23046. name: string;
  23047. shader: string;
  23048. };
  23049. }
  23050. declare module BABYLON {
  23051. /** @hidden */
  23052. export var kernelBlurFragment: {
  23053. name: string;
  23054. shader: string;
  23055. };
  23056. }
  23057. declare module BABYLON {
  23058. /** @hidden */
  23059. export var kernelBlurFragment2: {
  23060. name: string;
  23061. shader: string;
  23062. };
  23063. }
  23064. declare module BABYLON {
  23065. /** @hidden */
  23066. export var kernelBlurPixelShader: {
  23067. name: string;
  23068. shader: string;
  23069. };
  23070. }
  23071. declare module BABYLON {
  23072. /** @hidden */
  23073. export var kernelBlurVertex: {
  23074. name: string;
  23075. shader: string;
  23076. };
  23077. }
  23078. declare module BABYLON {
  23079. /** @hidden */
  23080. export var kernelBlurVertexShader: {
  23081. name: string;
  23082. shader: string;
  23083. };
  23084. }
  23085. declare module BABYLON {
  23086. /**
  23087. * The Blur Post Process which blurs an image based on a kernel and direction.
  23088. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23089. */
  23090. export class BlurPostProcess extends PostProcess {
  23091. private blockCompilation;
  23092. protected _kernel: number;
  23093. protected _idealKernel: number;
  23094. protected _packedFloat: boolean;
  23095. private _staticDefines;
  23096. /** The direction in which to blur the image. */
  23097. direction: Vector2;
  23098. /**
  23099. * Sets the length in pixels of the blur sample region
  23100. */
  23101. set kernel(v: number);
  23102. /**
  23103. * Gets the length in pixels of the blur sample region
  23104. */
  23105. get kernel(): number;
  23106. /**
  23107. * Sets wether or not the blur needs to unpack/repack floats
  23108. */
  23109. set packedFloat(v: boolean);
  23110. /**
  23111. * Gets wether or not the blur is unpacking/repacking floats
  23112. */
  23113. get packedFloat(): boolean;
  23114. /**
  23115. * Gets a string identifying the name of the class
  23116. * @returns "BlurPostProcess" string
  23117. */
  23118. getClassName(): string;
  23119. /**
  23120. * Creates a new instance BlurPostProcess
  23121. * @param name The name of the effect.
  23122. * @param direction The direction in which to blur the image.
  23123. * @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.
  23124. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23125. * @param camera The camera to apply the render pass to.
  23126. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23127. * @param engine The engine which the post process will be applied. (default: current engine)
  23128. * @param reusable If the post process can be reused on the same frame. (default: false)
  23129. * @param textureType Type of textures used when performing the post process. (default: 0)
  23130. * @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)
  23131. */
  23132. 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);
  23133. /**
  23134. * Updates the effect with the current post process compile time values and recompiles the shader.
  23135. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23136. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23137. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23138. * @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
  23139. * @param onCompiled Called when the shader has been compiled.
  23140. * @param onError Called if there is an error when compiling a shader.
  23141. */
  23142. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23143. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23144. /**
  23145. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23146. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23147. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23148. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23149. * The gaps between physical kernels are compensated for in the weighting of the samples
  23150. * @param idealKernel Ideal blur kernel.
  23151. * @return Nearest best kernel.
  23152. */
  23153. protected _nearestBestKernel(idealKernel: number): number;
  23154. /**
  23155. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23156. * @param x The point on the Gaussian distribution to sample.
  23157. * @return the value of the Gaussian function at x.
  23158. */
  23159. protected _gaussianWeight(x: number): number;
  23160. /**
  23161. * Generates a string that can be used as a floating point number in GLSL.
  23162. * @param x Value to print.
  23163. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23164. * @return GLSL float string.
  23165. */
  23166. protected _glslFloat(x: number, decimalFigures?: number): string;
  23167. /** @hidden */
  23168. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23169. }
  23170. }
  23171. declare module BABYLON {
  23172. /**
  23173. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23174. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23175. * You can then easily use it as a reflectionTexture on a flat surface.
  23176. * In case the surface is not a plane, please consider relying on reflection probes.
  23177. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23178. */
  23179. export class MirrorTexture extends RenderTargetTexture {
  23180. private scene;
  23181. /**
  23182. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23183. * 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.
  23184. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23185. */
  23186. mirrorPlane: Plane;
  23187. /**
  23188. * Define the blur ratio used to blur the reflection if needed.
  23189. */
  23190. set blurRatio(value: number);
  23191. get blurRatio(): number;
  23192. /**
  23193. * Define the adaptive blur kernel used to blur the reflection if needed.
  23194. * This will autocompute the closest best match for the `blurKernel`
  23195. */
  23196. set adaptiveBlurKernel(value: number);
  23197. /**
  23198. * Define the blur kernel used to blur the reflection if needed.
  23199. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23200. */
  23201. set blurKernel(value: number);
  23202. /**
  23203. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23204. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23205. */
  23206. set blurKernelX(value: number);
  23207. get blurKernelX(): number;
  23208. /**
  23209. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23210. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23211. */
  23212. set blurKernelY(value: number);
  23213. get blurKernelY(): number;
  23214. private _autoComputeBlurKernel;
  23215. protected _onRatioRescale(): void;
  23216. private _updateGammaSpace;
  23217. private _imageProcessingConfigChangeObserver;
  23218. private _transformMatrix;
  23219. private _mirrorMatrix;
  23220. private _savedViewMatrix;
  23221. private _blurX;
  23222. private _blurY;
  23223. private _adaptiveBlurKernel;
  23224. private _blurKernelX;
  23225. private _blurKernelY;
  23226. private _blurRatio;
  23227. /**
  23228. * Instantiates a Mirror Texture.
  23229. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23230. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23231. * You can then easily use it as a reflectionTexture on a flat surface.
  23232. * In case the surface is not a plane, please consider relying on reflection probes.
  23233. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23234. * @param name
  23235. * @param size
  23236. * @param scene
  23237. * @param generateMipMaps
  23238. * @param type
  23239. * @param samplingMode
  23240. * @param generateDepthBuffer
  23241. */
  23242. constructor(name: string, size: number | {
  23243. width: number;
  23244. height: number;
  23245. } | {
  23246. ratio: number;
  23247. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23248. private _preparePostProcesses;
  23249. /**
  23250. * Clone the mirror texture.
  23251. * @returns the cloned texture
  23252. */
  23253. clone(): MirrorTexture;
  23254. /**
  23255. * Serialize the texture to a JSON representation you could use in Parse later on
  23256. * @returns the serialized JSON representation
  23257. */
  23258. serialize(): any;
  23259. /**
  23260. * Dispose the texture and release its associated resources.
  23261. */
  23262. dispose(): void;
  23263. }
  23264. }
  23265. declare module BABYLON {
  23266. /**
  23267. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23268. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23269. */
  23270. export class Texture extends BaseTexture {
  23271. /**
  23272. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23273. */
  23274. static SerializeBuffers: boolean;
  23275. /** @hidden */
  23276. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23277. /** @hidden */
  23278. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23279. /** @hidden */
  23280. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23281. /** nearest is mag = nearest and min = nearest and mip = linear */
  23282. static readonly NEAREST_SAMPLINGMODE: number;
  23283. /** nearest is mag = nearest and min = nearest and mip = linear */
  23284. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23285. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23286. static readonly BILINEAR_SAMPLINGMODE: number;
  23287. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23288. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23289. /** Trilinear is mag = linear and min = linear and mip = linear */
  23290. static readonly TRILINEAR_SAMPLINGMODE: number;
  23291. /** Trilinear is mag = linear and min = linear and mip = linear */
  23292. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23293. /** mag = nearest and min = nearest and mip = nearest */
  23294. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23295. /** mag = nearest and min = linear and mip = nearest */
  23296. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23297. /** mag = nearest and min = linear and mip = linear */
  23298. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23299. /** mag = nearest and min = linear and mip = none */
  23300. static readonly NEAREST_LINEAR: number;
  23301. /** mag = nearest and min = nearest and mip = none */
  23302. static readonly NEAREST_NEAREST: number;
  23303. /** mag = linear and min = nearest and mip = nearest */
  23304. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23305. /** mag = linear and min = nearest and mip = linear */
  23306. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23307. /** mag = linear and min = linear and mip = none */
  23308. static readonly LINEAR_LINEAR: number;
  23309. /** mag = linear and min = nearest and mip = none */
  23310. static readonly LINEAR_NEAREST: number;
  23311. /** Explicit coordinates mode */
  23312. static readonly EXPLICIT_MODE: number;
  23313. /** Spherical coordinates mode */
  23314. static readonly SPHERICAL_MODE: number;
  23315. /** Planar coordinates mode */
  23316. static readonly PLANAR_MODE: number;
  23317. /** Cubic coordinates mode */
  23318. static readonly CUBIC_MODE: number;
  23319. /** Projection coordinates mode */
  23320. static readonly PROJECTION_MODE: number;
  23321. /** Inverse Cubic coordinates mode */
  23322. static readonly SKYBOX_MODE: number;
  23323. /** Inverse Cubic coordinates mode */
  23324. static readonly INVCUBIC_MODE: number;
  23325. /** Equirectangular coordinates mode */
  23326. static readonly EQUIRECTANGULAR_MODE: number;
  23327. /** Equirectangular Fixed coordinates mode */
  23328. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23329. /** Equirectangular Fixed Mirrored coordinates mode */
  23330. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23331. /** Texture is not repeating outside of 0..1 UVs */
  23332. static readonly CLAMP_ADDRESSMODE: number;
  23333. /** Texture is repeating outside of 0..1 UVs */
  23334. static readonly WRAP_ADDRESSMODE: number;
  23335. /** Texture is repeating and mirrored */
  23336. static readonly MIRROR_ADDRESSMODE: number;
  23337. /**
  23338. * 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
  23339. */
  23340. static UseSerializedUrlIfAny: boolean;
  23341. /**
  23342. * Define the url of the texture.
  23343. */
  23344. url: Nullable<string>;
  23345. /**
  23346. * Define an offset on the texture to offset the u coordinates of the UVs
  23347. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23348. */
  23349. uOffset: number;
  23350. /**
  23351. * Define an offset on the texture to offset the v coordinates of the UVs
  23352. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23353. */
  23354. vOffset: number;
  23355. /**
  23356. * Define an offset on the texture to scale the u coordinates of the UVs
  23357. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23358. */
  23359. uScale: number;
  23360. /**
  23361. * Define an offset on the texture to scale the v coordinates of the UVs
  23362. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23363. */
  23364. vScale: number;
  23365. /**
  23366. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23367. * @see https://doc.babylonjs.com/how_to/more_materials
  23368. */
  23369. uAng: number;
  23370. /**
  23371. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23372. * @see https://doc.babylonjs.com/how_to/more_materials
  23373. */
  23374. vAng: number;
  23375. /**
  23376. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23377. * @see https://doc.babylonjs.com/how_to/more_materials
  23378. */
  23379. wAng: number;
  23380. /**
  23381. * Defines the center of rotation (U)
  23382. */
  23383. uRotationCenter: number;
  23384. /**
  23385. * Defines the center of rotation (V)
  23386. */
  23387. vRotationCenter: number;
  23388. /**
  23389. * Defines the center of rotation (W)
  23390. */
  23391. wRotationCenter: number;
  23392. /**
  23393. * Are mip maps generated for this texture or not.
  23394. */
  23395. get noMipmap(): boolean;
  23396. /**
  23397. * List of inspectable custom properties (used by the Inspector)
  23398. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23399. */
  23400. inspectableCustomProperties: Nullable<IInspectable[]>;
  23401. private _noMipmap;
  23402. /** @hidden */
  23403. _invertY: boolean;
  23404. private _rowGenerationMatrix;
  23405. private _cachedTextureMatrix;
  23406. private _projectionModeMatrix;
  23407. private _t0;
  23408. private _t1;
  23409. private _t2;
  23410. private _cachedUOffset;
  23411. private _cachedVOffset;
  23412. private _cachedUScale;
  23413. private _cachedVScale;
  23414. private _cachedUAng;
  23415. private _cachedVAng;
  23416. private _cachedWAng;
  23417. private _cachedProjectionMatrixId;
  23418. private _cachedCoordinatesMode;
  23419. /** @hidden */
  23420. protected _initialSamplingMode: number;
  23421. /** @hidden */
  23422. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23423. private _deleteBuffer;
  23424. protected _format: Nullable<number>;
  23425. private _delayedOnLoad;
  23426. private _delayedOnError;
  23427. private _mimeType?;
  23428. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23429. get mimeType(): string | undefined;
  23430. /**
  23431. * Observable triggered once the texture has been loaded.
  23432. */
  23433. onLoadObservable: Observable<Texture>;
  23434. protected _isBlocking: boolean;
  23435. /**
  23436. * Is the texture preventing material to render while loading.
  23437. * If false, a default texture will be used instead of the loading one during the preparation step.
  23438. */
  23439. set isBlocking(value: boolean);
  23440. get isBlocking(): boolean;
  23441. /**
  23442. * Get the current sampling mode associated with the texture.
  23443. */
  23444. get samplingMode(): number;
  23445. /**
  23446. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23447. */
  23448. get invertY(): boolean;
  23449. /**
  23450. * Instantiates a new texture.
  23451. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23452. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23453. * @param url defines the url of the picture to load as a texture
  23454. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23455. * @param noMipmap defines if the texture will require mip maps or not
  23456. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23457. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23458. * @param onLoad defines a callback triggered when the texture has been loaded
  23459. * @param onError defines a callback triggered when an error occurred during the loading session
  23460. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23461. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23462. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23463. * @param mimeType defines an optional mime type information
  23464. */
  23465. 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);
  23466. /**
  23467. * Update the url (and optional buffer) of this texture if url was null during construction.
  23468. * @param url the url of the texture
  23469. * @param buffer the buffer of the texture (defaults to null)
  23470. * @param onLoad callback called when the texture is loaded (defaults to null)
  23471. */
  23472. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23473. /**
  23474. * Finish the loading sequence of a texture flagged as delayed load.
  23475. * @hidden
  23476. */
  23477. delayLoad(): void;
  23478. private _prepareRowForTextureGeneration;
  23479. /**
  23480. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23481. * @returns the transform matrix of the texture.
  23482. */
  23483. getTextureMatrix(uBase?: number): Matrix;
  23484. /**
  23485. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23486. * @returns The reflection texture transform
  23487. */
  23488. getReflectionTextureMatrix(): Matrix;
  23489. /**
  23490. * Clones the texture.
  23491. * @returns the cloned texture
  23492. */
  23493. clone(): Texture;
  23494. /**
  23495. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23496. * @returns The JSON representation of the texture
  23497. */
  23498. serialize(): any;
  23499. /**
  23500. * Get the current class name of the texture useful for serialization or dynamic coding.
  23501. * @returns "Texture"
  23502. */
  23503. getClassName(): string;
  23504. /**
  23505. * Dispose the texture and release its associated resources.
  23506. */
  23507. dispose(): void;
  23508. /**
  23509. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23510. * @param parsedTexture Define the JSON representation of the texture
  23511. * @param scene Define the scene the parsed texture should be instantiated in
  23512. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23513. * @returns The parsed texture if successful
  23514. */
  23515. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23516. /**
  23517. * Creates a texture from its base 64 representation.
  23518. * @param data Define the base64 payload without the data: prefix
  23519. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23520. * @param scene Define the scene the texture should belong to
  23521. * @param noMipmap Forces the texture to not create mip map information if true
  23522. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23523. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23524. * @param onLoad define a callback triggered when the texture has been loaded
  23525. * @param onError define a callback triggered when an error occurred during the loading session
  23526. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23527. * @returns the created texture
  23528. */
  23529. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23530. /**
  23531. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23532. * @param data Define the base64 payload without the data: prefix
  23533. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23534. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23535. * @param scene Define the scene the texture should belong to
  23536. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23537. * @param noMipmap Forces the texture to not create mip map information if true
  23538. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23539. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23540. * @param onLoad define a callback triggered when the texture has been loaded
  23541. * @param onError define a callback triggered when an error occurred during the loading session
  23542. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23543. * @returns the created texture
  23544. */
  23545. 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;
  23546. }
  23547. }
  23548. declare module BABYLON {
  23549. /**
  23550. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23551. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23552. */
  23553. export class PostProcessManager {
  23554. private _scene;
  23555. private _indexBuffer;
  23556. private _vertexBuffers;
  23557. /**
  23558. * Creates a new instance PostProcess
  23559. * @param scene The scene that the post process is associated with.
  23560. */
  23561. constructor(scene: Scene);
  23562. private _prepareBuffers;
  23563. private _buildIndexBuffer;
  23564. /**
  23565. * Rebuilds the vertex buffers of the manager.
  23566. * @hidden
  23567. */
  23568. _rebuild(): void;
  23569. /**
  23570. * Prepares a frame to be run through a post process.
  23571. * @param sourceTexture The input texture to the post procesess. (default: null)
  23572. * @param postProcesses An array of post processes to be run. (default: null)
  23573. * @returns True if the post processes were able to be run.
  23574. * @hidden
  23575. */
  23576. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23577. /**
  23578. * Manually render a set of post processes to a texture.
  23579. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23580. * @param postProcesses An array of post processes to be run.
  23581. * @param targetTexture The target texture to render to.
  23582. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23583. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23584. * @param lodLevel defines which lod of the texture to render to
  23585. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23586. */
  23587. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23588. /**
  23589. * Finalize the result of the output of the postprocesses.
  23590. * @param doNotPresent If true the result will not be displayed to the screen.
  23591. * @param targetTexture The target texture to render to.
  23592. * @param faceIndex The index of the face to bind the target texture to.
  23593. * @param postProcesses The array of post processes to render.
  23594. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23595. * @hidden
  23596. */
  23597. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23598. /**
  23599. * Disposes of the post process manager.
  23600. */
  23601. dispose(): void;
  23602. }
  23603. }
  23604. declare module BABYLON {
  23605. /**
  23606. * This Helps creating a texture that will be created from a camera in your scene.
  23607. * It is basically a dynamic texture that could be used to create special effects for instance.
  23608. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23609. */
  23610. export class RenderTargetTexture extends Texture {
  23611. /**
  23612. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23613. */
  23614. static readonly REFRESHRATE_RENDER_ONCE: number;
  23615. /**
  23616. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23617. */
  23618. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23619. /**
  23620. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23621. * the central point of your effect and can save a lot of performances.
  23622. */
  23623. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23624. /**
  23625. * Use this predicate to dynamically define the list of mesh you want to render.
  23626. * If set, the renderList property will be overwritten.
  23627. */
  23628. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23629. private _renderList;
  23630. /**
  23631. * Use this list to define the list of mesh you want to render.
  23632. */
  23633. get renderList(): Nullable<Array<AbstractMesh>>;
  23634. set renderList(value: Nullable<Array<AbstractMesh>>);
  23635. /**
  23636. * Use this function to overload the renderList array at rendering time.
  23637. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23638. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23639. * the cube (if the RTT is a cube, else layerOrFace=0).
  23640. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23641. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23642. * hold dummy elements!
  23643. */
  23644. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23645. private _hookArray;
  23646. /**
  23647. * Define if particles should be rendered in your texture.
  23648. */
  23649. renderParticles: boolean;
  23650. /**
  23651. * Define if sprites should be rendered in your texture.
  23652. */
  23653. renderSprites: boolean;
  23654. /**
  23655. * Define the camera used to render the texture.
  23656. */
  23657. activeCamera: Nullable<Camera>;
  23658. /**
  23659. * Override the mesh isReady function with your own one.
  23660. */
  23661. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23662. /**
  23663. * Override the render function of the texture with your own one.
  23664. */
  23665. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23666. /**
  23667. * Define if camera post processes should be use while rendering the texture.
  23668. */
  23669. useCameraPostProcesses: boolean;
  23670. /**
  23671. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23672. */
  23673. ignoreCameraViewport: boolean;
  23674. private _postProcessManager;
  23675. private _postProcesses;
  23676. private _resizeObserver;
  23677. /**
  23678. * An event triggered when the texture is unbind.
  23679. */
  23680. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23681. /**
  23682. * An event triggered when the texture is unbind.
  23683. */
  23684. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23685. private _onAfterUnbindObserver;
  23686. /**
  23687. * Set a after unbind callback in the texture.
  23688. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23689. */
  23690. set onAfterUnbind(callback: () => void);
  23691. /**
  23692. * An event triggered before rendering the texture
  23693. */
  23694. onBeforeRenderObservable: Observable<number>;
  23695. private _onBeforeRenderObserver;
  23696. /**
  23697. * Set a before render callback in the texture.
  23698. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23699. */
  23700. set onBeforeRender(callback: (faceIndex: number) => void);
  23701. /**
  23702. * An event triggered after rendering the texture
  23703. */
  23704. onAfterRenderObservable: Observable<number>;
  23705. private _onAfterRenderObserver;
  23706. /**
  23707. * Set a after render callback in the texture.
  23708. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23709. */
  23710. set onAfterRender(callback: (faceIndex: number) => void);
  23711. /**
  23712. * An event triggered after the texture clear
  23713. */
  23714. onClearObservable: Observable<Engine>;
  23715. private _onClearObserver;
  23716. /**
  23717. * Set a clear callback in the texture.
  23718. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23719. */
  23720. set onClear(callback: (Engine: Engine) => void);
  23721. /**
  23722. * An event triggered when the texture is resized.
  23723. */
  23724. onResizeObservable: Observable<RenderTargetTexture>;
  23725. /**
  23726. * Define the clear color of the Render Target if it should be different from the scene.
  23727. */
  23728. clearColor: Color4;
  23729. protected _size: number | {
  23730. width: number;
  23731. height: number;
  23732. layers?: number;
  23733. };
  23734. protected _initialSizeParameter: number | {
  23735. width: number;
  23736. height: number;
  23737. } | {
  23738. ratio: number;
  23739. };
  23740. protected _sizeRatio: Nullable<number>;
  23741. /** @hidden */
  23742. _generateMipMaps: boolean;
  23743. protected _renderingManager: RenderingManager;
  23744. /** @hidden */
  23745. _waitingRenderList?: string[];
  23746. protected _doNotChangeAspectRatio: boolean;
  23747. protected _currentRefreshId: number;
  23748. protected _refreshRate: number;
  23749. protected _textureMatrix: Matrix;
  23750. protected _samples: number;
  23751. protected _renderTargetOptions: RenderTargetCreationOptions;
  23752. /**
  23753. * Gets render target creation options that were used.
  23754. */
  23755. get renderTargetOptions(): RenderTargetCreationOptions;
  23756. protected _onRatioRescale(): void;
  23757. /**
  23758. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23759. * It must define where the camera used to render the texture is set
  23760. */
  23761. boundingBoxPosition: Vector3;
  23762. private _boundingBoxSize;
  23763. /**
  23764. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23765. * When defined, the cubemap will switch to local mode
  23766. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23767. * @example https://www.babylonjs-playground.com/#RNASML
  23768. */
  23769. set boundingBoxSize(value: Vector3);
  23770. get boundingBoxSize(): Vector3;
  23771. /**
  23772. * In case the RTT has been created with a depth texture, get the associated
  23773. * depth texture.
  23774. * Otherwise, return null.
  23775. */
  23776. get depthStencilTexture(): Nullable<InternalTexture>;
  23777. /**
  23778. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23779. * or used a shadow, depth texture...
  23780. * @param name The friendly name of the texture
  23781. * @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)
  23782. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23783. * @param generateMipMaps True if mip maps need to be generated after render.
  23784. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23785. * @param type The type of the buffer in the RTT (int, half float, float...)
  23786. * @param isCube True if a cube texture needs to be created
  23787. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23788. * @param generateDepthBuffer True to generate a depth buffer
  23789. * @param generateStencilBuffer True to generate a stencil buffer
  23790. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23791. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23792. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23793. */
  23794. constructor(name: string, size: number | {
  23795. width: number;
  23796. height: number;
  23797. layers?: number;
  23798. } | {
  23799. ratio: number;
  23800. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23801. /**
  23802. * Creates a depth stencil texture.
  23803. * This is only available in WebGL 2 or with the depth texture extension available.
  23804. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23805. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23806. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23807. */
  23808. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23809. private _processSizeParameter;
  23810. /**
  23811. * Define the number of samples to use in case of MSAA.
  23812. * It defaults to one meaning no MSAA has been enabled.
  23813. */
  23814. get samples(): number;
  23815. set samples(value: number);
  23816. /**
  23817. * Resets the refresh counter of the texture and start bak from scratch.
  23818. * Could be useful to regenerate the texture if it is setup to render only once.
  23819. */
  23820. resetRefreshCounter(): void;
  23821. /**
  23822. * Define the refresh rate of the texture or the rendering frequency.
  23823. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23824. */
  23825. get refreshRate(): number;
  23826. set refreshRate(value: number);
  23827. /**
  23828. * Adds a post process to the render target rendering passes.
  23829. * @param postProcess define the post process to add
  23830. */
  23831. addPostProcess(postProcess: PostProcess): void;
  23832. /**
  23833. * Clear all the post processes attached to the render target
  23834. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23835. */
  23836. clearPostProcesses(dispose?: boolean): void;
  23837. /**
  23838. * Remove one of the post process from the list of attached post processes to the texture
  23839. * @param postProcess define the post process to remove from the list
  23840. */
  23841. removePostProcess(postProcess: PostProcess): void;
  23842. /** @hidden */
  23843. _shouldRender(): boolean;
  23844. /**
  23845. * Gets the actual render size of the texture.
  23846. * @returns the width of the render size
  23847. */
  23848. getRenderSize(): number;
  23849. /**
  23850. * Gets the actual render width of the texture.
  23851. * @returns the width of the render size
  23852. */
  23853. getRenderWidth(): number;
  23854. /**
  23855. * Gets the actual render height of the texture.
  23856. * @returns the height of the render size
  23857. */
  23858. getRenderHeight(): number;
  23859. /**
  23860. * Gets the actual number of layers of the texture.
  23861. * @returns the number of layers
  23862. */
  23863. getRenderLayers(): number;
  23864. /**
  23865. * Get if the texture can be rescaled or not.
  23866. */
  23867. get canRescale(): boolean;
  23868. /**
  23869. * Resize the texture using a ratio.
  23870. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23871. */
  23872. scale(ratio: number): void;
  23873. /**
  23874. * Get the texture reflection matrix used to rotate/transform the reflection.
  23875. * @returns the reflection matrix
  23876. */
  23877. getReflectionTextureMatrix(): Matrix;
  23878. /**
  23879. * Resize the texture to a new desired size.
  23880. * Be carrefull as it will recreate all the data in the new texture.
  23881. * @param size Define the new size. It can be:
  23882. * - a number for squared texture,
  23883. * - an object containing { width: number, height: number }
  23884. * - or an object containing a ratio { ratio: number }
  23885. */
  23886. resize(size: number | {
  23887. width: number;
  23888. height: number;
  23889. } | {
  23890. ratio: number;
  23891. }): void;
  23892. private _defaultRenderListPrepared;
  23893. /**
  23894. * Renders all the objects from the render list into the texture.
  23895. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23896. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23897. */
  23898. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23899. private _bestReflectionRenderTargetDimension;
  23900. private _prepareRenderingManager;
  23901. /**
  23902. * @hidden
  23903. * @param faceIndex face index to bind to if this is a cubetexture
  23904. * @param layer defines the index of the texture to bind in the array
  23905. */
  23906. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23907. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23908. private renderToTarget;
  23909. /**
  23910. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23911. * This allowed control for front to back rendering or reversly depending of the special needs.
  23912. *
  23913. * @param renderingGroupId The rendering group id corresponding to its index
  23914. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23915. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23916. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23917. */
  23918. 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;
  23919. /**
  23920. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23921. *
  23922. * @param renderingGroupId The rendering group id corresponding to its index
  23923. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23924. */
  23925. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23926. /**
  23927. * Clones the texture.
  23928. * @returns the cloned texture
  23929. */
  23930. clone(): RenderTargetTexture;
  23931. /**
  23932. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23933. * @returns The JSON representation of the texture
  23934. */
  23935. serialize(): any;
  23936. /**
  23937. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23938. */
  23939. disposeFramebufferObjects(): void;
  23940. /**
  23941. * Dispose the texture and release its associated resources.
  23942. */
  23943. dispose(): void;
  23944. /** @hidden */
  23945. _rebuild(): void;
  23946. /**
  23947. * Clear the info related to rendering groups preventing retention point in material dispose.
  23948. */
  23949. freeRenderingGroups(): void;
  23950. /**
  23951. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23952. * @returns the view count
  23953. */
  23954. getViewCount(): number;
  23955. }
  23956. }
  23957. declare module BABYLON {
  23958. /**
  23959. * Class used to manipulate GUIDs
  23960. */
  23961. export class GUID {
  23962. /**
  23963. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23964. * Be aware Math.random() could cause collisions, but:
  23965. * "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"
  23966. * @returns a pseudo random id
  23967. */
  23968. static RandomId(): string;
  23969. }
  23970. }
  23971. declare module BABYLON {
  23972. /**
  23973. * Options to be used when creating a shadow depth material
  23974. */
  23975. export interface IIOptionShadowDepthMaterial {
  23976. /** Variables in the vertex shader code that need to have their names remapped.
  23977. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23978. * "var_name" should be either: worldPos or vNormalW
  23979. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23980. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23981. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23982. */
  23983. remappedVariables?: string[];
  23984. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23985. standalone?: boolean;
  23986. }
  23987. /**
  23988. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23989. */
  23990. export class ShadowDepthWrapper {
  23991. private _scene;
  23992. private _options?;
  23993. private _baseMaterial;
  23994. private _onEffectCreatedObserver;
  23995. private _subMeshToEffect;
  23996. private _subMeshToDepthEffect;
  23997. private _meshes;
  23998. /** @hidden */
  23999. _matriceNames: any;
  24000. /** Gets the standalone status of the wrapper */
  24001. get standalone(): boolean;
  24002. /** Gets the base material the wrapper is built upon */
  24003. get baseMaterial(): Material;
  24004. /**
  24005. * Instantiate a new shadow depth wrapper.
  24006. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24007. * generate the shadow depth map. For more information, please refer to the documentation:
  24008. * https://doc.babylonjs.com/babylon101/shadows
  24009. * @param baseMaterial Material to wrap
  24010. * @param scene Define the scene the material belongs to
  24011. * @param options Options used to create the wrapper
  24012. */
  24013. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24014. /**
  24015. * Gets the effect to use to generate the depth map
  24016. * @param subMesh subMesh to get the effect for
  24017. * @param shadowGenerator shadow generator to get the effect for
  24018. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24019. */
  24020. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24021. /**
  24022. * Specifies that the submesh is ready to be used for depth rendering
  24023. * @param subMesh submesh to check
  24024. * @param defines the list of defines to take into account when checking the effect
  24025. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24026. * @param useInstances specifies that instances should be used
  24027. * @returns a boolean indicating that the submesh is ready or not
  24028. */
  24029. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24030. /**
  24031. * Disposes the resources
  24032. */
  24033. dispose(): void;
  24034. private _makeEffect;
  24035. }
  24036. }
  24037. declare module BABYLON {
  24038. interface ThinEngine {
  24039. /**
  24040. * Unbind a list of render target textures from the webGL context
  24041. * This is used only when drawBuffer extension or webGL2 are active
  24042. * @param textures defines the render target textures to unbind
  24043. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24044. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24045. */
  24046. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24047. /**
  24048. * Create a multi render target texture
  24049. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24050. * @param size defines the size of the texture
  24051. * @param options defines the creation options
  24052. * @returns the cube texture as an InternalTexture
  24053. */
  24054. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24055. /**
  24056. * Update the sample count for a given multiple render target texture
  24057. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24058. * @param textures defines the textures to update
  24059. * @param samples defines the sample count to set
  24060. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24061. */
  24062. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24063. /**
  24064. * Select a subsets of attachments to draw to.
  24065. * @param attachments gl attachments
  24066. */
  24067. bindAttachments(attachments: number[]): void;
  24068. }
  24069. }
  24070. declare module BABYLON {
  24071. /**
  24072. * Creation options of the multi render target texture.
  24073. */
  24074. export interface IMultiRenderTargetOptions {
  24075. /**
  24076. * Define if the texture needs to create mip maps after render.
  24077. */
  24078. generateMipMaps?: boolean;
  24079. /**
  24080. * Define the types of all the draw buffers we want to create
  24081. */
  24082. types?: number[];
  24083. /**
  24084. * Define the sampling modes of all the draw buffers we want to create
  24085. */
  24086. samplingModes?: number[];
  24087. /**
  24088. * Define if a depth buffer is required
  24089. */
  24090. generateDepthBuffer?: boolean;
  24091. /**
  24092. * Define if a stencil buffer is required
  24093. */
  24094. generateStencilBuffer?: boolean;
  24095. /**
  24096. * Define if a depth texture is required instead of a depth buffer
  24097. */
  24098. generateDepthTexture?: boolean;
  24099. /**
  24100. * Define the number of desired draw buffers
  24101. */
  24102. textureCount?: number;
  24103. /**
  24104. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24105. */
  24106. doNotChangeAspectRatio?: boolean;
  24107. /**
  24108. * Define the default type of the buffers we are creating
  24109. */
  24110. defaultType?: number;
  24111. }
  24112. /**
  24113. * A multi render target, like a render target provides the ability to render to a texture.
  24114. * Unlike the render target, it can render to several draw buffers in one draw.
  24115. * This is specially interesting in deferred rendering or for any effects requiring more than
  24116. * just one color from a single pass.
  24117. */
  24118. export class MultiRenderTarget extends RenderTargetTexture {
  24119. private _internalTextures;
  24120. private _textures;
  24121. private _multiRenderTargetOptions;
  24122. private _count;
  24123. /**
  24124. * Get if draw buffers are currently supported by the used hardware and browser.
  24125. */
  24126. get isSupported(): boolean;
  24127. /**
  24128. * Get the list of textures generated by the multi render target.
  24129. */
  24130. get textures(): Texture[];
  24131. /**
  24132. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24133. */
  24134. get count(): number;
  24135. /**
  24136. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24137. */
  24138. get depthTexture(): Texture;
  24139. /**
  24140. * Set the wrapping mode on U of all the textures we are rendering to.
  24141. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24142. */
  24143. set wrapU(wrap: number);
  24144. /**
  24145. * Set the wrapping mode on V of all the textures we are rendering to.
  24146. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24147. */
  24148. set wrapV(wrap: number);
  24149. /**
  24150. * Instantiate a new multi render target texture.
  24151. * A multi render target, like a render target provides the ability to render to a texture.
  24152. * Unlike the render target, it can render to several draw buffers in one draw.
  24153. * This is specially interesting in deferred rendering or for any effects requiring more than
  24154. * just one color from a single pass.
  24155. * @param name Define the name of the texture
  24156. * @param size Define the size of the buffers to render to
  24157. * @param count Define the number of target we are rendering into
  24158. * @param scene Define the scene the texture belongs to
  24159. * @param options Define the options used to create the multi render target
  24160. */
  24161. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24162. /** @hidden */
  24163. _rebuild(): void;
  24164. private _createInternalTextures;
  24165. private _createTextures;
  24166. /**
  24167. * Define the number of samples used if MSAA is enabled.
  24168. */
  24169. get samples(): number;
  24170. set samples(value: number);
  24171. /**
  24172. * Resize all the textures in the multi render target.
  24173. * Be carrefull as it will recreate all the data in the new texture.
  24174. * @param size Define the new size
  24175. */
  24176. resize(size: any): void;
  24177. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24178. /**
  24179. * Dispose the render targets and their associated resources
  24180. */
  24181. dispose(): void;
  24182. /**
  24183. * Release all the underlying texture used as draw buffers.
  24184. */
  24185. releaseInternalTextures(): void;
  24186. }
  24187. }
  24188. declare module BABYLON {
  24189. /** @hidden */
  24190. export var imageProcessingPixelShader: {
  24191. name: string;
  24192. shader: string;
  24193. };
  24194. }
  24195. declare module BABYLON {
  24196. /**
  24197. * ImageProcessingPostProcess
  24198. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24199. */
  24200. export class ImageProcessingPostProcess extends PostProcess {
  24201. /**
  24202. * Default configuration related to image processing available in the PBR Material.
  24203. */
  24204. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24205. /**
  24206. * Gets the image processing configuration used either in this material.
  24207. */
  24208. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24209. /**
  24210. * Sets the Default image processing configuration used either in the this material.
  24211. *
  24212. * If sets to null, the scene one is in use.
  24213. */
  24214. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24215. /**
  24216. * Keep track of the image processing observer to allow dispose and replace.
  24217. */
  24218. private _imageProcessingObserver;
  24219. /**
  24220. * Attaches a new image processing configuration to the PBR Material.
  24221. * @param configuration
  24222. */
  24223. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24224. /**
  24225. * If the post process is supported.
  24226. */
  24227. get isSupported(): boolean;
  24228. /**
  24229. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24230. */
  24231. get colorCurves(): Nullable<ColorCurves>;
  24232. /**
  24233. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24234. */
  24235. set colorCurves(value: Nullable<ColorCurves>);
  24236. /**
  24237. * Gets wether the color curves effect is enabled.
  24238. */
  24239. get colorCurvesEnabled(): boolean;
  24240. /**
  24241. * Sets wether the color curves effect is enabled.
  24242. */
  24243. set colorCurvesEnabled(value: boolean);
  24244. /**
  24245. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24246. */
  24247. get colorGradingTexture(): Nullable<BaseTexture>;
  24248. /**
  24249. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24250. */
  24251. set colorGradingTexture(value: Nullable<BaseTexture>);
  24252. /**
  24253. * Gets wether the color grading effect is enabled.
  24254. */
  24255. get colorGradingEnabled(): boolean;
  24256. /**
  24257. * Gets wether the color grading effect is enabled.
  24258. */
  24259. set colorGradingEnabled(value: boolean);
  24260. /**
  24261. * Gets exposure used in the effect.
  24262. */
  24263. get exposure(): number;
  24264. /**
  24265. * Sets exposure used in the effect.
  24266. */
  24267. set exposure(value: number);
  24268. /**
  24269. * Gets wether tonemapping is enabled or not.
  24270. */
  24271. get toneMappingEnabled(): boolean;
  24272. /**
  24273. * Sets wether tonemapping is enabled or not
  24274. */
  24275. set toneMappingEnabled(value: boolean);
  24276. /**
  24277. * Gets the type of tone mapping effect.
  24278. */
  24279. get toneMappingType(): number;
  24280. /**
  24281. * Sets the type of tone mapping effect.
  24282. */
  24283. set toneMappingType(value: number);
  24284. /**
  24285. * Gets contrast used in the effect.
  24286. */
  24287. get contrast(): number;
  24288. /**
  24289. * Sets contrast used in the effect.
  24290. */
  24291. set contrast(value: number);
  24292. /**
  24293. * Gets Vignette stretch size.
  24294. */
  24295. get vignetteStretch(): number;
  24296. /**
  24297. * Sets Vignette stretch size.
  24298. */
  24299. set vignetteStretch(value: number);
  24300. /**
  24301. * Gets Vignette centre X Offset.
  24302. */
  24303. get vignetteCentreX(): number;
  24304. /**
  24305. * Sets Vignette centre X Offset.
  24306. */
  24307. set vignetteCentreX(value: number);
  24308. /**
  24309. * Gets Vignette centre Y Offset.
  24310. */
  24311. get vignetteCentreY(): number;
  24312. /**
  24313. * Sets Vignette centre Y Offset.
  24314. */
  24315. set vignetteCentreY(value: number);
  24316. /**
  24317. * Gets Vignette weight or intensity of the vignette effect.
  24318. */
  24319. get vignetteWeight(): number;
  24320. /**
  24321. * Sets Vignette weight or intensity of the vignette effect.
  24322. */
  24323. set vignetteWeight(value: number);
  24324. /**
  24325. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24326. * if vignetteEnabled is set to true.
  24327. */
  24328. get vignetteColor(): Color4;
  24329. /**
  24330. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24331. * if vignetteEnabled is set to true.
  24332. */
  24333. set vignetteColor(value: Color4);
  24334. /**
  24335. * Gets Camera field of view used by the Vignette effect.
  24336. */
  24337. get vignetteCameraFov(): number;
  24338. /**
  24339. * Sets Camera field of view used by the Vignette effect.
  24340. */
  24341. set vignetteCameraFov(value: number);
  24342. /**
  24343. * Gets the vignette blend mode allowing different kind of effect.
  24344. */
  24345. get vignetteBlendMode(): number;
  24346. /**
  24347. * Sets the vignette blend mode allowing different kind of effect.
  24348. */
  24349. set vignetteBlendMode(value: number);
  24350. /**
  24351. * Gets wether the vignette effect is enabled.
  24352. */
  24353. get vignetteEnabled(): boolean;
  24354. /**
  24355. * Sets wether the vignette effect is enabled.
  24356. */
  24357. set vignetteEnabled(value: boolean);
  24358. private _fromLinearSpace;
  24359. /**
  24360. * Gets wether the input of the processing is in Gamma or Linear Space.
  24361. */
  24362. get fromLinearSpace(): boolean;
  24363. /**
  24364. * Sets wether the input of the processing is in Gamma or Linear Space.
  24365. */
  24366. set fromLinearSpace(value: boolean);
  24367. /**
  24368. * Defines cache preventing GC.
  24369. */
  24370. private _defines;
  24371. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24372. /**
  24373. * "ImageProcessingPostProcess"
  24374. * @returns "ImageProcessingPostProcess"
  24375. */
  24376. getClassName(): string;
  24377. /**
  24378. * @hidden
  24379. */
  24380. _updateParameters(): void;
  24381. dispose(camera?: Camera): void;
  24382. }
  24383. }
  24384. declare module BABYLON {
  24385. /** @hidden */
  24386. export var fibonacci: {
  24387. name: string;
  24388. shader: string;
  24389. };
  24390. }
  24391. declare module BABYLON {
  24392. /** @hidden */
  24393. export var subSurfaceScatteringFunctions: {
  24394. name: string;
  24395. shader: string;
  24396. };
  24397. }
  24398. declare module BABYLON {
  24399. /** @hidden */
  24400. export var diffusionProfile: {
  24401. name: string;
  24402. shader: string;
  24403. };
  24404. }
  24405. declare module BABYLON {
  24406. /** @hidden */
  24407. export var subSurfaceScatteringPixelShader: {
  24408. name: string;
  24409. shader: string;
  24410. };
  24411. }
  24412. declare module BABYLON {
  24413. /**
  24414. * Sub surface scattering post process
  24415. */
  24416. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24417. /**
  24418. * Gets a string identifying the name of the class
  24419. * @returns "SubSurfaceScatteringPostProcess" string
  24420. */
  24421. getClassName(): string;
  24422. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24423. }
  24424. }
  24425. declare module BABYLON {
  24426. /**
  24427. * Interface for defining prepass effects in the prepass post-process pipeline
  24428. */
  24429. export interface PrePassEffectConfiguration {
  24430. /**
  24431. * Post process to attach for this effect
  24432. */
  24433. postProcess: PostProcess;
  24434. /**
  24435. * Is the effect enabled
  24436. */
  24437. enabled: boolean;
  24438. /**
  24439. * Disposes the effect configuration
  24440. */
  24441. dispose(): void;
  24442. /**
  24443. * Disposes the effect configuration
  24444. */
  24445. createPostProcess: () => PostProcess;
  24446. }
  24447. }
  24448. declare module BABYLON {
  24449. /**
  24450. * Contains all parameters needed for the prepass to perform
  24451. * screen space subsurface scattering
  24452. */
  24453. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24454. private _ssDiffusionS;
  24455. private _ssFilterRadii;
  24456. private _ssDiffusionD;
  24457. /**
  24458. * Post process to attach for screen space subsurface scattering
  24459. */
  24460. postProcess: SubSurfaceScatteringPostProcess;
  24461. /**
  24462. * Diffusion profile color for subsurface scattering
  24463. */
  24464. get ssDiffusionS(): number[];
  24465. /**
  24466. * Diffusion profile max color channel value for subsurface scattering
  24467. */
  24468. get ssDiffusionD(): number[];
  24469. /**
  24470. * Diffusion profile filter radius for subsurface scattering
  24471. */
  24472. get ssFilterRadii(): number[];
  24473. /**
  24474. * Is subsurface enabled
  24475. */
  24476. enabled: boolean;
  24477. /**
  24478. * Diffusion profile colors for subsurface scattering
  24479. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24480. * See ...
  24481. * Note that you can only store up to 5 of them
  24482. */
  24483. ssDiffusionProfileColors: Color3[];
  24484. /**
  24485. * Defines the ratio real world => scene units.
  24486. * Used for subsurface scattering
  24487. */
  24488. metersPerUnit: number;
  24489. private _scene;
  24490. /**
  24491. * Builds a subsurface configuration object
  24492. * @param scene The scene
  24493. */
  24494. constructor(scene: Scene);
  24495. /**
  24496. * Adds a new diffusion profile.
  24497. * Useful for more realistic subsurface scattering on diverse materials.
  24498. * @param color The color of the diffusion profile. Should be the average color of the material.
  24499. * @return The index of the diffusion profile for the material subsurface configuration
  24500. */
  24501. addDiffusionProfile(color: Color3): number;
  24502. /**
  24503. * Creates the sss post process
  24504. * @return The created post process
  24505. */
  24506. createPostProcess(): SubSurfaceScatteringPostProcess;
  24507. /**
  24508. * Deletes all diffusion profiles.
  24509. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24510. */
  24511. clearAllDiffusionProfiles(): void;
  24512. /**
  24513. * Disposes this object
  24514. */
  24515. dispose(): void;
  24516. /**
  24517. * @hidden
  24518. * https://zero-radiance.github.io/post/sampling-diffusion/
  24519. *
  24520. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24521. * ------------------------------------------------------------------------------------
  24522. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24523. * PDF[r, phi, s] = r * R[r, phi, s]
  24524. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24525. * ------------------------------------------------------------------------------------
  24526. * We importance sample the color channel with the widest scattering distance.
  24527. */
  24528. getDiffusionProfileParameters(color: Color3): number;
  24529. /**
  24530. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24531. * 'u' is the random number (the value of the CDF): [0, 1).
  24532. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24533. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24534. */
  24535. private _sampleBurleyDiffusionProfile;
  24536. }
  24537. }
  24538. declare module BABYLON {
  24539. /**
  24540. * Renders a pre pass of the scene
  24541. * This means every mesh in the scene will be rendered to a render target texture
  24542. * And then this texture will be composited to the rendering canvas with post processes
  24543. * It is necessary for effects like subsurface scattering or deferred shading
  24544. */
  24545. export class PrePassRenderer {
  24546. /** @hidden */
  24547. static _SceneComponentInitialization: (scene: Scene) => void;
  24548. private _scene;
  24549. private _engine;
  24550. private _isDirty;
  24551. /**
  24552. * Number of textures in the multi render target texture where the scene is directly rendered
  24553. */
  24554. readonly mrtCount: number;
  24555. /**
  24556. * The render target where the scene is directly rendered
  24557. */
  24558. prePassRT: MultiRenderTarget;
  24559. private _mrtTypes;
  24560. private _multiRenderAttachments;
  24561. private _defaultAttachments;
  24562. private _clearAttachments;
  24563. private _postProcesses;
  24564. private readonly _clearColor;
  24565. /**
  24566. * Image processing post process for composition
  24567. */
  24568. imageProcessingPostProcess: ImageProcessingPostProcess;
  24569. /**
  24570. * Configuration for sub surface scattering post process
  24571. */
  24572. subSurfaceConfiguration: SubSurfaceConfiguration;
  24573. /**
  24574. * Should materials render their geometry on the MRT
  24575. */
  24576. materialsShouldRenderGeometry: boolean;
  24577. /**
  24578. * Should materials render the irradiance information on the MRT
  24579. */
  24580. materialsShouldRenderIrradiance: boolean;
  24581. private _enabled;
  24582. /**
  24583. * Indicates if the prepass is enabled
  24584. */
  24585. get enabled(): boolean;
  24586. /**
  24587. * How many samples are used for MSAA of the scene render target
  24588. */
  24589. get samples(): number;
  24590. set samples(n: number);
  24591. /**
  24592. * Instanciates a prepass renderer
  24593. * @param scene The scene
  24594. */
  24595. constructor(scene: Scene);
  24596. private _initializeAttachments;
  24597. private _createCompositionEffect;
  24598. /**
  24599. * Indicates if rendering a prepass is supported
  24600. */
  24601. get isSupported(): boolean;
  24602. /**
  24603. * Sets the proper output textures to draw in the engine.
  24604. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24605. */
  24606. bindAttachmentsForEffect(effect: Effect): void;
  24607. /**
  24608. * @hidden
  24609. */
  24610. _beforeCameraDraw(): void;
  24611. /**
  24612. * @hidden
  24613. */
  24614. _afterCameraDraw(): void;
  24615. private _checkRTSize;
  24616. private _bindFrameBuffer;
  24617. /**
  24618. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24619. */
  24620. clear(): void;
  24621. private _setState;
  24622. private _enable;
  24623. private _disable;
  24624. private _resetPostProcessChain;
  24625. private _bindPostProcessChain;
  24626. /**
  24627. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24628. */
  24629. markAsDirty(): void;
  24630. private _update;
  24631. /**
  24632. * Disposes the prepass renderer.
  24633. */
  24634. dispose(): void;
  24635. }
  24636. }
  24637. declare module BABYLON {
  24638. /**
  24639. * Options for compiling materials.
  24640. */
  24641. export interface IMaterialCompilationOptions {
  24642. /**
  24643. * Defines whether clip planes are enabled.
  24644. */
  24645. clipPlane: boolean;
  24646. /**
  24647. * Defines whether instances are enabled.
  24648. */
  24649. useInstances: boolean;
  24650. }
  24651. /**
  24652. * Options passed when calling customShaderNameResolve
  24653. */
  24654. export interface ICustomShaderNameResolveOptions {
  24655. /**
  24656. * 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
  24657. */
  24658. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24659. }
  24660. /**
  24661. * Base class for the main features of a material in Babylon.js
  24662. */
  24663. export class Material implements IAnimatable {
  24664. /**
  24665. * Returns the triangle fill mode
  24666. */
  24667. static readonly TriangleFillMode: number;
  24668. /**
  24669. * Returns the wireframe mode
  24670. */
  24671. static readonly WireFrameFillMode: number;
  24672. /**
  24673. * Returns the point fill mode
  24674. */
  24675. static readonly PointFillMode: number;
  24676. /**
  24677. * Returns the point list draw mode
  24678. */
  24679. static readonly PointListDrawMode: number;
  24680. /**
  24681. * Returns the line list draw mode
  24682. */
  24683. static readonly LineListDrawMode: number;
  24684. /**
  24685. * Returns the line loop draw mode
  24686. */
  24687. static readonly LineLoopDrawMode: number;
  24688. /**
  24689. * Returns the line strip draw mode
  24690. */
  24691. static readonly LineStripDrawMode: number;
  24692. /**
  24693. * Returns the triangle strip draw mode
  24694. */
  24695. static readonly TriangleStripDrawMode: number;
  24696. /**
  24697. * Returns the triangle fan draw mode
  24698. */
  24699. static readonly TriangleFanDrawMode: number;
  24700. /**
  24701. * Stores the clock-wise side orientation
  24702. */
  24703. static readonly ClockWiseSideOrientation: number;
  24704. /**
  24705. * Stores the counter clock-wise side orientation
  24706. */
  24707. static readonly CounterClockWiseSideOrientation: number;
  24708. /**
  24709. * The dirty texture flag value
  24710. */
  24711. static readonly TextureDirtyFlag: number;
  24712. /**
  24713. * The dirty light flag value
  24714. */
  24715. static readonly LightDirtyFlag: number;
  24716. /**
  24717. * The dirty fresnel flag value
  24718. */
  24719. static readonly FresnelDirtyFlag: number;
  24720. /**
  24721. * The dirty attribute flag value
  24722. */
  24723. static readonly AttributesDirtyFlag: number;
  24724. /**
  24725. * The dirty misc flag value
  24726. */
  24727. static readonly MiscDirtyFlag: number;
  24728. /**
  24729. * The all dirty flag value
  24730. */
  24731. static readonly AllDirtyFlag: number;
  24732. /**
  24733. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24734. */
  24735. static readonly MATERIAL_OPAQUE: number;
  24736. /**
  24737. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24738. */
  24739. static readonly MATERIAL_ALPHATEST: number;
  24740. /**
  24741. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24742. */
  24743. static readonly MATERIAL_ALPHABLEND: number;
  24744. /**
  24745. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24746. * They are also discarded below the alpha cutoff threshold to improve performances.
  24747. */
  24748. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24749. /**
  24750. * The Whiteout method is used to blend normals.
  24751. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24752. */
  24753. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24754. /**
  24755. * The Reoriented Normal Mapping method is used to blend normals.
  24756. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24757. */
  24758. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24759. /**
  24760. * Custom callback helping to override the default shader used in the material.
  24761. */
  24762. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24763. /**
  24764. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24765. */
  24766. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24767. /**
  24768. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24769. * This means that the material can keep using a previous shader while a new one is being compiled.
  24770. * This is mostly used when shader parallel compilation is supported (true by default)
  24771. */
  24772. allowShaderHotSwapping: boolean;
  24773. /**
  24774. * The ID of the material
  24775. */
  24776. id: string;
  24777. /**
  24778. * Gets or sets the unique id of the material
  24779. */
  24780. uniqueId: number;
  24781. /**
  24782. * The name of the material
  24783. */
  24784. name: string;
  24785. /**
  24786. * Gets or sets user defined metadata
  24787. */
  24788. metadata: any;
  24789. /**
  24790. * For internal use only. Please do not use.
  24791. */
  24792. reservedDataStore: any;
  24793. /**
  24794. * Specifies if the ready state should be checked on each call
  24795. */
  24796. checkReadyOnEveryCall: boolean;
  24797. /**
  24798. * Specifies if the ready state should be checked once
  24799. */
  24800. checkReadyOnlyOnce: boolean;
  24801. /**
  24802. * The state of the material
  24803. */
  24804. state: string;
  24805. /**
  24806. * If the material can be rendered to several textures with MRT extension
  24807. */
  24808. get canRenderToMRT(): boolean;
  24809. /**
  24810. * The alpha value of the material
  24811. */
  24812. protected _alpha: number;
  24813. /**
  24814. * List of inspectable custom properties (used by the Inspector)
  24815. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24816. */
  24817. inspectableCustomProperties: IInspectable[];
  24818. /**
  24819. * Sets the alpha value of the material
  24820. */
  24821. set alpha(value: number);
  24822. /**
  24823. * Gets the alpha value of the material
  24824. */
  24825. get alpha(): number;
  24826. /**
  24827. * Specifies if back face culling is enabled
  24828. */
  24829. protected _backFaceCulling: boolean;
  24830. /**
  24831. * Sets the back-face culling state
  24832. */
  24833. set backFaceCulling(value: boolean);
  24834. /**
  24835. * Gets the back-face culling state
  24836. */
  24837. get backFaceCulling(): boolean;
  24838. /**
  24839. * Stores the value for side orientation
  24840. */
  24841. sideOrientation: number;
  24842. /**
  24843. * Callback triggered when the material is compiled
  24844. */
  24845. onCompiled: Nullable<(effect: Effect) => void>;
  24846. /**
  24847. * Callback triggered when an error occurs
  24848. */
  24849. onError: Nullable<(effect: Effect, errors: string) => void>;
  24850. /**
  24851. * Callback triggered to get the render target textures
  24852. */
  24853. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24854. /**
  24855. * Gets a boolean indicating that current material needs to register RTT
  24856. */
  24857. get hasRenderTargetTextures(): boolean;
  24858. /**
  24859. * Specifies if the material should be serialized
  24860. */
  24861. doNotSerialize: boolean;
  24862. /**
  24863. * @hidden
  24864. */
  24865. _storeEffectOnSubMeshes: boolean;
  24866. /**
  24867. * Stores the animations for the material
  24868. */
  24869. animations: Nullable<Array<Animation>>;
  24870. /**
  24871. * An event triggered when the material is disposed
  24872. */
  24873. onDisposeObservable: Observable<Material>;
  24874. /**
  24875. * An observer which watches for dispose events
  24876. */
  24877. private _onDisposeObserver;
  24878. private _onUnBindObservable;
  24879. /**
  24880. * Called during a dispose event
  24881. */
  24882. set onDispose(callback: () => void);
  24883. private _onBindObservable;
  24884. /**
  24885. * An event triggered when the material is bound
  24886. */
  24887. get onBindObservable(): Observable<AbstractMesh>;
  24888. /**
  24889. * An observer which watches for bind events
  24890. */
  24891. private _onBindObserver;
  24892. /**
  24893. * Called during a bind event
  24894. */
  24895. set onBind(callback: (Mesh: AbstractMesh) => void);
  24896. /**
  24897. * An event triggered when the material is unbound
  24898. */
  24899. get onUnBindObservable(): Observable<Material>;
  24900. protected _onEffectCreatedObservable: Nullable<Observable<{
  24901. effect: Effect;
  24902. subMesh: Nullable<SubMesh>;
  24903. }>>;
  24904. /**
  24905. * An event triggered when the effect is (re)created
  24906. */
  24907. get onEffectCreatedObservable(): Observable<{
  24908. effect: Effect;
  24909. subMesh: Nullable<SubMesh>;
  24910. }>;
  24911. /**
  24912. * Stores the value of the alpha mode
  24913. */
  24914. private _alphaMode;
  24915. /**
  24916. * Sets the value of the alpha mode.
  24917. *
  24918. * | Value | Type | Description |
  24919. * | --- | --- | --- |
  24920. * | 0 | ALPHA_DISABLE | |
  24921. * | 1 | ALPHA_ADD | |
  24922. * | 2 | ALPHA_COMBINE | |
  24923. * | 3 | ALPHA_SUBTRACT | |
  24924. * | 4 | ALPHA_MULTIPLY | |
  24925. * | 5 | ALPHA_MAXIMIZED | |
  24926. * | 6 | ALPHA_ONEONE | |
  24927. * | 7 | ALPHA_PREMULTIPLIED | |
  24928. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24929. * | 9 | ALPHA_INTERPOLATE | |
  24930. * | 10 | ALPHA_SCREENMODE | |
  24931. *
  24932. */
  24933. set alphaMode(value: number);
  24934. /**
  24935. * Gets the value of the alpha mode
  24936. */
  24937. get alphaMode(): number;
  24938. /**
  24939. * Stores the state of the need depth pre-pass value
  24940. */
  24941. private _needDepthPrePass;
  24942. /**
  24943. * Sets the need depth pre-pass value
  24944. */
  24945. set needDepthPrePass(value: boolean);
  24946. /**
  24947. * Gets the depth pre-pass value
  24948. */
  24949. get needDepthPrePass(): boolean;
  24950. /**
  24951. * Specifies if depth writing should be disabled
  24952. */
  24953. disableDepthWrite: boolean;
  24954. /**
  24955. * Specifies if color writing should be disabled
  24956. */
  24957. disableColorWrite: boolean;
  24958. /**
  24959. * Specifies if depth writing should be forced
  24960. */
  24961. forceDepthWrite: boolean;
  24962. /**
  24963. * Specifies the depth function that should be used. 0 means the default engine function
  24964. */
  24965. depthFunction: number;
  24966. /**
  24967. * Specifies if there should be a separate pass for culling
  24968. */
  24969. separateCullingPass: boolean;
  24970. /**
  24971. * Stores the state specifing if fog should be enabled
  24972. */
  24973. private _fogEnabled;
  24974. /**
  24975. * Sets the state for enabling fog
  24976. */
  24977. set fogEnabled(value: boolean);
  24978. /**
  24979. * Gets the value of the fog enabled state
  24980. */
  24981. get fogEnabled(): boolean;
  24982. /**
  24983. * Stores the size of points
  24984. */
  24985. pointSize: number;
  24986. /**
  24987. * Stores the z offset value
  24988. */
  24989. zOffset: number;
  24990. get wireframe(): boolean;
  24991. /**
  24992. * Sets the state of wireframe mode
  24993. */
  24994. set wireframe(value: boolean);
  24995. /**
  24996. * Gets the value specifying if point clouds are enabled
  24997. */
  24998. get pointsCloud(): boolean;
  24999. /**
  25000. * Sets the state of point cloud mode
  25001. */
  25002. set pointsCloud(value: boolean);
  25003. /**
  25004. * Gets the material fill mode
  25005. */
  25006. get fillMode(): number;
  25007. /**
  25008. * Sets the material fill mode
  25009. */
  25010. set fillMode(value: number);
  25011. /**
  25012. * @hidden
  25013. * Stores the effects for the material
  25014. */
  25015. _effect: Nullable<Effect>;
  25016. /**
  25017. * Specifies if uniform buffers should be used
  25018. */
  25019. private _useUBO;
  25020. /**
  25021. * Stores a reference to the scene
  25022. */
  25023. private _scene;
  25024. /**
  25025. * Stores the fill mode state
  25026. */
  25027. private _fillMode;
  25028. /**
  25029. * Specifies if the depth write state should be cached
  25030. */
  25031. private _cachedDepthWriteState;
  25032. /**
  25033. * Specifies if the color write state should be cached
  25034. */
  25035. private _cachedColorWriteState;
  25036. /**
  25037. * Specifies if the depth function state should be cached
  25038. */
  25039. private _cachedDepthFunctionState;
  25040. /**
  25041. * Stores the uniform buffer
  25042. */
  25043. protected _uniformBuffer: UniformBuffer;
  25044. /** @hidden */
  25045. _indexInSceneMaterialArray: number;
  25046. /** @hidden */
  25047. meshMap: Nullable<{
  25048. [id: string]: AbstractMesh | undefined;
  25049. }>;
  25050. /**
  25051. * Creates a material instance
  25052. * @param name defines the name of the material
  25053. * @param scene defines the scene to reference
  25054. * @param doNotAdd specifies if the material should be added to the scene
  25055. */
  25056. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25057. /**
  25058. * Returns a string representation of the current material
  25059. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25060. * @returns a string with material information
  25061. */
  25062. toString(fullDetails?: boolean): string;
  25063. /**
  25064. * Gets the class name of the material
  25065. * @returns a string with the class name of the material
  25066. */
  25067. getClassName(): string;
  25068. /**
  25069. * Specifies if updates for the material been locked
  25070. */
  25071. get isFrozen(): boolean;
  25072. /**
  25073. * Locks updates for the material
  25074. */
  25075. freeze(): void;
  25076. /**
  25077. * Unlocks updates for the material
  25078. */
  25079. unfreeze(): void;
  25080. /**
  25081. * Specifies if the material is ready to be used
  25082. * @param mesh defines the mesh to check
  25083. * @param useInstances specifies if instances should be used
  25084. * @returns a boolean indicating if the material is ready to be used
  25085. */
  25086. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25087. /**
  25088. * Specifies that the submesh is ready to be used
  25089. * @param mesh defines the mesh to check
  25090. * @param subMesh defines which submesh to check
  25091. * @param useInstances specifies that instances should be used
  25092. * @returns a boolean indicating that the submesh is ready or not
  25093. */
  25094. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25095. /**
  25096. * Returns the material effect
  25097. * @returns the effect associated with the material
  25098. */
  25099. getEffect(): Nullable<Effect>;
  25100. /**
  25101. * Returns the current scene
  25102. * @returns a Scene
  25103. */
  25104. getScene(): Scene;
  25105. /**
  25106. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25107. */
  25108. protected _forceAlphaTest: boolean;
  25109. /**
  25110. * The transparency mode of the material.
  25111. */
  25112. protected _transparencyMode: Nullable<number>;
  25113. /**
  25114. * Gets the current transparency mode.
  25115. */
  25116. get transparencyMode(): Nullable<number>;
  25117. /**
  25118. * Sets the transparency mode of the material.
  25119. *
  25120. * | Value | Type | Description |
  25121. * | ----- | ----------------------------------- | ----------- |
  25122. * | 0 | OPAQUE | |
  25123. * | 1 | ALPHATEST | |
  25124. * | 2 | ALPHABLEND | |
  25125. * | 3 | ALPHATESTANDBLEND | |
  25126. *
  25127. */
  25128. set transparencyMode(value: Nullable<number>);
  25129. /**
  25130. * Returns true if alpha blending should be disabled.
  25131. */
  25132. protected get _disableAlphaBlending(): boolean;
  25133. /**
  25134. * Specifies whether or not this material should be rendered in alpha blend mode.
  25135. * @returns a boolean specifying if alpha blending is needed
  25136. */
  25137. needAlphaBlending(): boolean;
  25138. /**
  25139. * Specifies if the mesh will require alpha blending
  25140. * @param mesh defines the mesh to check
  25141. * @returns a boolean specifying if alpha blending is needed for the mesh
  25142. */
  25143. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25144. /**
  25145. * Specifies whether or not this material should be rendered in alpha test mode.
  25146. * @returns a boolean specifying if an alpha test is needed.
  25147. */
  25148. needAlphaTesting(): boolean;
  25149. /**
  25150. * Specifies if material alpha testing should be turned on for the mesh
  25151. * @param mesh defines the mesh to check
  25152. */
  25153. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25154. /**
  25155. * Gets the texture used for the alpha test
  25156. * @returns the texture to use for alpha testing
  25157. */
  25158. getAlphaTestTexture(): Nullable<BaseTexture>;
  25159. /**
  25160. * Marks the material to indicate that it needs to be re-calculated
  25161. */
  25162. markDirty(): void;
  25163. /** @hidden */
  25164. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25165. /**
  25166. * Binds the material to the mesh
  25167. * @param world defines the world transformation matrix
  25168. * @param mesh defines the mesh to bind the material to
  25169. */
  25170. bind(world: Matrix, mesh?: Mesh): void;
  25171. /**
  25172. * Binds the submesh to the material
  25173. * @param world defines the world transformation matrix
  25174. * @param mesh defines the mesh containing the submesh
  25175. * @param subMesh defines the submesh to bind the material to
  25176. */
  25177. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25178. /**
  25179. * Binds the world matrix to the material
  25180. * @param world defines the world transformation matrix
  25181. */
  25182. bindOnlyWorldMatrix(world: Matrix): void;
  25183. /**
  25184. * Binds the scene's uniform buffer to the effect.
  25185. * @param effect defines the effect to bind to the scene uniform buffer
  25186. * @param sceneUbo defines the uniform buffer storing scene data
  25187. */
  25188. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25189. /**
  25190. * Binds the view matrix to the effect
  25191. * @param effect defines the effect to bind the view matrix to
  25192. */
  25193. bindView(effect: Effect): void;
  25194. /**
  25195. * Binds the view projection matrix to the effect
  25196. * @param effect defines the effect to bind the view projection matrix to
  25197. */
  25198. bindViewProjection(effect: Effect): void;
  25199. /**
  25200. * Processes to execute after binding the material to a mesh
  25201. * @param mesh defines the rendered mesh
  25202. */
  25203. protected _afterBind(mesh?: Mesh): void;
  25204. /**
  25205. * Unbinds the material from the mesh
  25206. */
  25207. unbind(): void;
  25208. /**
  25209. * Gets the active textures from the material
  25210. * @returns an array of textures
  25211. */
  25212. getActiveTextures(): BaseTexture[];
  25213. /**
  25214. * Specifies if the material uses a texture
  25215. * @param texture defines the texture to check against the material
  25216. * @returns a boolean specifying if the material uses the texture
  25217. */
  25218. hasTexture(texture: BaseTexture): boolean;
  25219. /**
  25220. * Makes a duplicate of the material, and gives it a new name
  25221. * @param name defines the new name for the duplicated material
  25222. * @returns the cloned material
  25223. */
  25224. clone(name: string): Nullable<Material>;
  25225. /**
  25226. * Gets the meshes bound to the material
  25227. * @returns an array of meshes bound to the material
  25228. */
  25229. getBindedMeshes(): AbstractMesh[];
  25230. /**
  25231. * Force shader compilation
  25232. * @param mesh defines the mesh associated with this material
  25233. * @param onCompiled defines a function to execute once the material is compiled
  25234. * @param options defines the options to configure the compilation
  25235. * @param onError defines a function to execute if the material fails compiling
  25236. */
  25237. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25238. /**
  25239. * Force shader compilation
  25240. * @param mesh defines the mesh that will use this material
  25241. * @param options defines additional options for compiling the shaders
  25242. * @returns a promise that resolves when the compilation completes
  25243. */
  25244. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25245. private static readonly _AllDirtyCallBack;
  25246. private static readonly _ImageProcessingDirtyCallBack;
  25247. private static readonly _TextureDirtyCallBack;
  25248. private static readonly _FresnelDirtyCallBack;
  25249. private static readonly _MiscDirtyCallBack;
  25250. private static readonly _LightsDirtyCallBack;
  25251. private static readonly _AttributeDirtyCallBack;
  25252. private static _FresnelAndMiscDirtyCallBack;
  25253. private static _TextureAndMiscDirtyCallBack;
  25254. private static readonly _DirtyCallbackArray;
  25255. private static readonly _RunDirtyCallBacks;
  25256. /**
  25257. * Marks a define in the material to indicate that it needs to be re-computed
  25258. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25259. */
  25260. markAsDirty(flag: number): void;
  25261. /**
  25262. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25263. * @param func defines a function which checks material defines against the submeshes
  25264. */
  25265. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25266. /**
  25267. * Indicates that the scene should check if the rendering now needs a prepass
  25268. */
  25269. protected _markScenePrePassDirty(): void;
  25270. /**
  25271. * Indicates that we need to re-calculated for all submeshes
  25272. */
  25273. protected _markAllSubMeshesAsAllDirty(): void;
  25274. /**
  25275. * Indicates that image processing needs to be re-calculated for all submeshes
  25276. */
  25277. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25278. /**
  25279. * Indicates that textures need to be re-calculated for all submeshes
  25280. */
  25281. protected _markAllSubMeshesAsTexturesDirty(): void;
  25282. /**
  25283. * Indicates that fresnel needs to be re-calculated for all submeshes
  25284. */
  25285. protected _markAllSubMeshesAsFresnelDirty(): void;
  25286. /**
  25287. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25288. */
  25289. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25290. /**
  25291. * Indicates that lights need to be re-calculated for all submeshes
  25292. */
  25293. protected _markAllSubMeshesAsLightsDirty(): void;
  25294. /**
  25295. * Indicates that attributes need to be re-calculated for all submeshes
  25296. */
  25297. protected _markAllSubMeshesAsAttributesDirty(): void;
  25298. /**
  25299. * Indicates that misc needs to be re-calculated for all submeshes
  25300. */
  25301. protected _markAllSubMeshesAsMiscDirty(): void;
  25302. /**
  25303. * Indicates that textures and misc need to be re-calculated for all submeshes
  25304. */
  25305. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25306. /**
  25307. * Sets the required values to the prepass renderer.
  25308. * @param prePassRenderer defines the prepass renderer to setup.
  25309. * @returns true if the pre pass is needed.
  25310. */
  25311. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25312. /**
  25313. * Disposes the material
  25314. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25315. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25316. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25317. */
  25318. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25319. /** @hidden */
  25320. private releaseVertexArrayObject;
  25321. /**
  25322. * Serializes this material
  25323. * @returns the serialized material object
  25324. */
  25325. serialize(): any;
  25326. /**
  25327. * Creates a material from parsed material data
  25328. * @param parsedMaterial defines parsed material data
  25329. * @param scene defines the hosting scene
  25330. * @param rootUrl defines the root URL to use to load textures
  25331. * @returns a new material
  25332. */
  25333. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25334. }
  25335. }
  25336. declare module BABYLON {
  25337. /**
  25338. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25339. * separate meshes. This can be use to improve performances.
  25340. * @see https://doc.babylonjs.com/how_to/multi_materials
  25341. */
  25342. export class MultiMaterial extends Material {
  25343. private _subMaterials;
  25344. /**
  25345. * Gets or Sets the list of Materials used within the multi material.
  25346. * They need to be ordered according to the submeshes order in the associated mesh
  25347. */
  25348. get subMaterials(): Nullable<Material>[];
  25349. set subMaterials(value: Nullable<Material>[]);
  25350. /**
  25351. * Function used to align with Node.getChildren()
  25352. * @returns the list of Materials used within the multi material
  25353. */
  25354. getChildren(): Nullable<Material>[];
  25355. /**
  25356. * Instantiates a new Multi Material
  25357. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25358. * separate meshes. This can be use to improve performances.
  25359. * @see https://doc.babylonjs.com/how_to/multi_materials
  25360. * @param name Define the name in the scene
  25361. * @param scene Define the scene the material belongs to
  25362. */
  25363. constructor(name: string, scene: Scene);
  25364. private _hookArray;
  25365. /**
  25366. * Get one of the submaterial by its index in the submaterials array
  25367. * @param index The index to look the sub material at
  25368. * @returns The Material if the index has been defined
  25369. */
  25370. getSubMaterial(index: number): Nullable<Material>;
  25371. /**
  25372. * Get the list of active textures for the whole sub materials list.
  25373. * @returns All the textures that will be used during the rendering
  25374. */
  25375. getActiveTextures(): BaseTexture[];
  25376. /**
  25377. * Gets the current class name of the material e.g. "MultiMaterial"
  25378. * Mainly use in serialization.
  25379. * @returns the class name
  25380. */
  25381. getClassName(): string;
  25382. /**
  25383. * Checks if the material is ready to render the requested sub mesh
  25384. * @param mesh Define the mesh the submesh belongs to
  25385. * @param subMesh Define the sub mesh to look readyness for
  25386. * @param useInstances Define whether or not the material is used with instances
  25387. * @returns true if ready, otherwise false
  25388. */
  25389. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25390. /**
  25391. * Clones the current material and its related sub materials
  25392. * @param name Define the name of the newly cloned material
  25393. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25394. * @returns the cloned material
  25395. */
  25396. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25397. /**
  25398. * Serializes the materials into a JSON representation.
  25399. * @returns the JSON representation
  25400. */
  25401. serialize(): any;
  25402. /**
  25403. * Dispose the material and release its associated resources
  25404. * @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)
  25405. * @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)
  25406. * @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)
  25407. */
  25408. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25409. /**
  25410. * Creates a MultiMaterial from parsed MultiMaterial data.
  25411. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25412. * @param scene defines the hosting scene
  25413. * @returns a new MultiMaterial
  25414. */
  25415. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25416. }
  25417. }
  25418. declare module BABYLON {
  25419. /**
  25420. * Defines a subdivision inside a mesh
  25421. */
  25422. export class SubMesh implements ICullable {
  25423. /** the material index to use */
  25424. materialIndex: number;
  25425. /** vertex index start */
  25426. verticesStart: number;
  25427. /** vertices count */
  25428. verticesCount: number;
  25429. /** index start */
  25430. indexStart: number;
  25431. /** indices count */
  25432. indexCount: number;
  25433. /** @hidden */
  25434. _materialDefines: Nullable<MaterialDefines>;
  25435. /** @hidden */
  25436. _materialEffect: Nullable<Effect>;
  25437. /** @hidden */
  25438. _effectOverride: Nullable<Effect>;
  25439. /**
  25440. * Gets material defines used by the effect associated to the sub mesh
  25441. */
  25442. get materialDefines(): Nullable<MaterialDefines>;
  25443. /**
  25444. * Sets material defines used by the effect associated to the sub mesh
  25445. */
  25446. set materialDefines(defines: Nullable<MaterialDefines>);
  25447. /**
  25448. * Gets associated effect
  25449. */
  25450. get effect(): Nullable<Effect>;
  25451. /**
  25452. * Sets associated effect (effect used to render this submesh)
  25453. * @param effect defines the effect to associate with
  25454. * @param defines defines the set of defines used to compile this effect
  25455. */
  25456. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25457. /** @hidden */
  25458. _linesIndexCount: number;
  25459. private _mesh;
  25460. private _renderingMesh;
  25461. private _boundingInfo;
  25462. private _linesIndexBuffer;
  25463. /** @hidden */
  25464. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25465. /** @hidden */
  25466. _trianglePlanes: Plane[];
  25467. /** @hidden */
  25468. _lastColliderTransformMatrix: Nullable<Matrix>;
  25469. /** @hidden */
  25470. _renderId: number;
  25471. /** @hidden */
  25472. _alphaIndex: number;
  25473. /** @hidden */
  25474. _distanceToCamera: number;
  25475. /** @hidden */
  25476. _id: number;
  25477. private _currentMaterial;
  25478. /**
  25479. * Add a new submesh to a mesh
  25480. * @param materialIndex defines the material index to use
  25481. * @param verticesStart defines vertex index start
  25482. * @param verticesCount defines vertices count
  25483. * @param indexStart defines index start
  25484. * @param indexCount defines indices count
  25485. * @param mesh defines the parent mesh
  25486. * @param renderingMesh defines an optional rendering mesh
  25487. * @param createBoundingBox defines if bounding box should be created for this submesh
  25488. * @returns the new submesh
  25489. */
  25490. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25491. /**
  25492. * Creates a new submesh
  25493. * @param materialIndex defines the material index to use
  25494. * @param verticesStart defines vertex index start
  25495. * @param verticesCount defines vertices count
  25496. * @param indexStart defines index start
  25497. * @param indexCount defines indices count
  25498. * @param mesh defines the parent mesh
  25499. * @param renderingMesh defines an optional rendering mesh
  25500. * @param createBoundingBox defines if bounding box should be created for this submesh
  25501. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25502. */
  25503. constructor(
  25504. /** the material index to use */
  25505. materialIndex: number,
  25506. /** vertex index start */
  25507. verticesStart: number,
  25508. /** vertices count */
  25509. verticesCount: number,
  25510. /** index start */
  25511. indexStart: number,
  25512. /** indices count */
  25513. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25514. /**
  25515. * Returns true if this submesh covers the entire parent mesh
  25516. * @ignorenaming
  25517. */
  25518. get IsGlobal(): boolean;
  25519. /**
  25520. * Returns the submesh BoudingInfo object
  25521. * @returns current bounding info (or mesh's one if the submesh is global)
  25522. */
  25523. getBoundingInfo(): BoundingInfo;
  25524. /**
  25525. * Sets the submesh BoundingInfo
  25526. * @param boundingInfo defines the new bounding info to use
  25527. * @returns the SubMesh
  25528. */
  25529. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25530. /**
  25531. * Returns the mesh of the current submesh
  25532. * @return the parent mesh
  25533. */
  25534. getMesh(): AbstractMesh;
  25535. /**
  25536. * Returns the rendering mesh of the submesh
  25537. * @returns the rendering mesh (could be different from parent mesh)
  25538. */
  25539. getRenderingMesh(): Mesh;
  25540. /**
  25541. * Returns the replacement mesh of the submesh
  25542. * @returns the replacement mesh (could be different from parent mesh)
  25543. */
  25544. getReplacementMesh(): Nullable<AbstractMesh>;
  25545. /**
  25546. * Returns the effective mesh of the submesh
  25547. * @returns the effective mesh (could be different from parent mesh)
  25548. */
  25549. getEffectiveMesh(): AbstractMesh;
  25550. /**
  25551. * Returns the submesh material
  25552. * @returns null or the current material
  25553. */
  25554. getMaterial(): Nullable<Material>;
  25555. private _IsMultiMaterial;
  25556. /**
  25557. * Sets a new updated BoundingInfo object to the submesh
  25558. * @param data defines an optional position array to use to determine the bounding info
  25559. * @returns the SubMesh
  25560. */
  25561. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25562. /** @hidden */
  25563. _checkCollision(collider: Collider): boolean;
  25564. /**
  25565. * Updates the submesh BoundingInfo
  25566. * @param world defines the world matrix to use to update the bounding info
  25567. * @returns the submesh
  25568. */
  25569. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25570. /**
  25571. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25572. * @param frustumPlanes defines the frustum planes
  25573. * @returns true if the submesh is intersecting with the frustum
  25574. */
  25575. isInFrustum(frustumPlanes: Plane[]): boolean;
  25576. /**
  25577. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25578. * @param frustumPlanes defines the frustum planes
  25579. * @returns true if the submesh is inside the frustum
  25580. */
  25581. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25582. /**
  25583. * Renders the submesh
  25584. * @param enableAlphaMode defines if alpha needs to be used
  25585. * @returns the submesh
  25586. */
  25587. render(enableAlphaMode: boolean): SubMesh;
  25588. /**
  25589. * @hidden
  25590. */
  25591. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25592. /**
  25593. * Checks if the submesh intersects with a ray
  25594. * @param ray defines the ray to test
  25595. * @returns true is the passed ray intersects the submesh bounding box
  25596. */
  25597. canIntersects(ray: Ray): boolean;
  25598. /**
  25599. * Intersects current submesh with a ray
  25600. * @param ray defines the ray to test
  25601. * @param positions defines mesh's positions array
  25602. * @param indices defines mesh's indices array
  25603. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25604. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25605. * @returns intersection info or null if no intersection
  25606. */
  25607. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25608. /** @hidden */
  25609. private _intersectLines;
  25610. /** @hidden */
  25611. private _intersectUnIndexedLines;
  25612. /** @hidden */
  25613. private _intersectTriangles;
  25614. /** @hidden */
  25615. private _intersectUnIndexedTriangles;
  25616. /** @hidden */
  25617. _rebuild(): void;
  25618. /**
  25619. * Creates a new submesh from the passed mesh
  25620. * @param newMesh defines the new hosting mesh
  25621. * @param newRenderingMesh defines an optional rendering mesh
  25622. * @returns the new submesh
  25623. */
  25624. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25625. /**
  25626. * Release associated resources
  25627. */
  25628. dispose(): void;
  25629. /**
  25630. * Gets the class name
  25631. * @returns the string "SubMesh".
  25632. */
  25633. getClassName(): string;
  25634. /**
  25635. * Creates a new submesh from indices data
  25636. * @param materialIndex the index of the main mesh material
  25637. * @param startIndex the index where to start the copy in the mesh indices array
  25638. * @param indexCount the number of indices to copy then from the startIndex
  25639. * @param mesh the main mesh to create the submesh from
  25640. * @param renderingMesh the optional rendering mesh
  25641. * @returns a new submesh
  25642. */
  25643. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25644. }
  25645. }
  25646. declare module BABYLON {
  25647. /**
  25648. * Class used to represent data loading progression
  25649. */
  25650. export class SceneLoaderFlags {
  25651. private static _ForceFullSceneLoadingForIncremental;
  25652. private static _ShowLoadingScreen;
  25653. private static _CleanBoneMatrixWeights;
  25654. private static _loggingLevel;
  25655. /**
  25656. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25657. */
  25658. static get ForceFullSceneLoadingForIncremental(): boolean;
  25659. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25660. /**
  25661. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25662. */
  25663. static get ShowLoadingScreen(): boolean;
  25664. static set ShowLoadingScreen(value: boolean);
  25665. /**
  25666. * Defines the current logging level (while loading the scene)
  25667. * @ignorenaming
  25668. */
  25669. static get loggingLevel(): number;
  25670. static set loggingLevel(value: number);
  25671. /**
  25672. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25673. */
  25674. static get CleanBoneMatrixWeights(): boolean;
  25675. static set CleanBoneMatrixWeights(value: boolean);
  25676. }
  25677. }
  25678. declare module BABYLON {
  25679. /**
  25680. * Class used to store geometry data (vertex buffers + index buffer)
  25681. */
  25682. export class Geometry implements IGetSetVerticesData {
  25683. /**
  25684. * Gets or sets the ID of the geometry
  25685. */
  25686. id: string;
  25687. /**
  25688. * Gets or sets the unique ID of the geometry
  25689. */
  25690. uniqueId: number;
  25691. /**
  25692. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25693. */
  25694. delayLoadState: number;
  25695. /**
  25696. * Gets the file containing the data to load when running in delay load state
  25697. */
  25698. delayLoadingFile: Nullable<string>;
  25699. /**
  25700. * Callback called when the geometry is updated
  25701. */
  25702. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25703. private _scene;
  25704. private _engine;
  25705. private _meshes;
  25706. private _totalVertices;
  25707. /** @hidden */
  25708. _indices: IndicesArray;
  25709. /** @hidden */
  25710. _vertexBuffers: {
  25711. [key: string]: VertexBuffer;
  25712. };
  25713. private _isDisposed;
  25714. private _extend;
  25715. private _boundingBias;
  25716. /** @hidden */
  25717. _delayInfo: Array<string>;
  25718. private _indexBuffer;
  25719. private _indexBufferIsUpdatable;
  25720. /** @hidden */
  25721. _boundingInfo: Nullable<BoundingInfo>;
  25722. /** @hidden */
  25723. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25724. /** @hidden */
  25725. _softwareSkinningFrameId: number;
  25726. private _vertexArrayObjects;
  25727. private _updatable;
  25728. /** @hidden */
  25729. _positions: Nullable<Vector3[]>;
  25730. /**
  25731. * 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
  25732. */
  25733. get boundingBias(): Vector2;
  25734. /**
  25735. * 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
  25736. */
  25737. set boundingBias(value: Vector2);
  25738. /**
  25739. * Static function used to attach a new empty geometry to a mesh
  25740. * @param mesh defines the mesh to attach the geometry to
  25741. * @returns the new Geometry
  25742. */
  25743. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25744. /** Get the list of meshes using this geometry */
  25745. get meshes(): Mesh[];
  25746. /**
  25747. * 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
  25748. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25749. */
  25750. useBoundingInfoFromGeometry: boolean;
  25751. /**
  25752. * Creates a new geometry
  25753. * @param id defines the unique ID
  25754. * @param scene defines the hosting scene
  25755. * @param vertexData defines the VertexData used to get geometry data
  25756. * @param updatable defines if geometry must be updatable (false by default)
  25757. * @param mesh defines the mesh that will be associated with the geometry
  25758. */
  25759. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25760. /**
  25761. * Gets the current extend of the geometry
  25762. */
  25763. get extend(): {
  25764. minimum: Vector3;
  25765. maximum: Vector3;
  25766. };
  25767. /**
  25768. * Gets the hosting scene
  25769. * @returns the hosting Scene
  25770. */
  25771. getScene(): Scene;
  25772. /**
  25773. * Gets the hosting engine
  25774. * @returns the hosting Engine
  25775. */
  25776. getEngine(): Engine;
  25777. /**
  25778. * Defines if the geometry is ready to use
  25779. * @returns true if the geometry is ready to be used
  25780. */
  25781. isReady(): boolean;
  25782. /**
  25783. * Gets a value indicating that the geometry should not be serialized
  25784. */
  25785. get doNotSerialize(): boolean;
  25786. /** @hidden */
  25787. _rebuild(): void;
  25788. /**
  25789. * Affects all geometry data in one call
  25790. * @param vertexData defines the geometry data
  25791. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25792. */
  25793. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25794. /**
  25795. * Set specific vertex data
  25796. * @param kind defines the data kind (Position, normal, etc...)
  25797. * @param data defines the vertex data to use
  25798. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25799. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25800. */
  25801. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25802. /**
  25803. * Removes a specific vertex data
  25804. * @param kind defines the data kind (Position, normal, etc...)
  25805. */
  25806. removeVerticesData(kind: string): void;
  25807. /**
  25808. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25809. * @param buffer defines the vertex buffer to use
  25810. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25811. */
  25812. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25813. /**
  25814. * Update a specific vertex buffer
  25815. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25816. * It will do nothing if the buffer is not updatable
  25817. * @param kind defines the data kind (Position, normal, etc...)
  25818. * @param data defines the data to use
  25819. * @param offset defines the offset in the target buffer where to store the data
  25820. * @param useBytes set to true if the offset is in bytes
  25821. */
  25822. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25823. /**
  25824. * Update a specific vertex buffer
  25825. * This function will create a new buffer if the current one is not updatable
  25826. * @param kind defines the data kind (Position, normal, etc...)
  25827. * @param data defines the data to use
  25828. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25829. */
  25830. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25831. private _updateBoundingInfo;
  25832. /** @hidden */
  25833. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25834. /**
  25835. * Gets total number of vertices
  25836. * @returns the total number of vertices
  25837. */
  25838. getTotalVertices(): number;
  25839. /**
  25840. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25841. * @param kind defines the data kind (Position, normal, etc...)
  25842. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25843. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25844. * @returns a float array containing vertex data
  25845. */
  25846. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25847. /**
  25848. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25849. * @param kind defines the data kind (Position, normal, etc...)
  25850. * @returns true if the vertex buffer with the specified kind is updatable
  25851. */
  25852. isVertexBufferUpdatable(kind: string): boolean;
  25853. /**
  25854. * Gets a specific vertex buffer
  25855. * @param kind defines the data kind (Position, normal, etc...)
  25856. * @returns a VertexBuffer
  25857. */
  25858. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25859. /**
  25860. * Returns all vertex buffers
  25861. * @return an object holding all vertex buffers indexed by kind
  25862. */
  25863. getVertexBuffers(): Nullable<{
  25864. [key: string]: VertexBuffer;
  25865. }>;
  25866. /**
  25867. * Gets a boolean indicating if specific vertex buffer is present
  25868. * @param kind defines the data kind (Position, normal, etc...)
  25869. * @returns true if data is present
  25870. */
  25871. isVerticesDataPresent(kind: string): boolean;
  25872. /**
  25873. * Gets a list of all attached data kinds (Position, normal, etc...)
  25874. * @returns a list of string containing all kinds
  25875. */
  25876. getVerticesDataKinds(): string[];
  25877. /**
  25878. * Update index buffer
  25879. * @param indices defines the indices to store in the index buffer
  25880. * @param offset defines the offset in the target buffer where to store the data
  25881. * @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)
  25882. */
  25883. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25884. /**
  25885. * Creates a new index buffer
  25886. * @param indices defines the indices to store in the index buffer
  25887. * @param totalVertices defines the total number of vertices (could be null)
  25888. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25889. */
  25890. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25891. /**
  25892. * Return the total number of indices
  25893. * @returns the total number of indices
  25894. */
  25895. getTotalIndices(): number;
  25896. /**
  25897. * Gets the index buffer array
  25898. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25899. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25900. * @returns the index buffer array
  25901. */
  25902. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25903. /**
  25904. * Gets the index buffer
  25905. * @return the index buffer
  25906. */
  25907. getIndexBuffer(): Nullable<DataBuffer>;
  25908. /** @hidden */
  25909. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25910. /**
  25911. * Release the associated resources for a specific mesh
  25912. * @param mesh defines the source mesh
  25913. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25914. */
  25915. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25916. /**
  25917. * Apply current geometry to a given mesh
  25918. * @param mesh defines the mesh to apply geometry to
  25919. */
  25920. applyToMesh(mesh: Mesh): void;
  25921. private _updateExtend;
  25922. private _applyToMesh;
  25923. private notifyUpdate;
  25924. /**
  25925. * Load the geometry if it was flagged as delay loaded
  25926. * @param scene defines the hosting scene
  25927. * @param onLoaded defines a callback called when the geometry is loaded
  25928. */
  25929. load(scene: Scene, onLoaded?: () => void): void;
  25930. private _queueLoad;
  25931. /**
  25932. * Invert the geometry to move from a right handed system to a left handed one.
  25933. */
  25934. toLeftHanded(): void;
  25935. /** @hidden */
  25936. _resetPointsArrayCache(): void;
  25937. /** @hidden */
  25938. _generatePointsArray(): boolean;
  25939. /**
  25940. * Gets a value indicating if the geometry is disposed
  25941. * @returns true if the geometry was disposed
  25942. */
  25943. isDisposed(): boolean;
  25944. private _disposeVertexArrayObjects;
  25945. /**
  25946. * Free all associated resources
  25947. */
  25948. dispose(): void;
  25949. /**
  25950. * Clone the current geometry into a new geometry
  25951. * @param id defines the unique ID of the new geometry
  25952. * @returns a new geometry object
  25953. */
  25954. copy(id: string): Geometry;
  25955. /**
  25956. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25957. * @return a JSON representation of the current geometry data (without the vertices data)
  25958. */
  25959. serialize(): any;
  25960. private toNumberArray;
  25961. /**
  25962. * Serialize all vertices data into a JSON oject
  25963. * @returns a JSON representation of the current geometry data
  25964. */
  25965. serializeVerticeData(): any;
  25966. /**
  25967. * Extracts a clone of a mesh geometry
  25968. * @param mesh defines the source mesh
  25969. * @param id defines the unique ID of the new geometry object
  25970. * @returns the new geometry object
  25971. */
  25972. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25973. /**
  25974. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25975. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25976. * Be aware Math.random() could cause collisions, but:
  25977. * "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"
  25978. * @returns a string containing a new GUID
  25979. */
  25980. static RandomId(): string;
  25981. /** @hidden */
  25982. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25983. private static _CleanMatricesWeights;
  25984. /**
  25985. * Create a new geometry from persisted data (Using .babylon file format)
  25986. * @param parsedVertexData defines the persisted data
  25987. * @param scene defines the hosting scene
  25988. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25989. * @returns the new geometry object
  25990. */
  25991. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25992. }
  25993. }
  25994. declare module BABYLON {
  25995. /**
  25996. * Define an interface for all classes that will get and set the data on vertices
  25997. */
  25998. export interface IGetSetVerticesData {
  25999. /**
  26000. * Gets a boolean indicating if specific vertex data is present
  26001. * @param kind defines the vertex data kind to use
  26002. * @returns true is data kind is present
  26003. */
  26004. isVerticesDataPresent(kind: string): boolean;
  26005. /**
  26006. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26007. * @param kind defines the data kind (Position, normal, etc...)
  26008. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26009. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26010. * @returns a float array containing vertex data
  26011. */
  26012. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26013. /**
  26014. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26015. * @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.
  26016. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26017. * @returns the indices array or an empty array if the mesh has no geometry
  26018. */
  26019. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26020. /**
  26021. * Set specific vertex data
  26022. * @param kind defines the data kind (Position, normal, etc...)
  26023. * @param data defines the vertex data to use
  26024. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26025. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26026. */
  26027. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26028. /**
  26029. * Update a specific associated vertex buffer
  26030. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26031. * - VertexBuffer.PositionKind
  26032. * - VertexBuffer.UVKind
  26033. * - VertexBuffer.UV2Kind
  26034. * - VertexBuffer.UV3Kind
  26035. * - VertexBuffer.UV4Kind
  26036. * - VertexBuffer.UV5Kind
  26037. * - VertexBuffer.UV6Kind
  26038. * - VertexBuffer.ColorKind
  26039. * - VertexBuffer.MatricesIndicesKind
  26040. * - VertexBuffer.MatricesIndicesExtraKind
  26041. * - VertexBuffer.MatricesWeightsKind
  26042. * - VertexBuffer.MatricesWeightsExtraKind
  26043. * @param data defines the data source
  26044. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26045. * @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)
  26046. */
  26047. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26048. /**
  26049. * Creates a new index buffer
  26050. * @param indices defines the indices to store in the index buffer
  26051. * @param totalVertices defines the total number of vertices (could be null)
  26052. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26053. */
  26054. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26055. }
  26056. /**
  26057. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26058. */
  26059. export class VertexData {
  26060. /**
  26061. * Mesh side orientation : usually the external or front surface
  26062. */
  26063. static readonly FRONTSIDE: number;
  26064. /**
  26065. * Mesh side orientation : usually the internal or back surface
  26066. */
  26067. static readonly BACKSIDE: number;
  26068. /**
  26069. * Mesh side orientation : both internal and external or front and back surfaces
  26070. */
  26071. static readonly DOUBLESIDE: number;
  26072. /**
  26073. * Mesh side orientation : by default, `FRONTSIDE`
  26074. */
  26075. static readonly DEFAULTSIDE: number;
  26076. /**
  26077. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26078. */
  26079. positions: Nullable<FloatArray>;
  26080. /**
  26081. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26082. */
  26083. normals: Nullable<FloatArray>;
  26084. /**
  26085. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26086. */
  26087. tangents: Nullable<FloatArray>;
  26088. /**
  26089. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26090. */
  26091. uvs: Nullable<FloatArray>;
  26092. /**
  26093. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26094. */
  26095. uvs2: Nullable<FloatArray>;
  26096. /**
  26097. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26098. */
  26099. uvs3: Nullable<FloatArray>;
  26100. /**
  26101. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26102. */
  26103. uvs4: Nullable<FloatArray>;
  26104. /**
  26105. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26106. */
  26107. uvs5: Nullable<FloatArray>;
  26108. /**
  26109. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26110. */
  26111. uvs6: Nullable<FloatArray>;
  26112. /**
  26113. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26114. */
  26115. colors: Nullable<FloatArray>;
  26116. /**
  26117. * 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).
  26118. */
  26119. matricesIndices: Nullable<FloatArray>;
  26120. /**
  26121. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26122. */
  26123. matricesWeights: Nullable<FloatArray>;
  26124. /**
  26125. * An array extending the number of possible indices
  26126. */
  26127. matricesIndicesExtra: Nullable<FloatArray>;
  26128. /**
  26129. * An array extending the number of possible weights when the number of indices is extended
  26130. */
  26131. matricesWeightsExtra: Nullable<FloatArray>;
  26132. /**
  26133. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26134. */
  26135. indices: Nullable<IndicesArray>;
  26136. /**
  26137. * Uses the passed data array to set the set the values for the specified kind of data
  26138. * @param data a linear array of floating numbers
  26139. * @param kind the type of data that is being set, eg positions, colors etc
  26140. */
  26141. set(data: FloatArray, kind: string): void;
  26142. /**
  26143. * Associates the vertexData to the passed Mesh.
  26144. * Sets it as updatable or not (default `false`)
  26145. * @param mesh the mesh the vertexData is applied to
  26146. * @param updatable when used and having the value true allows new data to update the vertexData
  26147. * @returns the VertexData
  26148. */
  26149. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26150. /**
  26151. * Associates the vertexData to the passed Geometry.
  26152. * Sets it as updatable or not (default `false`)
  26153. * @param geometry the geometry the vertexData is applied to
  26154. * @param updatable when used and having the value true allows new data to update the vertexData
  26155. * @returns VertexData
  26156. */
  26157. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26158. /**
  26159. * Updates the associated mesh
  26160. * @param mesh the mesh to be updated
  26161. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26162. * @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
  26163. * @returns VertexData
  26164. */
  26165. updateMesh(mesh: Mesh): VertexData;
  26166. /**
  26167. * Updates the associated geometry
  26168. * @param geometry the geometry to be updated
  26169. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26170. * @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
  26171. * @returns VertexData.
  26172. */
  26173. updateGeometry(geometry: Geometry): VertexData;
  26174. private _applyTo;
  26175. private _update;
  26176. /**
  26177. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26178. * @param matrix the transforming matrix
  26179. * @returns the VertexData
  26180. */
  26181. transform(matrix: Matrix): VertexData;
  26182. /**
  26183. * Merges the passed VertexData into the current one
  26184. * @param other the VertexData to be merged into the current one
  26185. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26186. * @returns the modified VertexData
  26187. */
  26188. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26189. private _mergeElement;
  26190. private _validate;
  26191. /**
  26192. * Serializes the VertexData
  26193. * @returns a serialized object
  26194. */
  26195. serialize(): any;
  26196. /**
  26197. * Extracts the vertexData from a mesh
  26198. * @param mesh the mesh from which to extract the VertexData
  26199. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26200. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26201. * @returns the object VertexData associated to the passed mesh
  26202. */
  26203. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26204. /**
  26205. * Extracts the vertexData from the geometry
  26206. * @param geometry the geometry from which to extract the VertexData
  26207. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26208. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26209. * @returns the object VertexData associated to the passed mesh
  26210. */
  26211. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26212. private static _ExtractFrom;
  26213. /**
  26214. * Creates the VertexData for a Ribbon
  26215. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26216. * * pathArray array of paths, each of which an array of successive Vector3
  26217. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26218. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26219. * * 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
  26220. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26221. * * 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)
  26222. * * 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)
  26223. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26224. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26225. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26226. * @returns the VertexData of the ribbon
  26227. */
  26228. static CreateRibbon(options: {
  26229. pathArray: Vector3[][];
  26230. closeArray?: boolean;
  26231. closePath?: boolean;
  26232. offset?: number;
  26233. sideOrientation?: number;
  26234. frontUVs?: Vector4;
  26235. backUVs?: Vector4;
  26236. invertUV?: boolean;
  26237. uvs?: Vector2[];
  26238. colors?: Color4[];
  26239. }): VertexData;
  26240. /**
  26241. * Creates the VertexData for a box
  26242. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26243. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26244. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26245. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26246. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26247. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26248. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26250. * * 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)
  26251. * * 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)
  26252. * @returns the VertexData of the box
  26253. */
  26254. static CreateBox(options: {
  26255. size?: number;
  26256. width?: number;
  26257. height?: number;
  26258. depth?: number;
  26259. faceUV?: Vector4[];
  26260. faceColors?: Color4[];
  26261. sideOrientation?: number;
  26262. frontUVs?: Vector4;
  26263. backUVs?: Vector4;
  26264. }): VertexData;
  26265. /**
  26266. * Creates the VertexData for a tiled box
  26267. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26268. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26269. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26270. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26271. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26272. * @returns the VertexData of the box
  26273. */
  26274. static CreateTiledBox(options: {
  26275. pattern?: number;
  26276. width?: number;
  26277. height?: number;
  26278. depth?: number;
  26279. tileSize?: number;
  26280. tileWidth?: number;
  26281. tileHeight?: number;
  26282. alignHorizontal?: number;
  26283. alignVertical?: number;
  26284. faceUV?: Vector4[];
  26285. faceColors?: Color4[];
  26286. sideOrientation?: number;
  26287. }): VertexData;
  26288. /**
  26289. * Creates the VertexData for a tiled plane
  26290. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26291. * * pattern a limited pattern arrangement depending on the number
  26292. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26293. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26294. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26295. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26296. * * 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)
  26297. * * 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)
  26298. * @returns the VertexData of the tiled plane
  26299. */
  26300. static CreateTiledPlane(options: {
  26301. pattern?: number;
  26302. tileSize?: number;
  26303. tileWidth?: number;
  26304. tileHeight?: number;
  26305. size?: number;
  26306. width?: number;
  26307. height?: number;
  26308. alignHorizontal?: number;
  26309. alignVertical?: number;
  26310. sideOrientation?: number;
  26311. frontUVs?: Vector4;
  26312. backUVs?: Vector4;
  26313. }): VertexData;
  26314. /**
  26315. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26316. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26317. * * segments sets the number of horizontal strips optional, default 32
  26318. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26319. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26320. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26321. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26322. * * 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
  26323. * * 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
  26324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26325. * * 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)
  26326. * * 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)
  26327. * @returns the VertexData of the ellipsoid
  26328. */
  26329. static CreateSphere(options: {
  26330. segments?: number;
  26331. diameter?: number;
  26332. diameterX?: number;
  26333. diameterY?: number;
  26334. diameterZ?: number;
  26335. arc?: number;
  26336. slice?: number;
  26337. sideOrientation?: number;
  26338. frontUVs?: Vector4;
  26339. backUVs?: Vector4;
  26340. }): VertexData;
  26341. /**
  26342. * Creates the VertexData for a cylinder, cone or prism
  26343. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26344. * * height sets the height (y direction) of the cylinder, optional, default 2
  26345. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26346. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26347. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26348. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26349. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26350. * * 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
  26351. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26352. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26353. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26354. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26356. * * 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)
  26357. * * 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)
  26358. * @returns the VertexData of the cylinder, cone or prism
  26359. */
  26360. static CreateCylinder(options: {
  26361. height?: number;
  26362. diameterTop?: number;
  26363. diameterBottom?: number;
  26364. diameter?: number;
  26365. tessellation?: number;
  26366. subdivisions?: number;
  26367. arc?: number;
  26368. faceColors?: Color4[];
  26369. faceUV?: Vector4[];
  26370. hasRings?: boolean;
  26371. enclose?: boolean;
  26372. sideOrientation?: number;
  26373. frontUVs?: Vector4;
  26374. backUVs?: Vector4;
  26375. }): VertexData;
  26376. /**
  26377. * Creates the VertexData for a torus
  26378. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26379. * * diameter the diameter of the torus, optional default 1
  26380. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26381. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26382. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26383. * * 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)
  26384. * * 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)
  26385. * @returns the VertexData of the torus
  26386. */
  26387. static CreateTorus(options: {
  26388. diameter?: number;
  26389. thickness?: number;
  26390. tessellation?: number;
  26391. sideOrientation?: number;
  26392. frontUVs?: Vector4;
  26393. backUVs?: Vector4;
  26394. }): VertexData;
  26395. /**
  26396. * Creates the VertexData of the LineSystem
  26397. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26398. * - lines an array of lines, each line being an array of successive Vector3
  26399. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26400. * @returns the VertexData of the LineSystem
  26401. */
  26402. static CreateLineSystem(options: {
  26403. lines: Vector3[][];
  26404. colors?: Nullable<Color4[][]>;
  26405. }): VertexData;
  26406. /**
  26407. * Create the VertexData for a DashedLines
  26408. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26409. * - points an array successive Vector3
  26410. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26411. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26412. * - dashNb the intended total number of dashes, optional, default 200
  26413. * @returns the VertexData for the DashedLines
  26414. */
  26415. static CreateDashedLines(options: {
  26416. points: Vector3[];
  26417. dashSize?: number;
  26418. gapSize?: number;
  26419. dashNb?: number;
  26420. }): VertexData;
  26421. /**
  26422. * Creates the VertexData for a Ground
  26423. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26424. * - width the width (x direction) of the ground, optional, default 1
  26425. * - height the height (z direction) of the ground, optional, default 1
  26426. * - subdivisions the number of subdivisions per side, optional, default 1
  26427. * @returns the VertexData of the Ground
  26428. */
  26429. static CreateGround(options: {
  26430. width?: number;
  26431. height?: number;
  26432. subdivisions?: number;
  26433. subdivisionsX?: number;
  26434. subdivisionsY?: number;
  26435. }): VertexData;
  26436. /**
  26437. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26438. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26439. * * xmin the ground minimum X coordinate, optional, default -1
  26440. * * zmin the ground minimum Z coordinate, optional, default -1
  26441. * * xmax the ground maximum X coordinate, optional, default 1
  26442. * * zmax the ground maximum Z coordinate, optional, default 1
  26443. * * 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}
  26444. * * 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}
  26445. * @returns the VertexData of the TiledGround
  26446. */
  26447. static CreateTiledGround(options: {
  26448. xmin: number;
  26449. zmin: number;
  26450. xmax: number;
  26451. zmax: number;
  26452. subdivisions?: {
  26453. w: number;
  26454. h: number;
  26455. };
  26456. precision?: {
  26457. w: number;
  26458. h: number;
  26459. };
  26460. }): VertexData;
  26461. /**
  26462. * Creates the VertexData of the Ground designed from a heightmap
  26463. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26464. * * width the width (x direction) of the ground
  26465. * * height the height (z direction) of the ground
  26466. * * subdivisions the number of subdivisions per side
  26467. * * minHeight the minimum altitude on the ground, optional, default 0
  26468. * * maxHeight the maximum altitude on the ground, optional default 1
  26469. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26470. * * buffer the array holding the image color data
  26471. * * bufferWidth the width of image
  26472. * * bufferHeight the height of image
  26473. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26474. * @returns the VertexData of the Ground designed from a heightmap
  26475. */
  26476. static CreateGroundFromHeightMap(options: {
  26477. width: number;
  26478. height: number;
  26479. subdivisions: number;
  26480. minHeight: number;
  26481. maxHeight: number;
  26482. colorFilter: Color3;
  26483. buffer: Uint8Array;
  26484. bufferWidth: number;
  26485. bufferHeight: number;
  26486. alphaFilter: number;
  26487. }): VertexData;
  26488. /**
  26489. * Creates the VertexData for a Plane
  26490. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26491. * * size sets the width and height of the plane to the value of size, optional default 1
  26492. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26493. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26494. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26495. * * 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)
  26496. * * 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)
  26497. * @returns the VertexData of the box
  26498. */
  26499. static CreatePlane(options: {
  26500. size?: number;
  26501. width?: number;
  26502. height?: number;
  26503. sideOrientation?: number;
  26504. frontUVs?: Vector4;
  26505. backUVs?: Vector4;
  26506. }): VertexData;
  26507. /**
  26508. * Creates the VertexData of the Disc or regular Polygon
  26509. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26510. * * radius the radius of the disc, optional default 0.5
  26511. * * tessellation the number of polygon sides, optional, default 64
  26512. * * 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
  26513. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26514. * * 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)
  26515. * * 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)
  26516. * @returns the VertexData of the box
  26517. */
  26518. static CreateDisc(options: {
  26519. radius?: number;
  26520. tessellation?: number;
  26521. arc?: number;
  26522. sideOrientation?: number;
  26523. frontUVs?: Vector4;
  26524. backUVs?: Vector4;
  26525. }): VertexData;
  26526. /**
  26527. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26528. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26529. * @param polygon a mesh built from polygonTriangulation.build()
  26530. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26531. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26532. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26533. * @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)
  26534. * @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)
  26535. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26536. * @returns the VertexData of the Polygon
  26537. */
  26538. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26539. /**
  26540. * Creates the VertexData of the IcoSphere
  26541. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26542. * * radius the radius of the IcoSphere, optional default 1
  26543. * * radiusX allows stretching in the x direction, optional, default radius
  26544. * * radiusY allows stretching in the y direction, optional, default radius
  26545. * * radiusZ allows stretching in the z direction, optional, default radius
  26546. * * flat when true creates a flat shaded mesh, optional, default true
  26547. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26548. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26549. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26550. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26551. * @returns the VertexData of the IcoSphere
  26552. */
  26553. static CreateIcoSphere(options: {
  26554. radius?: number;
  26555. radiusX?: number;
  26556. radiusY?: number;
  26557. radiusZ?: number;
  26558. flat?: boolean;
  26559. subdivisions?: number;
  26560. sideOrientation?: number;
  26561. frontUVs?: Vector4;
  26562. backUVs?: Vector4;
  26563. }): VertexData;
  26564. /**
  26565. * Creates the VertexData for a Polyhedron
  26566. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26567. * * type provided types are:
  26568. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26569. * * 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)
  26570. * * size the size of the IcoSphere, optional default 1
  26571. * * sizeX allows stretching in the x direction, optional, default size
  26572. * * sizeY allows stretching in the y direction, optional, default size
  26573. * * sizeZ allows stretching in the z direction, optional, default size
  26574. * * 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
  26575. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26576. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26577. * * flat when true creates a flat shaded mesh, optional, default true
  26578. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26579. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26580. * * 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)
  26581. * * 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)
  26582. * @returns the VertexData of the Polyhedron
  26583. */
  26584. static CreatePolyhedron(options: {
  26585. type?: number;
  26586. size?: number;
  26587. sizeX?: number;
  26588. sizeY?: number;
  26589. sizeZ?: number;
  26590. custom?: any;
  26591. faceUV?: Vector4[];
  26592. faceColors?: Color4[];
  26593. flat?: boolean;
  26594. sideOrientation?: number;
  26595. frontUVs?: Vector4;
  26596. backUVs?: Vector4;
  26597. }): VertexData;
  26598. /**
  26599. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  26600. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  26601. * @returns the VertexData of the Capsule
  26602. */
  26603. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  26604. /**
  26605. * Creates the VertexData for a TorusKnot
  26606. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26607. * * radius the radius of the torus knot, optional, default 2
  26608. * * tube the thickness of the tube, optional, default 0.5
  26609. * * radialSegments the number of sides on each tube segments, optional, default 32
  26610. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26611. * * p the number of windings around the z axis, optional, default 2
  26612. * * q the number of windings around the x axis, optional, default 3
  26613. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26614. * * 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)
  26615. * * 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)
  26616. * @returns the VertexData of the Torus Knot
  26617. */
  26618. static CreateTorusKnot(options: {
  26619. radius?: number;
  26620. tube?: number;
  26621. radialSegments?: number;
  26622. tubularSegments?: number;
  26623. p?: number;
  26624. q?: number;
  26625. sideOrientation?: number;
  26626. frontUVs?: Vector4;
  26627. backUVs?: Vector4;
  26628. }): VertexData;
  26629. /**
  26630. * Compute normals for given positions and indices
  26631. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26632. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26633. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26634. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26635. * * facetNormals : optional array of facet normals (vector3)
  26636. * * facetPositions : optional array of facet positions (vector3)
  26637. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26638. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26639. * * bInfo : optional bounding info, required for facetPartitioning computation
  26640. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26641. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26642. * * useRightHandedSystem: optional boolean to for right handed system computation
  26643. * * depthSort : optional boolean to enable the facet depth sort computation
  26644. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26645. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26646. */
  26647. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26648. facetNormals?: any;
  26649. facetPositions?: any;
  26650. facetPartitioning?: any;
  26651. ratio?: number;
  26652. bInfo?: any;
  26653. bbSize?: Vector3;
  26654. subDiv?: any;
  26655. useRightHandedSystem?: boolean;
  26656. depthSort?: boolean;
  26657. distanceTo?: Vector3;
  26658. depthSortedFacets?: any;
  26659. }): void;
  26660. /** @hidden */
  26661. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26662. /**
  26663. * Applies VertexData created from the imported parameters to the geometry
  26664. * @param parsedVertexData the parsed data from an imported file
  26665. * @param geometry the geometry to apply the VertexData to
  26666. */
  26667. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26668. }
  26669. }
  26670. declare module BABYLON {
  26671. /**
  26672. * Defines a target to use with MorphTargetManager
  26673. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26674. */
  26675. export class MorphTarget implements IAnimatable {
  26676. /** defines the name of the target */
  26677. name: string;
  26678. /**
  26679. * Gets or sets the list of animations
  26680. */
  26681. animations: Animation[];
  26682. private _scene;
  26683. private _positions;
  26684. private _normals;
  26685. private _tangents;
  26686. private _uvs;
  26687. private _influence;
  26688. private _uniqueId;
  26689. /**
  26690. * Observable raised when the influence changes
  26691. */
  26692. onInfluenceChanged: Observable<boolean>;
  26693. /** @hidden */
  26694. _onDataLayoutChanged: Observable<void>;
  26695. /**
  26696. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26697. */
  26698. get influence(): number;
  26699. set influence(influence: number);
  26700. /**
  26701. * Gets or sets the id of the morph Target
  26702. */
  26703. id: string;
  26704. private _animationPropertiesOverride;
  26705. /**
  26706. * Gets or sets the animation properties override
  26707. */
  26708. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26709. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26710. /**
  26711. * Creates a new MorphTarget
  26712. * @param name defines the name of the target
  26713. * @param influence defines the influence to use
  26714. * @param scene defines the scene the morphtarget belongs to
  26715. */
  26716. constructor(
  26717. /** defines the name of the target */
  26718. name: string, influence?: number, scene?: Nullable<Scene>);
  26719. /**
  26720. * Gets the unique ID of this manager
  26721. */
  26722. get uniqueId(): number;
  26723. /**
  26724. * Gets a boolean defining if the target contains position data
  26725. */
  26726. get hasPositions(): boolean;
  26727. /**
  26728. * Gets a boolean defining if the target contains normal data
  26729. */
  26730. get hasNormals(): boolean;
  26731. /**
  26732. * Gets a boolean defining if the target contains tangent data
  26733. */
  26734. get hasTangents(): boolean;
  26735. /**
  26736. * Gets a boolean defining if the target contains texture coordinates data
  26737. */
  26738. get hasUVs(): boolean;
  26739. /**
  26740. * Affects position data to this target
  26741. * @param data defines the position data to use
  26742. */
  26743. setPositions(data: Nullable<FloatArray>): void;
  26744. /**
  26745. * Gets the position data stored in this target
  26746. * @returns a FloatArray containing the position data (or null if not present)
  26747. */
  26748. getPositions(): Nullable<FloatArray>;
  26749. /**
  26750. * Affects normal data to this target
  26751. * @param data defines the normal data to use
  26752. */
  26753. setNormals(data: Nullable<FloatArray>): void;
  26754. /**
  26755. * Gets the normal data stored in this target
  26756. * @returns a FloatArray containing the normal data (or null if not present)
  26757. */
  26758. getNormals(): Nullable<FloatArray>;
  26759. /**
  26760. * Affects tangent data to this target
  26761. * @param data defines the tangent data to use
  26762. */
  26763. setTangents(data: Nullable<FloatArray>): void;
  26764. /**
  26765. * Gets the tangent data stored in this target
  26766. * @returns a FloatArray containing the tangent data (or null if not present)
  26767. */
  26768. getTangents(): Nullable<FloatArray>;
  26769. /**
  26770. * Affects texture coordinates data to this target
  26771. * @param data defines the texture coordinates data to use
  26772. */
  26773. setUVs(data: Nullable<FloatArray>): void;
  26774. /**
  26775. * Gets the texture coordinates data stored in this target
  26776. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26777. */
  26778. getUVs(): Nullable<FloatArray>;
  26779. /**
  26780. * Clone the current target
  26781. * @returns a new MorphTarget
  26782. */
  26783. clone(): MorphTarget;
  26784. /**
  26785. * Serializes the current target into a Serialization object
  26786. * @returns the serialized object
  26787. */
  26788. serialize(): any;
  26789. /**
  26790. * Returns the string "MorphTarget"
  26791. * @returns "MorphTarget"
  26792. */
  26793. getClassName(): string;
  26794. /**
  26795. * Creates a new target from serialized data
  26796. * @param serializationObject defines the serialized data to use
  26797. * @returns a new MorphTarget
  26798. */
  26799. static Parse(serializationObject: any): MorphTarget;
  26800. /**
  26801. * Creates a MorphTarget from mesh data
  26802. * @param mesh defines the source mesh
  26803. * @param name defines the name to use for the new target
  26804. * @param influence defines the influence to attach to the target
  26805. * @returns a new MorphTarget
  26806. */
  26807. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26808. }
  26809. }
  26810. declare module BABYLON {
  26811. /**
  26812. * This class is used to deform meshes using morphing between different targets
  26813. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26814. */
  26815. export class MorphTargetManager {
  26816. private _targets;
  26817. private _targetInfluenceChangedObservers;
  26818. private _targetDataLayoutChangedObservers;
  26819. private _activeTargets;
  26820. private _scene;
  26821. private _influences;
  26822. private _supportsNormals;
  26823. private _supportsTangents;
  26824. private _supportsUVs;
  26825. private _vertexCount;
  26826. private _uniqueId;
  26827. private _tempInfluences;
  26828. /**
  26829. * Gets or sets a boolean indicating if normals must be morphed
  26830. */
  26831. enableNormalMorphing: boolean;
  26832. /**
  26833. * Gets or sets a boolean indicating if tangents must be morphed
  26834. */
  26835. enableTangentMorphing: boolean;
  26836. /**
  26837. * Gets or sets a boolean indicating if UV must be morphed
  26838. */
  26839. enableUVMorphing: boolean;
  26840. /**
  26841. * Creates a new MorphTargetManager
  26842. * @param scene defines the current scene
  26843. */
  26844. constructor(scene?: Nullable<Scene>);
  26845. /**
  26846. * Gets the unique ID of this manager
  26847. */
  26848. get uniqueId(): number;
  26849. /**
  26850. * Gets the number of vertices handled by this manager
  26851. */
  26852. get vertexCount(): number;
  26853. /**
  26854. * Gets a boolean indicating if this manager supports morphing of normals
  26855. */
  26856. get supportsNormals(): boolean;
  26857. /**
  26858. * Gets a boolean indicating if this manager supports morphing of tangents
  26859. */
  26860. get supportsTangents(): boolean;
  26861. /**
  26862. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26863. */
  26864. get supportsUVs(): boolean;
  26865. /**
  26866. * Gets the number of targets stored in this manager
  26867. */
  26868. get numTargets(): number;
  26869. /**
  26870. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26871. */
  26872. get numInfluencers(): number;
  26873. /**
  26874. * Gets the list of influences (one per target)
  26875. */
  26876. get influences(): Float32Array;
  26877. /**
  26878. * Gets the active target at specified index. An active target is a target with an influence > 0
  26879. * @param index defines the index to check
  26880. * @returns the requested target
  26881. */
  26882. getActiveTarget(index: number): MorphTarget;
  26883. /**
  26884. * Gets the target at specified index
  26885. * @param index defines the index to check
  26886. * @returns the requested target
  26887. */
  26888. getTarget(index: number): MorphTarget;
  26889. /**
  26890. * Add a new target to this manager
  26891. * @param target defines the target to add
  26892. */
  26893. addTarget(target: MorphTarget): void;
  26894. /**
  26895. * Removes a target from the manager
  26896. * @param target defines the target to remove
  26897. */
  26898. removeTarget(target: MorphTarget): void;
  26899. /**
  26900. * Clone the current manager
  26901. * @returns a new MorphTargetManager
  26902. */
  26903. clone(): MorphTargetManager;
  26904. /**
  26905. * Serializes the current manager into a Serialization object
  26906. * @returns the serialized object
  26907. */
  26908. serialize(): any;
  26909. private _syncActiveTargets;
  26910. /**
  26911. * Syncrhonize the targets with all the meshes using this morph target manager
  26912. */
  26913. synchronize(): void;
  26914. /**
  26915. * Creates a new MorphTargetManager from serialized data
  26916. * @param serializationObject defines the serialized data
  26917. * @param scene defines the hosting scene
  26918. * @returns the new MorphTargetManager
  26919. */
  26920. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26921. }
  26922. }
  26923. declare module BABYLON {
  26924. /**
  26925. * Class used to represent a specific level of detail of a mesh
  26926. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26927. */
  26928. export class MeshLODLevel {
  26929. /** Defines the distance where this level should start being displayed */
  26930. distance: number;
  26931. /** Defines the mesh to use to render this level */
  26932. mesh: Nullable<Mesh>;
  26933. /**
  26934. * Creates a new LOD level
  26935. * @param distance defines the distance where this level should star being displayed
  26936. * @param mesh defines the mesh to use to render this level
  26937. */
  26938. constructor(
  26939. /** Defines the distance where this level should start being displayed */
  26940. distance: number,
  26941. /** Defines the mesh to use to render this level */
  26942. mesh: Nullable<Mesh>);
  26943. }
  26944. }
  26945. declare module BABYLON {
  26946. /**
  26947. * Helper class used to generate a canvas to manipulate images
  26948. */
  26949. export class CanvasGenerator {
  26950. /**
  26951. * Create a new canvas (or offscreen canvas depending on the context)
  26952. * @param width defines the expected width
  26953. * @param height defines the expected height
  26954. * @return a new canvas or offscreen canvas
  26955. */
  26956. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26957. }
  26958. }
  26959. declare module BABYLON {
  26960. /**
  26961. * Mesh representing the gorund
  26962. */
  26963. export class GroundMesh extends Mesh {
  26964. /** If octree should be generated */
  26965. generateOctree: boolean;
  26966. private _heightQuads;
  26967. /** @hidden */
  26968. _subdivisionsX: number;
  26969. /** @hidden */
  26970. _subdivisionsY: number;
  26971. /** @hidden */
  26972. _width: number;
  26973. /** @hidden */
  26974. _height: number;
  26975. /** @hidden */
  26976. _minX: number;
  26977. /** @hidden */
  26978. _maxX: number;
  26979. /** @hidden */
  26980. _minZ: number;
  26981. /** @hidden */
  26982. _maxZ: number;
  26983. constructor(name: string, scene: Scene);
  26984. /**
  26985. * "GroundMesh"
  26986. * @returns "GroundMesh"
  26987. */
  26988. getClassName(): string;
  26989. /**
  26990. * The minimum of x and y subdivisions
  26991. */
  26992. get subdivisions(): number;
  26993. /**
  26994. * X subdivisions
  26995. */
  26996. get subdivisionsX(): number;
  26997. /**
  26998. * Y subdivisions
  26999. */
  27000. get subdivisionsY(): number;
  27001. /**
  27002. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27003. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27004. * @param chunksCount the number of subdivisions for x and y
  27005. * @param octreeBlocksSize (Default: 32)
  27006. */
  27007. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27008. /**
  27009. * Returns a height (y) value in the Worl system :
  27010. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27011. * @param x x coordinate
  27012. * @param z z coordinate
  27013. * @returns the ground y position if (x, z) are outside the ground surface.
  27014. */
  27015. getHeightAtCoordinates(x: number, z: number): number;
  27016. /**
  27017. * Returns a normalized vector (Vector3) orthogonal to the ground
  27018. * at the ground coordinates (x, z) expressed in the World system.
  27019. * @param x x coordinate
  27020. * @param z z coordinate
  27021. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27022. */
  27023. getNormalAtCoordinates(x: number, z: number): Vector3;
  27024. /**
  27025. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27026. * at the ground coordinates (x, z) expressed in the World system.
  27027. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27028. * @param x x coordinate
  27029. * @param z z coordinate
  27030. * @param ref vector to store the result
  27031. * @returns the GroundMesh.
  27032. */
  27033. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27034. /**
  27035. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27036. * if the ground has been updated.
  27037. * This can be used in the render loop.
  27038. * @returns the GroundMesh.
  27039. */
  27040. updateCoordinateHeights(): GroundMesh;
  27041. private _getFacetAt;
  27042. private _initHeightQuads;
  27043. private _computeHeightQuads;
  27044. /**
  27045. * Serializes this ground mesh
  27046. * @param serializationObject object to write serialization to
  27047. */
  27048. serialize(serializationObject: any): void;
  27049. /**
  27050. * Parses a serialized ground mesh
  27051. * @param parsedMesh the serialized mesh
  27052. * @param scene the scene to create the ground mesh in
  27053. * @returns the created ground mesh
  27054. */
  27055. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27056. }
  27057. }
  27058. declare module BABYLON {
  27059. /**
  27060. * Interface for Physics-Joint data
  27061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27062. */
  27063. export interface PhysicsJointData {
  27064. /**
  27065. * The main pivot of the joint
  27066. */
  27067. mainPivot?: Vector3;
  27068. /**
  27069. * The connected pivot of the joint
  27070. */
  27071. connectedPivot?: Vector3;
  27072. /**
  27073. * The main axis of the joint
  27074. */
  27075. mainAxis?: Vector3;
  27076. /**
  27077. * The connected axis of the joint
  27078. */
  27079. connectedAxis?: Vector3;
  27080. /**
  27081. * The collision of the joint
  27082. */
  27083. collision?: boolean;
  27084. /**
  27085. * Native Oimo/Cannon/Energy data
  27086. */
  27087. nativeParams?: any;
  27088. }
  27089. /**
  27090. * This is a holder class for the physics joint created by the physics plugin
  27091. * It holds a set of functions to control the underlying joint
  27092. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27093. */
  27094. export class PhysicsJoint {
  27095. /**
  27096. * The type of the physics joint
  27097. */
  27098. type: number;
  27099. /**
  27100. * The data for the physics joint
  27101. */
  27102. jointData: PhysicsJointData;
  27103. private _physicsJoint;
  27104. protected _physicsPlugin: IPhysicsEnginePlugin;
  27105. /**
  27106. * Initializes the physics joint
  27107. * @param type The type of the physics joint
  27108. * @param jointData The data for the physics joint
  27109. */
  27110. constructor(
  27111. /**
  27112. * The type of the physics joint
  27113. */
  27114. type: number,
  27115. /**
  27116. * The data for the physics joint
  27117. */
  27118. jointData: PhysicsJointData);
  27119. /**
  27120. * Gets the physics joint
  27121. */
  27122. get physicsJoint(): any;
  27123. /**
  27124. * Sets the physics joint
  27125. */
  27126. set physicsJoint(newJoint: any);
  27127. /**
  27128. * Sets the physics plugin
  27129. */
  27130. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27131. /**
  27132. * Execute a function that is physics-plugin specific.
  27133. * @param {Function} func the function that will be executed.
  27134. * It accepts two parameters: the physics world and the physics joint
  27135. */
  27136. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27137. /**
  27138. * Distance-Joint type
  27139. */
  27140. static DistanceJoint: number;
  27141. /**
  27142. * Hinge-Joint type
  27143. */
  27144. static HingeJoint: number;
  27145. /**
  27146. * Ball-and-Socket joint type
  27147. */
  27148. static BallAndSocketJoint: number;
  27149. /**
  27150. * Wheel-Joint type
  27151. */
  27152. static WheelJoint: number;
  27153. /**
  27154. * Slider-Joint type
  27155. */
  27156. static SliderJoint: number;
  27157. /**
  27158. * Prismatic-Joint type
  27159. */
  27160. static PrismaticJoint: number;
  27161. /**
  27162. * Universal-Joint type
  27163. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27164. */
  27165. static UniversalJoint: number;
  27166. /**
  27167. * Hinge-Joint 2 type
  27168. */
  27169. static Hinge2Joint: number;
  27170. /**
  27171. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27172. */
  27173. static PointToPointJoint: number;
  27174. /**
  27175. * Spring-Joint type
  27176. */
  27177. static SpringJoint: number;
  27178. /**
  27179. * Lock-Joint type
  27180. */
  27181. static LockJoint: number;
  27182. }
  27183. /**
  27184. * A class representing a physics distance joint
  27185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27186. */
  27187. export class DistanceJoint extends PhysicsJoint {
  27188. /**
  27189. *
  27190. * @param jointData The data for the Distance-Joint
  27191. */
  27192. constructor(jointData: DistanceJointData);
  27193. /**
  27194. * Update the predefined distance.
  27195. * @param maxDistance The maximum preferred distance
  27196. * @param minDistance The minimum preferred distance
  27197. */
  27198. updateDistance(maxDistance: number, minDistance?: number): void;
  27199. }
  27200. /**
  27201. * Represents a Motor-Enabled Joint
  27202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27203. */
  27204. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27205. /**
  27206. * Initializes the Motor-Enabled Joint
  27207. * @param type The type of the joint
  27208. * @param jointData The physica joint data for the joint
  27209. */
  27210. constructor(type: number, jointData: PhysicsJointData);
  27211. /**
  27212. * Set the motor values.
  27213. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27214. * @param force the force to apply
  27215. * @param maxForce max force for this motor.
  27216. */
  27217. setMotor(force?: number, maxForce?: number): void;
  27218. /**
  27219. * Set the motor's limits.
  27220. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27221. * @param upperLimit The upper limit of the motor
  27222. * @param lowerLimit The lower limit of the motor
  27223. */
  27224. setLimit(upperLimit: number, lowerLimit?: number): void;
  27225. }
  27226. /**
  27227. * This class represents a single physics Hinge-Joint
  27228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27229. */
  27230. export class HingeJoint extends MotorEnabledJoint {
  27231. /**
  27232. * Initializes the Hinge-Joint
  27233. * @param jointData The joint data for the Hinge-Joint
  27234. */
  27235. constructor(jointData: PhysicsJointData);
  27236. /**
  27237. * Set the motor values.
  27238. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27239. * @param {number} force the force to apply
  27240. * @param {number} maxForce max force for this motor.
  27241. */
  27242. setMotor(force?: number, maxForce?: number): void;
  27243. /**
  27244. * Set the motor's limits.
  27245. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27246. * @param upperLimit The upper limit of the motor
  27247. * @param lowerLimit The lower limit of the motor
  27248. */
  27249. setLimit(upperLimit: number, lowerLimit?: number): void;
  27250. }
  27251. /**
  27252. * This class represents a dual hinge physics joint (same as wheel joint)
  27253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27254. */
  27255. export class Hinge2Joint extends MotorEnabledJoint {
  27256. /**
  27257. * Initializes the Hinge2-Joint
  27258. * @param jointData The joint data for the Hinge2-Joint
  27259. */
  27260. constructor(jointData: PhysicsJointData);
  27261. /**
  27262. * Set the motor values.
  27263. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27264. * @param {number} targetSpeed the speed the motor is to reach
  27265. * @param {number} maxForce max force for this motor.
  27266. * @param {motorIndex} the motor's index, 0 or 1.
  27267. */
  27268. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27269. /**
  27270. * Set the motor limits.
  27271. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27272. * @param {number} upperLimit the upper limit
  27273. * @param {number} lowerLimit lower limit
  27274. * @param {motorIndex} the motor's index, 0 or 1.
  27275. */
  27276. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27277. }
  27278. /**
  27279. * Interface for a motor enabled joint
  27280. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27281. */
  27282. export interface IMotorEnabledJoint {
  27283. /**
  27284. * Physics joint
  27285. */
  27286. physicsJoint: any;
  27287. /**
  27288. * Sets the motor of the motor-enabled joint
  27289. * @param force The force of the motor
  27290. * @param maxForce The maximum force of the motor
  27291. * @param motorIndex The index of the motor
  27292. */
  27293. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27294. /**
  27295. * Sets the limit of the motor
  27296. * @param upperLimit The upper limit of the motor
  27297. * @param lowerLimit The lower limit of the motor
  27298. * @param motorIndex The index of the motor
  27299. */
  27300. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27301. }
  27302. /**
  27303. * Joint data for a Distance-Joint
  27304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27305. */
  27306. export interface DistanceJointData extends PhysicsJointData {
  27307. /**
  27308. * Max distance the 2 joint objects can be apart
  27309. */
  27310. maxDistance: number;
  27311. }
  27312. /**
  27313. * Joint data from a spring joint
  27314. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27315. */
  27316. export interface SpringJointData extends PhysicsJointData {
  27317. /**
  27318. * Length of the spring
  27319. */
  27320. length: number;
  27321. /**
  27322. * Stiffness of the spring
  27323. */
  27324. stiffness: number;
  27325. /**
  27326. * Damping of the spring
  27327. */
  27328. damping: number;
  27329. /** this callback will be called when applying the force to the impostors. */
  27330. forceApplicationCallback: () => void;
  27331. }
  27332. }
  27333. declare module BABYLON {
  27334. /**
  27335. * Holds the data for the raycast result
  27336. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27337. */
  27338. export class PhysicsRaycastResult {
  27339. private _hasHit;
  27340. private _hitDistance;
  27341. private _hitNormalWorld;
  27342. private _hitPointWorld;
  27343. private _rayFromWorld;
  27344. private _rayToWorld;
  27345. /**
  27346. * Gets if there was a hit
  27347. */
  27348. get hasHit(): boolean;
  27349. /**
  27350. * Gets the distance from the hit
  27351. */
  27352. get hitDistance(): number;
  27353. /**
  27354. * Gets the hit normal/direction in the world
  27355. */
  27356. get hitNormalWorld(): Vector3;
  27357. /**
  27358. * Gets the hit point in the world
  27359. */
  27360. get hitPointWorld(): Vector3;
  27361. /**
  27362. * Gets the ray "start point" of the ray in the world
  27363. */
  27364. get rayFromWorld(): Vector3;
  27365. /**
  27366. * Gets the ray "end point" of the ray in the world
  27367. */
  27368. get rayToWorld(): Vector3;
  27369. /**
  27370. * Sets the hit data (normal & point in world space)
  27371. * @param hitNormalWorld defines the normal in world space
  27372. * @param hitPointWorld defines the point in world space
  27373. */
  27374. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27375. /**
  27376. * Sets the distance from the start point to the hit point
  27377. * @param distance
  27378. */
  27379. setHitDistance(distance: number): void;
  27380. /**
  27381. * Calculates the distance manually
  27382. */
  27383. calculateHitDistance(): void;
  27384. /**
  27385. * Resets all the values to default
  27386. * @param from The from point on world space
  27387. * @param to The to point on world space
  27388. */
  27389. reset(from?: Vector3, to?: Vector3): void;
  27390. }
  27391. /**
  27392. * Interface for the size containing width and height
  27393. */
  27394. interface IXYZ {
  27395. /**
  27396. * X
  27397. */
  27398. x: number;
  27399. /**
  27400. * Y
  27401. */
  27402. y: number;
  27403. /**
  27404. * Z
  27405. */
  27406. z: number;
  27407. }
  27408. }
  27409. declare module BABYLON {
  27410. /**
  27411. * Interface used to describe a physics joint
  27412. */
  27413. export interface PhysicsImpostorJoint {
  27414. /** Defines the main impostor to which the joint is linked */
  27415. mainImpostor: PhysicsImpostor;
  27416. /** Defines the impostor that is connected to the main impostor using this joint */
  27417. connectedImpostor: PhysicsImpostor;
  27418. /** Defines the joint itself */
  27419. joint: PhysicsJoint;
  27420. }
  27421. /** @hidden */
  27422. export interface IPhysicsEnginePlugin {
  27423. world: any;
  27424. name: string;
  27425. setGravity(gravity: Vector3): void;
  27426. setTimeStep(timeStep: number): void;
  27427. getTimeStep(): number;
  27428. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27429. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27430. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27431. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27432. removePhysicsBody(impostor: PhysicsImpostor): void;
  27433. generateJoint(joint: PhysicsImpostorJoint): void;
  27434. removeJoint(joint: PhysicsImpostorJoint): void;
  27435. isSupported(): boolean;
  27436. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27437. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27438. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27439. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27440. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27441. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27442. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27443. getBodyMass(impostor: PhysicsImpostor): number;
  27444. getBodyFriction(impostor: PhysicsImpostor): number;
  27445. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27446. getBodyRestitution(impostor: PhysicsImpostor): number;
  27447. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27448. getBodyPressure?(impostor: PhysicsImpostor): number;
  27449. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27450. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27451. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27452. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27453. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27454. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27455. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27456. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27457. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27458. sleepBody(impostor: PhysicsImpostor): void;
  27459. wakeUpBody(impostor: PhysicsImpostor): void;
  27460. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27461. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27462. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27463. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27464. getRadius(impostor: PhysicsImpostor): number;
  27465. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27466. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27467. dispose(): void;
  27468. }
  27469. /**
  27470. * Interface used to define a physics engine
  27471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27472. */
  27473. export interface IPhysicsEngine {
  27474. /**
  27475. * Gets the gravity vector used by the simulation
  27476. */
  27477. gravity: Vector3;
  27478. /**
  27479. * Sets the gravity vector used by the simulation
  27480. * @param gravity defines the gravity vector to use
  27481. */
  27482. setGravity(gravity: Vector3): void;
  27483. /**
  27484. * Set the time step of the physics engine.
  27485. * Default is 1/60.
  27486. * To slow it down, enter 1/600 for example.
  27487. * To speed it up, 1/30
  27488. * @param newTimeStep the new timestep to apply to this world.
  27489. */
  27490. setTimeStep(newTimeStep: number): void;
  27491. /**
  27492. * Get the time step of the physics engine.
  27493. * @returns the current time step
  27494. */
  27495. getTimeStep(): number;
  27496. /**
  27497. * Set the sub time step of the physics engine.
  27498. * Default is 0 meaning there is no sub steps
  27499. * To increase physics resolution precision, set a small value (like 1 ms)
  27500. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27501. */
  27502. setSubTimeStep(subTimeStep: number): void;
  27503. /**
  27504. * Get the sub time step of the physics engine.
  27505. * @returns the current sub time step
  27506. */
  27507. getSubTimeStep(): number;
  27508. /**
  27509. * Release all resources
  27510. */
  27511. dispose(): void;
  27512. /**
  27513. * Gets the name of the current physics plugin
  27514. * @returns the name of the plugin
  27515. */
  27516. getPhysicsPluginName(): string;
  27517. /**
  27518. * Adding a new impostor for the impostor tracking.
  27519. * This will be done by the impostor itself.
  27520. * @param impostor the impostor to add
  27521. */
  27522. addImpostor(impostor: PhysicsImpostor): void;
  27523. /**
  27524. * Remove an impostor from the engine.
  27525. * This impostor and its mesh will not longer be updated by the physics engine.
  27526. * @param impostor the impostor to remove
  27527. */
  27528. removeImpostor(impostor: PhysicsImpostor): void;
  27529. /**
  27530. * Add a joint to the physics engine
  27531. * @param mainImpostor defines the main impostor to which the joint is added.
  27532. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27533. * @param joint defines the joint that will connect both impostors.
  27534. */
  27535. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27536. /**
  27537. * Removes a joint from the simulation
  27538. * @param mainImpostor defines the impostor used with the joint
  27539. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27540. * @param joint defines the joint to remove
  27541. */
  27542. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27543. /**
  27544. * Gets the current plugin used to run the simulation
  27545. * @returns current plugin
  27546. */
  27547. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27548. /**
  27549. * Gets the list of physic impostors
  27550. * @returns an array of PhysicsImpostor
  27551. */
  27552. getImpostors(): Array<PhysicsImpostor>;
  27553. /**
  27554. * Gets the impostor for a physics enabled object
  27555. * @param object defines the object impersonated by the impostor
  27556. * @returns the PhysicsImpostor or null if not found
  27557. */
  27558. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27559. /**
  27560. * Gets the impostor for a physics body object
  27561. * @param body defines physics body used by the impostor
  27562. * @returns the PhysicsImpostor or null if not found
  27563. */
  27564. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27565. /**
  27566. * Does a raycast in the physics world
  27567. * @param from when should the ray start?
  27568. * @param to when should the ray end?
  27569. * @returns PhysicsRaycastResult
  27570. */
  27571. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27572. /**
  27573. * Called by the scene. No need to call it.
  27574. * @param delta defines the timespam between frames
  27575. */
  27576. _step(delta: number): void;
  27577. }
  27578. }
  27579. declare module BABYLON {
  27580. /**
  27581. * The interface for the physics imposter parameters
  27582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27583. */
  27584. export interface PhysicsImpostorParameters {
  27585. /**
  27586. * The mass of the physics imposter
  27587. */
  27588. mass: number;
  27589. /**
  27590. * The friction of the physics imposter
  27591. */
  27592. friction?: number;
  27593. /**
  27594. * The coefficient of restitution of the physics imposter
  27595. */
  27596. restitution?: number;
  27597. /**
  27598. * The native options of the physics imposter
  27599. */
  27600. nativeOptions?: any;
  27601. /**
  27602. * Specifies if the parent should be ignored
  27603. */
  27604. ignoreParent?: boolean;
  27605. /**
  27606. * Specifies if bi-directional transformations should be disabled
  27607. */
  27608. disableBidirectionalTransformation?: boolean;
  27609. /**
  27610. * The pressure inside the physics imposter, soft object only
  27611. */
  27612. pressure?: number;
  27613. /**
  27614. * The stiffness the physics imposter, soft object only
  27615. */
  27616. stiffness?: number;
  27617. /**
  27618. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27619. */
  27620. velocityIterations?: number;
  27621. /**
  27622. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27623. */
  27624. positionIterations?: number;
  27625. /**
  27626. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27627. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27628. * Add to fix multiple points
  27629. */
  27630. fixedPoints?: number;
  27631. /**
  27632. * The collision margin around a soft object
  27633. */
  27634. margin?: number;
  27635. /**
  27636. * The collision margin around a soft object
  27637. */
  27638. damping?: number;
  27639. /**
  27640. * The path for a rope based on an extrusion
  27641. */
  27642. path?: any;
  27643. /**
  27644. * The shape of an extrusion used for a rope based on an extrusion
  27645. */
  27646. shape?: any;
  27647. }
  27648. /**
  27649. * Interface for a physics-enabled object
  27650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27651. */
  27652. export interface IPhysicsEnabledObject {
  27653. /**
  27654. * The position of the physics-enabled object
  27655. */
  27656. position: Vector3;
  27657. /**
  27658. * The rotation of the physics-enabled object
  27659. */
  27660. rotationQuaternion: Nullable<Quaternion>;
  27661. /**
  27662. * The scale of the physics-enabled object
  27663. */
  27664. scaling: Vector3;
  27665. /**
  27666. * The rotation of the physics-enabled object
  27667. */
  27668. rotation?: Vector3;
  27669. /**
  27670. * The parent of the physics-enabled object
  27671. */
  27672. parent?: any;
  27673. /**
  27674. * The bounding info of the physics-enabled object
  27675. * @returns The bounding info of the physics-enabled object
  27676. */
  27677. getBoundingInfo(): BoundingInfo;
  27678. /**
  27679. * Computes the world matrix
  27680. * @param force Specifies if the world matrix should be computed by force
  27681. * @returns A world matrix
  27682. */
  27683. computeWorldMatrix(force: boolean): Matrix;
  27684. /**
  27685. * Gets the world matrix
  27686. * @returns A world matrix
  27687. */
  27688. getWorldMatrix?(): Matrix;
  27689. /**
  27690. * Gets the child meshes
  27691. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27692. * @returns An array of abstract meshes
  27693. */
  27694. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27695. /**
  27696. * Gets the vertex data
  27697. * @param kind The type of vertex data
  27698. * @returns A nullable array of numbers, or a float32 array
  27699. */
  27700. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27701. /**
  27702. * Gets the indices from the mesh
  27703. * @returns A nullable array of index arrays
  27704. */
  27705. getIndices?(): Nullable<IndicesArray>;
  27706. /**
  27707. * Gets the scene from the mesh
  27708. * @returns the indices array or null
  27709. */
  27710. getScene?(): Scene;
  27711. /**
  27712. * Gets the absolute position from the mesh
  27713. * @returns the absolute position
  27714. */
  27715. getAbsolutePosition(): Vector3;
  27716. /**
  27717. * Gets the absolute pivot point from the mesh
  27718. * @returns the absolute pivot point
  27719. */
  27720. getAbsolutePivotPoint(): Vector3;
  27721. /**
  27722. * Rotates the mesh
  27723. * @param axis The axis of rotation
  27724. * @param amount The amount of rotation
  27725. * @param space The space of the rotation
  27726. * @returns The rotation transform node
  27727. */
  27728. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27729. /**
  27730. * Translates the mesh
  27731. * @param axis The axis of translation
  27732. * @param distance The distance of translation
  27733. * @param space The space of the translation
  27734. * @returns The transform node
  27735. */
  27736. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27737. /**
  27738. * Sets the absolute position of the mesh
  27739. * @param absolutePosition The absolute position of the mesh
  27740. * @returns The transform node
  27741. */
  27742. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27743. /**
  27744. * Gets the class name of the mesh
  27745. * @returns The class name
  27746. */
  27747. getClassName(): string;
  27748. }
  27749. /**
  27750. * Represents a physics imposter
  27751. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27752. */
  27753. export class PhysicsImpostor {
  27754. /**
  27755. * The physics-enabled object used as the physics imposter
  27756. */
  27757. object: IPhysicsEnabledObject;
  27758. /**
  27759. * The type of the physics imposter
  27760. */
  27761. type: number;
  27762. private _options;
  27763. private _scene?;
  27764. /**
  27765. * The default object size of the imposter
  27766. */
  27767. static DEFAULT_OBJECT_SIZE: Vector3;
  27768. /**
  27769. * The identity quaternion of the imposter
  27770. */
  27771. static IDENTITY_QUATERNION: Quaternion;
  27772. /** @hidden */
  27773. _pluginData: any;
  27774. private _physicsEngine;
  27775. private _physicsBody;
  27776. private _bodyUpdateRequired;
  27777. private _onBeforePhysicsStepCallbacks;
  27778. private _onAfterPhysicsStepCallbacks;
  27779. /** @hidden */
  27780. _onPhysicsCollideCallbacks: Array<{
  27781. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27782. otherImpostors: Array<PhysicsImpostor>;
  27783. }>;
  27784. private _deltaPosition;
  27785. private _deltaRotation;
  27786. private _deltaRotationConjugated;
  27787. /** @hidden */
  27788. _isFromLine: boolean;
  27789. private _parent;
  27790. private _isDisposed;
  27791. private static _tmpVecs;
  27792. private static _tmpQuat;
  27793. /**
  27794. * Specifies if the physics imposter is disposed
  27795. */
  27796. get isDisposed(): boolean;
  27797. /**
  27798. * Gets the mass of the physics imposter
  27799. */
  27800. get mass(): number;
  27801. set mass(value: number);
  27802. /**
  27803. * Gets the coefficient of friction
  27804. */
  27805. get friction(): number;
  27806. /**
  27807. * Sets the coefficient of friction
  27808. */
  27809. set friction(value: number);
  27810. /**
  27811. * Gets the coefficient of restitution
  27812. */
  27813. get restitution(): number;
  27814. /**
  27815. * Sets the coefficient of restitution
  27816. */
  27817. set restitution(value: number);
  27818. /**
  27819. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27820. */
  27821. get pressure(): number;
  27822. /**
  27823. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27824. */
  27825. set pressure(value: number);
  27826. /**
  27827. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27828. */
  27829. get stiffness(): number;
  27830. /**
  27831. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27832. */
  27833. set stiffness(value: number);
  27834. /**
  27835. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27836. */
  27837. get velocityIterations(): number;
  27838. /**
  27839. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27840. */
  27841. set velocityIterations(value: number);
  27842. /**
  27843. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27844. */
  27845. get positionIterations(): number;
  27846. /**
  27847. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27848. */
  27849. set positionIterations(value: number);
  27850. /**
  27851. * The unique id of the physics imposter
  27852. * set by the physics engine when adding this impostor to the array
  27853. */
  27854. uniqueId: number;
  27855. /**
  27856. * @hidden
  27857. */
  27858. soft: boolean;
  27859. /**
  27860. * @hidden
  27861. */
  27862. segments: number;
  27863. private _joints;
  27864. /**
  27865. * Initializes the physics imposter
  27866. * @param object The physics-enabled object used as the physics imposter
  27867. * @param type The type of the physics imposter
  27868. * @param _options The options for the physics imposter
  27869. * @param _scene The Babylon scene
  27870. */
  27871. constructor(
  27872. /**
  27873. * The physics-enabled object used as the physics imposter
  27874. */
  27875. object: IPhysicsEnabledObject,
  27876. /**
  27877. * The type of the physics imposter
  27878. */
  27879. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27880. /**
  27881. * This function will completly initialize this impostor.
  27882. * It will create a new body - but only if this mesh has no parent.
  27883. * If it has, this impostor will not be used other than to define the impostor
  27884. * of the child mesh.
  27885. * @hidden
  27886. */
  27887. _init(): void;
  27888. private _getPhysicsParent;
  27889. /**
  27890. * Should a new body be generated.
  27891. * @returns boolean specifying if body initialization is required
  27892. */
  27893. isBodyInitRequired(): boolean;
  27894. /**
  27895. * Sets the updated scaling
  27896. * @param updated Specifies if the scaling is updated
  27897. */
  27898. setScalingUpdated(): void;
  27899. /**
  27900. * Force a regeneration of this or the parent's impostor's body.
  27901. * Use under cautious - This will remove all joints already implemented.
  27902. */
  27903. forceUpdate(): void;
  27904. /**
  27905. * Gets the body that holds this impostor. Either its own, or its parent.
  27906. */
  27907. get physicsBody(): any;
  27908. /**
  27909. * Get the parent of the physics imposter
  27910. * @returns Physics imposter or null
  27911. */
  27912. get parent(): Nullable<PhysicsImpostor>;
  27913. /**
  27914. * Sets the parent of the physics imposter
  27915. */
  27916. set parent(value: Nullable<PhysicsImpostor>);
  27917. /**
  27918. * Set the physics body. Used mainly by the physics engine/plugin
  27919. */
  27920. set physicsBody(physicsBody: any);
  27921. /**
  27922. * Resets the update flags
  27923. */
  27924. resetUpdateFlags(): void;
  27925. /**
  27926. * Gets the object extend size
  27927. * @returns the object extend size
  27928. */
  27929. getObjectExtendSize(): Vector3;
  27930. /**
  27931. * Gets the object center
  27932. * @returns The object center
  27933. */
  27934. getObjectCenter(): Vector3;
  27935. /**
  27936. * Get a specific parameter from the options parameters
  27937. * @param paramName The object parameter name
  27938. * @returns The object parameter
  27939. */
  27940. getParam(paramName: string): any;
  27941. /**
  27942. * Sets a specific parameter in the options given to the physics plugin
  27943. * @param paramName The parameter name
  27944. * @param value The value of the parameter
  27945. */
  27946. setParam(paramName: string, value: number): void;
  27947. /**
  27948. * Specifically change the body's mass option. Won't recreate the physics body object
  27949. * @param mass The mass of the physics imposter
  27950. */
  27951. setMass(mass: number): void;
  27952. /**
  27953. * Gets the linear velocity
  27954. * @returns linear velocity or null
  27955. */
  27956. getLinearVelocity(): Nullable<Vector3>;
  27957. /**
  27958. * Sets the linear velocity
  27959. * @param velocity linear velocity or null
  27960. */
  27961. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27962. /**
  27963. * Gets the angular velocity
  27964. * @returns angular velocity or null
  27965. */
  27966. getAngularVelocity(): Nullable<Vector3>;
  27967. /**
  27968. * Sets the angular velocity
  27969. * @param velocity The velocity or null
  27970. */
  27971. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27972. /**
  27973. * Execute a function with the physics plugin native code
  27974. * Provide a function the will have two variables - the world object and the physics body object
  27975. * @param func The function to execute with the physics plugin native code
  27976. */
  27977. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27978. /**
  27979. * Register a function that will be executed before the physics world is stepping forward
  27980. * @param func The function to execute before the physics world is stepped forward
  27981. */
  27982. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27983. /**
  27984. * Unregister a function that will be executed before the physics world is stepping forward
  27985. * @param func The function to execute before the physics world is stepped forward
  27986. */
  27987. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27988. /**
  27989. * Register a function that will be executed after the physics step
  27990. * @param func The function to execute after physics step
  27991. */
  27992. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27993. /**
  27994. * Unregisters a function that will be executed after the physics step
  27995. * @param func The function to execute after physics step
  27996. */
  27997. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27998. /**
  27999. * register a function that will be executed when this impostor collides against a different body
  28000. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28001. * @param func Callback that is executed on collision
  28002. */
  28003. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28004. /**
  28005. * Unregisters the physics imposter on contact
  28006. * @param collideAgainst The physics object to collide against
  28007. * @param func Callback to execute on collision
  28008. */
  28009. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28010. private _tmpQuat;
  28011. private _tmpQuat2;
  28012. /**
  28013. * Get the parent rotation
  28014. * @returns The parent rotation
  28015. */
  28016. getParentsRotation(): Quaternion;
  28017. /**
  28018. * this function is executed by the physics engine.
  28019. */
  28020. beforeStep: () => void;
  28021. /**
  28022. * this function is executed by the physics engine
  28023. */
  28024. afterStep: () => void;
  28025. /**
  28026. * Legacy collision detection event support
  28027. */
  28028. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28029. /**
  28030. * event and body object due to cannon's event-based architecture.
  28031. */
  28032. onCollide: (e: {
  28033. body: any;
  28034. }) => void;
  28035. /**
  28036. * Apply a force
  28037. * @param force The force to apply
  28038. * @param contactPoint The contact point for the force
  28039. * @returns The physics imposter
  28040. */
  28041. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28042. /**
  28043. * Apply an impulse
  28044. * @param force The impulse force
  28045. * @param contactPoint The contact point for the impulse force
  28046. * @returns The physics imposter
  28047. */
  28048. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28049. /**
  28050. * A help function to create a joint
  28051. * @param otherImpostor A physics imposter used to create a joint
  28052. * @param jointType The type of joint
  28053. * @param jointData The data for the joint
  28054. * @returns The physics imposter
  28055. */
  28056. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28057. /**
  28058. * Add a joint to this impostor with a different impostor
  28059. * @param otherImpostor A physics imposter used to add a joint
  28060. * @param joint The joint to add
  28061. * @returns The physics imposter
  28062. */
  28063. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28064. /**
  28065. * Add an anchor to a cloth impostor
  28066. * @param otherImpostor rigid impostor to anchor to
  28067. * @param width ratio across width from 0 to 1
  28068. * @param height ratio up height from 0 to 1
  28069. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28070. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28071. * @returns impostor the soft imposter
  28072. */
  28073. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28074. /**
  28075. * Add a hook to a rope impostor
  28076. * @param otherImpostor rigid impostor to anchor to
  28077. * @param length ratio across rope from 0 to 1
  28078. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28079. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28080. * @returns impostor the rope imposter
  28081. */
  28082. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28083. /**
  28084. * Will keep this body still, in a sleep mode.
  28085. * @returns the physics imposter
  28086. */
  28087. sleep(): PhysicsImpostor;
  28088. /**
  28089. * Wake the body up.
  28090. * @returns The physics imposter
  28091. */
  28092. wakeUp(): PhysicsImpostor;
  28093. /**
  28094. * Clones the physics imposter
  28095. * @param newObject The physics imposter clones to this physics-enabled object
  28096. * @returns A nullable physics imposter
  28097. */
  28098. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28099. /**
  28100. * Disposes the physics imposter
  28101. */
  28102. dispose(): void;
  28103. /**
  28104. * Sets the delta position
  28105. * @param position The delta position amount
  28106. */
  28107. setDeltaPosition(position: Vector3): void;
  28108. /**
  28109. * Sets the delta rotation
  28110. * @param rotation The delta rotation amount
  28111. */
  28112. setDeltaRotation(rotation: Quaternion): void;
  28113. /**
  28114. * Gets the box size of the physics imposter and stores the result in the input parameter
  28115. * @param result Stores the box size
  28116. * @returns The physics imposter
  28117. */
  28118. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28119. /**
  28120. * Gets the radius of the physics imposter
  28121. * @returns Radius of the physics imposter
  28122. */
  28123. getRadius(): number;
  28124. /**
  28125. * Sync a bone with this impostor
  28126. * @param bone The bone to sync to the impostor.
  28127. * @param boneMesh The mesh that the bone is influencing.
  28128. * @param jointPivot The pivot of the joint / bone in local space.
  28129. * @param distToJoint Optional distance from the impostor to the joint.
  28130. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28131. */
  28132. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28133. /**
  28134. * Sync impostor to a bone
  28135. * @param bone The bone that the impostor will be synced to.
  28136. * @param boneMesh The mesh that the bone is influencing.
  28137. * @param jointPivot The pivot of the joint / bone in local space.
  28138. * @param distToJoint Optional distance from the impostor to the joint.
  28139. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28140. * @param boneAxis Optional vector3 axis the bone is aligned with
  28141. */
  28142. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28143. /**
  28144. * No-Imposter type
  28145. */
  28146. static NoImpostor: number;
  28147. /**
  28148. * Sphere-Imposter type
  28149. */
  28150. static SphereImpostor: number;
  28151. /**
  28152. * Box-Imposter type
  28153. */
  28154. static BoxImpostor: number;
  28155. /**
  28156. * Plane-Imposter type
  28157. */
  28158. static PlaneImpostor: number;
  28159. /**
  28160. * Mesh-imposter type
  28161. */
  28162. static MeshImpostor: number;
  28163. /**
  28164. * Capsule-Impostor type (Ammo.js plugin only)
  28165. */
  28166. static CapsuleImpostor: number;
  28167. /**
  28168. * Cylinder-Imposter type
  28169. */
  28170. static CylinderImpostor: number;
  28171. /**
  28172. * Particle-Imposter type
  28173. */
  28174. static ParticleImpostor: number;
  28175. /**
  28176. * Heightmap-Imposter type
  28177. */
  28178. static HeightmapImpostor: number;
  28179. /**
  28180. * ConvexHull-Impostor type (Ammo.js plugin only)
  28181. */
  28182. static ConvexHullImpostor: number;
  28183. /**
  28184. * Custom-Imposter type (Ammo.js plugin only)
  28185. */
  28186. static CustomImpostor: number;
  28187. /**
  28188. * Rope-Imposter type
  28189. */
  28190. static RopeImpostor: number;
  28191. /**
  28192. * Cloth-Imposter type
  28193. */
  28194. static ClothImpostor: number;
  28195. /**
  28196. * Softbody-Imposter type
  28197. */
  28198. static SoftbodyImpostor: number;
  28199. }
  28200. }
  28201. declare module BABYLON {
  28202. /**
  28203. * @hidden
  28204. **/
  28205. export class _CreationDataStorage {
  28206. closePath?: boolean;
  28207. closeArray?: boolean;
  28208. idx: number[];
  28209. dashSize: number;
  28210. gapSize: number;
  28211. path3D: Path3D;
  28212. pathArray: Vector3[][];
  28213. arc: number;
  28214. radius: number;
  28215. cap: number;
  28216. tessellation: number;
  28217. }
  28218. /**
  28219. * @hidden
  28220. **/
  28221. class _InstanceDataStorage {
  28222. visibleInstances: any;
  28223. batchCache: _InstancesBatch;
  28224. instancesBufferSize: number;
  28225. instancesBuffer: Nullable<Buffer>;
  28226. instancesData: Float32Array;
  28227. overridenInstanceCount: number;
  28228. isFrozen: boolean;
  28229. previousBatch: Nullable<_InstancesBatch>;
  28230. hardwareInstancedRendering: boolean;
  28231. sideOrientation: number;
  28232. manualUpdate: boolean;
  28233. previousRenderId: number;
  28234. }
  28235. /**
  28236. * @hidden
  28237. **/
  28238. export class _InstancesBatch {
  28239. mustReturn: boolean;
  28240. visibleInstances: Nullable<InstancedMesh[]>[];
  28241. renderSelf: boolean[];
  28242. hardwareInstancedRendering: boolean[];
  28243. }
  28244. /**
  28245. * @hidden
  28246. **/
  28247. class _ThinInstanceDataStorage {
  28248. instancesCount: number;
  28249. matrixBuffer: Nullable<Buffer>;
  28250. matrixBufferSize: number;
  28251. matrixData: Nullable<Float32Array>;
  28252. boundingVectors: Array<Vector3>;
  28253. worldMatrices: Nullable<Matrix[]>;
  28254. }
  28255. /**
  28256. * Class used to represent renderable models
  28257. */
  28258. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28259. /**
  28260. * Mesh side orientation : usually the external or front surface
  28261. */
  28262. static readonly FRONTSIDE: number;
  28263. /**
  28264. * Mesh side orientation : usually the internal or back surface
  28265. */
  28266. static readonly BACKSIDE: number;
  28267. /**
  28268. * Mesh side orientation : both internal and external or front and back surfaces
  28269. */
  28270. static readonly DOUBLESIDE: number;
  28271. /**
  28272. * Mesh side orientation : by default, `FRONTSIDE`
  28273. */
  28274. static readonly DEFAULTSIDE: number;
  28275. /**
  28276. * Mesh cap setting : no cap
  28277. */
  28278. static readonly NO_CAP: number;
  28279. /**
  28280. * Mesh cap setting : one cap at the beginning of the mesh
  28281. */
  28282. static readonly CAP_START: number;
  28283. /**
  28284. * Mesh cap setting : one cap at the end of the mesh
  28285. */
  28286. static readonly CAP_END: number;
  28287. /**
  28288. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28289. */
  28290. static readonly CAP_ALL: number;
  28291. /**
  28292. * Mesh pattern setting : no flip or rotate
  28293. */
  28294. static readonly NO_FLIP: number;
  28295. /**
  28296. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28297. */
  28298. static readonly FLIP_TILE: number;
  28299. /**
  28300. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28301. */
  28302. static readonly ROTATE_TILE: number;
  28303. /**
  28304. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28305. */
  28306. static readonly FLIP_ROW: number;
  28307. /**
  28308. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28309. */
  28310. static readonly ROTATE_ROW: number;
  28311. /**
  28312. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28313. */
  28314. static readonly FLIP_N_ROTATE_TILE: number;
  28315. /**
  28316. * Mesh pattern setting : rotate pattern and rotate
  28317. */
  28318. static readonly FLIP_N_ROTATE_ROW: number;
  28319. /**
  28320. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28321. */
  28322. static readonly CENTER: number;
  28323. /**
  28324. * Mesh tile positioning : part tiles on left
  28325. */
  28326. static readonly LEFT: number;
  28327. /**
  28328. * Mesh tile positioning : part tiles on right
  28329. */
  28330. static readonly RIGHT: number;
  28331. /**
  28332. * Mesh tile positioning : part tiles on top
  28333. */
  28334. static readonly TOP: number;
  28335. /**
  28336. * Mesh tile positioning : part tiles on bottom
  28337. */
  28338. static readonly BOTTOM: number;
  28339. /**
  28340. * Gets the default side orientation.
  28341. * @param orientation the orientation to value to attempt to get
  28342. * @returns the default orientation
  28343. * @hidden
  28344. */
  28345. static _GetDefaultSideOrientation(orientation?: number): number;
  28346. private _internalMeshDataInfo;
  28347. get computeBonesUsingShaders(): boolean;
  28348. set computeBonesUsingShaders(value: boolean);
  28349. /**
  28350. * An event triggered before rendering the mesh
  28351. */
  28352. get onBeforeRenderObservable(): Observable<Mesh>;
  28353. /**
  28354. * An event triggered before binding the mesh
  28355. */
  28356. get onBeforeBindObservable(): Observable<Mesh>;
  28357. /**
  28358. * An event triggered after rendering the mesh
  28359. */
  28360. get onAfterRenderObservable(): Observable<Mesh>;
  28361. /**
  28362. * An event triggered before drawing the mesh
  28363. */
  28364. get onBeforeDrawObservable(): Observable<Mesh>;
  28365. private _onBeforeDrawObserver;
  28366. /**
  28367. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28368. */
  28369. set onBeforeDraw(callback: () => void);
  28370. get hasInstances(): boolean;
  28371. get hasThinInstances(): boolean;
  28372. /**
  28373. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28374. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28375. */
  28376. delayLoadState: number;
  28377. /**
  28378. * Gets the list of instances created from this mesh
  28379. * it is not supposed to be modified manually.
  28380. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28381. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28382. */
  28383. instances: InstancedMesh[];
  28384. /**
  28385. * Gets the file containing delay loading data for this mesh
  28386. */
  28387. delayLoadingFile: string;
  28388. /** @hidden */
  28389. _binaryInfo: any;
  28390. /**
  28391. * User defined function used to change how LOD level selection is done
  28392. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28393. */
  28394. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28395. /**
  28396. * Gets or sets the morph target manager
  28397. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28398. */
  28399. get morphTargetManager(): Nullable<MorphTargetManager>;
  28400. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28401. /** @hidden */
  28402. _creationDataStorage: Nullable<_CreationDataStorage>;
  28403. /** @hidden */
  28404. _geometry: Nullable<Geometry>;
  28405. /** @hidden */
  28406. _delayInfo: Array<string>;
  28407. /** @hidden */
  28408. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28409. /** @hidden */
  28410. _instanceDataStorage: _InstanceDataStorage;
  28411. /** @hidden */
  28412. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28413. private _effectiveMaterial;
  28414. /** @hidden */
  28415. _shouldGenerateFlatShading: boolean;
  28416. /** @hidden */
  28417. _originalBuilderSideOrientation: number;
  28418. /**
  28419. * Use this property to change the original side orientation defined at construction time
  28420. */
  28421. overrideMaterialSideOrientation: Nullable<number>;
  28422. /**
  28423. * Gets the source mesh (the one used to clone this one from)
  28424. */
  28425. get source(): Nullable<Mesh>;
  28426. /**
  28427. * Gets the list of clones of this mesh
  28428. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  28429. * Note that useClonedMeshMap=true is the default setting
  28430. */
  28431. get cloneMeshMap(): Nullable<{
  28432. [id: string]: Mesh | undefined;
  28433. }>;
  28434. /**
  28435. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28436. */
  28437. get isUnIndexed(): boolean;
  28438. set isUnIndexed(value: boolean);
  28439. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28440. get worldMatrixInstancedBuffer(): Float32Array;
  28441. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28442. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28443. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28444. /**
  28445. * @constructor
  28446. * @param name The value used by scene.getMeshByName() to do a lookup.
  28447. * @param scene The scene to add this mesh to.
  28448. * @param parent The parent of this mesh, if it has one
  28449. * @param source An optional Mesh from which geometry is shared, cloned.
  28450. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28451. * When false, achieved by calling a clone(), also passing False.
  28452. * This will make creation of children, recursive.
  28453. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28454. */
  28455. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28456. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28457. doNotInstantiate: boolean;
  28458. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28459. /**
  28460. * Gets the class name
  28461. * @returns the string "Mesh".
  28462. */
  28463. getClassName(): string;
  28464. /** @hidden */
  28465. get _isMesh(): boolean;
  28466. /**
  28467. * Returns a description of this mesh
  28468. * @param fullDetails define if full details about this mesh must be used
  28469. * @returns a descriptive string representing this mesh
  28470. */
  28471. toString(fullDetails?: boolean): string;
  28472. /** @hidden */
  28473. _unBindEffect(): void;
  28474. /**
  28475. * Gets a boolean indicating if this mesh has LOD
  28476. */
  28477. get hasLODLevels(): boolean;
  28478. /**
  28479. * Gets the list of MeshLODLevel associated with the current mesh
  28480. * @returns an array of MeshLODLevel
  28481. */
  28482. getLODLevels(): MeshLODLevel[];
  28483. private _sortLODLevels;
  28484. /**
  28485. * Add a mesh as LOD level triggered at the given distance.
  28486. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28487. * @param distance The distance from the center of the object to show this level
  28488. * @param mesh The mesh to be added as LOD level (can be null)
  28489. * @return This mesh (for chaining)
  28490. */
  28491. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28492. /**
  28493. * Returns the LOD level mesh at the passed distance or null if not found.
  28494. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28495. * @param distance The distance from the center of the object to show this level
  28496. * @returns a Mesh or `null`
  28497. */
  28498. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28499. /**
  28500. * Remove a mesh from the LOD array
  28501. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28502. * @param mesh defines the mesh to be removed
  28503. * @return This mesh (for chaining)
  28504. */
  28505. removeLODLevel(mesh: Mesh): Mesh;
  28506. /**
  28507. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28508. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28509. * @param camera defines the camera to use to compute distance
  28510. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28511. * @return This mesh (for chaining)
  28512. */
  28513. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28514. /**
  28515. * Gets the mesh internal Geometry object
  28516. */
  28517. get geometry(): Nullable<Geometry>;
  28518. /**
  28519. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28520. * @returns the total number of vertices
  28521. */
  28522. getTotalVertices(): number;
  28523. /**
  28524. * Returns the content of an associated vertex buffer
  28525. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28526. * - VertexBuffer.PositionKind
  28527. * - VertexBuffer.UVKind
  28528. * - VertexBuffer.UV2Kind
  28529. * - VertexBuffer.UV3Kind
  28530. * - VertexBuffer.UV4Kind
  28531. * - VertexBuffer.UV5Kind
  28532. * - VertexBuffer.UV6Kind
  28533. * - VertexBuffer.ColorKind
  28534. * - VertexBuffer.MatricesIndicesKind
  28535. * - VertexBuffer.MatricesIndicesExtraKind
  28536. * - VertexBuffer.MatricesWeightsKind
  28537. * - VertexBuffer.MatricesWeightsExtraKind
  28538. * @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
  28539. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28540. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28541. */
  28542. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28543. /**
  28544. * Returns the mesh VertexBuffer object from the requested `kind`
  28545. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28546. * - VertexBuffer.PositionKind
  28547. * - VertexBuffer.NormalKind
  28548. * - VertexBuffer.UVKind
  28549. * - VertexBuffer.UV2Kind
  28550. * - VertexBuffer.UV3Kind
  28551. * - VertexBuffer.UV4Kind
  28552. * - VertexBuffer.UV5Kind
  28553. * - VertexBuffer.UV6Kind
  28554. * - VertexBuffer.ColorKind
  28555. * - VertexBuffer.MatricesIndicesKind
  28556. * - VertexBuffer.MatricesIndicesExtraKind
  28557. * - VertexBuffer.MatricesWeightsKind
  28558. * - VertexBuffer.MatricesWeightsExtraKind
  28559. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28560. */
  28561. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28562. /**
  28563. * Tests if a specific vertex buffer is associated with this mesh
  28564. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28565. * - VertexBuffer.PositionKind
  28566. * - VertexBuffer.NormalKind
  28567. * - VertexBuffer.UVKind
  28568. * - VertexBuffer.UV2Kind
  28569. * - VertexBuffer.UV3Kind
  28570. * - VertexBuffer.UV4Kind
  28571. * - VertexBuffer.UV5Kind
  28572. * - VertexBuffer.UV6Kind
  28573. * - VertexBuffer.ColorKind
  28574. * - VertexBuffer.MatricesIndicesKind
  28575. * - VertexBuffer.MatricesIndicesExtraKind
  28576. * - VertexBuffer.MatricesWeightsKind
  28577. * - VertexBuffer.MatricesWeightsExtraKind
  28578. * @returns a boolean
  28579. */
  28580. isVerticesDataPresent(kind: string): boolean;
  28581. /**
  28582. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28583. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28584. * - VertexBuffer.PositionKind
  28585. * - VertexBuffer.UVKind
  28586. * - VertexBuffer.UV2Kind
  28587. * - VertexBuffer.UV3Kind
  28588. * - VertexBuffer.UV4Kind
  28589. * - VertexBuffer.UV5Kind
  28590. * - VertexBuffer.UV6Kind
  28591. * - VertexBuffer.ColorKind
  28592. * - VertexBuffer.MatricesIndicesKind
  28593. * - VertexBuffer.MatricesIndicesExtraKind
  28594. * - VertexBuffer.MatricesWeightsKind
  28595. * - VertexBuffer.MatricesWeightsExtraKind
  28596. * @returns a boolean
  28597. */
  28598. isVertexBufferUpdatable(kind: string): boolean;
  28599. /**
  28600. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28601. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28602. * - VertexBuffer.PositionKind
  28603. * - VertexBuffer.NormalKind
  28604. * - VertexBuffer.UVKind
  28605. * - VertexBuffer.UV2Kind
  28606. * - VertexBuffer.UV3Kind
  28607. * - VertexBuffer.UV4Kind
  28608. * - VertexBuffer.UV5Kind
  28609. * - VertexBuffer.UV6Kind
  28610. * - VertexBuffer.ColorKind
  28611. * - VertexBuffer.MatricesIndicesKind
  28612. * - VertexBuffer.MatricesIndicesExtraKind
  28613. * - VertexBuffer.MatricesWeightsKind
  28614. * - VertexBuffer.MatricesWeightsExtraKind
  28615. * @returns an array of strings
  28616. */
  28617. getVerticesDataKinds(): string[];
  28618. /**
  28619. * Returns a positive integer : the total number of indices in this mesh geometry.
  28620. * @returns the numner of indices or zero if the mesh has no geometry.
  28621. */
  28622. getTotalIndices(): number;
  28623. /**
  28624. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28625. * @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.
  28626. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28627. * @returns the indices array or an empty array if the mesh has no geometry
  28628. */
  28629. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28630. get isBlocked(): boolean;
  28631. /**
  28632. * Determine if the current mesh is ready to be rendered
  28633. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28634. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28635. * @returns true if all associated assets are ready (material, textures, shaders)
  28636. */
  28637. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28638. /**
  28639. * 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.
  28640. */
  28641. get areNormalsFrozen(): boolean;
  28642. /**
  28643. * 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.
  28644. * @returns the current mesh
  28645. */
  28646. freezeNormals(): Mesh;
  28647. /**
  28648. * 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
  28649. * @returns the current mesh
  28650. */
  28651. unfreezeNormals(): Mesh;
  28652. /**
  28653. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28654. */
  28655. set overridenInstanceCount(count: number);
  28656. /** @hidden */
  28657. _preActivate(): Mesh;
  28658. /** @hidden */
  28659. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28660. /** @hidden */
  28661. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28662. protected _afterComputeWorldMatrix(): void;
  28663. /** @hidden */
  28664. _postActivate(): void;
  28665. /**
  28666. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28667. * This means the mesh underlying bounding box and sphere are recomputed.
  28668. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28669. * @returns the current mesh
  28670. */
  28671. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28672. /** @hidden */
  28673. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28674. /**
  28675. * This function will subdivide the mesh into multiple submeshes
  28676. * @param count defines the expected number of submeshes
  28677. */
  28678. subdivide(count: number): void;
  28679. /**
  28680. * Copy a FloatArray into a specific associated vertex buffer
  28681. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28682. * - VertexBuffer.PositionKind
  28683. * - VertexBuffer.UVKind
  28684. * - VertexBuffer.UV2Kind
  28685. * - VertexBuffer.UV3Kind
  28686. * - VertexBuffer.UV4Kind
  28687. * - VertexBuffer.UV5Kind
  28688. * - VertexBuffer.UV6Kind
  28689. * - VertexBuffer.ColorKind
  28690. * - VertexBuffer.MatricesIndicesKind
  28691. * - VertexBuffer.MatricesIndicesExtraKind
  28692. * - VertexBuffer.MatricesWeightsKind
  28693. * - VertexBuffer.MatricesWeightsExtraKind
  28694. * @param data defines the data source
  28695. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28696. * @param stride defines the data stride size (can be null)
  28697. * @returns the current mesh
  28698. */
  28699. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28700. /**
  28701. * Delete a vertex buffer associated with this mesh
  28702. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28703. * - VertexBuffer.PositionKind
  28704. * - VertexBuffer.UVKind
  28705. * - VertexBuffer.UV2Kind
  28706. * - VertexBuffer.UV3Kind
  28707. * - VertexBuffer.UV4Kind
  28708. * - VertexBuffer.UV5Kind
  28709. * - VertexBuffer.UV6Kind
  28710. * - VertexBuffer.ColorKind
  28711. * - VertexBuffer.MatricesIndicesKind
  28712. * - VertexBuffer.MatricesIndicesExtraKind
  28713. * - VertexBuffer.MatricesWeightsKind
  28714. * - VertexBuffer.MatricesWeightsExtraKind
  28715. */
  28716. removeVerticesData(kind: string): void;
  28717. /**
  28718. * Flags an associated vertex buffer as updatable
  28719. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28720. * - VertexBuffer.PositionKind
  28721. * - VertexBuffer.UVKind
  28722. * - VertexBuffer.UV2Kind
  28723. * - VertexBuffer.UV3Kind
  28724. * - VertexBuffer.UV4Kind
  28725. * - VertexBuffer.UV5Kind
  28726. * - VertexBuffer.UV6Kind
  28727. * - VertexBuffer.ColorKind
  28728. * - VertexBuffer.MatricesIndicesKind
  28729. * - VertexBuffer.MatricesIndicesExtraKind
  28730. * - VertexBuffer.MatricesWeightsKind
  28731. * - VertexBuffer.MatricesWeightsExtraKind
  28732. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28733. */
  28734. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28735. /**
  28736. * Sets the mesh global Vertex Buffer
  28737. * @param buffer defines the buffer to use
  28738. * @returns the current mesh
  28739. */
  28740. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28741. /**
  28742. * Update a specific associated vertex buffer
  28743. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28744. * - VertexBuffer.PositionKind
  28745. * - VertexBuffer.UVKind
  28746. * - VertexBuffer.UV2Kind
  28747. * - VertexBuffer.UV3Kind
  28748. * - VertexBuffer.UV4Kind
  28749. * - VertexBuffer.UV5Kind
  28750. * - VertexBuffer.UV6Kind
  28751. * - VertexBuffer.ColorKind
  28752. * - VertexBuffer.MatricesIndicesKind
  28753. * - VertexBuffer.MatricesIndicesExtraKind
  28754. * - VertexBuffer.MatricesWeightsKind
  28755. * - VertexBuffer.MatricesWeightsExtraKind
  28756. * @param data defines the data source
  28757. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28758. * @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)
  28759. * @returns the current mesh
  28760. */
  28761. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28762. /**
  28763. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28764. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28765. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28766. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28767. * @returns the current mesh
  28768. */
  28769. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28770. /**
  28771. * Creates a un-shared specific occurence of the geometry for the mesh.
  28772. * @returns the current mesh
  28773. */
  28774. makeGeometryUnique(): Mesh;
  28775. /**
  28776. * Set the index buffer of this mesh
  28777. * @param indices defines the source data
  28778. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28779. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28780. * @returns the current mesh
  28781. */
  28782. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28783. /**
  28784. * Update the current index buffer
  28785. * @param indices defines the source data
  28786. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28787. * @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)
  28788. * @returns the current mesh
  28789. */
  28790. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28791. /**
  28792. * Invert the geometry to move from a right handed system to a left handed one.
  28793. * @returns the current mesh
  28794. */
  28795. toLeftHanded(): Mesh;
  28796. /** @hidden */
  28797. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28798. /** @hidden */
  28799. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28800. /**
  28801. * Registers for this mesh a javascript function called just before the rendering process
  28802. * @param func defines the function to call before rendering this mesh
  28803. * @returns the current mesh
  28804. */
  28805. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28806. /**
  28807. * Disposes a previously registered javascript function called before the rendering
  28808. * @param func defines the function to remove
  28809. * @returns the current mesh
  28810. */
  28811. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28812. /**
  28813. * Registers for this mesh a javascript function called just after the rendering is complete
  28814. * @param func defines the function to call after rendering this mesh
  28815. * @returns the current mesh
  28816. */
  28817. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28818. /**
  28819. * Disposes a previously registered javascript function called after the rendering.
  28820. * @param func defines the function to remove
  28821. * @returns the current mesh
  28822. */
  28823. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28824. /** @hidden */
  28825. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28826. /** @hidden */
  28827. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28828. /** @hidden */
  28829. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28830. /** @hidden */
  28831. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28832. /** @hidden */
  28833. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28834. /** @hidden */
  28835. _rebuild(): void;
  28836. /** @hidden */
  28837. _freeze(): void;
  28838. /** @hidden */
  28839. _unFreeze(): void;
  28840. /**
  28841. * 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
  28842. * @param subMesh defines the subMesh to render
  28843. * @param enableAlphaMode defines if alpha mode can be changed
  28844. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28845. * @returns the current mesh
  28846. */
  28847. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28848. private _onBeforeDraw;
  28849. /**
  28850. * Renormalize the mesh and patch it up if there are no weights
  28851. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28852. * However in the case of zero weights then we set just a single influence to 1.
  28853. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28854. */
  28855. cleanMatrixWeights(): void;
  28856. private normalizeSkinFourWeights;
  28857. private normalizeSkinWeightsAndExtra;
  28858. /**
  28859. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28860. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28861. * the user know there was an issue with importing the mesh
  28862. * @returns a validation object with skinned, valid and report string
  28863. */
  28864. validateSkinning(): {
  28865. skinned: boolean;
  28866. valid: boolean;
  28867. report: string;
  28868. };
  28869. /** @hidden */
  28870. _checkDelayState(): Mesh;
  28871. private _queueLoad;
  28872. /**
  28873. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28874. * A mesh is in the frustum if its bounding box intersects the frustum
  28875. * @param frustumPlanes defines the frustum to test
  28876. * @returns true if the mesh is in the frustum planes
  28877. */
  28878. isInFrustum(frustumPlanes: Plane[]): boolean;
  28879. /**
  28880. * Sets the mesh material by the material or multiMaterial `id` property
  28881. * @param id is a string identifying the material or the multiMaterial
  28882. * @returns the current mesh
  28883. */
  28884. setMaterialByID(id: string): Mesh;
  28885. /**
  28886. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28887. * @returns an array of IAnimatable
  28888. */
  28889. getAnimatables(): IAnimatable[];
  28890. /**
  28891. * Modifies the mesh geometry according to the passed transformation matrix.
  28892. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28893. * The mesh normals are modified using the same transformation.
  28894. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28895. * @param transform defines the transform matrix to use
  28896. * @see https://doc.babylonjs.com/resources/baking_transformations
  28897. * @returns the current mesh
  28898. */
  28899. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28900. /**
  28901. * Modifies the mesh geometry according to its own current World Matrix.
  28902. * The mesh World Matrix is then reset.
  28903. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28904. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28905. * @see https://doc.babylonjs.com/resources/baking_transformations
  28906. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28907. * @returns the current mesh
  28908. */
  28909. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28910. /** @hidden */
  28911. get _positions(): Nullable<Vector3[]>;
  28912. /** @hidden */
  28913. _resetPointsArrayCache(): Mesh;
  28914. /** @hidden */
  28915. _generatePointsArray(): boolean;
  28916. /**
  28917. * Returns a new Mesh object generated from the current mesh properties.
  28918. * This method must not get confused with createInstance()
  28919. * @param name is a string, the name given to the new mesh
  28920. * @param newParent can be any Node object (default `null`)
  28921. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28922. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28923. * @returns a new mesh
  28924. */
  28925. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28926. /**
  28927. * Releases resources associated with this mesh.
  28928. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28929. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28930. */
  28931. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28932. /** @hidden */
  28933. _disposeInstanceSpecificData(): void;
  28934. /** @hidden */
  28935. _disposeThinInstanceSpecificData(): void;
  28936. /**
  28937. * Modifies the mesh geometry according to a displacement map.
  28938. * 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.
  28939. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28940. * @param url is a string, the URL from the image file is to be downloaded.
  28941. * @param minHeight is the lower limit of the displacement.
  28942. * @param maxHeight is the upper limit of the displacement.
  28943. * @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.
  28944. * @param uvOffset is an optional vector2 used to offset UV.
  28945. * @param uvScale is an optional vector2 used to scale UV.
  28946. * @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.
  28947. * @returns the Mesh.
  28948. */
  28949. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28950. /**
  28951. * Modifies the mesh geometry according to a displacementMap buffer.
  28952. * 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.
  28953. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28954. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28955. * @param heightMapWidth is the width of the buffer image.
  28956. * @param heightMapHeight is the height of the buffer image.
  28957. * @param minHeight is the lower limit of the displacement.
  28958. * @param maxHeight is the upper limit of the displacement.
  28959. * @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.
  28960. * @param uvOffset is an optional vector2 used to offset UV.
  28961. * @param uvScale is an optional vector2 used to scale UV.
  28962. * @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.
  28963. * @returns the Mesh.
  28964. */
  28965. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28966. /**
  28967. * Modify the mesh to get a flat shading rendering.
  28968. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28969. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28970. * @returns current mesh
  28971. */
  28972. convertToFlatShadedMesh(): Mesh;
  28973. /**
  28974. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28975. * In other words, more vertices, no more indices and a single bigger VBO.
  28976. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28977. * @returns current mesh
  28978. */
  28979. convertToUnIndexedMesh(): Mesh;
  28980. /**
  28981. * Inverses facet orientations.
  28982. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28983. * @param flipNormals will also inverts the normals
  28984. * @returns current mesh
  28985. */
  28986. flipFaces(flipNormals?: boolean): Mesh;
  28987. /**
  28988. * Increase the number of facets and hence vertices in a mesh
  28989. * Vertex normals are interpolated from existing vertex normals
  28990. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28991. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28992. */
  28993. increaseVertices(numberPerEdge: number): void;
  28994. /**
  28995. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28996. * This will undo any application of covertToFlatShadedMesh
  28997. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28998. */
  28999. forceSharedVertices(): void;
  29000. /** @hidden */
  29001. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29002. /** @hidden */
  29003. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29004. /**
  29005. * Creates a new InstancedMesh object from the mesh model.
  29006. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29007. * @param name defines the name of the new instance
  29008. * @returns a new InstancedMesh
  29009. */
  29010. createInstance(name: string): InstancedMesh;
  29011. /**
  29012. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29013. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29014. * @returns the current mesh
  29015. */
  29016. synchronizeInstances(): Mesh;
  29017. /**
  29018. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29019. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29020. * This should be used together with the simplification to avoid disappearing triangles.
  29021. * @param successCallback an optional success callback to be called after the optimization finished.
  29022. * @returns the current mesh
  29023. */
  29024. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29025. /**
  29026. * Serialize current mesh
  29027. * @param serializationObject defines the object which will receive the serialization data
  29028. */
  29029. serialize(serializationObject: any): void;
  29030. /** @hidden */
  29031. _syncGeometryWithMorphTargetManager(): void;
  29032. /** @hidden */
  29033. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29034. /**
  29035. * Returns a new Mesh object parsed from the source provided.
  29036. * @param parsedMesh is the source
  29037. * @param scene defines the hosting scene
  29038. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29039. * @returns a new Mesh
  29040. */
  29041. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29042. /**
  29043. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29044. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29045. * @param name defines the name of the mesh to create
  29046. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29047. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29048. * @param closePath creates a seam between the first and the last points of each path of the path array
  29049. * @param offset is taken in account only if the `pathArray` is containing a single path
  29050. * @param scene defines the hosting scene
  29051. * @param updatable defines if the mesh must be flagged as updatable
  29052. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29053. * @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)
  29054. * @returns a new Mesh
  29055. */
  29056. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29057. /**
  29058. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29059. * @param name defines the name of the mesh to create
  29060. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29061. * @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
  29062. * @param scene defines the hosting scene
  29063. * @param updatable defines if the mesh must be flagged as updatable
  29064. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29065. * @returns a new Mesh
  29066. */
  29067. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29068. /**
  29069. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29070. * @param name defines the name of the mesh to create
  29071. * @param size sets the size (float) of each box side (default 1)
  29072. * @param scene defines the hosting scene
  29073. * @param updatable defines if the mesh must be flagged as updatable
  29074. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29075. * @returns a new Mesh
  29076. */
  29077. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29078. /**
  29079. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29080. * @param name defines the name of the mesh to create
  29081. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29082. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29083. * @param scene defines the hosting scene
  29084. * @param updatable defines if the mesh must be flagged as updatable
  29085. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29086. * @returns a new Mesh
  29087. */
  29088. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29089. /**
  29090. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29091. * @param name defines the name of the mesh to create
  29092. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29093. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29094. * @param scene defines the hosting scene
  29095. * @returns a new Mesh
  29096. */
  29097. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29098. /**
  29099. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29100. * @param name defines the name of the mesh to create
  29101. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29102. * @param diameterTop set the top cap diameter (floats, default 1)
  29103. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29104. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29105. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29106. * @param scene defines the hosting scene
  29107. * @param updatable defines if the mesh must be flagged as updatable
  29108. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29109. * @returns a new Mesh
  29110. */
  29111. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29112. /**
  29113. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29114. * @param name defines the name of the mesh to create
  29115. * @param diameter sets the diameter size (float) of the torus (default 1)
  29116. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29117. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29118. * @param scene defines the hosting scene
  29119. * @param updatable defines if the mesh must be flagged as updatable
  29120. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29121. * @returns a new Mesh
  29122. */
  29123. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29124. /**
  29125. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29126. * @param name defines the name of the mesh to create
  29127. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29128. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29129. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29130. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29131. * @param p the number of windings on X axis (positive integers, default 2)
  29132. * @param q the number of windings on Y axis (positive integers, default 3)
  29133. * @param scene defines the hosting scene
  29134. * @param updatable defines if the mesh must be flagged as updatable
  29135. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29136. * @returns a new Mesh
  29137. */
  29138. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29139. /**
  29140. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29141. * @param name defines the name of the mesh to create
  29142. * @param points is an array successive Vector3
  29143. * @param scene defines the hosting scene
  29144. * @param updatable defines if the mesh must be flagged as updatable
  29145. * @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).
  29146. * @returns a new Mesh
  29147. */
  29148. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29149. /**
  29150. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29151. * @param name defines the name of the mesh to create
  29152. * @param points is an array successive Vector3
  29153. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29154. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29155. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29156. * @param scene defines the hosting scene
  29157. * @param updatable defines if the mesh must be flagged as updatable
  29158. * @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)
  29159. * @returns a new Mesh
  29160. */
  29161. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29162. /**
  29163. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29164. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29165. * 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.
  29166. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29167. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29168. * Remember you can only change the shape positions, not their number when updating a polygon.
  29169. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29170. * @param name defines the name of the mesh to create
  29171. * @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
  29172. * @param scene defines the hosting scene
  29173. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29174. * @param updatable defines if the mesh must be flagged as updatable
  29175. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29176. * @param earcutInjection can be used to inject your own earcut reference
  29177. * @returns a new Mesh
  29178. */
  29179. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29180. /**
  29181. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29182. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29183. * @param name defines the name of the mesh to create
  29184. * @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
  29185. * @param depth defines the height of extrusion
  29186. * @param scene defines the hosting scene
  29187. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29188. * @param updatable defines if the mesh must be flagged as updatable
  29189. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29190. * @param earcutInjection can be used to inject your own earcut reference
  29191. * @returns a new Mesh
  29192. */
  29193. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29194. /**
  29195. * Creates an extruded shape mesh.
  29196. * 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
  29197. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29198. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29199. * @param name defines the name of the mesh to create
  29200. * @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
  29201. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29202. * @param scale is the value to scale the shape
  29203. * @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
  29204. * @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
  29205. * @param scene defines the hosting scene
  29206. * @param updatable defines if the mesh must be flagged as updatable
  29207. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29208. * @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)
  29209. * @returns a new Mesh
  29210. */
  29211. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29212. /**
  29213. * Creates an custom extruded shape mesh.
  29214. * The custom extrusion is a parametric shape.
  29215. * It has no predefined shape. Its final shape will depend on the input parameters.
  29216. * Please consider using the same method from the MeshBuilder class instead
  29217. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29218. * @param name defines the name of the mesh to create
  29219. * @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
  29220. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29221. * @param scaleFunction is a custom Javascript function called on each path point
  29222. * @param rotationFunction is a custom Javascript function called on each path point
  29223. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29224. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29225. * @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
  29226. * @param scene defines the hosting scene
  29227. * @param updatable defines if the mesh must be flagged as updatable
  29228. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29229. * @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)
  29230. * @returns a new Mesh
  29231. */
  29232. 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;
  29233. /**
  29234. * Creates lathe mesh.
  29235. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29236. * Please consider using the same method from the MeshBuilder class instead
  29237. * @param name defines the name of the mesh to create
  29238. * @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
  29239. * @param radius is the radius value of the lathe
  29240. * @param tessellation is the side number of the lathe.
  29241. * @param scene defines the hosting scene
  29242. * @param updatable defines if the mesh must be flagged as updatable
  29243. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29244. * @returns a new Mesh
  29245. */
  29246. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29247. /**
  29248. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29249. * @param name defines the name of the mesh to create
  29250. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29251. * @param scene defines the hosting scene
  29252. * @param updatable defines if the mesh must be flagged as updatable
  29253. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29254. * @returns a new Mesh
  29255. */
  29256. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29257. /**
  29258. * Creates a ground mesh.
  29259. * Please consider using the same method from the MeshBuilder class instead
  29260. * @param name defines the name of the mesh to create
  29261. * @param width set the width of the ground
  29262. * @param height set the height of the ground
  29263. * @param subdivisions sets the number of subdivisions per side
  29264. * @param scene defines the hosting scene
  29265. * @param updatable defines if the mesh must be flagged as updatable
  29266. * @returns a new Mesh
  29267. */
  29268. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29269. /**
  29270. * Creates a tiled ground mesh.
  29271. * Please consider using the same method from the MeshBuilder class instead
  29272. * @param name defines the name of the mesh to create
  29273. * @param xmin set the ground minimum X coordinate
  29274. * @param zmin set the ground minimum Y coordinate
  29275. * @param xmax set the ground maximum X coordinate
  29276. * @param zmax set the ground maximum Z coordinate
  29277. * @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
  29278. * @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
  29279. * @param scene defines the hosting scene
  29280. * @param updatable defines if the mesh must be flagged as updatable
  29281. * @returns a new Mesh
  29282. */
  29283. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29284. w: number;
  29285. h: number;
  29286. }, precision: {
  29287. w: number;
  29288. h: number;
  29289. }, scene: Scene, updatable?: boolean): Mesh;
  29290. /**
  29291. * Creates a ground mesh from a height map.
  29292. * Please consider using the same method from the MeshBuilder class instead
  29293. * @see https://doc.babylonjs.com/babylon101/height_map
  29294. * @param name defines the name of the mesh to create
  29295. * @param url sets the URL of the height map image resource
  29296. * @param width set the ground width size
  29297. * @param height set the ground height size
  29298. * @param subdivisions sets the number of subdivision per side
  29299. * @param minHeight is the minimum altitude on the ground
  29300. * @param maxHeight is the maximum altitude on the ground
  29301. * @param scene defines the hosting scene
  29302. * @param updatable defines if the mesh must be flagged as updatable
  29303. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29304. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29305. * @returns a new Mesh
  29306. */
  29307. 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;
  29308. /**
  29309. * Creates a tube mesh.
  29310. * The tube is a parametric shape.
  29311. * It has no predefined shape. Its final shape will depend on the input parameters.
  29312. * Please consider using the same method from the MeshBuilder class instead
  29313. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29314. * @param name defines the name of the mesh to create
  29315. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29316. * @param radius sets the tube radius size
  29317. * @param tessellation is the number of sides on the tubular surface
  29318. * @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
  29319. * @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
  29320. * @param scene defines the hosting scene
  29321. * @param updatable defines if the mesh must be flagged as updatable
  29322. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29323. * @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)
  29324. * @returns a new Mesh
  29325. */
  29326. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29327. (i: number, distance: number): number;
  29328. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29329. /**
  29330. * Creates a polyhedron mesh.
  29331. * Please consider using the same method from the MeshBuilder class instead.
  29332. * * 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
  29333. * * The parameter `size` (positive float, default 1) sets the polygon size
  29334. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29335. * * 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`
  29336. * * 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
  29337. * * 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)`)
  29338. * * 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
  29339. * * 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
  29340. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29341. * * 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
  29342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29343. * @param name defines the name of the mesh to create
  29344. * @param options defines the options used to create the mesh
  29345. * @param scene defines the hosting scene
  29346. * @returns a new Mesh
  29347. */
  29348. static CreatePolyhedron(name: string, options: {
  29349. type?: number;
  29350. size?: number;
  29351. sizeX?: number;
  29352. sizeY?: number;
  29353. sizeZ?: number;
  29354. custom?: any;
  29355. faceUV?: Vector4[];
  29356. faceColors?: Color4[];
  29357. updatable?: boolean;
  29358. sideOrientation?: number;
  29359. }, scene: Scene): Mesh;
  29360. /**
  29361. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29362. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29363. * * 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`)
  29364. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29365. * * 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
  29366. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29367. * * 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
  29368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29369. * @param name defines the name of the mesh
  29370. * @param options defines the options used to create the mesh
  29371. * @param scene defines the hosting scene
  29372. * @returns a new Mesh
  29373. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29374. */
  29375. static CreateIcoSphere(name: string, options: {
  29376. radius?: number;
  29377. flat?: boolean;
  29378. subdivisions?: number;
  29379. sideOrientation?: number;
  29380. updatable?: boolean;
  29381. }, scene: Scene): Mesh;
  29382. /**
  29383. * Creates a decal mesh.
  29384. * Please consider using the same method from the MeshBuilder class instead.
  29385. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29386. * @param name defines the name of the mesh
  29387. * @param sourceMesh defines the mesh receiving the decal
  29388. * @param position sets the position of the decal in world coordinates
  29389. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29390. * @param size sets the decal scaling
  29391. * @param angle sets the angle to rotate the decal
  29392. * @returns a new Mesh
  29393. */
  29394. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29395. /** Creates a Capsule Mesh
  29396. * @param name defines the name of the mesh.
  29397. * @param options the constructors options used to shape the mesh.
  29398. * @param scene defines the scene the mesh is scoped to.
  29399. * @returns the capsule mesh
  29400. * @see https://doc.babylonjs.com/how_to/capsule_shape
  29401. */
  29402. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  29403. /**
  29404. * Prepare internal position array for software CPU skinning
  29405. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29406. */
  29407. setPositionsForCPUSkinning(): Float32Array;
  29408. /**
  29409. * Prepare internal normal array for software CPU skinning
  29410. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29411. */
  29412. setNormalsForCPUSkinning(): Float32Array;
  29413. /**
  29414. * Updates the vertex buffer by applying transformation from the bones
  29415. * @param skeleton defines the skeleton to apply to current mesh
  29416. * @returns the current mesh
  29417. */
  29418. applySkeleton(skeleton: Skeleton): Mesh;
  29419. /**
  29420. * 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
  29421. * @param meshes defines the list of meshes to scan
  29422. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29423. */
  29424. static MinMax(meshes: AbstractMesh[]): {
  29425. min: Vector3;
  29426. max: Vector3;
  29427. };
  29428. /**
  29429. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29430. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29431. * @returns a vector3
  29432. */
  29433. static Center(meshesOrMinMaxVector: {
  29434. min: Vector3;
  29435. max: Vector3;
  29436. } | AbstractMesh[]): Vector3;
  29437. /**
  29438. * Merge the array of meshes into a single mesh for performance reasons.
  29439. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29440. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29441. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29442. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29443. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29444. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29445. * @returns a new mesh
  29446. */
  29447. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29448. /** @hidden */
  29449. addInstance(instance: InstancedMesh): void;
  29450. /** @hidden */
  29451. removeInstance(instance: InstancedMesh): void;
  29452. }
  29453. }
  29454. declare module BABYLON {
  29455. /**
  29456. * This is the base class of all the camera used in the application.
  29457. * @see https://doc.babylonjs.com/features/cameras
  29458. */
  29459. export class Camera extends Node {
  29460. /** @hidden */
  29461. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29462. /**
  29463. * This is the default projection mode used by the cameras.
  29464. * It helps recreating a feeling of perspective and better appreciate depth.
  29465. * This is the best way to simulate real life cameras.
  29466. */
  29467. static readonly PERSPECTIVE_CAMERA: number;
  29468. /**
  29469. * This helps creating camera with an orthographic mode.
  29470. * 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.
  29471. */
  29472. static readonly ORTHOGRAPHIC_CAMERA: number;
  29473. /**
  29474. * This is the default FOV mode for perspective cameras.
  29475. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29476. */
  29477. static readonly FOVMODE_VERTICAL_FIXED: number;
  29478. /**
  29479. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29480. */
  29481. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29482. /**
  29483. * This specifies ther is no need for a camera rig.
  29484. * Basically only one eye is rendered corresponding to the camera.
  29485. */
  29486. static readonly RIG_MODE_NONE: number;
  29487. /**
  29488. * Simulates a camera Rig with one blue eye and one red eye.
  29489. * This can be use with 3d blue and red glasses.
  29490. */
  29491. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29492. /**
  29493. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29494. */
  29495. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29496. /**
  29497. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29498. */
  29499. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29500. /**
  29501. * Defines that both eyes of the camera will be rendered over under each other.
  29502. */
  29503. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29504. /**
  29505. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29506. */
  29507. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29508. /**
  29509. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29510. */
  29511. static readonly RIG_MODE_VR: number;
  29512. /**
  29513. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29514. */
  29515. static readonly RIG_MODE_WEBVR: number;
  29516. /**
  29517. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29518. */
  29519. static readonly RIG_MODE_CUSTOM: number;
  29520. /**
  29521. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29522. */
  29523. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29524. /**
  29525. * Define the input manager associated with the camera.
  29526. */
  29527. inputs: CameraInputsManager<Camera>;
  29528. /** @hidden */
  29529. _position: Vector3;
  29530. /**
  29531. * Define the current local position of the camera in the scene
  29532. */
  29533. get position(): Vector3;
  29534. set position(newPosition: Vector3);
  29535. protected _upVector: Vector3;
  29536. /**
  29537. * The vector the camera should consider as up.
  29538. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29539. */
  29540. set upVector(vec: Vector3);
  29541. get upVector(): Vector3;
  29542. /**
  29543. * Define the current limit on the left side for an orthographic camera
  29544. * In scene unit
  29545. */
  29546. orthoLeft: Nullable<number>;
  29547. /**
  29548. * Define the current limit on the right side for an orthographic camera
  29549. * In scene unit
  29550. */
  29551. orthoRight: Nullable<number>;
  29552. /**
  29553. * Define the current limit on the bottom side for an orthographic camera
  29554. * In scene unit
  29555. */
  29556. orthoBottom: Nullable<number>;
  29557. /**
  29558. * Define the current limit on the top side for an orthographic camera
  29559. * In scene unit
  29560. */
  29561. orthoTop: Nullable<number>;
  29562. /**
  29563. * Field Of View is set in Radians. (default is 0.8)
  29564. */
  29565. fov: number;
  29566. /**
  29567. * Define the minimum distance the camera can see from.
  29568. * This is important to note that the depth buffer are not infinite and the closer it starts
  29569. * the more your scene might encounter depth fighting issue.
  29570. */
  29571. minZ: number;
  29572. /**
  29573. * Define the maximum distance the camera can see to.
  29574. * This is important to note that the depth buffer are not infinite and the further it end
  29575. * the more your scene might encounter depth fighting issue.
  29576. */
  29577. maxZ: number;
  29578. /**
  29579. * Define the default inertia of the camera.
  29580. * This helps giving a smooth feeling to the camera movement.
  29581. */
  29582. inertia: number;
  29583. /**
  29584. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29585. */
  29586. mode: number;
  29587. /**
  29588. * Define whether the camera is intermediate.
  29589. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29590. */
  29591. isIntermediate: boolean;
  29592. /**
  29593. * Define the viewport of the camera.
  29594. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29595. */
  29596. viewport: Viewport;
  29597. /**
  29598. * Restricts the camera to viewing objects with the same layerMask.
  29599. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29600. */
  29601. layerMask: number;
  29602. /**
  29603. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29604. */
  29605. fovMode: number;
  29606. /**
  29607. * Rig mode of the camera.
  29608. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29609. * This is normally controlled byt the camera themselves as internal use.
  29610. */
  29611. cameraRigMode: number;
  29612. /**
  29613. * Defines the distance between both "eyes" in case of a RIG
  29614. */
  29615. interaxialDistance: number;
  29616. /**
  29617. * Defines if stereoscopic rendering is done side by side or over under.
  29618. */
  29619. isStereoscopicSideBySide: boolean;
  29620. /**
  29621. * 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
  29622. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29623. * else in the scene. (Eg. security camera)
  29624. *
  29625. * 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)
  29626. */
  29627. customRenderTargets: RenderTargetTexture[];
  29628. /**
  29629. * When set, the camera will render to this render target instead of the default canvas
  29630. *
  29631. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29632. */
  29633. outputRenderTarget: Nullable<RenderTargetTexture>;
  29634. /**
  29635. * Observable triggered when the camera view matrix has changed.
  29636. */
  29637. onViewMatrixChangedObservable: Observable<Camera>;
  29638. /**
  29639. * Observable triggered when the camera Projection matrix has changed.
  29640. */
  29641. onProjectionMatrixChangedObservable: Observable<Camera>;
  29642. /**
  29643. * Observable triggered when the inputs have been processed.
  29644. */
  29645. onAfterCheckInputsObservable: Observable<Camera>;
  29646. /**
  29647. * Observable triggered when reset has been called and applied to the camera.
  29648. */
  29649. onRestoreStateObservable: Observable<Camera>;
  29650. /**
  29651. * Is this camera a part of a rig system?
  29652. */
  29653. isRigCamera: boolean;
  29654. /**
  29655. * If isRigCamera set to true this will be set with the parent camera.
  29656. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29657. */
  29658. rigParent?: Camera;
  29659. /** @hidden */
  29660. _cameraRigParams: any;
  29661. /** @hidden */
  29662. _rigCameras: Camera[];
  29663. /** @hidden */
  29664. _rigPostProcess: Nullable<PostProcess>;
  29665. protected _webvrViewMatrix: Matrix;
  29666. /** @hidden */
  29667. _skipRendering: boolean;
  29668. /** @hidden */
  29669. _projectionMatrix: Matrix;
  29670. /** @hidden */
  29671. _postProcesses: Nullable<PostProcess>[];
  29672. /** @hidden */
  29673. _activeMeshes: SmartArray<AbstractMesh>;
  29674. protected _globalPosition: Vector3;
  29675. /** @hidden */
  29676. _computedViewMatrix: Matrix;
  29677. private _doNotComputeProjectionMatrix;
  29678. private _transformMatrix;
  29679. private _frustumPlanes;
  29680. private _refreshFrustumPlanes;
  29681. private _storedFov;
  29682. private _stateStored;
  29683. /**
  29684. * Instantiates a new camera object.
  29685. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29686. * @see https://doc.babylonjs.com/features/cameras
  29687. * @param name Defines the name of the camera in the scene
  29688. * @param position Defines the position of the camera
  29689. * @param scene Defines the scene the camera belongs too
  29690. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29691. */
  29692. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29693. /**
  29694. * Store current camera state (fov, position, etc..)
  29695. * @returns the camera
  29696. */
  29697. storeState(): Camera;
  29698. /**
  29699. * Restores the camera state values if it has been stored. You must call storeState() first
  29700. */
  29701. protected _restoreStateValues(): boolean;
  29702. /**
  29703. * Restored camera state. You must call storeState() first.
  29704. * @returns true if restored and false otherwise
  29705. */
  29706. restoreState(): boolean;
  29707. /**
  29708. * Gets the class name of the camera.
  29709. * @returns the class name
  29710. */
  29711. getClassName(): string;
  29712. /** @hidden */
  29713. readonly _isCamera: boolean;
  29714. /**
  29715. * Gets a string representation of the camera useful for debug purpose.
  29716. * @param fullDetails Defines that a more verboe level of logging is required
  29717. * @returns the string representation
  29718. */
  29719. toString(fullDetails?: boolean): string;
  29720. /**
  29721. * Gets the current world space position of the camera.
  29722. */
  29723. get globalPosition(): Vector3;
  29724. /**
  29725. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29726. * @returns the active meshe list
  29727. */
  29728. getActiveMeshes(): SmartArray<AbstractMesh>;
  29729. /**
  29730. * Check whether a mesh is part of the current active mesh list of the camera
  29731. * @param mesh Defines the mesh to check
  29732. * @returns true if active, false otherwise
  29733. */
  29734. isActiveMesh(mesh: Mesh): boolean;
  29735. /**
  29736. * Is this camera ready to be used/rendered
  29737. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29738. * @return true if the camera is ready
  29739. */
  29740. isReady(completeCheck?: boolean): boolean;
  29741. /** @hidden */
  29742. _initCache(): void;
  29743. /** @hidden */
  29744. _updateCache(ignoreParentClass?: boolean): void;
  29745. /** @hidden */
  29746. _isSynchronized(): boolean;
  29747. /** @hidden */
  29748. _isSynchronizedViewMatrix(): boolean;
  29749. /** @hidden */
  29750. _isSynchronizedProjectionMatrix(): boolean;
  29751. /**
  29752. * Attach the input controls to a specific dom element to get the input from.
  29753. * @param element Defines the element the controls should be listened from
  29754. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29755. */
  29756. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29757. /**
  29758. * Detach the current controls from the specified dom element.
  29759. * @param element Defines the element to stop listening the inputs from
  29760. */
  29761. detachControl(element: HTMLElement): void;
  29762. /**
  29763. * Update the camera state according to the different inputs gathered during the frame.
  29764. */
  29765. update(): void;
  29766. /** @hidden */
  29767. _checkInputs(): void;
  29768. /** @hidden */
  29769. get rigCameras(): Camera[];
  29770. /**
  29771. * Gets the post process used by the rig cameras
  29772. */
  29773. get rigPostProcess(): Nullable<PostProcess>;
  29774. /**
  29775. * Internal, gets the first post proces.
  29776. * @returns the first post process to be run on this camera.
  29777. */
  29778. _getFirstPostProcess(): Nullable<PostProcess>;
  29779. private _cascadePostProcessesToRigCams;
  29780. /**
  29781. * Attach a post process to the camera.
  29782. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29783. * @param postProcess The post process to attach to the camera
  29784. * @param insertAt The position of the post process in case several of them are in use in the scene
  29785. * @returns the position the post process has been inserted at
  29786. */
  29787. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29788. /**
  29789. * Detach a post process to the camera.
  29790. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29791. * @param postProcess The post process to detach from the camera
  29792. */
  29793. detachPostProcess(postProcess: PostProcess): void;
  29794. /**
  29795. * Gets the current world matrix of the camera
  29796. */
  29797. getWorldMatrix(): Matrix;
  29798. /** @hidden */
  29799. _getViewMatrix(): Matrix;
  29800. /**
  29801. * Gets the current view matrix of the camera.
  29802. * @param force forces the camera to recompute the matrix without looking at the cached state
  29803. * @returns the view matrix
  29804. */
  29805. getViewMatrix(force?: boolean): Matrix;
  29806. /**
  29807. * Freeze the projection matrix.
  29808. * It will prevent the cache check of the camera projection compute and can speed up perf
  29809. * if no parameter of the camera are meant to change
  29810. * @param projection Defines manually a projection if necessary
  29811. */
  29812. freezeProjectionMatrix(projection?: Matrix): void;
  29813. /**
  29814. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29815. */
  29816. unfreezeProjectionMatrix(): void;
  29817. /**
  29818. * Gets the current projection matrix of the camera.
  29819. * @param force forces the camera to recompute the matrix without looking at the cached state
  29820. * @returns the projection matrix
  29821. */
  29822. getProjectionMatrix(force?: boolean): Matrix;
  29823. /**
  29824. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29825. * @returns a Matrix
  29826. */
  29827. getTransformationMatrix(): Matrix;
  29828. private _updateFrustumPlanes;
  29829. /**
  29830. * Checks if a cullable object (mesh...) is in the camera frustum
  29831. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29832. * @param target The object to check
  29833. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29834. * @returns true if the object is in frustum otherwise false
  29835. */
  29836. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29837. /**
  29838. * Checks if a cullable object (mesh...) is in the camera frustum
  29839. * Unlike isInFrustum this cheks the full bounding box
  29840. * @param target The object to check
  29841. * @returns true if the object is in frustum otherwise false
  29842. */
  29843. isCompletelyInFrustum(target: ICullable): boolean;
  29844. /**
  29845. * Gets a ray in the forward direction from the camera.
  29846. * @param length Defines the length of the ray to create
  29847. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29848. * @param origin Defines the start point of the ray which defaults to the camera position
  29849. * @returns the forward ray
  29850. */
  29851. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29852. /**
  29853. * Gets a ray in the forward direction from the camera.
  29854. * @param refRay the ray to (re)use when setting the values
  29855. * @param length Defines the length of the ray to create
  29856. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29857. * @param origin Defines the start point of the ray which defaults to the camera position
  29858. * @returns the forward ray
  29859. */
  29860. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29861. /**
  29862. * Releases resources associated with this node.
  29863. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29864. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29865. */
  29866. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29867. /** @hidden */
  29868. _isLeftCamera: boolean;
  29869. /**
  29870. * Gets the left camera of a rig setup in case of Rigged Camera
  29871. */
  29872. get isLeftCamera(): boolean;
  29873. /** @hidden */
  29874. _isRightCamera: boolean;
  29875. /**
  29876. * Gets the right camera of a rig setup in case of Rigged Camera
  29877. */
  29878. get isRightCamera(): boolean;
  29879. /**
  29880. * Gets the left camera of a rig setup in case of Rigged Camera
  29881. */
  29882. get leftCamera(): Nullable<FreeCamera>;
  29883. /**
  29884. * Gets the right camera of a rig setup in case of Rigged Camera
  29885. */
  29886. get rightCamera(): Nullable<FreeCamera>;
  29887. /**
  29888. * Gets the left camera target of a rig setup in case of Rigged Camera
  29889. * @returns the target position
  29890. */
  29891. getLeftTarget(): Nullable<Vector3>;
  29892. /**
  29893. * Gets the right camera target of a rig setup in case of Rigged Camera
  29894. * @returns the target position
  29895. */
  29896. getRightTarget(): Nullable<Vector3>;
  29897. /**
  29898. * @hidden
  29899. */
  29900. setCameraRigMode(mode: number, rigParams: any): void;
  29901. /** @hidden */
  29902. static _setStereoscopicRigMode(camera: Camera): void;
  29903. /** @hidden */
  29904. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29905. /** @hidden */
  29906. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29907. /** @hidden */
  29908. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29909. /** @hidden */
  29910. _getVRProjectionMatrix(): Matrix;
  29911. protected _updateCameraRotationMatrix(): void;
  29912. protected _updateWebVRCameraRotationMatrix(): void;
  29913. /**
  29914. * This function MUST be overwritten by the different WebVR cameras available.
  29915. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29916. * @hidden
  29917. */
  29918. _getWebVRProjectionMatrix(): Matrix;
  29919. /**
  29920. * This function MUST be overwritten by the different WebVR cameras available.
  29921. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29922. * @hidden
  29923. */
  29924. _getWebVRViewMatrix(): Matrix;
  29925. /** @hidden */
  29926. setCameraRigParameter(name: string, value: any): void;
  29927. /**
  29928. * needs to be overridden by children so sub has required properties to be copied
  29929. * @hidden
  29930. */
  29931. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29932. /**
  29933. * May need to be overridden by children
  29934. * @hidden
  29935. */
  29936. _updateRigCameras(): void;
  29937. /** @hidden */
  29938. _setupInputs(): void;
  29939. /**
  29940. * Serialiaze the camera setup to a json represention
  29941. * @returns the JSON representation
  29942. */
  29943. serialize(): any;
  29944. /**
  29945. * Clones the current camera.
  29946. * @param name The cloned camera name
  29947. * @returns the cloned camera
  29948. */
  29949. clone(name: string): Camera;
  29950. /**
  29951. * Gets the direction of the camera relative to a given local axis.
  29952. * @param localAxis Defines the reference axis to provide a relative direction.
  29953. * @return the direction
  29954. */
  29955. getDirection(localAxis: Vector3): Vector3;
  29956. /**
  29957. * Returns the current camera absolute rotation
  29958. */
  29959. get absoluteRotation(): Quaternion;
  29960. /**
  29961. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29962. * @param localAxis Defines the reference axis to provide a relative direction.
  29963. * @param result Defines the vector to store the result in
  29964. */
  29965. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29966. /**
  29967. * Gets a camera constructor for a given camera type
  29968. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29969. * @param name The name of the camera the result will be able to instantiate
  29970. * @param scene The scene the result will construct the camera in
  29971. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29972. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29973. * @returns a factory method to construc the camera
  29974. */
  29975. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29976. /**
  29977. * Compute the world matrix of the camera.
  29978. * @returns the camera world matrix
  29979. */
  29980. computeWorldMatrix(): Matrix;
  29981. /**
  29982. * Parse a JSON and creates the camera from the parsed information
  29983. * @param parsedCamera The JSON to parse
  29984. * @param scene The scene to instantiate the camera in
  29985. * @returns the newly constructed camera
  29986. */
  29987. static Parse(parsedCamera: any, scene: Scene): Camera;
  29988. }
  29989. }
  29990. declare module BABYLON {
  29991. /**
  29992. * Class containing static functions to help procedurally build meshes
  29993. */
  29994. export class DiscBuilder {
  29995. /**
  29996. * Creates a plane polygonal mesh. By default, this is a disc
  29997. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29998. * * 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
  29999. * * 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
  30000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30001. * * 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
  30002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30003. * @param name defines the name of the mesh
  30004. * @param options defines the options used to create the mesh
  30005. * @param scene defines the hosting scene
  30006. * @returns the plane polygonal mesh
  30007. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30008. */
  30009. static CreateDisc(name: string, options: {
  30010. radius?: number;
  30011. tessellation?: number;
  30012. arc?: number;
  30013. updatable?: boolean;
  30014. sideOrientation?: number;
  30015. frontUVs?: Vector4;
  30016. backUVs?: Vector4;
  30017. }, scene?: Nullable<Scene>): Mesh;
  30018. }
  30019. }
  30020. declare module BABYLON {
  30021. /**
  30022. * Options to be used when creating a FresnelParameters.
  30023. */
  30024. export type IFresnelParametersCreationOptions = {
  30025. /**
  30026. * Define the color used on edges (grazing angle)
  30027. */
  30028. leftColor?: Color3;
  30029. /**
  30030. * Define the color used on center
  30031. */
  30032. rightColor?: Color3;
  30033. /**
  30034. * Define bias applied to computed fresnel term
  30035. */
  30036. bias?: number;
  30037. /**
  30038. * Defined the power exponent applied to fresnel term
  30039. */
  30040. power?: number;
  30041. /**
  30042. * Define if the fresnel effect is enable or not.
  30043. */
  30044. isEnabled?: boolean;
  30045. };
  30046. /**
  30047. * Serialized format for FresnelParameters.
  30048. */
  30049. export type IFresnelParametersSerialized = {
  30050. /**
  30051. * Define the color used on edges (grazing angle) [as an array]
  30052. */
  30053. leftColor: number[];
  30054. /**
  30055. * Define the color used on center [as an array]
  30056. */
  30057. rightColor: number[];
  30058. /**
  30059. * Define bias applied to computed fresnel term
  30060. */
  30061. bias: number;
  30062. /**
  30063. * Defined the power exponent applied to fresnel term
  30064. */
  30065. power?: number;
  30066. /**
  30067. * Define if the fresnel effect is enable or not.
  30068. */
  30069. isEnabled: boolean;
  30070. };
  30071. /**
  30072. * This represents all the required information to add a fresnel effect on a material:
  30073. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30074. */
  30075. export class FresnelParameters {
  30076. private _isEnabled;
  30077. /**
  30078. * Define if the fresnel effect is enable or not.
  30079. */
  30080. get isEnabled(): boolean;
  30081. set isEnabled(value: boolean);
  30082. /**
  30083. * Define the color used on edges (grazing angle)
  30084. */
  30085. leftColor: Color3;
  30086. /**
  30087. * Define the color used on center
  30088. */
  30089. rightColor: Color3;
  30090. /**
  30091. * Define bias applied to computed fresnel term
  30092. */
  30093. bias: number;
  30094. /**
  30095. * Defined the power exponent applied to fresnel term
  30096. */
  30097. power: number;
  30098. /**
  30099. * Creates a new FresnelParameters object.
  30100. *
  30101. * @param options provide your own settings to optionally to override defaults
  30102. */
  30103. constructor(options?: IFresnelParametersCreationOptions);
  30104. /**
  30105. * Clones the current fresnel and its valuues
  30106. * @returns a clone fresnel configuration
  30107. */
  30108. clone(): FresnelParameters;
  30109. /**
  30110. * Determines equality between FresnelParameters objects
  30111. * @param otherFresnelParameters defines the second operand
  30112. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30113. */
  30114. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30115. /**
  30116. * Serializes the current fresnel parameters to a JSON representation.
  30117. * @return the JSON serialization
  30118. */
  30119. serialize(): IFresnelParametersSerialized;
  30120. /**
  30121. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30122. * @param parsedFresnelParameters Define the JSON representation
  30123. * @returns the parsed parameters
  30124. */
  30125. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30126. }
  30127. }
  30128. declare module BABYLON {
  30129. /**
  30130. * This groups all the flags used to control the materials channel.
  30131. */
  30132. export class MaterialFlags {
  30133. private static _DiffuseTextureEnabled;
  30134. /**
  30135. * Are diffuse textures enabled in the application.
  30136. */
  30137. static get DiffuseTextureEnabled(): boolean;
  30138. static set DiffuseTextureEnabled(value: boolean);
  30139. private static _DetailTextureEnabled;
  30140. /**
  30141. * Are detail textures enabled in the application.
  30142. */
  30143. static get DetailTextureEnabled(): boolean;
  30144. static set DetailTextureEnabled(value: boolean);
  30145. private static _AmbientTextureEnabled;
  30146. /**
  30147. * Are ambient textures enabled in the application.
  30148. */
  30149. static get AmbientTextureEnabled(): boolean;
  30150. static set AmbientTextureEnabled(value: boolean);
  30151. private static _OpacityTextureEnabled;
  30152. /**
  30153. * Are opacity textures enabled in the application.
  30154. */
  30155. static get OpacityTextureEnabled(): boolean;
  30156. static set OpacityTextureEnabled(value: boolean);
  30157. private static _ReflectionTextureEnabled;
  30158. /**
  30159. * Are reflection textures enabled in the application.
  30160. */
  30161. static get ReflectionTextureEnabled(): boolean;
  30162. static set ReflectionTextureEnabled(value: boolean);
  30163. private static _EmissiveTextureEnabled;
  30164. /**
  30165. * Are emissive textures enabled in the application.
  30166. */
  30167. static get EmissiveTextureEnabled(): boolean;
  30168. static set EmissiveTextureEnabled(value: boolean);
  30169. private static _SpecularTextureEnabled;
  30170. /**
  30171. * Are specular textures enabled in the application.
  30172. */
  30173. static get SpecularTextureEnabled(): boolean;
  30174. static set SpecularTextureEnabled(value: boolean);
  30175. private static _BumpTextureEnabled;
  30176. /**
  30177. * Are bump textures enabled in the application.
  30178. */
  30179. static get BumpTextureEnabled(): boolean;
  30180. static set BumpTextureEnabled(value: boolean);
  30181. private static _LightmapTextureEnabled;
  30182. /**
  30183. * Are lightmap textures enabled in the application.
  30184. */
  30185. static get LightmapTextureEnabled(): boolean;
  30186. static set LightmapTextureEnabled(value: boolean);
  30187. private static _RefractionTextureEnabled;
  30188. /**
  30189. * Are refraction textures enabled in the application.
  30190. */
  30191. static get RefractionTextureEnabled(): boolean;
  30192. static set RefractionTextureEnabled(value: boolean);
  30193. private static _ColorGradingTextureEnabled;
  30194. /**
  30195. * Are color grading textures enabled in the application.
  30196. */
  30197. static get ColorGradingTextureEnabled(): boolean;
  30198. static set ColorGradingTextureEnabled(value: boolean);
  30199. private static _FresnelEnabled;
  30200. /**
  30201. * Are fresnels enabled in the application.
  30202. */
  30203. static get FresnelEnabled(): boolean;
  30204. static set FresnelEnabled(value: boolean);
  30205. private static _ClearCoatTextureEnabled;
  30206. /**
  30207. * Are clear coat textures enabled in the application.
  30208. */
  30209. static get ClearCoatTextureEnabled(): boolean;
  30210. static set ClearCoatTextureEnabled(value: boolean);
  30211. private static _ClearCoatBumpTextureEnabled;
  30212. /**
  30213. * Are clear coat bump textures enabled in the application.
  30214. */
  30215. static get ClearCoatBumpTextureEnabled(): boolean;
  30216. static set ClearCoatBumpTextureEnabled(value: boolean);
  30217. private static _ClearCoatTintTextureEnabled;
  30218. /**
  30219. * Are clear coat tint textures enabled in the application.
  30220. */
  30221. static get ClearCoatTintTextureEnabled(): boolean;
  30222. static set ClearCoatTintTextureEnabled(value: boolean);
  30223. private static _SheenTextureEnabled;
  30224. /**
  30225. * Are sheen textures enabled in the application.
  30226. */
  30227. static get SheenTextureEnabled(): boolean;
  30228. static set SheenTextureEnabled(value: boolean);
  30229. private static _AnisotropicTextureEnabled;
  30230. /**
  30231. * Are anisotropic textures enabled in the application.
  30232. */
  30233. static get AnisotropicTextureEnabled(): boolean;
  30234. static set AnisotropicTextureEnabled(value: boolean);
  30235. private static _ThicknessTextureEnabled;
  30236. /**
  30237. * Are thickness textures enabled in the application.
  30238. */
  30239. static get ThicknessTextureEnabled(): boolean;
  30240. static set ThicknessTextureEnabled(value: boolean);
  30241. }
  30242. }
  30243. declare module BABYLON {
  30244. /** @hidden */
  30245. export var defaultFragmentDeclaration: {
  30246. name: string;
  30247. shader: string;
  30248. };
  30249. }
  30250. declare module BABYLON {
  30251. /** @hidden */
  30252. export var defaultUboDeclaration: {
  30253. name: string;
  30254. shader: string;
  30255. };
  30256. }
  30257. declare module BABYLON {
  30258. /** @hidden */
  30259. export var prePassDeclaration: {
  30260. name: string;
  30261. shader: string;
  30262. };
  30263. }
  30264. declare module BABYLON {
  30265. /** @hidden */
  30266. export var lightFragmentDeclaration: {
  30267. name: string;
  30268. shader: string;
  30269. };
  30270. }
  30271. declare module BABYLON {
  30272. /** @hidden */
  30273. export var lightUboDeclaration: {
  30274. name: string;
  30275. shader: string;
  30276. };
  30277. }
  30278. declare module BABYLON {
  30279. /** @hidden */
  30280. export var lightsFragmentFunctions: {
  30281. name: string;
  30282. shader: string;
  30283. };
  30284. }
  30285. declare module BABYLON {
  30286. /** @hidden */
  30287. export var shadowsFragmentFunctions: {
  30288. name: string;
  30289. shader: string;
  30290. };
  30291. }
  30292. declare module BABYLON {
  30293. /** @hidden */
  30294. export var fresnelFunction: {
  30295. name: string;
  30296. shader: string;
  30297. };
  30298. }
  30299. declare module BABYLON {
  30300. /** @hidden */
  30301. export var bumpFragmentMainFunctions: {
  30302. name: string;
  30303. shader: string;
  30304. };
  30305. }
  30306. declare module BABYLON {
  30307. /** @hidden */
  30308. export var bumpFragmentFunctions: {
  30309. name: string;
  30310. shader: string;
  30311. };
  30312. }
  30313. declare module BABYLON {
  30314. /** @hidden */
  30315. export var logDepthDeclaration: {
  30316. name: string;
  30317. shader: string;
  30318. };
  30319. }
  30320. declare module BABYLON {
  30321. /** @hidden */
  30322. export var bumpFragment: {
  30323. name: string;
  30324. shader: string;
  30325. };
  30326. }
  30327. declare module BABYLON {
  30328. /** @hidden */
  30329. export var depthPrePass: {
  30330. name: string;
  30331. shader: string;
  30332. };
  30333. }
  30334. declare module BABYLON {
  30335. /** @hidden */
  30336. export var lightFragment: {
  30337. name: string;
  30338. shader: string;
  30339. };
  30340. }
  30341. declare module BABYLON {
  30342. /** @hidden */
  30343. export var logDepthFragment: {
  30344. name: string;
  30345. shader: string;
  30346. };
  30347. }
  30348. declare module BABYLON {
  30349. /** @hidden */
  30350. export var defaultPixelShader: {
  30351. name: string;
  30352. shader: string;
  30353. };
  30354. }
  30355. declare module BABYLON {
  30356. /** @hidden */
  30357. export var defaultVertexDeclaration: {
  30358. name: string;
  30359. shader: string;
  30360. };
  30361. }
  30362. declare module BABYLON {
  30363. /** @hidden */
  30364. export var bumpVertexDeclaration: {
  30365. name: string;
  30366. shader: string;
  30367. };
  30368. }
  30369. declare module BABYLON {
  30370. /** @hidden */
  30371. export var bumpVertex: {
  30372. name: string;
  30373. shader: string;
  30374. };
  30375. }
  30376. declare module BABYLON {
  30377. /** @hidden */
  30378. export var fogVertex: {
  30379. name: string;
  30380. shader: string;
  30381. };
  30382. }
  30383. declare module BABYLON {
  30384. /** @hidden */
  30385. export var shadowsVertex: {
  30386. name: string;
  30387. shader: string;
  30388. };
  30389. }
  30390. declare module BABYLON {
  30391. /** @hidden */
  30392. export var pointCloudVertex: {
  30393. name: string;
  30394. shader: string;
  30395. };
  30396. }
  30397. declare module BABYLON {
  30398. /** @hidden */
  30399. export var logDepthVertex: {
  30400. name: string;
  30401. shader: string;
  30402. };
  30403. }
  30404. declare module BABYLON {
  30405. /** @hidden */
  30406. export var defaultVertexShader: {
  30407. name: string;
  30408. shader: string;
  30409. };
  30410. }
  30411. declare module BABYLON {
  30412. /**
  30413. * @hidden
  30414. */
  30415. export interface IMaterialDetailMapDefines {
  30416. DETAIL: boolean;
  30417. DETAILDIRECTUV: number;
  30418. DETAIL_NORMALBLENDMETHOD: number;
  30419. /** @hidden */
  30420. _areTexturesDirty: boolean;
  30421. }
  30422. /**
  30423. * Define the code related to the detail map parameters of a material
  30424. *
  30425. * Inspired from:
  30426. * 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
  30427. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30428. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30429. */
  30430. export class DetailMapConfiguration {
  30431. private _texture;
  30432. /**
  30433. * The detail texture of the material.
  30434. */
  30435. texture: Nullable<BaseTexture>;
  30436. /**
  30437. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30438. * Bigger values mean stronger blending
  30439. */
  30440. diffuseBlendLevel: number;
  30441. /**
  30442. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30443. * Bigger values mean stronger blending. Only used with PBR materials
  30444. */
  30445. roughnessBlendLevel: number;
  30446. /**
  30447. * Defines how strong the bump effect from the detail map is
  30448. * Bigger values mean stronger effect
  30449. */
  30450. bumpLevel: number;
  30451. private _normalBlendMethod;
  30452. /**
  30453. * The method used to blend the bump and detail normals together
  30454. */
  30455. normalBlendMethod: number;
  30456. private _isEnabled;
  30457. /**
  30458. * Enable or disable the detail map on this material
  30459. */
  30460. isEnabled: boolean;
  30461. /** @hidden */
  30462. private _internalMarkAllSubMeshesAsTexturesDirty;
  30463. /** @hidden */
  30464. _markAllSubMeshesAsTexturesDirty(): void;
  30465. /**
  30466. * Instantiate a new detail map
  30467. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30468. */
  30469. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30470. /**
  30471. * Gets whether the submesh is ready to be used or not.
  30472. * @param defines the list of "defines" to update.
  30473. * @param scene defines the scene the material belongs to.
  30474. * @returns - boolean indicating that the submesh is ready or not.
  30475. */
  30476. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30477. /**
  30478. * Update the defines for detail map usage
  30479. * @param defines the list of "defines" to update.
  30480. * @param scene defines the scene the material belongs to.
  30481. */
  30482. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30483. /**
  30484. * Binds the material data.
  30485. * @param uniformBuffer defines the Uniform buffer to fill in.
  30486. * @param scene defines the scene the material belongs to.
  30487. * @param isFrozen defines whether the material is frozen or not.
  30488. */
  30489. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30490. /**
  30491. * Checks to see if a texture is used in the material.
  30492. * @param texture - Base texture to use.
  30493. * @returns - Boolean specifying if a texture is used in the material.
  30494. */
  30495. hasTexture(texture: BaseTexture): boolean;
  30496. /**
  30497. * Returns an array of the actively used textures.
  30498. * @param activeTextures Array of BaseTextures
  30499. */
  30500. getActiveTextures(activeTextures: BaseTexture[]): void;
  30501. /**
  30502. * Returns the animatable textures.
  30503. * @param animatables Array of animatable textures.
  30504. */
  30505. getAnimatables(animatables: IAnimatable[]): void;
  30506. /**
  30507. * Disposes the resources of the material.
  30508. * @param forceDisposeTextures - Forces the disposal of all textures.
  30509. */
  30510. dispose(forceDisposeTextures?: boolean): void;
  30511. /**
  30512. * Get the current class name useful for serialization or dynamic coding.
  30513. * @returns "DetailMap"
  30514. */
  30515. getClassName(): string;
  30516. /**
  30517. * Add the required uniforms to the current list.
  30518. * @param uniforms defines the current uniform list.
  30519. */
  30520. static AddUniforms(uniforms: string[]): void;
  30521. /**
  30522. * Add the required samplers to the current list.
  30523. * @param samplers defines the current sampler list.
  30524. */
  30525. static AddSamplers(samplers: string[]): void;
  30526. /**
  30527. * Add the required uniforms to the current buffer.
  30528. * @param uniformBuffer defines the current uniform buffer.
  30529. */
  30530. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30531. /**
  30532. * Makes a duplicate of the current instance into another one.
  30533. * @param detailMap define the instance where to copy the info
  30534. */
  30535. copyTo(detailMap: DetailMapConfiguration): void;
  30536. /**
  30537. * Serializes this detail map instance
  30538. * @returns - An object with the serialized instance.
  30539. */
  30540. serialize(): any;
  30541. /**
  30542. * Parses a detail map setting from a serialized object.
  30543. * @param source - Serialized object.
  30544. * @param scene Defines the scene we are parsing for
  30545. * @param rootUrl Defines the rootUrl to load from
  30546. */
  30547. parse(source: any, scene: Scene, rootUrl: string): void;
  30548. }
  30549. }
  30550. declare module BABYLON {
  30551. /** @hidden */
  30552. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30553. MAINUV1: boolean;
  30554. MAINUV2: boolean;
  30555. DIFFUSE: boolean;
  30556. DIFFUSEDIRECTUV: number;
  30557. DETAIL: boolean;
  30558. DETAILDIRECTUV: number;
  30559. DETAIL_NORMALBLENDMETHOD: number;
  30560. AMBIENT: boolean;
  30561. AMBIENTDIRECTUV: number;
  30562. OPACITY: boolean;
  30563. OPACITYDIRECTUV: number;
  30564. OPACITYRGB: boolean;
  30565. REFLECTION: boolean;
  30566. EMISSIVE: boolean;
  30567. EMISSIVEDIRECTUV: number;
  30568. SPECULAR: boolean;
  30569. SPECULARDIRECTUV: number;
  30570. BUMP: boolean;
  30571. BUMPDIRECTUV: number;
  30572. PARALLAX: boolean;
  30573. PARALLAXOCCLUSION: boolean;
  30574. SPECULAROVERALPHA: boolean;
  30575. CLIPPLANE: boolean;
  30576. CLIPPLANE2: boolean;
  30577. CLIPPLANE3: boolean;
  30578. CLIPPLANE4: boolean;
  30579. CLIPPLANE5: boolean;
  30580. CLIPPLANE6: boolean;
  30581. ALPHATEST: boolean;
  30582. DEPTHPREPASS: boolean;
  30583. ALPHAFROMDIFFUSE: boolean;
  30584. POINTSIZE: boolean;
  30585. FOG: boolean;
  30586. SPECULARTERM: boolean;
  30587. DIFFUSEFRESNEL: boolean;
  30588. OPACITYFRESNEL: boolean;
  30589. REFLECTIONFRESNEL: boolean;
  30590. REFRACTIONFRESNEL: boolean;
  30591. EMISSIVEFRESNEL: boolean;
  30592. FRESNEL: boolean;
  30593. NORMAL: boolean;
  30594. UV1: boolean;
  30595. UV2: boolean;
  30596. VERTEXCOLOR: boolean;
  30597. VERTEXALPHA: boolean;
  30598. NUM_BONE_INFLUENCERS: number;
  30599. BonesPerMesh: number;
  30600. BONETEXTURE: boolean;
  30601. INSTANCES: boolean;
  30602. THIN_INSTANCES: boolean;
  30603. GLOSSINESS: boolean;
  30604. ROUGHNESS: boolean;
  30605. EMISSIVEASILLUMINATION: boolean;
  30606. LINKEMISSIVEWITHDIFFUSE: boolean;
  30607. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30608. LIGHTMAP: boolean;
  30609. LIGHTMAPDIRECTUV: number;
  30610. OBJECTSPACE_NORMALMAP: boolean;
  30611. USELIGHTMAPASSHADOWMAP: boolean;
  30612. REFLECTIONMAP_3D: boolean;
  30613. REFLECTIONMAP_SPHERICAL: boolean;
  30614. REFLECTIONMAP_PLANAR: boolean;
  30615. REFLECTIONMAP_CUBIC: boolean;
  30616. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30617. REFLECTIONMAP_PROJECTION: boolean;
  30618. REFLECTIONMAP_SKYBOX: boolean;
  30619. REFLECTIONMAP_EXPLICIT: boolean;
  30620. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30621. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30622. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30623. INVERTCUBICMAP: boolean;
  30624. LOGARITHMICDEPTH: boolean;
  30625. REFRACTION: boolean;
  30626. REFRACTIONMAP_3D: boolean;
  30627. REFLECTIONOVERALPHA: boolean;
  30628. TWOSIDEDLIGHTING: boolean;
  30629. SHADOWFLOAT: boolean;
  30630. MORPHTARGETS: boolean;
  30631. MORPHTARGETS_NORMAL: boolean;
  30632. MORPHTARGETS_TANGENT: boolean;
  30633. MORPHTARGETS_UV: boolean;
  30634. NUM_MORPH_INFLUENCERS: number;
  30635. NONUNIFORMSCALING: boolean;
  30636. PREMULTIPLYALPHA: boolean;
  30637. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30638. ALPHABLEND: boolean;
  30639. PREPASS: boolean;
  30640. SCENE_MRT_COUNT: number;
  30641. RGBDLIGHTMAP: boolean;
  30642. RGBDREFLECTION: boolean;
  30643. RGBDREFRACTION: boolean;
  30644. IMAGEPROCESSING: boolean;
  30645. VIGNETTE: boolean;
  30646. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30647. VIGNETTEBLENDMODEOPAQUE: boolean;
  30648. TONEMAPPING: boolean;
  30649. TONEMAPPING_ACES: boolean;
  30650. CONTRAST: boolean;
  30651. COLORCURVES: boolean;
  30652. COLORGRADING: boolean;
  30653. COLORGRADING3D: boolean;
  30654. SAMPLER3DGREENDEPTH: boolean;
  30655. SAMPLER3DBGRMAP: boolean;
  30656. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30657. MULTIVIEW: boolean;
  30658. /**
  30659. * If the reflection texture on this material is in linear color space
  30660. * @hidden
  30661. */
  30662. IS_REFLECTION_LINEAR: boolean;
  30663. /**
  30664. * If the refraction texture on this material is in linear color space
  30665. * @hidden
  30666. */
  30667. IS_REFRACTION_LINEAR: boolean;
  30668. EXPOSURE: boolean;
  30669. constructor();
  30670. setReflectionMode(modeToEnable: string): void;
  30671. }
  30672. /**
  30673. * This is the default material used in Babylon. It is the best trade off between quality
  30674. * and performances.
  30675. * @see https://doc.babylonjs.com/babylon101/materials
  30676. */
  30677. export class StandardMaterial extends PushMaterial {
  30678. private _diffuseTexture;
  30679. /**
  30680. * The basic texture of the material as viewed under a light.
  30681. */
  30682. diffuseTexture: Nullable<BaseTexture>;
  30683. private _ambientTexture;
  30684. /**
  30685. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30686. */
  30687. ambientTexture: Nullable<BaseTexture>;
  30688. private _opacityTexture;
  30689. /**
  30690. * Define the transparency of the material from a texture.
  30691. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30692. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30693. */
  30694. opacityTexture: Nullable<BaseTexture>;
  30695. private _reflectionTexture;
  30696. /**
  30697. * Define the texture used to display the reflection.
  30698. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30699. */
  30700. reflectionTexture: Nullable<BaseTexture>;
  30701. private _emissiveTexture;
  30702. /**
  30703. * Define texture of the material as if self lit.
  30704. * This will be mixed in the final result even in the absence of light.
  30705. */
  30706. emissiveTexture: Nullable<BaseTexture>;
  30707. private _specularTexture;
  30708. /**
  30709. * Define how the color and intensity of the highlight given by the light in the material.
  30710. */
  30711. specularTexture: Nullable<BaseTexture>;
  30712. private _bumpTexture;
  30713. /**
  30714. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30715. * 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.
  30716. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30717. */
  30718. bumpTexture: Nullable<BaseTexture>;
  30719. private _lightmapTexture;
  30720. /**
  30721. * Complex lighting can be computationally expensive to compute at runtime.
  30722. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30723. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30724. */
  30725. lightmapTexture: Nullable<BaseTexture>;
  30726. private _refractionTexture;
  30727. /**
  30728. * Define the texture used to display the refraction.
  30729. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30730. */
  30731. refractionTexture: Nullable<BaseTexture>;
  30732. /**
  30733. * The color of the material lit by the environmental background lighting.
  30734. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30735. */
  30736. ambientColor: Color3;
  30737. /**
  30738. * The basic color of the material as viewed under a light.
  30739. */
  30740. diffuseColor: Color3;
  30741. /**
  30742. * Define how the color and intensity of the highlight given by the light in the material.
  30743. */
  30744. specularColor: Color3;
  30745. /**
  30746. * Define the color of the material as if self lit.
  30747. * This will be mixed in the final result even in the absence of light.
  30748. */
  30749. emissiveColor: Color3;
  30750. /**
  30751. * Defines how sharp are the highlights in the material.
  30752. * The bigger the value the sharper giving a more glossy feeling to the result.
  30753. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30754. */
  30755. specularPower: number;
  30756. private _useAlphaFromDiffuseTexture;
  30757. /**
  30758. * Does the transparency come from the diffuse texture alpha channel.
  30759. */
  30760. useAlphaFromDiffuseTexture: boolean;
  30761. private _useEmissiveAsIllumination;
  30762. /**
  30763. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30764. */
  30765. useEmissiveAsIllumination: boolean;
  30766. private _linkEmissiveWithDiffuse;
  30767. /**
  30768. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30769. * the emissive level when the final color is close to one.
  30770. */
  30771. linkEmissiveWithDiffuse: boolean;
  30772. private _useSpecularOverAlpha;
  30773. /**
  30774. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30775. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30776. */
  30777. useSpecularOverAlpha: boolean;
  30778. private _useReflectionOverAlpha;
  30779. /**
  30780. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30781. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30782. */
  30783. useReflectionOverAlpha: boolean;
  30784. private _disableLighting;
  30785. /**
  30786. * Does lights from the scene impacts this material.
  30787. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30788. */
  30789. disableLighting: boolean;
  30790. private _useObjectSpaceNormalMap;
  30791. /**
  30792. * Allows using an object space normal map (instead of tangent space).
  30793. */
  30794. useObjectSpaceNormalMap: boolean;
  30795. private _useParallax;
  30796. /**
  30797. * Is parallax enabled or not.
  30798. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30799. */
  30800. useParallax: boolean;
  30801. private _useParallaxOcclusion;
  30802. /**
  30803. * Is parallax occlusion enabled or not.
  30804. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30805. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30806. */
  30807. useParallaxOcclusion: boolean;
  30808. /**
  30809. * 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.
  30810. */
  30811. parallaxScaleBias: number;
  30812. private _roughness;
  30813. /**
  30814. * Helps to define how blurry the reflections should appears in the material.
  30815. */
  30816. roughness: number;
  30817. /**
  30818. * In case of refraction, define the value of the index of refraction.
  30819. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30820. */
  30821. indexOfRefraction: number;
  30822. /**
  30823. * Invert the refraction texture alongside the y axis.
  30824. * It can be useful with procedural textures or probe for instance.
  30825. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30826. */
  30827. invertRefractionY: boolean;
  30828. /**
  30829. * Defines the alpha limits in alpha test mode.
  30830. */
  30831. alphaCutOff: number;
  30832. private _useLightmapAsShadowmap;
  30833. /**
  30834. * In case of light mapping, define whether the map contains light or shadow informations.
  30835. */
  30836. useLightmapAsShadowmap: boolean;
  30837. private _diffuseFresnelParameters;
  30838. /**
  30839. * Define the diffuse fresnel parameters of the material.
  30840. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30841. */
  30842. diffuseFresnelParameters: FresnelParameters;
  30843. private _opacityFresnelParameters;
  30844. /**
  30845. * Define the opacity fresnel parameters of the material.
  30846. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30847. */
  30848. opacityFresnelParameters: FresnelParameters;
  30849. private _reflectionFresnelParameters;
  30850. /**
  30851. * Define the reflection fresnel parameters of the material.
  30852. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30853. */
  30854. reflectionFresnelParameters: FresnelParameters;
  30855. private _refractionFresnelParameters;
  30856. /**
  30857. * Define the refraction fresnel parameters of the material.
  30858. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30859. */
  30860. refractionFresnelParameters: FresnelParameters;
  30861. private _emissiveFresnelParameters;
  30862. /**
  30863. * Define the emissive fresnel parameters of the material.
  30864. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30865. */
  30866. emissiveFresnelParameters: FresnelParameters;
  30867. private _useReflectionFresnelFromSpecular;
  30868. /**
  30869. * If true automatically deducts the fresnels values from the material specularity.
  30870. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30871. */
  30872. useReflectionFresnelFromSpecular: boolean;
  30873. private _useGlossinessFromSpecularMapAlpha;
  30874. /**
  30875. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30876. */
  30877. useGlossinessFromSpecularMapAlpha: boolean;
  30878. private _maxSimultaneousLights;
  30879. /**
  30880. * Defines the maximum number of lights that can be used in the material
  30881. */
  30882. maxSimultaneousLights: number;
  30883. private _invertNormalMapX;
  30884. /**
  30885. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30886. */
  30887. invertNormalMapX: boolean;
  30888. private _invertNormalMapY;
  30889. /**
  30890. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30891. */
  30892. invertNormalMapY: boolean;
  30893. private _twoSidedLighting;
  30894. /**
  30895. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30896. */
  30897. twoSidedLighting: boolean;
  30898. /**
  30899. * Default configuration related to image processing available in the standard Material.
  30900. */
  30901. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30902. /**
  30903. * Gets the image processing configuration used either in this material.
  30904. */
  30905. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30906. /**
  30907. * Sets the Default image processing configuration used either in the this material.
  30908. *
  30909. * If sets to null, the scene one is in use.
  30910. */
  30911. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30912. /**
  30913. * Keep track of the image processing observer to allow dispose and replace.
  30914. */
  30915. private _imageProcessingObserver;
  30916. /**
  30917. * Attaches a new image processing configuration to the Standard Material.
  30918. * @param configuration
  30919. */
  30920. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30921. /**
  30922. * Gets wether the color curves effect is enabled.
  30923. */
  30924. get cameraColorCurvesEnabled(): boolean;
  30925. /**
  30926. * Sets wether the color curves effect is enabled.
  30927. */
  30928. set cameraColorCurvesEnabled(value: boolean);
  30929. /**
  30930. * Gets wether the color grading effect is enabled.
  30931. */
  30932. get cameraColorGradingEnabled(): boolean;
  30933. /**
  30934. * Gets wether the color grading effect is enabled.
  30935. */
  30936. set cameraColorGradingEnabled(value: boolean);
  30937. /**
  30938. * Gets wether tonemapping is enabled or not.
  30939. */
  30940. get cameraToneMappingEnabled(): boolean;
  30941. /**
  30942. * Sets wether tonemapping is enabled or not
  30943. */
  30944. set cameraToneMappingEnabled(value: boolean);
  30945. /**
  30946. * The camera exposure used on this material.
  30947. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30948. * This corresponds to a photographic exposure.
  30949. */
  30950. get cameraExposure(): number;
  30951. /**
  30952. * The camera exposure used on this material.
  30953. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30954. * This corresponds to a photographic exposure.
  30955. */
  30956. set cameraExposure(value: number);
  30957. /**
  30958. * Gets The camera contrast used on this material.
  30959. */
  30960. get cameraContrast(): number;
  30961. /**
  30962. * Sets The camera contrast used on this material.
  30963. */
  30964. set cameraContrast(value: number);
  30965. /**
  30966. * Gets the Color Grading 2D Lookup Texture.
  30967. */
  30968. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30969. /**
  30970. * Sets the Color Grading 2D Lookup Texture.
  30971. */
  30972. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30973. /**
  30974. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30975. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30976. * 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;
  30977. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30978. */
  30979. get cameraColorCurves(): Nullable<ColorCurves>;
  30980. /**
  30981. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30982. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30983. * 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;
  30984. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30985. */
  30986. set cameraColorCurves(value: Nullable<ColorCurves>);
  30987. /**
  30988. * Can this material render to several textures at once
  30989. */
  30990. get canRenderToMRT(): boolean;
  30991. /**
  30992. * Defines the detail map parameters for the material.
  30993. */
  30994. readonly detailMap: DetailMapConfiguration;
  30995. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30996. protected _worldViewProjectionMatrix: Matrix;
  30997. protected _globalAmbientColor: Color3;
  30998. protected _useLogarithmicDepth: boolean;
  30999. protected _rebuildInParallel: boolean;
  31000. /**
  31001. * Instantiates a new standard material.
  31002. * This is the default material used in Babylon. It is the best trade off between quality
  31003. * and performances.
  31004. * @see https://doc.babylonjs.com/babylon101/materials
  31005. * @param name Define the name of the material in the scene
  31006. * @param scene Define the scene the material belong to
  31007. */
  31008. constructor(name: string, scene: Scene);
  31009. /**
  31010. * Gets a boolean indicating that current material needs to register RTT
  31011. */
  31012. get hasRenderTargetTextures(): boolean;
  31013. /**
  31014. * Gets the current class name of the material e.g. "StandardMaterial"
  31015. * Mainly use in serialization.
  31016. * @returns the class name
  31017. */
  31018. getClassName(): string;
  31019. /**
  31020. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31021. * You can try switching to logarithmic depth.
  31022. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31023. */
  31024. get useLogarithmicDepth(): boolean;
  31025. set useLogarithmicDepth(value: boolean);
  31026. /**
  31027. * Specifies if the material will require alpha blending
  31028. * @returns a boolean specifying if alpha blending is needed
  31029. */
  31030. needAlphaBlending(): boolean;
  31031. /**
  31032. * Specifies if this material should be rendered in alpha test mode
  31033. * @returns a boolean specifying if an alpha test is needed.
  31034. */
  31035. needAlphaTesting(): boolean;
  31036. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31037. /**
  31038. * Get the texture used for alpha test purpose.
  31039. * @returns the diffuse texture in case of the standard material.
  31040. */
  31041. getAlphaTestTexture(): Nullable<BaseTexture>;
  31042. /**
  31043. * Get if the submesh is ready to be used and all its information available.
  31044. * Child classes can use it to update shaders
  31045. * @param mesh defines the mesh to check
  31046. * @param subMesh defines which submesh to check
  31047. * @param useInstances specifies that instances should be used
  31048. * @returns a boolean indicating that the submesh is ready or not
  31049. */
  31050. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31051. /**
  31052. * Builds the material UBO layouts.
  31053. * Used internally during the effect preparation.
  31054. */
  31055. buildUniformLayout(): void;
  31056. /**
  31057. * Unbinds the material from the mesh
  31058. */
  31059. unbind(): void;
  31060. /**
  31061. * Binds the submesh to this material by preparing the effect and shader to draw
  31062. * @param world defines the world transformation matrix
  31063. * @param mesh defines the mesh containing the submesh
  31064. * @param subMesh defines the submesh to bind the material to
  31065. */
  31066. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31067. /**
  31068. * Get the list of animatables in the material.
  31069. * @returns the list of animatables object used in the material
  31070. */
  31071. getAnimatables(): IAnimatable[];
  31072. /**
  31073. * Gets the active textures from the material
  31074. * @returns an array of textures
  31075. */
  31076. getActiveTextures(): BaseTexture[];
  31077. /**
  31078. * Specifies if the material uses a texture
  31079. * @param texture defines the texture to check against the material
  31080. * @returns a boolean specifying if the material uses the texture
  31081. */
  31082. hasTexture(texture: BaseTexture): boolean;
  31083. /**
  31084. * Disposes the material
  31085. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31086. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31087. */
  31088. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31089. /**
  31090. * Makes a duplicate of the material, and gives it a new name
  31091. * @param name defines the new name for the duplicated material
  31092. * @returns the cloned material
  31093. */
  31094. clone(name: string): StandardMaterial;
  31095. /**
  31096. * Serializes this material in a JSON representation
  31097. * @returns the serialized material object
  31098. */
  31099. serialize(): any;
  31100. /**
  31101. * Creates a standard material from parsed material data
  31102. * @param source defines the JSON representation of the material
  31103. * @param scene defines the hosting scene
  31104. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31105. * @returns a new standard material
  31106. */
  31107. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31108. /**
  31109. * Are diffuse textures enabled in the application.
  31110. */
  31111. static get DiffuseTextureEnabled(): boolean;
  31112. static set DiffuseTextureEnabled(value: boolean);
  31113. /**
  31114. * Are detail textures enabled in the application.
  31115. */
  31116. static get DetailTextureEnabled(): boolean;
  31117. static set DetailTextureEnabled(value: boolean);
  31118. /**
  31119. * Are ambient textures enabled in the application.
  31120. */
  31121. static get AmbientTextureEnabled(): boolean;
  31122. static set AmbientTextureEnabled(value: boolean);
  31123. /**
  31124. * Are opacity textures enabled in the application.
  31125. */
  31126. static get OpacityTextureEnabled(): boolean;
  31127. static set OpacityTextureEnabled(value: boolean);
  31128. /**
  31129. * Are reflection textures enabled in the application.
  31130. */
  31131. static get ReflectionTextureEnabled(): boolean;
  31132. static set ReflectionTextureEnabled(value: boolean);
  31133. /**
  31134. * Are emissive textures enabled in the application.
  31135. */
  31136. static get EmissiveTextureEnabled(): boolean;
  31137. static set EmissiveTextureEnabled(value: boolean);
  31138. /**
  31139. * Are specular textures enabled in the application.
  31140. */
  31141. static get SpecularTextureEnabled(): boolean;
  31142. static set SpecularTextureEnabled(value: boolean);
  31143. /**
  31144. * Are bump textures enabled in the application.
  31145. */
  31146. static get BumpTextureEnabled(): boolean;
  31147. static set BumpTextureEnabled(value: boolean);
  31148. /**
  31149. * Are lightmap textures enabled in the application.
  31150. */
  31151. static get LightmapTextureEnabled(): boolean;
  31152. static set LightmapTextureEnabled(value: boolean);
  31153. /**
  31154. * Are refraction textures enabled in the application.
  31155. */
  31156. static get RefractionTextureEnabled(): boolean;
  31157. static set RefractionTextureEnabled(value: boolean);
  31158. /**
  31159. * Are color grading textures enabled in the application.
  31160. */
  31161. static get ColorGradingTextureEnabled(): boolean;
  31162. static set ColorGradingTextureEnabled(value: boolean);
  31163. /**
  31164. * Are fresnels enabled in the application.
  31165. */
  31166. static get FresnelEnabled(): boolean;
  31167. static set FresnelEnabled(value: boolean);
  31168. }
  31169. }
  31170. declare module BABYLON {
  31171. /**
  31172. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31173. *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.
  31174. * The SPS is also a particle system. It provides some methods to manage the particles.
  31175. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31176. *
  31177. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31178. */
  31179. export class SolidParticleSystem implements IDisposable {
  31180. /**
  31181. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31182. * Example : var p = SPS.particles[i];
  31183. */
  31184. particles: SolidParticle[];
  31185. /**
  31186. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31187. */
  31188. nbParticles: number;
  31189. /**
  31190. * If the particles must ever face the camera (default false). Useful for planar particles.
  31191. */
  31192. billboard: boolean;
  31193. /**
  31194. * Recompute normals when adding a shape
  31195. */
  31196. recomputeNormals: boolean;
  31197. /**
  31198. * This a counter ofr your own usage. It's not set by any SPS functions.
  31199. */
  31200. counter: number;
  31201. /**
  31202. * The SPS name. This name is also given to the underlying mesh.
  31203. */
  31204. name: string;
  31205. /**
  31206. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31207. */
  31208. mesh: Mesh;
  31209. /**
  31210. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31211. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31212. */
  31213. vars: any;
  31214. /**
  31215. * This array is populated when the SPS is set as 'pickable'.
  31216. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31217. * Each element of this array is an object `{idx: int, faceId: int}`.
  31218. * `idx` is the picked particle index in the `SPS.particles` array
  31219. * `faceId` is the picked face index counted within this particle.
  31220. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31221. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31222. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31223. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31224. */
  31225. pickedParticles: {
  31226. idx: number;
  31227. faceId: number;
  31228. }[];
  31229. /**
  31230. * This array is populated when the SPS is set as 'pickable'
  31231. * Each key of this array is a submesh index.
  31232. * Each element of this array is a second array defined like this :
  31233. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31234. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31235. * `idx` is the picked particle index in the `SPS.particles` array
  31236. * `faceId` is the picked face index counted within this particle.
  31237. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31238. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31239. */
  31240. pickedBySubMesh: {
  31241. idx: number;
  31242. faceId: number;
  31243. }[][];
  31244. /**
  31245. * This array is populated when `enableDepthSort` is set to true.
  31246. * Each element of this array is an instance of the class DepthSortedParticle.
  31247. */
  31248. depthSortedParticles: DepthSortedParticle[];
  31249. /**
  31250. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31251. * @hidden
  31252. */
  31253. _bSphereOnly: boolean;
  31254. /**
  31255. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31256. * @hidden
  31257. */
  31258. _bSphereRadiusFactor: number;
  31259. private _scene;
  31260. private _positions;
  31261. private _indices;
  31262. private _normals;
  31263. private _colors;
  31264. private _uvs;
  31265. private _indices32;
  31266. private _positions32;
  31267. private _normals32;
  31268. private _fixedNormal32;
  31269. private _colors32;
  31270. private _uvs32;
  31271. private _index;
  31272. private _updatable;
  31273. private _pickable;
  31274. private _isVisibilityBoxLocked;
  31275. private _alwaysVisible;
  31276. private _depthSort;
  31277. private _expandable;
  31278. private _shapeCounter;
  31279. private _copy;
  31280. private _color;
  31281. private _computeParticleColor;
  31282. private _computeParticleTexture;
  31283. private _computeParticleRotation;
  31284. private _computeParticleVertex;
  31285. private _computeBoundingBox;
  31286. private _depthSortParticles;
  31287. private _camera;
  31288. private _mustUnrotateFixedNormals;
  31289. private _particlesIntersect;
  31290. private _needs32Bits;
  31291. private _isNotBuilt;
  31292. private _lastParticleId;
  31293. private _idxOfId;
  31294. private _multimaterialEnabled;
  31295. private _useModelMaterial;
  31296. private _indicesByMaterial;
  31297. private _materialIndexes;
  31298. private _depthSortFunction;
  31299. private _materialSortFunction;
  31300. private _materials;
  31301. private _multimaterial;
  31302. private _materialIndexesById;
  31303. private _defaultMaterial;
  31304. private _autoUpdateSubMeshes;
  31305. private _tmpVertex;
  31306. /**
  31307. * Creates a SPS (Solid Particle System) object.
  31308. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31309. * @param scene (Scene) is the scene in which the SPS is added.
  31310. * @param options defines the options of the sps e.g.
  31311. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31312. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31313. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31314. * * 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.
  31315. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31316. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31317. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31318. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31319. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31320. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31321. */
  31322. constructor(name: string, scene: Scene, options?: {
  31323. updatable?: boolean;
  31324. isPickable?: boolean;
  31325. enableDepthSort?: boolean;
  31326. particleIntersection?: boolean;
  31327. boundingSphereOnly?: boolean;
  31328. bSphereRadiusFactor?: number;
  31329. expandable?: boolean;
  31330. useModelMaterial?: boolean;
  31331. enableMultiMaterial?: boolean;
  31332. });
  31333. /**
  31334. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31335. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31336. * @returns the created mesh
  31337. */
  31338. buildMesh(): Mesh;
  31339. /**
  31340. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31341. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31342. * Thus the particles generated from `digest()` have their property `position` set yet.
  31343. * @param mesh ( Mesh ) is the mesh to be digested
  31344. * @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
  31345. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31346. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31347. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31348. * @returns the current SPS
  31349. */
  31350. digest(mesh: Mesh, options?: {
  31351. facetNb?: number;
  31352. number?: number;
  31353. delta?: number;
  31354. storage?: [];
  31355. }): SolidParticleSystem;
  31356. /**
  31357. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31358. * @hidden
  31359. */
  31360. private _unrotateFixedNormals;
  31361. /**
  31362. * Resets the temporary working copy particle
  31363. * @hidden
  31364. */
  31365. private _resetCopy;
  31366. /**
  31367. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31368. * @param p the current index in the positions array to be updated
  31369. * @param ind the current index in the indices array
  31370. * @param shape a Vector3 array, the shape geometry
  31371. * @param positions the positions array to be updated
  31372. * @param meshInd the shape indices array
  31373. * @param indices the indices array to be updated
  31374. * @param meshUV the shape uv array
  31375. * @param uvs the uv array to be updated
  31376. * @param meshCol the shape color array
  31377. * @param colors the color array to be updated
  31378. * @param meshNor the shape normals array
  31379. * @param normals the normals array to be updated
  31380. * @param idx the particle index
  31381. * @param idxInShape the particle index in its shape
  31382. * @param options the addShape() method passed options
  31383. * @model the particle model
  31384. * @hidden
  31385. */
  31386. private _meshBuilder;
  31387. /**
  31388. * Returns a shape Vector3 array from positions float array
  31389. * @param positions float array
  31390. * @returns a vector3 array
  31391. * @hidden
  31392. */
  31393. private _posToShape;
  31394. /**
  31395. * Returns a shapeUV array from a float uvs (array deep copy)
  31396. * @param uvs as a float array
  31397. * @returns a shapeUV array
  31398. * @hidden
  31399. */
  31400. private _uvsToShapeUV;
  31401. /**
  31402. * Adds a new particle object in the particles array
  31403. * @param idx particle index in particles array
  31404. * @param id particle id
  31405. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31406. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31407. * @param model particle ModelShape object
  31408. * @param shapeId model shape identifier
  31409. * @param idxInShape index of the particle in the current model
  31410. * @param bInfo model bounding info object
  31411. * @param storage target storage array, if any
  31412. * @hidden
  31413. */
  31414. private _addParticle;
  31415. /**
  31416. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31417. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31418. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31419. * @param nb (positive integer) the number of particles to be created from this model
  31420. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31421. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31422. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31423. * @returns the number of shapes in the system
  31424. */
  31425. addShape(mesh: Mesh, nb: number, options?: {
  31426. positionFunction?: any;
  31427. vertexFunction?: any;
  31428. storage?: [];
  31429. }): number;
  31430. /**
  31431. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31432. * @hidden
  31433. */
  31434. private _rebuildParticle;
  31435. /**
  31436. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31437. * @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.
  31438. * @returns the SPS.
  31439. */
  31440. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31441. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31442. * Returns an array with the removed particles.
  31443. * 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.
  31444. * The SPS can't be empty so at least one particle needs to remain in place.
  31445. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31446. * @param start index of the first particle to remove
  31447. * @param end index of the last particle to remove (included)
  31448. * @returns an array populated with the removed particles
  31449. */
  31450. removeParticles(start: number, end: number): SolidParticle[];
  31451. /**
  31452. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31453. * @param solidParticleArray an array populated with Solid Particles objects
  31454. * @returns the SPS
  31455. */
  31456. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31457. /**
  31458. * Creates a new particle and modifies the SPS mesh geometry :
  31459. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31460. * - calls _addParticle() to populate the particle array
  31461. * factorized code from addShape() and insertParticlesFromArray()
  31462. * @param idx particle index in the particles array
  31463. * @param i particle index in its shape
  31464. * @param modelShape particle ModelShape object
  31465. * @param shape shape vertex array
  31466. * @param meshInd shape indices array
  31467. * @param meshUV shape uv array
  31468. * @param meshCol shape color array
  31469. * @param meshNor shape normals array
  31470. * @param bbInfo shape bounding info
  31471. * @param storage target particle storage
  31472. * @options addShape() passed options
  31473. * @hidden
  31474. */
  31475. private _insertNewParticle;
  31476. /**
  31477. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31478. * This method calls `updateParticle()` for each particle of the SPS.
  31479. * For an animated SPS, it is usually called within the render loop.
  31480. * 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.
  31481. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31482. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31483. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31484. * @returns the SPS.
  31485. */
  31486. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31487. /**
  31488. * Disposes the SPS.
  31489. */
  31490. dispose(): void;
  31491. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31492. * idx is the particle index in the SPS
  31493. * faceId is the picked face index counted within this particle.
  31494. * Returns null if the pickInfo can't identify a picked particle.
  31495. * @param pickingInfo (PickingInfo object)
  31496. * @returns {idx: number, faceId: number} or null
  31497. */
  31498. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31499. idx: number;
  31500. faceId: number;
  31501. }>;
  31502. /**
  31503. * Returns a SolidParticle object from its identifier : particle.id
  31504. * @param id (integer) the particle Id
  31505. * @returns the searched particle or null if not found in the SPS.
  31506. */
  31507. getParticleById(id: number): Nullable<SolidParticle>;
  31508. /**
  31509. * Returns a new array populated with the particles having the passed shapeId.
  31510. * @param shapeId (integer) the shape identifier
  31511. * @returns a new solid particle array
  31512. */
  31513. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31514. /**
  31515. * Populates the passed array "ref" with the particles having the passed shapeId.
  31516. * @param shapeId the shape identifier
  31517. * @returns the SPS
  31518. * @param ref
  31519. */
  31520. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31521. /**
  31522. * Computes the required SubMeshes according the materials assigned to the particles.
  31523. * @returns the solid particle system.
  31524. * Does nothing if called before the SPS mesh is built.
  31525. */
  31526. computeSubMeshes(): SolidParticleSystem;
  31527. /**
  31528. * Sorts the solid particles by material when MultiMaterial is enabled.
  31529. * Updates the indices32 array.
  31530. * Updates the indicesByMaterial array.
  31531. * Updates the mesh indices array.
  31532. * @returns the SPS
  31533. * @hidden
  31534. */
  31535. private _sortParticlesByMaterial;
  31536. /**
  31537. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31538. * @hidden
  31539. */
  31540. private _setMaterialIndexesById;
  31541. /**
  31542. * Returns an array with unique values of Materials from the passed array
  31543. * @param array the material array to be checked and filtered
  31544. * @hidden
  31545. */
  31546. private _filterUniqueMaterialId;
  31547. /**
  31548. * Sets a new Standard Material as _defaultMaterial if not already set.
  31549. * @hidden
  31550. */
  31551. private _setDefaultMaterial;
  31552. /**
  31553. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31554. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31555. * @returns the SPS.
  31556. */
  31557. refreshVisibleSize(): SolidParticleSystem;
  31558. /**
  31559. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31560. * @param size the size (float) of the visibility box
  31561. * note : this doesn't lock the SPS mesh bounding box.
  31562. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31563. */
  31564. setVisibilityBox(size: number): void;
  31565. /**
  31566. * Gets whether the SPS as always visible or not
  31567. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31568. */
  31569. get isAlwaysVisible(): boolean;
  31570. /**
  31571. * Sets the SPS as always visible or not
  31572. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31573. */
  31574. set isAlwaysVisible(val: boolean);
  31575. /**
  31576. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31577. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31578. */
  31579. set isVisibilityBoxLocked(val: boolean);
  31580. /**
  31581. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31582. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31583. */
  31584. get isVisibilityBoxLocked(): boolean;
  31585. /**
  31586. * Tells to `setParticles()` to compute the particle rotations or not.
  31587. * Default value : true. The SPS is faster when it's set to false.
  31588. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31589. */
  31590. set computeParticleRotation(val: boolean);
  31591. /**
  31592. * Tells to `setParticles()` to compute the particle colors or not.
  31593. * Default value : true. The SPS is faster when it's set to false.
  31594. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31595. */
  31596. set computeParticleColor(val: boolean);
  31597. set computeParticleTexture(val: boolean);
  31598. /**
  31599. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31600. * Default value : false. The SPS is faster when it's set to false.
  31601. * Note : the particle custom vertex positions aren't stored values.
  31602. */
  31603. set computeParticleVertex(val: boolean);
  31604. /**
  31605. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31606. */
  31607. set computeBoundingBox(val: boolean);
  31608. /**
  31609. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31610. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31611. * Default : `true`
  31612. */
  31613. set depthSortParticles(val: boolean);
  31614. /**
  31615. * Gets if `setParticles()` computes the particle rotations or not.
  31616. * Default value : true. The SPS is faster when it's set to false.
  31617. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31618. */
  31619. get computeParticleRotation(): boolean;
  31620. /**
  31621. * Gets if `setParticles()` computes the particle colors or not.
  31622. * Default value : true. The SPS is faster when it's set to false.
  31623. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31624. */
  31625. get computeParticleColor(): boolean;
  31626. /**
  31627. * Gets if `setParticles()` computes the particle textures or not.
  31628. * Default value : true. The SPS is faster when it's set to false.
  31629. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31630. */
  31631. get computeParticleTexture(): boolean;
  31632. /**
  31633. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31634. * Default value : false. The SPS is faster when it's set to false.
  31635. * Note : the particle custom vertex positions aren't stored values.
  31636. */
  31637. get computeParticleVertex(): boolean;
  31638. /**
  31639. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31640. */
  31641. get computeBoundingBox(): boolean;
  31642. /**
  31643. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31644. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31645. * Default : `true`
  31646. */
  31647. get depthSortParticles(): boolean;
  31648. /**
  31649. * Gets if the SPS is created as expandable at construction time.
  31650. * Default : `false`
  31651. */
  31652. get expandable(): boolean;
  31653. /**
  31654. * Gets if the SPS supports the Multi Materials
  31655. */
  31656. get multimaterialEnabled(): boolean;
  31657. /**
  31658. * Gets if the SPS uses the model materials for its own multimaterial.
  31659. */
  31660. get useModelMaterial(): boolean;
  31661. /**
  31662. * The SPS used material array.
  31663. */
  31664. get materials(): Material[];
  31665. /**
  31666. * Sets the SPS MultiMaterial from the passed materials.
  31667. * Note : the passed array is internally copied and not used then by reference.
  31668. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31669. */
  31670. setMultiMaterial(materials: Material[]): void;
  31671. /**
  31672. * The SPS computed multimaterial object
  31673. */
  31674. get multimaterial(): MultiMaterial;
  31675. set multimaterial(mm: MultiMaterial);
  31676. /**
  31677. * If the subMeshes must be updated on the next call to setParticles()
  31678. */
  31679. get autoUpdateSubMeshes(): boolean;
  31680. set autoUpdateSubMeshes(val: boolean);
  31681. /**
  31682. * This function does nothing. It may be overwritten to set all the particle first values.
  31683. * The SPS doesn't call this function, you may have to call it by your own.
  31684. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31685. */
  31686. initParticles(): void;
  31687. /**
  31688. * This function does nothing. It may be overwritten to recycle a particle.
  31689. * The SPS doesn't call this function, you may have to call it by your own.
  31690. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31691. * @param particle The particle to recycle
  31692. * @returns the recycled particle
  31693. */
  31694. recycleParticle(particle: SolidParticle): SolidParticle;
  31695. /**
  31696. * Updates a particle : this function should be overwritten by the user.
  31697. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31698. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31699. * @example : just set a particle position or velocity and recycle conditions
  31700. * @param particle The particle to update
  31701. * @returns the updated particle
  31702. */
  31703. updateParticle(particle: SolidParticle): SolidParticle;
  31704. /**
  31705. * Updates a vertex of a particle : it can be overwritten by the user.
  31706. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31707. * @param particle the current particle
  31708. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31709. * @param pt the index of the current vertex in the particle shape
  31710. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31711. * @example : just set a vertex particle position or color
  31712. * @returns the sps
  31713. */
  31714. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31715. /**
  31716. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31717. * This does nothing and may be overwritten by the user.
  31718. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31719. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31720. * @param update the boolean update value actually passed to setParticles()
  31721. */
  31722. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31723. /**
  31724. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31725. * This will be passed three parameters.
  31726. * This does nothing and may be overwritten by the user.
  31727. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31728. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31729. * @param update the boolean update value actually passed to setParticles()
  31730. */
  31731. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31732. }
  31733. }
  31734. declare module BABYLON {
  31735. /**
  31736. * Represents one particle of a solid particle system.
  31737. */
  31738. export class SolidParticle {
  31739. /**
  31740. * particle global index
  31741. */
  31742. idx: number;
  31743. /**
  31744. * particle identifier
  31745. */
  31746. id: number;
  31747. /**
  31748. * The color of the particle
  31749. */
  31750. color: Nullable<Color4>;
  31751. /**
  31752. * The world space position of the particle.
  31753. */
  31754. position: Vector3;
  31755. /**
  31756. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31757. */
  31758. rotation: Vector3;
  31759. /**
  31760. * The world space rotation quaternion of the particle.
  31761. */
  31762. rotationQuaternion: Nullable<Quaternion>;
  31763. /**
  31764. * The scaling of the particle.
  31765. */
  31766. scaling: Vector3;
  31767. /**
  31768. * The uvs of the particle.
  31769. */
  31770. uvs: Vector4;
  31771. /**
  31772. * The current speed of the particle.
  31773. */
  31774. velocity: Vector3;
  31775. /**
  31776. * The pivot point in the particle local space.
  31777. */
  31778. pivot: Vector3;
  31779. /**
  31780. * Must the particle be translated from its pivot point in its local space ?
  31781. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31782. * Default : false
  31783. */
  31784. translateFromPivot: boolean;
  31785. /**
  31786. * Is the particle active or not ?
  31787. */
  31788. alive: boolean;
  31789. /**
  31790. * Is the particle visible or not ?
  31791. */
  31792. isVisible: boolean;
  31793. /**
  31794. * Index of this particle in the global "positions" array (Internal use)
  31795. * @hidden
  31796. */
  31797. _pos: number;
  31798. /**
  31799. * @hidden Index of this particle in the global "indices" array (Internal use)
  31800. */
  31801. _ind: number;
  31802. /**
  31803. * @hidden ModelShape of this particle (Internal use)
  31804. */
  31805. _model: ModelShape;
  31806. /**
  31807. * ModelShape id of this particle
  31808. */
  31809. shapeId: number;
  31810. /**
  31811. * Index of the particle in its shape id
  31812. */
  31813. idxInShape: number;
  31814. /**
  31815. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31816. */
  31817. _modelBoundingInfo: BoundingInfo;
  31818. /**
  31819. * @hidden Particle BoundingInfo object (Internal use)
  31820. */
  31821. _boundingInfo: BoundingInfo;
  31822. /**
  31823. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31824. */
  31825. _sps: SolidParticleSystem;
  31826. /**
  31827. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31828. */
  31829. _stillInvisible: boolean;
  31830. /**
  31831. * @hidden Last computed particle rotation matrix
  31832. */
  31833. _rotationMatrix: number[];
  31834. /**
  31835. * Parent particle Id, if any.
  31836. * Default null.
  31837. */
  31838. parentId: Nullable<number>;
  31839. /**
  31840. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31841. */
  31842. materialIndex: Nullable<number>;
  31843. /**
  31844. * Custom object or properties.
  31845. */
  31846. props: Nullable<any>;
  31847. /**
  31848. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31849. * The possible values are :
  31850. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31851. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31852. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31853. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31854. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31855. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31856. * */
  31857. cullingStrategy: number;
  31858. /**
  31859. * @hidden Internal global position in the SPS.
  31860. */
  31861. _globalPosition: Vector3;
  31862. /**
  31863. * Creates a Solid Particle object.
  31864. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31865. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31866. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31867. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31868. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31869. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31870. * @param shapeId (integer) is the model shape identifier in the SPS.
  31871. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31872. * @param sps defines the sps it is associated to
  31873. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31874. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31875. */
  31876. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31877. /**
  31878. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31879. * @param target the particle target
  31880. * @returns the current particle
  31881. */
  31882. copyToRef(target: SolidParticle): SolidParticle;
  31883. /**
  31884. * Legacy support, changed scale to scaling
  31885. */
  31886. get scale(): Vector3;
  31887. /**
  31888. * Legacy support, changed scale to scaling
  31889. */
  31890. set scale(scale: Vector3);
  31891. /**
  31892. * Legacy support, changed quaternion to rotationQuaternion
  31893. */
  31894. get quaternion(): Nullable<Quaternion>;
  31895. /**
  31896. * Legacy support, changed quaternion to rotationQuaternion
  31897. */
  31898. set quaternion(q: Nullable<Quaternion>);
  31899. /**
  31900. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31901. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31902. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31903. * @returns true if it intersects
  31904. */
  31905. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31906. /**
  31907. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31908. * A particle is in the frustum if its bounding box intersects the frustum
  31909. * @param frustumPlanes defines the frustum to test
  31910. * @returns true if the particle is in the frustum planes
  31911. */
  31912. isInFrustum(frustumPlanes: Plane[]): boolean;
  31913. /**
  31914. * get the rotation matrix of the particle
  31915. * @hidden
  31916. */
  31917. getRotationMatrix(m: Matrix): void;
  31918. }
  31919. /**
  31920. * Represents the shape of the model used by one particle of a solid particle system.
  31921. * SPS internal tool, don't use it manually.
  31922. */
  31923. export class ModelShape {
  31924. /**
  31925. * The shape id
  31926. * @hidden
  31927. */
  31928. shapeID: number;
  31929. /**
  31930. * flat array of model positions (internal use)
  31931. * @hidden
  31932. */
  31933. _shape: Vector3[];
  31934. /**
  31935. * flat array of model UVs (internal use)
  31936. * @hidden
  31937. */
  31938. _shapeUV: number[];
  31939. /**
  31940. * color array of the model
  31941. * @hidden
  31942. */
  31943. _shapeColors: number[];
  31944. /**
  31945. * indices array of the model
  31946. * @hidden
  31947. */
  31948. _indices: number[];
  31949. /**
  31950. * normals array of the model
  31951. * @hidden
  31952. */
  31953. _normals: number[];
  31954. /**
  31955. * length of the shape in the model indices array (internal use)
  31956. * @hidden
  31957. */
  31958. _indicesLength: number;
  31959. /**
  31960. * Custom position function (internal use)
  31961. * @hidden
  31962. */
  31963. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31964. /**
  31965. * Custom vertex function (internal use)
  31966. * @hidden
  31967. */
  31968. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31969. /**
  31970. * Model material (internal use)
  31971. * @hidden
  31972. */
  31973. _material: Nullable<Material>;
  31974. /**
  31975. * 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.
  31976. * SPS internal tool, don't use it manually.
  31977. * @hidden
  31978. */
  31979. 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>);
  31980. }
  31981. /**
  31982. * Represents a Depth Sorted Particle in the solid particle system.
  31983. * @hidden
  31984. */
  31985. export class DepthSortedParticle {
  31986. /**
  31987. * Particle index
  31988. */
  31989. idx: number;
  31990. /**
  31991. * Index of the particle in the "indices" array
  31992. */
  31993. ind: number;
  31994. /**
  31995. * Length of the particle shape in the "indices" array
  31996. */
  31997. indicesLength: number;
  31998. /**
  31999. * Squared distance from the particle to the camera
  32000. */
  32001. sqDistance: number;
  32002. /**
  32003. * Material index when used with MultiMaterials
  32004. */
  32005. materialIndex: number;
  32006. /**
  32007. * Creates a new sorted particle
  32008. * @param materialIndex
  32009. */
  32010. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32011. }
  32012. /**
  32013. * Represents a solid particle vertex
  32014. */
  32015. export class SolidParticleVertex {
  32016. /**
  32017. * Vertex position
  32018. */
  32019. position: Vector3;
  32020. /**
  32021. * Vertex color
  32022. */
  32023. color: Color4;
  32024. /**
  32025. * Vertex UV
  32026. */
  32027. uv: Vector2;
  32028. /**
  32029. * Creates a new solid particle vertex
  32030. */
  32031. constructor();
  32032. /** Vertex x coordinate */
  32033. get x(): number;
  32034. set x(val: number);
  32035. /** Vertex y coordinate */
  32036. get y(): number;
  32037. set y(val: number);
  32038. /** Vertex z coordinate */
  32039. get z(): number;
  32040. set z(val: number);
  32041. }
  32042. }
  32043. declare module BABYLON {
  32044. /**
  32045. * @hidden
  32046. */
  32047. export class _MeshCollisionData {
  32048. _checkCollisions: boolean;
  32049. _collisionMask: number;
  32050. _collisionGroup: number;
  32051. _surroundingMeshes: Nullable<AbstractMesh[]>;
  32052. _collider: Nullable<Collider>;
  32053. _oldPositionForCollisions: Vector3;
  32054. _diffPositionForCollisions: Vector3;
  32055. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32056. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32057. _collisionResponse: boolean;
  32058. }
  32059. }
  32060. declare module BABYLON {
  32061. /** @hidden */
  32062. class _FacetDataStorage {
  32063. facetPositions: Vector3[];
  32064. facetNormals: Vector3[];
  32065. facetPartitioning: number[][];
  32066. facetNb: number;
  32067. partitioningSubdivisions: number;
  32068. partitioningBBoxRatio: number;
  32069. facetDataEnabled: boolean;
  32070. facetParameters: any;
  32071. bbSize: Vector3;
  32072. subDiv: {
  32073. max: number;
  32074. X: number;
  32075. Y: number;
  32076. Z: number;
  32077. };
  32078. facetDepthSort: boolean;
  32079. facetDepthSortEnabled: boolean;
  32080. depthSortedIndices: IndicesArray;
  32081. depthSortedFacets: {
  32082. ind: number;
  32083. sqDistance: number;
  32084. }[];
  32085. facetDepthSortFunction: (f1: {
  32086. ind: number;
  32087. sqDistance: number;
  32088. }, f2: {
  32089. ind: number;
  32090. sqDistance: number;
  32091. }) => number;
  32092. facetDepthSortFrom: Vector3;
  32093. facetDepthSortOrigin: Vector3;
  32094. invertedMatrix: Matrix;
  32095. }
  32096. /**
  32097. * @hidden
  32098. **/
  32099. class _InternalAbstractMeshDataInfo {
  32100. _hasVertexAlpha: boolean;
  32101. _useVertexColors: boolean;
  32102. _numBoneInfluencers: number;
  32103. _applyFog: boolean;
  32104. _receiveShadows: boolean;
  32105. _facetData: _FacetDataStorage;
  32106. _visibility: number;
  32107. _skeleton: Nullable<Skeleton>;
  32108. _layerMask: number;
  32109. _computeBonesUsingShaders: boolean;
  32110. _isActive: boolean;
  32111. _onlyForInstances: boolean;
  32112. _isActiveIntermediate: boolean;
  32113. _onlyForInstancesIntermediate: boolean;
  32114. _actAsRegularMesh: boolean;
  32115. }
  32116. /**
  32117. * Class used to store all common mesh properties
  32118. */
  32119. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32120. /** No occlusion */
  32121. static OCCLUSION_TYPE_NONE: number;
  32122. /** Occlusion set to optimisitic */
  32123. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32124. /** Occlusion set to strict */
  32125. static OCCLUSION_TYPE_STRICT: number;
  32126. /** Use an accurante occlusion algorithm */
  32127. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32128. /** Use a conservative occlusion algorithm */
  32129. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32130. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32131. * Test order :
  32132. * Is the bounding sphere outside the frustum ?
  32133. * If not, are the bounding box vertices outside the frustum ?
  32134. * It not, then the cullable object is in the frustum.
  32135. */
  32136. static readonly CULLINGSTRATEGY_STANDARD: number;
  32137. /** Culling strategy : Bounding Sphere Only.
  32138. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32139. * It's also less accurate than the standard because some not visible objects can still be selected.
  32140. * Test : is the bounding sphere outside the frustum ?
  32141. * If not, then the cullable object is in the frustum.
  32142. */
  32143. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32144. /** Culling strategy : Optimistic Inclusion.
  32145. * This in an inclusion test first, then the standard exclusion test.
  32146. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32147. * 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.
  32148. * Anyway, it's as accurate as the standard strategy.
  32149. * Test :
  32150. * Is the cullable object bounding sphere center in the frustum ?
  32151. * If not, apply the default culling strategy.
  32152. */
  32153. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32154. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32155. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32156. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32157. * 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.
  32158. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32159. * Test :
  32160. * Is the cullable object bounding sphere center in the frustum ?
  32161. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32162. */
  32163. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32164. /**
  32165. * No billboard
  32166. */
  32167. static get BILLBOARDMODE_NONE(): number;
  32168. /** Billboard on X axis */
  32169. static get BILLBOARDMODE_X(): number;
  32170. /** Billboard on Y axis */
  32171. static get BILLBOARDMODE_Y(): number;
  32172. /** Billboard on Z axis */
  32173. static get BILLBOARDMODE_Z(): number;
  32174. /** Billboard on all axes */
  32175. static get BILLBOARDMODE_ALL(): number;
  32176. /** Billboard on using position instead of orientation */
  32177. static get BILLBOARDMODE_USE_POSITION(): number;
  32178. /** @hidden */
  32179. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32180. /**
  32181. * The culling strategy to use to check whether the mesh must be rendered or not.
  32182. * This value can be changed at any time and will be used on the next render mesh selection.
  32183. * The possible values are :
  32184. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32185. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32186. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32187. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32188. * Please read each static variable documentation to get details about the culling process.
  32189. * */
  32190. cullingStrategy: number;
  32191. /**
  32192. * Gets the number of facets in the mesh
  32193. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32194. */
  32195. get facetNb(): number;
  32196. /**
  32197. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32198. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32199. */
  32200. get partitioningSubdivisions(): number;
  32201. set partitioningSubdivisions(nb: number);
  32202. /**
  32203. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32204. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32205. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32206. */
  32207. get partitioningBBoxRatio(): number;
  32208. set partitioningBBoxRatio(ratio: number);
  32209. /**
  32210. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32211. * Works only for updatable meshes.
  32212. * Doesn't work with multi-materials
  32213. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32214. */
  32215. get mustDepthSortFacets(): boolean;
  32216. set mustDepthSortFacets(sort: boolean);
  32217. /**
  32218. * The location (Vector3) where the facet depth sort must be computed from.
  32219. * By default, the active camera position.
  32220. * Used only when facet depth sort is enabled
  32221. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32222. */
  32223. get facetDepthSortFrom(): Vector3;
  32224. set facetDepthSortFrom(location: Vector3);
  32225. /**
  32226. * gets a boolean indicating if facetData is enabled
  32227. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32228. */
  32229. get isFacetDataEnabled(): boolean;
  32230. /** @hidden */
  32231. _updateNonUniformScalingState(value: boolean): boolean;
  32232. /**
  32233. * An event triggered when this mesh collides with another one
  32234. */
  32235. onCollideObservable: Observable<AbstractMesh>;
  32236. /** Set a function to call when this mesh collides with another one */
  32237. set onCollide(callback: () => void);
  32238. /**
  32239. * An event triggered when the collision's position changes
  32240. */
  32241. onCollisionPositionChangeObservable: Observable<Vector3>;
  32242. /** Set a function to call when the collision's position changes */
  32243. set onCollisionPositionChange(callback: () => void);
  32244. /**
  32245. * An event triggered when material is changed
  32246. */
  32247. onMaterialChangedObservable: Observable<AbstractMesh>;
  32248. /**
  32249. * Gets or sets the orientation for POV movement & rotation
  32250. */
  32251. definedFacingForward: boolean;
  32252. /** @hidden */
  32253. _occlusionQuery: Nullable<WebGLQuery>;
  32254. /** @hidden */
  32255. _renderingGroup: Nullable<RenderingGroup>;
  32256. /**
  32257. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32258. */
  32259. get visibility(): number;
  32260. /**
  32261. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32262. */
  32263. set visibility(value: number);
  32264. /** Gets or sets the alpha index used to sort transparent meshes
  32265. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32266. */
  32267. alphaIndex: number;
  32268. /**
  32269. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32270. */
  32271. isVisible: boolean;
  32272. /**
  32273. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32274. */
  32275. isPickable: boolean;
  32276. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32277. showSubMeshesBoundingBox: boolean;
  32278. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32279. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32280. */
  32281. isBlocker: boolean;
  32282. /**
  32283. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32284. */
  32285. enablePointerMoveEvents: boolean;
  32286. private _renderingGroupId;
  32287. /**
  32288. * Specifies the rendering group id for this mesh (0 by default)
  32289. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32290. */
  32291. get renderingGroupId(): number;
  32292. set renderingGroupId(value: number);
  32293. private _material;
  32294. /** Gets or sets current material */
  32295. get material(): Nullable<Material>;
  32296. set material(value: Nullable<Material>);
  32297. /**
  32298. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32299. * @see https://doc.babylonjs.com/babylon101/shadows
  32300. */
  32301. get receiveShadows(): boolean;
  32302. set receiveShadows(value: boolean);
  32303. /** Defines color to use when rendering outline */
  32304. outlineColor: Color3;
  32305. /** Define width to use when rendering outline */
  32306. outlineWidth: number;
  32307. /** Defines color to use when rendering overlay */
  32308. overlayColor: Color3;
  32309. /** Defines alpha to use when rendering overlay */
  32310. overlayAlpha: number;
  32311. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32312. get hasVertexAlpha(): boolean;
  32313. set hasVertexAlpha(value: boolean);
  32314. /** 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) */
  32315. get useVertexColors(): boolean;
  32316. set useVertexColors(value: boolean);
  32317. /**
  32318. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32319. */
  32320. get computeBonesUsingShaders(): boolean;
  32321. set computeBonesUsingShaders(value: boolean);
  32322. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32323. get numBoneInfluencers(): number;
  32324. set numBoneInfluencers(value: number);
  32325. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32326. get applyFog(): boolean;
  32327. set applyFog(value: boolean);
  32328. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32329. useOctreeForRenderingSelection: boolean;
  32330. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32331. useOctreeForPicking: boolean;
  32332. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32333. useOctreeForCollisions: boolean;
  32334. /**
  32335. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32336. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32337. */
  32338. get layerMask(): number;
  32339. set layerMask(value: number);
  32340. /**
  32341. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32342. */
  32343. alwaysSelectAsActiveMesh: boolean;
  32344. /**
  32345. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32346. */
  32347. doNotSyncBoundingInfo: boolean;
  32348. /**
  32349. * Gets or sets the current action manager
  32350. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32351. */
  32352. actionManager: Nullable<AbstractActionManager>;
  32353. private _meshCollisionData;
  32354. /**
  32355. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32356. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32357. */
  32358. ellipsoid: Vector3;
  32359. /**
  32360. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32361. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32362. */
  32363. ellipsoidOffset: Vector3;
  32364. /**
  32365. * Gets or sets a collision mask used to mask collisions (default is -1).
  32366. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32367. */
  32368. get collisionMask(): number;
  32369. set collisionMask(mask: number);
  32370. /**
  32371. * Gets or sets a collision response flag (default is true).
  32372. * when collisionResponse is false, events are still triggered but colliding entity has no response
  32373. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  32374. * to respond to the collision.
  32375. */
  32376. get collisionResponse(): boolean;
  32377. set collisionResponse(response: boolean);
  32378. /**
  32379. * Gets or sets the current collision group mask (-1 by default).
  32380. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32381. */
  32382. get collisionGroup(): number;
  32383. set collisionGroup(mask: number);
  32384. /**
  32385. * Gets or sets current surrounding meshes (null by default).
  32386. *
  32387. * By default collision detection is tested against every mesh in the scene.
  32388. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32389. * meshes will be tested for the collision.
  32390. *
  32391. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32392. */
  32393. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32394. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32395. /**
  32396. * Defines edge width used when edgesRenderer is enabled
  32397. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32398. */
  32399. edgesWidth: number;
  32400. /**
  32401. * Defines edge color used when edgesRenderer is enabled
  32402. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32403. */
  32404. edgesColor: Color4;
  32405. /** @hidden */
  32406. _edgesRenderer: Nullable<IEdgesRenderer>;
  32407. /** @hidden */
  32408. _masterMesh: Nullable<AbstractMesh>;
  32409. /** @hidden */
  32410. _boundingInfo: Nullable<BoundingInfo>;
  32411. /** @hidden */
  32412. _renderId: number;
  32413. /**
  32414. * Gets or sets the list of subMeshes
  32415. * @see https://doc.babylonjs.com/how_to/multi_materials
  32416. */
  32417. subMeshes: SubMesh[];
  32418. /** @hidden */
  32419. _intersectionsInProgress: AbstractMesh[];
  32420. /** @hidden */
  32421. _unIndexed: boolean;
  32422. /** @hidden */
  32423. _lightSources: Light[];
  32424. /** Gets the list of lights affecting that mesh */
  32425. get lightSources(): Light[];
  32426. /** @hidden */
  32427. get _positions(): Nullable<Vector3[]>;
  32428. /** @hidden */
  32429. _waitingData: {
  32430. lods: Nullable<any>;
  32431. actions: Nullable<any>;
  32432. freezeWorldMatrix: Nullable<boolean>;
  32433. };
  32434. /** @hidden */
  32435. _bonesTransformMatrices: Nullable<Float32Array>;
  32436. /** @hidden */
  32437. _transformMatrixTexture: Nullable<RawTexture>;
  32438. /**
  32439. * Gets or sets a skeleton to apply skining transformations
  32440. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32441. */
  32442. set skeleton(value: Nullable<Skeleton>);
  32443. get skeleton(): Nullable<Skeleton>;
  32444. /**
  32445. * An event triggered when the mesh is rebuilt.
  32446. */
  32447. onRebuildObservable: Observable<AbstractMesh>;
  32448. /**
  32449. * Creates a new AbstractMesh
  32450. * @param name defines the name of the mesh
  32451. * @param scene defines the hosting scene
  32452. */
  32453. constructor(name: string, scene?: Nullable<Scene>);
  32454. /**
  32455. * Returns the string "AbstractMesh"
  32456. * @returns "AbstractMesh"
  32457. */
  32458. getClassName(): string;
  32459. /**
  32460. * Gets a string representation of the current mesh
  32461. * @param fullDetails defines a boolean indicating if full details must be included
  32462. * @returns a string representation of the current mesh
  32463. */
  32464. toString(fullDetails?: boolean): string;
  32465. /**
  32466. * @hidden
  32467. */
  32468. protected _getEffectiveParent(): Nullable<Node>;
  32469. /** @hidden */
  32470. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32471. /** @hidden */
  32472. _rebuild(): void;
  32473. /** @hidden */
  32474. _resyncLightSources(): void;
  32475. /** @hidden */
  32476. _resyncLightSource(light: Light): void;
  32477. /** @hidden */
  32478. _unBindEffect(): void;
  32479. /** @hidden */
  32480. _removeLightSource(light: Light, dispose: boolean): void;
  32481. private _markSubMeshesAsDirty;
  32482. /** @hidden */
  32483. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32484. /** @hidden */
  32485. _markSubMeshesAsAttributesDirty(): void;
  32486. /** @hidden */
  32487. _markSubMeshesAsMiscDirty(): void;
  32488. /**
  32489. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32490. */
  32491. get scaling(): Vector3;
  32492. set scaling(newScaling: Vector3);
  32493. /**
  32494. * Returns true if the mesh is blocked. Implemented by child classes
  32495. */
  32496. get isBlocked(): boolean;
  32497. /**
  32498. * Returns the mesh itself by default. Implemented by child classes
  32499. * @param camera defines the camera to use to pick the right LOD level
  32500. * @returns the currentAbstractMesh
  32501. */
  32502. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32503. /**
  32504. * Returns 0 by default. Implemented by child classes
  32505. * @returns an integer
  32506. */
  32507. getTotalVertices(): number;
  32508. /**
  32509. * Returns a positive integer : the total number of indices in this mesh geometry.
  32510. * @returns the numner of indices or zero if the mesh has no geometry.
  32511. */
  32512. getTotalIndices(): number;
  32513. /**
  32514. * Returns null by default. Implemented by child classes
  32515. * @returns null
  32516. */
  32517. getIndices(): Nullable<IndicesArray>;
  32518. /**
  32519. * Returns the array of the requested vertex data kind. Implemented by child classes
  32520. * @param kind defines the vertex data kind to use
  32521. * @returns null
  32522. */
  32523. getVerticesData(kind: string): Nullable<FloatArray>;
  32524. /**
  32525. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32526. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32527. * Note that a new underlying VertexBuffer object is created each call.
  32528. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32529. * @param kind defines vertex data kind:
  32530. * * VertexBuffer.PositionKind
  32531. * * VertexBuffer.UVKind
  32532. * * VertexBuffer.UV2Kind
  32533. * * VertexBuffer.UV3Kind
  32534. * * VertexBuffer.UV4Kind
  32535. * * VertexBuffer.UV5Kind
  32536. * * VertexBuffer.UV6Kind
  32537. * * VertexBuffer.ColorKind
  32538. * * VertexBuffer.MatricesIndicesKind
  32539. * * VertexBuffer.MatricesIndicesExtraKind
  32540. * * VertexBuffer.MatricesWeightsKind
  32541. * * VertexBuffer.MatricesWeightsExtraKind
  32542. * @param data defines the data source
  32543. * @param updatable defines if the data must be flagged as updatable (or static)
  32544. * @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
  32545. * @returns the current mesh
  32546. */
  32547. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32548. /**
  32549. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32550. * If the mesh has no geometry, it is simply returned as it is.
  32551. * @param kind defines vertex data kind:
  32552. * * VertexBuffer.PositionKind
  32553. * * VertexBuffer.UVKind
  32554. * * VertexBuffer.UV2Kind
  32555. * * VertexBuffer.UV3Kind
  32556. * * VertexBuffer.UV4Kind
  32557. * * VertexBuffer.UV5Kind
  32558. * * VertexBuffer.UV6Kind
  32559. * * VertexBuffer.ColorKind
  32560. * * VertexBuffer.MatricesIndicesKind
  32561. * * VertexBuffer.MatricesIndicesExtraKind
  32562. * * VertexBuffer.MatricesWeightsKind
  32563. * * VertexBuffer.MatricesWeightsExtraKind
  32564. * @param data defines the data source
  32565. * @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
  32566. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32567. * @returns the current mesh
  32568. */
  32569. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32570. /**
  32571. * Sets the mesh indices,
  32572. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32573. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32574. * @param totalVertices Defines the total number of vertices
  32575. * @returns the current mesh
  32576. */
  32577. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32578. /**
  32579. * Gets a boolean indicating if specific vertex data is present
  32580. * @param kind defines the vertex data kind to use
  32581. * @returns true is data kind is present
  32582. */
  32583. isVerticesDataPresent(kind: string): boolean;
  32584. /**
  32585. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32586. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32587. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32588. * @returns a BoundingInfo
  32589. */
  32590. getBoundingInfo(): BoundingInfo;
  32591. /**
  32592. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32593. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32594. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32595. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32596. * @returns the current mesh
  32597. */
  32598. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32599. /**
  32600. * Overwrite the current bounding info
  32601. * @param boundingInfo defines the new bounding info
  32602. * @returns the current mesh
  32603. */
  32604. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32605. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32606. get useBones(): boolean;
  32607. /** @hidden */
  32608. _preActivate(): void;
  32609. /** @hidden */
  32610. _preActivateForIntermediateRendering(renderId: number): void;
  32611. /** @hidden */
  32612. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32613. /** @hidden */
  32614. _postActivate(): void;
  32615. /** @hidden */
  32616. _freeze(): void;
  32617. /** @hidden */
  32618. _unFreeze(): void;
  32619. /**
  32620. * Gets the current world matrix
  32621. * @returns a Matrix
  32622. */
  32623. getWorldMatrix(): Matrix;
  32624. /** @hidden */
  32625. _getWorldMatrixDeterminant(): number;
  32626. /**
  32627. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32628. */
  32629. get isAnInstance(): boolean;
  32630. /**
  32631. * Gets a boolean indicating if this mesh has instances
  32632. */
  32633. get hasInstances(): boolean;
  32634. /**
  32635. * Gets a boolean indicating if this mesh has thin instances
  32636. */
  32637. get hasThinInstances(): boolean;
  32638. /**
  32639. * Perform relative position change from the point of view of behind the front of the mesh.
  32640. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32641. * Supports definition of mesh facing forward or backward
  32642. * @param amountRight defines the distance on the right axis
  32643. * @param amountUp defines the distance on the up axis
  32644. * @param amountForward defines the distance on the forward axis
  32645. * @returns the current mesh
  32646. */
  32647. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32648. /**
  32649. * Calculate relative position change from the point of view of behind the front of the mesh.
  32650. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32651. * Supports definition of mesh facing forward or backward
  32652. * @param amountRight defines the distance on the right axis
  32653. * @param amountUp defines the distance on the up axis
  32654. * @param amountForward defines the distance on the forward axis
  32655. * @returns the new displacement vector
  32656. */
  32657. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32658. /**
  32659. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32660. * Supports definition of mesh facing forward or backward
  32661. * @param flipBack defines the flip
  32662. * @param twirlClockwise defines the twirl
  32663. * @param tiltRight defines the tilt
  32664. * @returns the current mesh
  32665. */
  32666. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32667. /**
  32668. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32669. * Supports definition of mesh facing forward or backward.
  32670. * @param flipBack defines the flip
  32671. * @param twirlClockwise defines the twirl
  32672. * @param tiltRight defines the tilt
  32673. * @returns the new rotation vector
  32674. */
  32675. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32676. /**
  32677. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32678. * This means the mesh underlying bounding box and sphere are recomputed.
  32679. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32680. * @returns the current mesh
  32681. */
  32682. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32683. /** @hidden */
  32684. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32685. /** @hidden */
  32686. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32687. /** @hidden */
  32688. _updateBoundingInfo(): AbstractMesh;
  32689. /** @hidden */
  32690. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32691. /** @hidden */
  32692. protected _afterComputeWorldMatrix(): void;
  32693. /** @hidden */
  32694. get _effectiveMesh(): AbstractMesh;
  32695. /**
  32696. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32697. * A mesh is in the frustum if its bounding box intersects the frustum
  32698. * @param frustumPlanes defines the frustum to test
  32699. * @returns true if the mesh is in the frustum planes
  32700. */
  32701. isInFrustum(frustumPlanes: Plane[]): boolean;
  32702. /**
  32703. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32704. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32705. * @param frustumPlanes defines the frustum to test
  32706. * @returns true if the mesh is completely in the frustum planes
  32707. */
  32708. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32709. /**
  32710. * True if the mesh intersects another mesh or a SolidParticle object
  32711. * @param mesh defines a target mesh or SolidParticle to test
  32712. * @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)
  32713. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32714. * @returns true if there is an intersection
  32715. */
  32716. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32717. /**
  32718. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32719. * @param point defines the point to test
  32720. * @returns true if there is an intersection
  32721. */
  32722. intersectsPoint(point: Vector3): boolean;
  32723. /**
  32724. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32725. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32726. */
  32727. get checkCollisions(): boolean;
  32728. set checkCollisions(collisionEnabled: boolean);
  32729. /**
  32730. * Gets Collider object used to compute collisions (not physics)
  32731. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32732. */
  32733. get collider(): Nullable<Collider>;
  32734. /**
  32735. * Move the mesh using collision engine
  32736. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32737. * @param displacement defines the requested displacement vector
  32738. * @returns the current mesh
  32739. */
  32740. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32741. private _onCollisionPositionChange;
  32742. /** @hidden */
  32743. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32744. /** @hidden */
  32745. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32746. /** @hidden */
  32747. _checkCollision(collider: Collider): AbstractMesh;
  32748. /** @hidden */
  32749. _generatePointsArray(): boolean;
  32750. /**
  32751. * Checks if the passed Ray intersects with the mesh
  32752. * @param ray defines the ray to use
  32753. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32754. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32755. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32756. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32757. * @returns the picking info
  32758. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32759. */
  32760. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32761. /**
  32762. * Clones the current mesh
  32763. * @param name defines the mesh name
  32764. * @param newParent defines the new mesh parent
  32765. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32766. * @returns the new mesh
  32767. */
  32768. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32769. /**
  32770. * Disposes all the submeshes of the current meshnp
  32771. * @returns the current mesh
  32772. */
  32773. releaseSubMeshes(): AbstractMesh;
  32774. /**
  32775. * Releases resources associated with this abstract mesh.
  32776. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32777. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32778. */
  32779. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32780. /**
  32781. * Adds the passed mesh as a child to the current mesh
  32782. * @param mesh defines the child mesh
  32783. * @returns the current mesh
  32784. */
  32785. addChild(mesh: AbstractMesh): AbstractMesh;
  32786. /**
  32787. * Removes the passed mesh from the current mesh children list
  32788. * @param mesh defines the child mesh
  32789. * @returns the current mesh
  32790. */
  32791. removeChild(mesh: AbstractMesh): AbstractMesh;
  32792. /** @hidden */
  32793. private _initFacetData;
  32794. /**
  32795. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32796. * This method can be called within the render loop.
  32797. * 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
  32798. * @returns the current mesh
  32799. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32800. */
  32801. updateFacetData(): AbstractMesh;
  32802. /**
  32803. * Returns the facetLocalNormals array.
  32804. * The normals are expressed in the mesh local spac
  32805. * @returns an array of Vector3
  32806. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32807. */
  32808. getFacetLocalNormals(): Vector3[];
  32809. /**
  32810. * Returns the facetLocalPositions array.
  32811. * The facet positions are expressed in the mesh local space
  32812. * @returns an array of Vector3
  32813. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32814. */
  32815. getFacetLocalPositions(): Vector3[];
  32816. /**
  32817. * Returns the facetLocalPartioning array
  32818. * @returns an array of array of numbers
  32819. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32820. */
  32821. getFacetLocalPartitioning(): number[][];
  32822. /**
  32823. * Returns the i-th facet position in the world system.
  32824. * This method allocates a new Vector3 per call
  32825. * @param i defines the facet index
  32826. * @returns a new Vector3
  32827. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32828. */
  32829. getFacetPosition(i: number): Vector3;
  32830. /**
  32831. * Sets the reference Vector3 with the i-th facet position in the world system
  32832. * @param i defines the facet index
  32833. * @param ref defines the target vector
  32834. * @returns the current mesh
  32835. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32836. */
  32837. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32838. /**
  32839. * Returns the i-th facet normal in the world system.
  32840. * This method allocates a new Vector3 per call
  32841. * @param i defines the facet index
  32842. * @returns a new Vector3
  32843. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32844. */
  32845. getFacetNormal(i: number): Vector3;
  32846. /**
  32847. * Sets the reference Vector3 with the i-th facet normal in the world system
  32848. * @param i defines the facet index
  32849. * @param ref defines the target vector
  32850. * @returns the current mesh
  32851. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32852. */
  32853. getFacetNormalToRef(i: number, ref: Vector3): this;
  32854. /**
  32855. * 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)
  32856. * @param x defines x coordinate
  32857. * @param y defines y coordinate
  32858. * @param z defines z coordinate
  32859. * @returns the array of facet indexes
  32860. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32861. */
  32862. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32863. /**
  32864. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32865. * @param projected sets as the (x,y,z) world projection on the facet
  32866. * @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
  32867. * @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
  32868. * @param x defines x coordinate
  32869. * @param y defines y coordinate
  32870. * @param z defines z coordinate
  32871. * @returns the face index if found (or null instead)
  32872. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32873. */
  32874. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32875. /**
  32876. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32877. * @param projected sets as the (x,y,z) local projection on the facet
  32878. * @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
  32879. * @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
  32880. * @param x defines x coordinate
  32881. * @param y defines y coordinate
  32882. * @param z defines z coordinate
  32883. * @returns the face index if found (or null instead)
  32884. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32885. */
  32886. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32887. /**
  32888. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32889. * @returns the parameters
  32890. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32891. */
  32892. getFacetDataParameters(): any;
  32893. /**
  32894. * Disables the feature FacetData and frees the related memory
  32895. * @returns the current mesh
  32896. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32897. */
  32898. disableFacetData(): AbstractMesh;
  32899. /**
  32900. * Updates the AbstractMesh indices array
  32901. * @param indices defines the data source
  32902. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32903. * @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)
  32904. * @returns the current mesh
  32905. */
  32906. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32907. /**
  32908. * Creates new normals data for the mesh
  32909. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32910. * @returns the current mesh
  32911. */
  32912. createNormals(updatable: boolean): AbstractMesh;
  32913. /**
  32914. * Align the mesh with a normal
  32915. * @param normal defines the normal to use
  32916. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32917. * @returns the current mesh
  32918. */
  32919. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32920. /** @hidden */
  32921. _checkOcclusionQuery(): boolean;
  32922. /**
  32923. * Disables the mesh edge rendering mode
  32924. * @returns the currentAbstractMesh
  32925. */
  32926. disableEdgesRendering(): AbstractMesh;
  32927. /**
  32928. * Enables the edge rendering mode on the mesh.
  32929. * This mode makes the mesh edges visible
  32930. * @param epsilon defines the maximal distance between two angles to detect a face
  32931. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32932. * @returns the currentAbstractMesh
  32933. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32934. */
  32935. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32936. /**
  32937. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32938. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32939. */
  32940. getConnectedParticleSystems(): IParticleSystem[];
  32941. }
  32942. }
  32943. declare module BABYLON {
  32944. /**
  32945. * Interface used to define ActionEvent
  32946. */
  32947. export interface IActionEvent {
  32948. /** The mesh or sprite that triggered the action */
  32949. source: any;
  32950. /** The X mouse cursor position at the time of the event */
  32951. pointerX: number;
  32952. /** The Y mouse cursor position at the time of the event */
  32953. pointerY: number;
  32954. /** The mesh that is currently pointed at (can be null) */
  32955. meshUnderPointer: Nullable<AbstractMesh>;
  32956. /** the original (browser) event that triggered the ActionEvent */
  32957. sourceEvent?: any;
  32958. /** additional data for the event */
  32959. additionalData?: any;
  32960. }
  32961. /**
  32962. * ActionEvent is the event being sent when an action is triggered.
  32963. */
  32964. export class ActionEvent implements IActionEvent {
  32965. /** The mesh or sprite that triggered the action */
  32966. source: any;
  32967. /** The X mouse cursor position at the time of the event */
  32968. pointerX: number;
  32969. /** The Y mouse cursor position at the time of the event */
  32970. pointerY: number;
  32971. /** The mesh that is currently pointed at (can be null) */
  32972. meshUnderPointer: Nullable<AbstractMesh>;
  32973. /** the original (browser) event that triggered the ActionEvent */
  32974. sourceEvent?: any;
  32975. /** additional data for the event */
  32976. additionalData?: any;
  32977. /**
  32978. * Creates a new ActionEvent
  32979. * @param source The mesh or sprite that triggered the action
  32980. * @param pointerX The X mouse cursor position at the time of the event
  32981. * @param pointerY The Y mouse cursor position at the time of the event
  32982. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32983. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32984. * @param additionalData additional data for the event
  32985. */
  32986. constructor(
  32987. /** The mesh or sprite that triggered the action */
  32988. source: any,
  32989. /** The X mouse cursor position at the time of the event */
  32990. pointerX: number,
  32991. /** The Y mouse cursor position at the time of the event */
  32992. pointerY: number,
  32993. /** The mesh that is currently pointed at (can be null) */
  32994. meshUnderPointer: Nullable<AbstractMesh>,
  32995. /** the original (browser) event that triggered the ActionEvent */
  32996. sourceEvent?: any,
  32997. /** additional data for the event */
  32998. additionalData?: any);
  32999. /**
  33000. * Helper function to auto-create an ActionEvent from a source mesh.
  33001. * @param source The source mesh that triggered the event
  33002. * @param evt The original (browser) event
  33003. * @param additionalData additional data for the event
  33004. * @returns the new ActionEvent
  33005. */
  33006. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33007. /**
  33008. * Helper function to auto-create an ActionEvent from a source sprite
  33009. * @param source The source sprite that triggered the event
  33010. * @param scene Scene associated with the sprite
  33011. * @param evt The original (browser) event
  33012. * @param additionalData additional data for the event
  33013. * @returns the new ActionEvent
  33014. */
  33015. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  33016. /**
  33017. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  33018. * @param scene the scene where the event occurred
  33019. * @param evt The original (browser) event
  33020. * @returns the new ActionEvent
  33021. */
  33022. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  33023. /**
  33024. * Helper function to auto-create an ActionEvent from a primitive
  33025. * @param prim defines the target primitive
  33026. * @param pointerPos defines the pointer position
  33027. * @param evt The original (browser) event
  33028. * @param additionalData additional data for the event
  33029. * @returns the new ActionEvent
  33030. */
  33031. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  33032. }
  33033. }
  33034. declare module BABYLON {
  33035. /**
  33036. * Abstract class used to decouple action Manager from scene and meshes.
  33037. * Do not instantiate.
  33038. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33039. */
  33040. export abstract class AbstractActionManager implements IDisposable {
  33041. /** Gets the list of active triggers */
  33042. static Triggers: {
  33043. [key: string]: number;
  33044. };
  33045. /** Gets the cursor to use when hovering items */
  33046. hoverCursor: string;
  33047. /** Gets the list of actions */
  33048. actions: IAction[];
  33049. /**
  33050. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33051. */
  33052. isRecursive: boolean;
  33053. /**
  33054. * Releases all associated resources
  33055. */
  33056. abstract dispose(): void;
  33057. /**
  33058. * Does this action manager has pointer triggers
  33059. */
  33060. abstract get hasPointerTriggers(): boolean;
  33061. /**
  33062. * Does this action manager has pick triggers
  33063. */
  33064. abstract get hasPickTriggers(): boolean;
  33065. /**
  33066. * Process a specific trigger
  33067. * @param trigger defines the trigger to process
  33068. * @param evt defines the event details to be processed
  33069. */
  33070. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33071. /**
  33072. * Does this action manager handles actions of any of the given triggers
  33073. * @param triggers defines the triggers to be tested
  33074. * @return a boolean indicating whether one (or more) of the triggers is handled
  33075. */
  33076. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33077. /**
  33078. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33079. * speed.
  33080. * @param triggerA defines the trigger to be tested
  33081. * @param triggerB defines the trigger to be tested
  33082. * @return a boolean indicating whether one (or more) of the triggers is handled
  33083. */
  33084. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33085. /**
  33086. * Does this action manager handles actions of a given trigger
  33087. * @param trigger defines the trigger to be tested
  33088. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33089. * @return whether the trigger is handled
  33090. */
  33091. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33092. /**
  33093. * Serialize this manager to a JSON object
  33094. * @param name defines the property name to store this manager
  33095. * @returns a JSON representation of this manager
  33096. */
  33097. abstract serialize(name: string): any;
  33098. /**
  33099. * Registers an action to this action manager
  33100. * @param action defines the action to be registered
  33101. * @return the action amended (prepared) after registration
  33102. */
  33103. abstract registerAction(action: IAction): Nullable<IAction>;
  33104. /**
  33105. * Unregisters an action to this action manager
  33106. * @param action defines the action to be unregistered
  33107. * @return a boolean indicating whether the action has been unregistered
  33108. */
  33109. abstract unregisterAction(action: IAction): Boolean;
  33110. /**
  33111. * Does exist one action manager with at least one trigger
  33112. **/
  33113. static get HasTriggers(): boolean;
  33114. /**
  33115. * Does exist one action manager with at least one pick trigger
  33116. **/
  33117. static get HasPickTriggers(): boolean;
  33118. /**
  33119. * Does exist one action manager that handles actions of a given trigger
  33120. * @param trigger defines the trigger to be tested
  33121. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33122. **/
  33123. static HasSpecificTrigger(trigger: number): boolean;
  33124. }
  33125. }
  33126. declare module BABYLON {
  33127. /**
  33128. * Defines how a node can be built from a string name.
  33129. */
  33130. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33131. /**
  33132. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33133. */
  33134. export class Node implements IBehaviorAware<Node> {
  33135. /** @hidden */
  33136. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33137. private static _NodeConstructors;
  33138. /**
  33139. * Add a new node constructor
  33140. * @param type defines the type name of the node to construct
  33141. * @param constructorFunc defines the constructor function
  33142. */
  33143. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33144. /**
  33145. * Returns a node constructor based on type name
  33146. * @param type defines the type name
  33147. * @param name defines the new node name
  33148. * @param scene defines the hosting scene
  33149. * @param options defines optional options to transmit to constructors
  33150. * @returns the new constructor or null
  33151. */
  33152. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33153. /**
  33154. * Gets or sets the name of the node
  33155. */
  33156. name: string;
  33157. /**
  33158. * Gets or sets the id of the node
  33159. */
  33160. id: string;
  33161. /**
  33162. * Gets or sets the unique id of the node
  33163. */
  33164. uniqueId: number;
  33165. /**
  33166. * Gets or sets a string used to store user defined state for the node
  33167. */
  33168. state: string;
  33169. /**
  33170. * Gets or sets an object used to store user defined information for the node
  33171. */
  33172. metadata: any;
  33173. /**
  33174. * For internal use only. Please do not use.
  33175. */
  33176. reservedDataStore: any;
  33177. /**
  33178. * List of inspectable custom properties (used by the Inspector)
  33179. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33180. */
  33181. inspectableCustomProperties: IInspectable[];
  33182. private _doNotSerialize;
  33183. /**
  33184. * Gets or sets a boolean used to define if the node must be serialized
  33185. */
  33186. get doNotSerialize(): boolean;
  33187. set doNotSerialize(value: boolean);
  33188. /** @hidden */
  33189. _isDisposed: boolean;
  33190. /**
  33191. * Gets a list of Animations associated with the node
  33192. */
  33193. animations: Animation[];
  33194. protected _ranges: {
  33195. [name: string]: Nullable<AnimationRange>;
  33196. };
  33197. /**
  33198. * Callback raised when the node is ready to be used
  33199. */
  33200. onReady: Nullable<(node: Node) => void>;
  33201. private _isEnabled;
  33202. private _isParentEnabled;
  33203. private _isReady;
  33204. /** @hidden */
  33205. _currentRenderId: number;
  33206. private _parentUpdateId;
  33207. /** @hidden */
  33208. _childUpdateId: number;
  33209. /** @hidden */
  33210. _waitingParentId: Nullable<string>;
  33211. /** @hidden */
  33212. _scene: Scene;
  33213. /** @hidden */
  33214. _cache: any;
  33215. private _parentNode;
  33216. private _children;
  33217. /** @hidden */
  33218. _worldMatrix: Matrix;
  33219. /** @hidden */
  33220. _worldMatrixDeterminant: number;
  33221. /** @hidden */
  33222. _worldMatrixDeterminantIsDirty: boolean;
  33223. /** @hidden */
  33224. private _sceneRootNodesIndex;
  33225. /**
  33226. * Gets a boolean indicating if the node has been disposed
  33227. * @returns true if the node was disposed
  33228. */
  33229. isDisposed(): boolean;
  33230. /**
  33231. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33232. * @see https://doc.babylonjs.com/how_to/parenting
  33233. */
  33234. set parent(parent: Nullable<Node>);
  33235. get parent(): Nullable<Node>;
  33236. /** @hidden */
  33237. _addToSceneRootNodes(): void;
  33238. /** @hidden */
  33239. _removeFromSceneRootNodes(): void;
  33240. private _animationPropertiesOverride;
  33241. /**
  33242. * Gets or sets the animation properties override
  33243. */
  33244. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33245. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33246. /**
  33247. * Gets a string identifying the name of the class
  33248. * @returns "Node" string
  33249. */
  33250. getClassName(): string;
  33251. /** @hidden */
  33252. readonly _isNode: boolean;
  33253. /**
  33254. * An event triggered when the mesh is disposed
  33255. */
  33256. onDisposeObservable: Observable<Node>;
  33257. private _onDisposeObserver;
  33258. /**
  33259. * Sets a callback that will be raised when the node will be disposed
  33260. */
  33261. set onDispose(callback: () => void);
  33262. /**
  33263. * Creates a new Node
  33264. * @param name the name and id to be given to this node
  33265. * @param scene the scene this node will be added to
  33266. */
  33267. constructor(name: string, scene?: Nullable<Scene>);
  33268. /**
  33269. * Gets the scene of the node
  33270. * @returns a scene
  33271. */
  33272. getScene(): Scene;
  33273. /**
  33274. * Gets the engine of the node
  33275. * @returns a Engine
  33276. */
  33277. getEngine(): Engine;
  33278. private _behaviors;
  33279. /**
  33280. * Attach a behavior to the node
  33281. * @see https://doc.babylonjs.com/features/behaviour
  33282. * @param behavior defines the behavior to attach
  33283. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33284. * @returns the current Node
  33285. */
  33286. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33287. /**
  33288. * Remove an attached behavior
  33289. * @see https://doc.babylonjs.com/features/behaviour
  33290. * @param behavior defines the behavior to attach
  33291. * @returns the current Node
  33292. */
  33293. removeBehavior(behavior: Behavior<Node>): Node;
  33294. /**
  33295. * Gets the list of attached behaviors
  33296. * @see https://doc.babylonjs.com/features/behaviour
  33297. */
  33298. get behaviors(): Behavior<Node>[];
  33299. /**
  33300. * Gets an attached behavior by name
  33301. * @param name defines the name of the behavior to look for
  33302. * @see https://doc.babylonjs.com/features/behaviour
  33303. * @returns null if behavior was not found else the requested behavior
  33304. */
  33305. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33306. /**
  33307. * Returns the latest update of the World matrix
  33308. * @returns a Matrix
  33309. */
  33310. getWorldMatrix(): Matrix;
  33311. /** @hidden */
  33312. _getWorldMatrixDeterminant(): number;
  33313. /**
  33314. * Returns directly the latest state of the mesh World matrix.
  33315. * A Matrix is returned.
  33316. */
  33317. get worldMatrixFromCache(): Matrix;
  33318. /** @hidden */
  33319. _initCache(): void;
  33320. /** @hidden */
  33321. updateCache(force?: boolean): void;
  33322. /** @hidden */
  33323. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33324. /** @hidden */
  33325. _updateCache(ignoreParentClass?: boolean): void;
  33326. /** @hidden */
  33327. _isSynchronized(): boolean;
  33328. /** @hidden */
  33329. _markSyncedWithParent(): void;
  33330. /** @hidden */
  33331. isSynchronizedWithParent(): boolean;
  33332. /** @hidden */
  33333. isSynchronized(): boolean;
  33334. /**
  33335. * Is this node ready to be used/rendered
  33336. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33337. * @return true if the node is ready
  33338. */
  33339. isReady(completeCheck?: boolean): boolean;
  33340. /**
  33341. * Is this node enabled?
  33342. * 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
  33343. * @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
  33344. * @return whether this node (and its parent) is enabled
  33345. */
  33346. isEnabled(checkAncestors?: boolean): boolean;
  33347. /** @hidden */
  33348. protected _syncParentEnabledState(): void;
  33349. /**
  33350. * Set the enabled state of this node
  33351. * @param value defines the new enabled state
  33352. */
  33353. setEnabled(value: boolean): void;
  33354. /**
  33355. * Is this node a descendant of the given node?
  33356. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33357. * @param ancestor defines the parent node to inspect
  33358. * @returns a boolean indicating if this node is a descendant of the given node
  33359. */
  33360. isDescendantOf(ancestor: Node): boolean;
  33361. /** @hidden */
  33362. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33363. /**
  33364. * Will return all nodes that have this node as ascendant
  33365. * @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
  33366. * @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
  33367. * @return all children nodes of all types
  33368. */
  33369. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33370. /**
  33371. * Get all child-meshes of this node
  33372. * @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)
  33373. * @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
  33374. * @returns an array of AbstractMesh
  33375. */
  33376. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33377. /**
  33378. * Get all direct children of this node
  33379. * @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
  33380. * @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)
  33381. * @returns an array of Node
  33382. */
  33383. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33384. /** @hidden */
  33385. _setReady(state: boolean): void;
  33386. /**
  33387. * Get an animation by name
  33388. * @param name defines the name of the animation to look for
  33389. * @returns null if not found else the requested animation
  33390. */
  33391. getAnimationByName(name: string): Nullable<Animation>;
  33392. /**
  33393. * Creates an animation range for this node
  33394. * @param name defines the name of the range
  33395. * @param from defines the starting key
  33396. * @param to defines the end key
  33397. */
  33398. createAnimationRange(name: string, from: number, to: number): void;
  33399. /**
  33400. * Delete a specific animation range
  33401. * @param name defines the name of the range to delete
  33402. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33403. */
  33404. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33405. /**
  33406. * Get an animation range by name
  33407. * @param name defines the name of the animation range to look for
  33408. * @returns null if not found else the requested animation range
  33409. */
  33410. getAnimationRange(name: string): Nullable<AnimationRange>;
  33411. /**
  33412. * Gets the list of all animation ranges defined on this node
  33413. * @returns an array
  33414. */
  33415. getAnimationRanges(): Nullable<AnimationRange>[];
  33416. /**
  33417. * Will start the animation sequence
  33418. * @param name defines the range frames for animation sequence
  33419. * @param loop defines if the animation should loop (false by default)
  33420. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33421. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33422. * @returns the object created for this animation. If range does not exist, it will return null
  33423. */
  33424. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33425. /**
  33426. * Serialize animation ranges into a JSON compatible object
  33427. * @returns serialization object
  33428. */
  33429. serializeAnimationRanges(): any;
  33430. /**
  33431. * Computes the world matrix of the node
  33432. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33433. * @returns the world matrix
  33434. */
  33435. computeWorldMatrix(force?: boolean): Matrix;
  33436. /**
  33437. * Releases resources associated with this node.
  33438. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33439. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33440. */
  33441. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33442. /**
  33443. * Parse animation range data from a serialization object and store them into a given node
  33444. * @param node defines where to store the animation ranges
  33445. * @param parsedNode defines the serialization object to read data from
  33446. * @param scene defines the hosting scene
  33447. */
  33448. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33449. /**
  33450. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33451. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33452. * @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
  33453. * @returns the new bounding vectors
  33454. */
  33455. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33456. min: Vector3;
  33457. max: Vector3;
  33458. };
  33459. }
  33460. }
  33461. declare module BABYLON {
  33462. /**
  33463. * @hidden
  33464. */
  33465. export class _IAnimationState {
  33466. key: number;
  33467. repeatCount: number;
  33468. workValue?: any;
  33469. loopMode?: number;
  33470. offsetValue?: any;
  33471. highLimitValue?: any;
  33472. }
  33473. /**
  33474. * Class used to store any kind of animation
  33475. */
  33476. export class Animation {
  33477. /**Name of the animation */
  33478. name: string;
  33479. /**Property to animate */
  33480. targetProperty: string;
  33481. /**The frames per second of the animation */
  33482. framePerSecond: number;
  33483. /**The data type of the animation */
  33484. dataType: number;
  33485. /**The loop mode of the animation */
  33486. loopMode?: number | undefined;
  33487. /**Specifies if blending should be enabled */
  33488. enableBlending?: boolean | undefined;
  33489. /**
  33490. * Use matrix interpolation instead of using direct key value when animating matrices
  33491. */
  33492. static AllowMatricesInterpolation: boolean;
  33493. /**
  33494. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33495. */
  33496. static AllowMatrixDecomposeForInterpolation: boolean;
  33497. /** Define the Url to load snippets */
  33498. static SnippetUrl: string;
  33499. /** Snippet ID if the animation was created from the snippet server */
  33500. snippetId: string;
  33501. /**
  33502. * Stores the key frames of the animation
  33503. */
  33504. private _keys;
  33505. /**
  33506. * Stores the easing function of the animation
  33507. */
  33508. private _easingFunction;
  33509. /**
  33510. * @hidden Internal use only
  33511. */
  33512. _runtimeAnimations: RuntimeAnimation[];
  33513. /**
  33514. * The set of event that will be linked to this animation
  33515. */
  33516. private _events;
  33517. /**
  33518. * Stores an array of target property paths
  33519. */
  33520. targetPropertyPath: string[];
  33521. /**
  33522. * Stores the blending speed of the animation
  33523. */
  33524. blendingSpeed: number;
  33525. /**
  33526. * Stores the animation ranges for the animation
  33527. */
  33528. private _ranges;
  33529. /**
  33530. * @hidden Internal use
  33531. */
  33532. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33533. /**
  33534. * Sets up an animation
  33535. * @param property The property to animate
  33536. * @param animationType The animation type to apply
  33537. * @param framePerSecond The frames per second of the animation
  33538. * @param easingFunction The easing function used in the animation
  33539. * @returns The created animation
  33540. */
  33541. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33542. /**
  33543. * Create and start an animation on a node
  33544. * @param name defines the name of the global animation that will be run on all nodes
  33545. * @param node defines the root node where the animation will take place
  33546. * @param targetProperty defines property to animate
  33547. * @param framePerSecond defines the number of frame per second yo use
  33548. * @param totalFrame defines the number of frames in total
  33549. * @param from defines the initial value
  33550. * @param to defines the final value
  33551. * @param loopMode defines which loop mode you want to use (off by default)
  33552. * @param easingFunction defines the easing function to use (linear by default)
  33553. * @param onAnimationEnd defines the callback to call when animation end
  33554. * @returns the animatable created for this animation
  33555. */
  33556. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33557. /**
  33558. * Create and start an animation on a node and its descendants
  33559. * @param name defines the name of the global animation that will be run on all nodes
  33560. * @param node defines the root node where the animation will take place
  33561. * @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
  33562. * @param targetProperty defines property to animate
  33563. * @param framePerSecond defines the number of frame per second to use
  33564. * @param totalFrame defines the number of frames in total
  33565. * @param from defines the initial value
  33566. * @param to defines the final value
  33567. * @param loopMode defines which loop mode you want to use (off by default)
  33568. * @param easingFunction defines the easing function to use (linear by default)
  33569. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33570. * @returns the list of animatables created for all nodes
  33571. * @example https://www.babylonjs-playground.com/#MH0VLI
  33572. */
  33573. 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[]>;
  33574. /**
  33575. * Creates a new animation, merges it with the existing animations and starts it
  33576. * @param name Name of the animation
  33577. * @param node Node which contains the scene that begins the animations
  33578. * @param targetProperty Specifies which property to animate
  33579. * @param framePerSecond The frames per second of the animation
  33580. * @param totalFrame The total number of frames
  33581. * @param from The frame at the beginning of the animation
  33582. * @param to The frame at the end of the animation
  33583. * @param loopMode Specifies the loop mode of the animation
  33584. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33585. * @param onAnimationEnd Callback to run once the animation is complete
  33586. * @returns Nullable animation
  33587. */
  33588. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33589. /**
  33590. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33591. * @param sourceAnimation defines the Animation containing keyframes to convert
  33592. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33593. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33594. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33595. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33596. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33597. */
  33598. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33599. /**
  33600. * Transition property of an host to the target Value
  33601. * @param property The property to transition
  33602. * @param targetValue The target Value of the property
  33603. * @param host The object where the property to animate belongs
  33604. * @param scene Scene used to run the animation
  33605. * @param frameRate Framerate (in frame/s) to use
  33606. * @param transition The transition type we want to use
  33607. * @param duration The duration of the animation, in milliseconds
  33608. * @param onAnimationEnd Callback trigger at the end of the animation
  33609. * @returns Nullable animation
  33610. */
  33611. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33612. /**
  33613. * Return the array of runtime animations currently using this animation
  33614. */
  33615. get runtimeAnimations(): RuntimeAnimation[];
  33616. /**
  33617. * Specifies if any of the runtime animations are currently running
  33618. */
  33619. get hasRunningRuntimeAnimations(): boolean;
  33620. /**
  33621. * Initializes the animation
  33622. * @param name Name of the animation
  33623. * @param targetProperty Property to animate
  33624. * @param framePerSecond The frames per second of the animation
  33625. * @param dataType The data type of the animation
  33626. * @param loopMode The loop mode of the animation
  33627. * @param enableBlending Specifies if blending should be enabled
  33628. */
  33629. constructor(
  33630. /**Name of the animation */
  33631. name: string,
  33632. /**Property to animate */
  33633. targetProperty: string,
  33634. /**The frames per second of the animation */
  33635. framePerSecond: number,
  33636. /**The data type of the animation */
  33637. dataType: number,
  33638. /**The loop mode of the animation */
  33639. loopMode?: number | undefined,
  33640. /**Specifies if blending should be enabled */
  33641. enableBlending?: boolean | undefined);
  33642. /**
  33643. * Converts the animation to a string
  33644. * @param fullDetails support for multiple levels of logging within scene loading
  33645. * @returns String form of the animation
  33646. */
  33647. toString(fullDetails?: boolean): string;
  33648. /**
  33649. * Add an event to this animation
  33650. * @param event Event to add
  33651. */
  33652. addEvent(event: AnimationEvent): void;
  33653. /**
  33654. * Remove all events found at the given frame
  33655. * @param frame The frame to remove events from
  33656. */
  33657. removeEvents(frame: number): void;
  33658. /**
  33659. * Retrieves all the events from the animation
  33660. * @returns Events from the animation
  33661. */
  33662. getEvents(): AnimationEvent[];
  33663. /**
  33664. * Creates an animation range
  33665. * @param name Name of the animation range
  33666. * @param from Starting frame of the animation range
  33667. * @param to Ending frame of the animation
  33668. */
  33669. createRange(name: string, from: number, to: number): void;
  33670. /**
  33671. * Deletes an animation range by name
  33672. * @param name Name of the animation range to delete
  33673. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33674. */
  33675. deleteRange(name: string, deleteFrames?: boolean): void;
  33676. /**
  33677. * Gets the animation range by name, or null if not defined
  33678. * @param name Name of the animation range
  33679. * @returns Nullable animation range
  33680. */
  33681. getRange(name: string): Nullable<AnimationRange>;
  33682. /**
  33683. * Gets the key frames from the animation
  33684. * @returns The key frames of the animation
  33685. */
  33686. getKeys(): Array<IAnimationKey>;
  33687. /**
  33688. * Gets the highest frame rate of the animation
  33689. * @returns Highest frame rate of the animation
  33690. */
  33691. getHighestFrame(): number;
  33692. /**
  33693. * Gets the easing function of the animation
  33694. * @returns Easing function of the animation
  33695. */
  33696. getEasingFunction(): IEasingFunction;
  33697. /**
  33698. * Sets the easing function of the animation
  33699. * @param easingFunction A custom mathematical formula for animation
  33700. */
  33701. setEasingFunction(easingFunction: EasingFunction): void;
  33702. /**
  33703. * Interpolates a scalar linearly
  33704. * @param startValue Start value of the animation curve
  33705. * @param endValue End value of the animation curve
  33706. * @param gradient Scalar amount to interpolate
  33707. * @returns Interpolated scalar value
  33708. */
  33709. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33710. /**
  33711. * Interpolates a scalar cubically
  33712. * @param startValue Start value of the animation curve
  33713. * @param outTangent End tangent of the animation
  33714. * @param endValue End value of the animation curve
  33715. * @param inTangent Start tangent of the animation curve
  33716. * @param gradient Scalar amount to interpolate
  33717. * @returns Interpolated scalar value
  33718. */
  33719. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33720. /**
  33721. * Interpolates a quaternion using a spherical linear interpolation
  33722. * @param startValue Start value of the animation curve
  33723. * @param endValue End value of the animation curve
  33724. * @param gradient Scalar amount to interpolate
  33725. * @returns Interpolated quaternion value
  33726. */
  33727. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33728. /**
  33729. * Interpolates a quaternion cubically
  33730. * @param startValue Start value of the animation curve
  33731. * @param outTangent End tangent of the animation curve
  33732. * @param endValue End value of the animation curve
  33733. * @param inTangent Start tangent of the animation curve
  33734. * @param gradient Scalar amount to interpolate
  33735. * @returns Interpolated quaternion value
  33736. */
  33737. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33738. /**
  33739. * Interpolates a Vector3 linearl
  33740. * @param startValue Start value of the animation curve
  33741. * @param endValue End value of the animation curve
  33742. * @param gradient Scalar amount to interpolate
  33743. * @returns Interpolated scalar value
  33744. */
  33745. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33746. /**
  33747. * Interpolates a Vector3 cubically
  33748. * @param startValue Start value of the animation curve
  33749. * @param outTangent End tangent of the animation
  33750. * @param endValue End value of the animation curve
  33751. * @param inTangent Start tangent of the animation curve
  33752. * @param gradient Scalar amount to interpolate
  33753. * @returns InterpolatedVector3 value
  33754. */
  33755. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33756. /**
  33757. * Interpolates a Vector2 linearly
  33758. * @param startValue Start value of the animation curve
  33759. * @param endValue End value of the animation curve
  33760. * @param gradient Scalar amount to interpolate
  33761. * @returns Interpolated Vector2 value
  33762. */
  33763. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33764. /**
  33765. * Interpolates a Vector2 cubically
  33766. * @param startValue Start value of the animation curve
  33767. * @param outTangent End tangent of the animation
  33768. * @param endValue End value of the animation curve
  33769. * @param inTangent Start tangent of the animation curve
  33770. * @param gradient Scalar amount to interpolate
  33771. * @returns Interpolated Vector2 value
  33772. */
  33773. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33774. /**
  33775. * Interpolates a size linearly
  33776. * @param startValue Start value of the animation curve
  33777. * @param endValue End value of the animation curve
  33778. * @param gradient Scalar amount to interpolate
  33779. * @returns Interpolated Size value
  33780. */
  33781. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33782. /**
  33783. * Interpolates a Color3 linearly
  33784. * @param startValue Start value of the animation curve
  33785. * @param endValue End value of the animation curve
  33786. * @param gradient Scalar amount to interpolate
  33787. * @returns Interpolated Color3 value
  33788. */
  33789. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33790. /**
  33791. * Interpolates a Color4 linearly
  33792. * @param startValue Start value of the animation curve
  33793. * @param endValue End value of the animation curve
  33794. * @param gradient Scalar amount to interpolate
  33795. * @returns Interpolated Color3 value
  33796. */
  33797. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33798. /**
  33799. * @hidden Internal use only
  33800. */
  33801. _getKeyValue(value: any): any;
  33802. /**
  33803. * @hidden Internal use only
  33804. */
  33805. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33806. /**
  33807. * Defines the function to use to interpolate matrices
  33808. * @param startValue defines the start matrix
  33809. * @param endValue defines the end matrix
  33810. * @param gradient defines the gradient between both matrices
  33811. * @param result defines an optional target matrix where to store the interpolation
  33812. * @returns the interpolated matrix
  33813. */
  33814. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33815. /**
  33816. * Makes a copy of the animation
  33817. * @returns Cloned animation
  33818. */
  33819. clone(): Animation;
  33820. /**
  33821. * Sets the key frames of the animation
  33822. * @param values The animation key frames to set
  33823. */
  33824. setKeys(values: Array<IAnimationKey>): void;
  33825. /**
  33826. * Serializes the animation to an object
  33827. * @returns Serialized object
  33828. */
  33829. serialize(): any;
  33830. /**
  33831. * Float animation type
  33832. */
  33833. static readonly ANIMATIONTYPE_FLOAT: number;
  33834. /**
  33835. * Vector3 animation type
  33836. */
  33837. static readonly ANIMATIONTYPE_VECTOR3: number;
  33838. /**
  33839. * Quaternion animation type
  33840. */
  33841. static readonly ANIMATIONTYPE_QUATERNION: number;
  33842. /**
  33843. * Matrix animation type
  33844. */
  33845. static readonly ANIMATIONTYPE_MATRIX: number;
  33846. /**
  33847. * Color3 animation type
  33848. */
  33849. static readonly ANIMATIONTYPE_COLOR3: number;
  33850. /**
  33851. * Color3 animation type
  33852. */
  33853. static readonly ANIMATIONTYPE_COLOR4: number;
  33854. /**
  33855. * Vector2 animation type
  33856. */
  33857. static readonly ANIMATIONTYPE_VECTOR2: number;
  33858. /**
  33859. * Size animation type
  33860. */
  33861. static readonly ANIMATIONTYPE_SIZE: number;
  33862. /**
  33863. * Relative Loop Mode
  33864. */
  33865. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33866. /**
  33867. * Cycle Loop Mode
  33868. */
  33869. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33870. /**
  33871. * Constant Loop Mode
  33872. */
  33873. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33874. /** @hidden */
  33875. static _UniversalLerp(left: any, right: any, amount: number): any;
  33876. /**
  33877. * Parses an animation object and creates an animation
  33878. * @param parsedAnimation Parsed animation object
  33879. * @returns Animation object
  33880. */
  33881. static Parse(parsedAnimation: any): Animation;
  33882. /**
  33883. * Appends the serialized animations from the source animations
  33884. * @param source Source containing the animations
  33885. * @param destination Target to store the animations
  33886. */
  33887. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33888. /**
  33889. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33890. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33891. * @param url defines the url to load from
  33892. * @returns a promise that will resolve to the new animation or an array of animations
  33893. */
  33894. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33895. /**
  33896. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33897. * @param snippetId defines the snippet to load
  33898. * @returns a promise that will resolve to the new animation or a new array of animations
  33899. */
  33900. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33901. }
  33902. }
  33903. declare module BABYLON {
  33904. /**
  33905. * Interface containing an array of animations
  33906. */
  33907. export interface IAnimatable {
  33908. /**
  33909. * Array of animations
  33910. */
  33911. animations: Nullable<Array<Animation>>;
  33912. }
  33913. }
  33914. declare module BABYLON {
  33915. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33916. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33917. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33918. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33919. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33920. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33921. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33922. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33923. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33924. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33925. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33926. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33927. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33928. /**
  33929. * Decorator used to define property that can be serialized as reference to a camera
  33930. * @param sourceName defines the name of the property to decorate
  33931. */
  33932. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33933. /**
  33934. * Class used to help serialization objects
  33935. */
  33936. export class SerializationHelper {
  33937. /** @hidden */
  33938. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33939. /** @hidden */
  33940. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33941. /** @hidden */
  33942. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33943. /** @hidden */
  33944. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33945. /**
  33946. * Appends the serialized animations from the source animations
  33947. * @param source Source containing the animations
  33948. * @param destination Target to store the animations
  33949. */
  33950. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33951. /**
  33952. * Static function used to serialized a specific entity
  33953. * @param entity defines the entity to serialize
  33954. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33955. * @returns a JSON compatible object representing the serialization of the entity
  33956. */
  33957. static Serialize<T>(entity: T, serializationObject?: any): any;
  33958. /**
  33959. * Creates a new entity from a serialization data object
  33960. * @param creationFunction defines a function used to instanciated the new entity
  33961. * @param source defines the source serialization data
  33962. * @param scene defines the hosting scene
  33963. * @param rootUrl defines the root url for resources
  33964. * @returns a new entity
  33965. */
  33966. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33967. /**
  33968. * Clones an object
  33969. * @param creationFunction defines the function used to instanciate the new object
  33970. * @param source defines the source object
  33971. * @returns the cloned object
  33972. */
  33973. static Clone<T>(creationFunction: () => T, source: T): T;
  33974. /**
  33975. * Instanciates a new object based on a source one (some data will be shared between both object)
  33976. * @param creationFunction defines the function used to instanciate the new object
  33977. * @param source defines the source object
  33978. * @returns the new object
  33979. */
  33980. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33981. }
  33982. }
  33983. declare module BABYLON {
  33984. /**
  33985. * Base class of all the textures in babylon.
  33986. * It groups all the common properties the materials, post process, lights... might need
  33987. * in order to make a correct use of the texture.
  33988. */
  33989. export class BaseTexture implements IAnimatable {
  33990. /**
  33991. * Default anisotropic filtering level for the application.
  33992. * It is set to 4 as a good tradeoff between perf and quality.
  33993. */
  33994. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33995. /**
  33996. * Gets or sets the unique id of the texture
  33997. */
  33998. uniqueId: number;
  33999. /**
  34000. * Define the name of the texture.
  34001. */
  34002. name: string;
  34003. /**
  34004. * Gets or sets an object used to store user defined information.
  34005. */
  34006. metadata: any;
  34007. /**
  34008. * For internal use only. Please do not use.
  34009. */
  34010. reservedDataStore: any;
  34011. private _hasAlpha;
  34012. /**
  34013. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34014. */
  34015. set hasAlpha(value: boolean);
  34016. get hasAlpha(): boolean;
  34017. /**
  34018. * Defines if the alpha value should be determined via the rgb values.
  34019. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34020. */
  34021. getAlphaFromRGB: boolean;
  34022. /**
  34023. * Intensity or strength of the texture.
  34024. * It is commonly used by materials to fine tune the intensity of the texture
  34025. */
  34026. level: number;
  34027. /**
  34028. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34029. * This is part of the texture as textures usually maps to one uv set.
  34030. */
  34031. coordinatesIndex: number;
  34032. protected _coordinatesMode: number;
  34033. /**
  34034. * How a texture is mapped.
  34035. *
  34036. * | Value | Type | Description |
  34037. * | ----- | ----------------------------------- | ----------- |
  34038. * | 0 | EXPLICIT_MODE | |
  34039. * | 1 | SPHERICAL_MODE | |
  34040. * | 2 | PLANAR_MODE | |
  34041. * | 3 | CUBIC_MODE | |
  34042. * | 4 | PROJECTION_MODE | |
  34043. * | 5 | SKYBOX_MODE | |
  34044. * | 6 | INVCUBIC_MODE | |
  34045. * | 7 | EQUIRECTANGULAR_MODE | |
  34046. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34047. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34048. */
  34049. set coordinatesMode(value: number);
  34050. get coordinatesMode(): number;
  34051. private _wrapU;
  34052. /**
  34053. * | Value | Type | Description |
  34054. * | ----- | ------------------ | ----------- |
  34055. * | 0 | CLAMP_ADDRESSMODE | |
  34056. * | 1 | WRAP_ADDRESSMODE | |
  34057. * | 2 | MIRROR_ADDRESSMODE | |
  34058. */
  34059. get wrapU(): number;
  34060. set wrapU(value: number);
  34061. private _wrapV;
  34062. /**
  34063. * | Value | Type | Description |
  34064. * | ----- | ------------------ | ----------- |
  34065. * | 0 | CLAMP_ADDRESSMODE | |
  34066. * | 1 | WRAP_ADDRESSMODE | |
  34067. * | 2 | MIRROR_ADDRESSMODE | |
  34068. */
  34069. get wrapV(): number;
  34070. set wrapV(value: number);
  34071. /**
  34072. * | Value | Type | Description |
  34073. * | ----- | ------------------ | ----------- |
  34074. * | 0 | CLAMP_ADDRESSMODE | |
  34075. * | 1 | WRAP_ADDRESSMODE | |
  34076. * | 2 | MIRROR_ADDRESSMODE | |
  34077. */
  34078. wrapR: number;
  34079. /**
  34080. * With compliant hardware and browser (supporting anisotropic filtering)
  34081. * this defines the level of anisotropic filtering in the texture.
  34082. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34083. */
  34084. anisotropicFilteringLevel: number;
  34085. /**
  34086. * Define if the texture is a cube texture or if false a 2d texture.
  34087. */
  34088. get isCube(): boolean;
  34089. set isCube(value: boolean);
  34090. /**
  34091. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34092. */
  34093. get is3D(): boolean;
  34094. set is3D(value: boolean);
  34095. /**
  34096. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34097. */
  34098. get is2DArray(): boolean;
  34099. set is2DArray(value: boolean);
  34100. private _gammaSpace;
  34101. /**
  34102. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34103. * HDR texture are usually stored in linear space.
  34104. * This only impacts the PBR and Background materials
  34105. */
  34106. get gammaSpace(): boolean;
  34107. set gammaSpace(gamma: boolean);
  34108. /**
  34109. * Gets or sets whether or not the texture contains RGBD data.
  34110. */
  34111. get isRGBD(): boolean;
  34112. set isRGBD(value: boolean);
  34113. /**
  34114. * Is Z inverted in the texture (useful in a cube texture).
  34115. */
  34116. invertZ: boolean;
  34117. /**
  34118. * Are mip maps generated for this texture or not.
  34119. */
  34120. get noMipmap(): boolean;
  34121. /**
  34122. * @hidden
  34123. */
  34124. lodLevelInAlpha: boolean;
  34125. /**
  34126. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34127. */
  34128. get lodGenerationOffset(): number;
  34129. set lodGenerationOffset(value: number);
  34130. /**
  34131. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34132. */
  34133. get lodGenerationScale(): number;
  34134. set lodGenerationScale(value: number);
  34135. /**
  34136. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34137. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34138. * average roughness values.
  34139. */
  34140. get linearSpecularLOD(): boolean;
  34141. set linearSpecularLOD(value: boolean);
  34142. /**
  34143. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34144. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34145. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34146. */
  34147. get irradianceTexture(): Nullable<BaseTexture>;
  34148. set irradianceTexture(value: Nullable<BaseTexture>);
  34149. /**
  34150. * Define if the texture is a render target.
  34151. */
  34152. isRenderTarget: boolean;
  34153. /**
  34154. * Define the unique id of the texture in the scene.
  34155. */
  34156. get uid(): string;
  34157. /** @hidden */
  34158. _prefiltered: boolean;
  34159. /**
  34160. * Return a string representation of the texture.
  34161. * @returns the texture as a string
  34162. */
  34163. toString(): string;
  34164. /**
  34165. * Get the class name of the texture.
  34166. * @returns "BaseTexture"
  34167. */
  34168. getClassName(): string;
  34169. /**
  34170. * Define the list of animation attached to the texture.
  34171. */
  34172. animations: Animation[];
  34173. /**
  34174. * An event triggered when the texture is disposed.
  34175. */
  34176. onDisposeObservable: Observable<BaseTexture>;
  34177. private _onDisposeObserver;
  34178. /**
  34179. * Callback triggered when the texture has been disposed.
  34180. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34181. */
  34182. set onDispose(callback: () => void);
  34183. /**
  34184. * Define the current state of the loading sequence when in delayed load mode.
  34185. */
  34186. delayLoadState: number;
  34187. protected _scene: Nullable<Scene>;
  34188. protected _engine: Nullable<ThinEngine>;
  34189. /** @hidden */
  34190. _texture: Nullable<InternalTexture>;
  34191. private _uid;
  34192. /**
  34193. * Define if the texture is preventinga material to render or not.
  34194. * If not and the texture is not ready, the engine will use a default black texture instead.
  34195. */
  34196. get isBlocking(): boolean;
  34197. /**
  34198. * Instantiates a new BaseTexture.
  34199. * Base class of all the textures in babylon.
  34200. * It groups all the common properties the materials, post process, lights... might need
  34201. * in order to make a correct use of the texture.
  34202. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34203. */
  34204. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34205. /**
  34206. * Get the scene the texture belongs to.
  34207. * @returns the scene or null if undefined
  34208. */
  34209. getScene(): Nullable<Scene>;
  34210. /** @hidden */
  34211. protected _getEngine(): Nullable<ThinEngine>;
  34212. /**
  34213. * Get the texture transform matrix used to offset tile the texture for istance.
  34214. * @returns the transformation matrix
  34215. */
  34216. getTextureMatrix(): Matrix;
  34217. /**
  34218. * Get the texture reflection matrix used to rotate/transform the reflection.
  34219. * @returns the reflection matrix
  34220. */
  34221. getReflectionTextureMatrix(): Matrix;
  34222. /**
  34223. * Get the underlying lower level texture from Babylon.
  34224. * @returns the insternal texture
  34225. */
  34226. getInternalTexture(): Nullable<InternalTexture>;
  34227. /**
  34228. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34229. * @returns true if ready or not blocking
  34230. */
  34231. isReadyOrNotBlocking(): boolean;
  34232. /**
  34233. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34234. * @returns true if fully ready
  34235. */
  34236. isReady(): boolean;
  34237. private _cachedSize;
  34238. /**
  34239. * Get the size of the texture.
  34240. * @returns the texture size.
  34241. */
  34242. getSize(): ISize;
  34243. /**
  34244. * Get the base size of the texture.
  34245. * It can be different from the size if the texture has been resized for POT for instance
  34246. * @returns the base size
  34247. */
  34248. getBaseSize(): ISize;
  34249. /**
  34250. * Update the sampling mode of the texture.
  34251. * Default is Trilinear mode.
  34252. *
  34253. * | Value | Type | Description |
  34254. * | ----- | ------------------ | ----------- |
  34255. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34256. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34257. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34258. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34259. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34260. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34261. * | 7 | NEAREST_LINEAR | |
  34262. * | 8 | NEAREST_NEAREST | |
  34263. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34264. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34265. * | 11 | LINEAR_LINEAR | |
  34266. * | 12 | LINEAR_NEAREST | |
  34267. *
  34268. * > _mag_: magnification filter (close to the viewer)
  34269. * > _min_: minification filter (far from the viewer)
  34270. * > _mip_: filter used between mip map levels
  34271. *@param samplingMode Define the new sampling mode of the texture
  34272. */
  34273. updateSamplingMode(samplingMode: number): void;
  34274. /**
  34275. * Scales the texture if is `canRescale()`
  34276. * @param ratio the resize factor we want to use to rescale
  34277. */
  34278. scale(ratio: number): void;
  34279. /**
  34280. * Get if the texture can rescale.
  34281. */
  34282. get canRescale(): boolean;
  34283. /** @hidden */
  34284. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34285. /** @hidden */
  34286. _rebuild(): void;
  34287. /**
  34288. * Triggers the load sequence in delayed load mode.
  34289. */
  34290. delayLoad(): void;
  34291. /**
  34292. * Clones the texture.
  34293. * @returns the cloned texture
  34294. */
  34295. clone(): Nullable<BaseTexture>;
  34296. /**
  34297. * Get the texture underlying type (INT, FLOAT...)
  34298. */
  34299. get textureType(): number;
  34300. /**
  34301. * Get the texture underlying format (RGB, RGBA...)
  34302. */
  34303. get textureFormat(): number;
  34304. /**
  34305. * Indicates that textures need to be re-calculated for all materials
  34306. */
  34307. protected _markAllSubMeshesAsTexturesDirty(): void;
  34308. /**
  34309. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34310. * This will returns an RGBA array buffer containing either in values (0-255) or
  34311. * float values (0-1) depending of the underlying buffer type.
  34312. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34313. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34314. * @param buffer defines a user defined buffer to fill with data (can be null)
  34315. * @returns The Array buffer containing the pixels data.
  34316. */
  34317. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34318. /**
  34319. * Release and destroy the underlying lower level texture aka internalTexture.
  34320. */
  34321. releaseInternalTexture(): void;
  34322. /** @hidden */
  34323. get _lodTextureHigh(): Nullable<BaseTexture>;
  34324. /** @hidden */
  34325. get _lodTextureMid(): Nullable<BaseTexture>;
  34326. /** @hidden */
  34327. get _lodTextureLow(): Nullable<BaseTexture>;
  34328. /**
  34329. * Dispose the texture and release its associated resources.
  34330. */
  34331. dispose(): void;
  34332. /**
  34333. * Serialize the texture into a JSON representation that can be parsed later on.
  34334. * @returns the JSON representation of the texture
  34335. */
  34336. serialize(): any;
  34337. /**
  34338. * Helper function to be called back once a list of texture contains only ready textures.
  34339. * @param textures Define the list of textures to wait for
  34340. * @param callback Define the callback triggered once the entire list will be ready
  34341. */
  34342. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34343. private static _isScene;
  34344. }
  34345. }
  34346. declare module BABYLON {
  34347. /**
  34348. * Options to be used when creating an effect.
  34349. */
  34350. export interface IEffectCreationOptions {
  34351. /**
  34352. * Atrributes that will be used in the shader.
  34353. */
  34354. attributes: string[];
  34355. /**
  34356. * Uniform varible names that will be set in the shader.
  34357. */
  34358. uniformsNames: string[];
  34359. /**
  34360. * Uniform buffer variable names that will be set in the shader.
  34361. */
  34362. uniformBuffersNames: string[];
  34363. /**
  34364. * Sampler texture variable names that will be set in the shader.
  34365. */
  34366. samplers: string[];
  34367. /**
  34368. * Define statements that will be set in the shader.
  34369. */
  34370. defines: any;
  34371. /**
  34372. * Possible fallbacks for this effect to improve performance when needed.
  34373. */
  34374. fallbacks: Nullable<IEffectFallbacks>;
  34375. /**
  34376. * Callback that will be called when the shader is compiled.
  34377. */
  34378. onCompiled: Nullable<(effect: Effect) => void>;
  34379. /**
  34380. * Callback that will be called if an error occurs during shader compilation.
  34381. */
  34382. onError: Nullable<(effect: Effect, errors: string) => void>;
  34383. /**
  34384. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34385. */
  34386. indexParameters?: any;
  34387. /**
  34388. * Max number of lights that can be used in the shader.
  34389. */
  34390. maxSimultaneousLights?: number;
  34391. /**
  34392. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34393. */
  34394. transformFeedbackVaryings?: Nullable<string[]>;
  34395. /**
  34396. * 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
  34397. */
  34398. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34399. /**
  34400. * Is this effect rendering to several color attachments ?
  34401. */
  34402. multiTarget?: boolean;
  34403. }
  34404. /**
  34405. * Effect containing vertex and fragment shader that can be executed on an object.
  34406. */
  34407. export class Effect implements IDisposable {
  34408. /**
  34409. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34410. */
  34411. static ShadersRepository: string;
  34412. /**
  34413. * Enable logging of the shader code when a compilation error occurs
  34414. */
  34415. static LogShaderCodeOnCompilationError: boolean;
  34416. /**
  34417. * Name of the effect.
  34418. */
  34419. name: any;
  34420. /**
  34421. * String container all the define statements that should be set on the shader.
  34422. */
  34423. defines: string;
  34424. /**
  34425. * Callback that will be called when the shader is compiled.
  34426. */
  34427. onCompiled: Nullable<(effect: Effect) => void>;
  34428. /**
  34429. * Callback that will be called if an error occurs during shader compilation.
  34430. */
  34431. onError: Nullable<(effect: Effect, errors: string) => void>;
  34432. /**
  34433. * Callback that will be called when effect is bound.
  34434. */
  34435. onBind: Nullable<(effect: Effect) => void>;
  34436. /**
  34437. * Unique ID of the effect.
  34438. */
  34439. uniqueId: number;
  34440. /**
  34441. * Observable that will be called when the shader is compiled.
  34442. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34443. */
  34444. onCompileObservable: Observable<Effect>;
  34445. /**
  34446. * Observable that will be called if an error occurs during shader compilation.
  34447. */
  34448. onErrorObservable: Observable<Effect>;
  34449. /** @hidden */
  34450. _onBindObservable: Nullable<Observable<Effect>>;
  34451. /**
  34452. * @hidden
  34453. * Specifies if the effect was previously ready
  34454. */
  34455. _wasPreviouslyReady: boolean;
  34456. /**
  34457. * Observable that will be called when effect is bound.
  34458. */
  34459. get onBindObservable(): Observable<Effect>;
  34460. /** @hidden */
  34461. _bonesComputationForcedToCPU: boolean;
  34462. /** @hidden */
  34463. _multiTarget: boolean;
  34464. private static _uniqueIdSeed;
  34465. private _engine;
  34466. private _uniformBuffersNames;
  34467. private _uniformBuffersNamesList;
  34468. private _uniformsNames;
  34469. private _samplerList;
  34470. private _samplers;
  34471. private _isReady;
  34472. private _compilationError;
  34473. private _allFallbacksProcessed;
  34474. private _attributesNames;
  34475. private _attributes;
  34476. private _attributeLocationByName;
  34477. private _uniforms;
  34478. /**
  34479. * Key for the effect.
  34480. * @hidden
  34481. */
  34482. _key: string;
  34483. private _indexParameters;
  34484. private _fallbacks;
  34485. private _vertexSourceCode;
  34486. private _fragmentSourceCode;
  34487. private _vertexSourceCodeOverride;
  34488. private _fragmentSourceCodeOverride;
  34489. private _transformFeedbackVaryings;
  34490. /**
  34491. * Compiled shader to webGL program.
  34492. * @hidden
  34493. */
  34494. _pipelineContext: Nullable<IPipelineContext>;
  34495. private _valueCache;
  34496. private static _baseCache;
  34497. /**
  34498. * Instantiates an effect.
  34499. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34500. * @param baseName Name of the effect.
  34501. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34502. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34503. * @param samplers List of sampler variables that will be passed to the shader.
  34504. * @param engine Engine to be used to render the effect
  34505. * @param defines Define statements to be added to the shader.
  34506. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34507. * @param onCompiled Callback that will be called when the shader is compiled.
  34508. * @param onError Callback that will be called if an error occurs during shader compilation.
  34509. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34510. */
  34511. 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);
  34512. private _useFinalCode;
  34513. /**
  34514. * Unique key for this effect
  34515. */
  34516. get key(): string;
  34517. /**
  34518. * If the effect has been compiled and prepared.
  34519. * @returns if the effect is compiled and prepared.
  34520. */
  34521. isReady(): boolean;
  34522. private _isReadyInternal;
  34523. /**
  34524. * The engine the effect was initialized with.
  34525. * @returns the engine.
  34526. */
  34527. getEngine(): Engine;
  34528. /**
  34529. * The pipeline context for this effect
  34530. * @returns the associated pipeline context
  34531. */
  34532. getPipelineContext(): Nullable<IPipelineContext>;
  34533. /**
  34534. * The set of names of attribute variables for the shader.
  34535. * @returns An array of attribute names.
  34536. */
  34537. getAttributesNames(): string[];
  34538. /**
  34539. * Returns the attribute at the given index.
  34540. * @param index The index of the attribute.
  34541. * @returns The location of the attribute.
  34542. */
  34543. getAttributeLocation(index: number): number;
  34544. /**
  34545. * Returns the attribute based on the name of the variable.
  34546. * @param name of the attribute to look up.
  34547. * @returns the attribute location.
  34548. */
  34549. getAttributeLocationByName(name: string): number;
  34550. /**
  34551. * The number of attributes.
  34552. * @returns the numnber of attributes.
  34553. */
  34554. getAttributesCount(): number;
  34555. /**
  34556. * Gets the index of a uniform variable.
  34557. * @param uniformName of the uniform to look up.
  34558. * @returns the index.
  34559. */
  34560. getUniformIndex(uniformName: string): number;
  34561. /**
  34562. * Returns the attribute based on the name of the variable.
  34563. * @param uniformName of the uniform to look up.
  34564. * @returns the location of the uniform.
  34565. */
  34566. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34567. /**
  34568. * Returns an array of sampler variable names
  34569. * @returns The array of sampler variable names.
  34570. */
  34571. getSamplers(): string[];
  34572. /**
  34573. * Returns an array of uniform variable names
  34574. * @returns The array of uniform variable names.
  34575. */
  34576. getUniformNames(): string[];
  34577. /**
  34578. * Returns an array of uniform buffer variable names
  34579. * @returns The array of uniform buffer variable names.
  34580. */
  34581. getUniformBuffersNames(): string[];
  34582. /**
  34583. * Returns the index parameters used to create the effect
  34584. * @returns The index parameters object
  34585. */
  34586. getIndexParameters(): any;
  34587. /**
  34588. * The error from the last compilation.
  34589. * @returns the error string.
  34590. */
  34591. getCompilationError(): string;
  34592. /**
  34593. * Gets a boolean indicating that all fallbacks were used during compilation
  34594. * @returns true if all fallbacks were used
  34595. */
  34596. allFallbacksProcessed(): boolean;
  34597. /**
  34598. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34599. * @param func The callback to be used.
  34600. */
  34601. executeWhenCompiled(func: (effect: Effect) => void): void;
  34602. private _checkIsReady;
  34603. private _loadShader;
  34604. /**
  34605. * Gets the vertex shader source code of this effect
  34606. */
  34607. get vertexSourceCode(): string;
  34608. /**
  34609. * Gets the fragment shader source code of this effect
  34610. */
  34611. get fragmentSourceCode(): string;
  34612. /**
  34613. * Recompiles the webGL program
  34614. * @param vertexSourceCode The source code for the vertex shader.
  34615. * @param fragmentSourceCode The source code for the fragment shader.
  34616. * @param onCompiled Callback called when completed.
  34617. * @param onError Callback called on error.
  34618. * @hidden
  34619. */
  34620. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34621. /**
  34622. * Prepares the effect
  34623. * @hidden
  34624. */
  34625. _prepareEffect(): void;
  34626. private _getShaderCodeAndErrorLine;
  34627. private _processCompilationErrors;
  34628. /**
  34629. * Checks if the effect is supported. (Must be called after compilation)
  34630. */
  34631. get isSupported(): boolean;
  34632. /**
  34633. * Binds a texture to the engine to be used as output of the shader.
  34634. * @param channel Name of the output variable.
  34635. * @param texture Texture to bind.
  34636. * @hidden
  34637. */
  34638. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34639. /**
  34640. * Sets a texture on the engine to be used in the shader.
  34641. * @param channel Name of the sampler variable.
  34642. * @param texture Texture to set.
  34643. */
  34644. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34645. /**
  34646. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34647. * @param channel Name of the sampler variable.
  34648. * @param texture Texture to set.
  34649. */
  34650. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34651. /**
  34652. * Sets an array of textures on the engine to be used in the shader.
  34653. * @param channel Name of the variable.
  34654. * @param textures Textures to set.
  34655. */
  34656. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34657. /**
  34658. * 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)
  34659. * @param channel Name of the sampler variable.
  34660. * @param postProcess Post process to get the input texture from.
  34661. */
  34662. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34663. /**
  34664. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34665. * 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)
  34666. * @param channel Name of the sampler variable.
  34667. * @param postProcess Post process to get the output texture from.
  34668. */
  34669. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34670. /** @hidden */
  34671. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34672. /** @hidden */
  34673. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34674. /** @hidden */
  34675. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34676. /** @hidden */
  34677. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34678. /**
  34679. * Binds a buffer to a uniform.
  34680. * @param buffer Buffer to bind.
  34681. * @param name Name of the uniform variable to bind to.
  34682. */
  34683. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34684. /**
  34685. * Binds block to a uniform.
  34686. * @param blockName Name of the block to bind.
  34687. * @param index Index to bind.
  34688. */
  34689. bindUniformBlock(blockName: string, index: number): void;
  34690. /**
  34691. * Sets an interger value on a uniform variable.
  34692. * @param uniformName Name of the variable.
  34693. * @param value Value to be set.
  34694. * @returns this effect.
  34695. */
  34696. setInt(uniformName: string, value: number): Effect;
  34697. /**
  34698. * Sets an int array on a uniform variable.
  34699. * @param uniformName Name of the variable.
  34700. * @param array array to be set.
  34701. * @returns this effect.
  34702. */
  34703. setIntArray(uniformName: string, array: Int32Array): Effect;
  34704. /**
  34705. * 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)
  34706. * @param uniformName Name of the variable.
  34707. * @param array array to be set.
  34708. * @returns this effect.
  34709. */
  34710. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34711. /**
  34712. * 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)
  34713. * @param uniformName Name of the variable.
  34714. * @param array array to be set.
  34715. * @returns this effect.
  34716. */
  34717. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34718. /**
  34719. * 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)
  34720. * @param uniformName Name of the variable.
  34721. * @param array array to be set.
  34722. * @returns this effect.
  34723. */
  34724. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34725. /**
  34726. * Sets an float array on a uniform variable.
  34727. * @param uniformName Name of the variable.
  34728. * @param array array to be set.
  34729. * @returns this effect.
  34730. */
  34731. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34732. /**
  34733. * 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)
  34734. * @param uniformName Name of the variable.
  34735. * @param array array to be set.
  34736. * @returns this effect.
  34737. */
  34738. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34739. /**
  34740. * 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)
  34741. * @param uniformName Name of the variable.
  34742. * @param array array to be set.
  34743. * @returns this effect.
  34744. */
  34745. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34746. /**
  34747. * 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)
  34748. * @param uniformName Name of the variable.
  34749. * @param array array to be set.
  34750. * @returns this effect.
  34751. */
  34752. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34753. /**
  34754. * Sets an array on a uniform variable.
  34755. * @param uniformName Name of the variable.
  34756. * @param array array to be set.
  34757. * @returns this effect.
  34758. */
  34759. setArray(uniformName: string, array: number[]): Effect;
  34760. /**
  34761. * 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)
  34762. * @param uniformName Name of the variable.
  34763. * @param array array to be set.
  34764. * @returns this effect.
  34765. */
  34766. setArray2(uniformName: string, array: number[]): Effect;
  34767. /**
  34768. * 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)
  34769. * @param uniformName Name of the variable.
  34770. * @param array array to be set.
  34771. * @returns this effect.
  34772. */
  34773. setArray3(uniformName: string, array: number[]): Effect;
  34774. /**
  34775. * 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)
  34776. * @param uniformName Name of the variable.
  34777. * @param array array to be set.
  34778. * @returns this effect.
  34779. */
  34780. setArray4(uniformName: string, array: number[]): Effect;
  34781. /**
  34782. * Sets matrices on a uniform variable.
  34783. * @param uniformName Name of the variable.
  34784. * @param matrices matrices to be set.
  34785. * @returns this effect.
  34786. */
  34787. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34788. /**
  34789. * Sets matrix on a uniform variable.
  34790. * @param uniformName Name of the variable.
  34791. * @param matrix matrix to be set.
  34792. * @returns this effect.
  34793. */
  34794. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34795. /**
  34796. * 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)
  34797. * @param uniformName Name of the variable.
  34798. * @param matrix matrix to be set.
  34799. * @returns this effect.
  34800. */
  34801. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34802. /**
  34803. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34804. * @param uniformName Name of the variable.
  34805. * @param matrix matrix to be set.
  34806. * @returns this effect.
  34807. */
  34808. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34809. /**
  34810. * Sets a float on a uniform variable.
  34811. * @param uniformName Name of the variable.
  34812. * @param value value to be set.
  34813. * @returns this effect.
  34814. */
  34815. setFloat(uniformName: string, value: number): Effect;
  34816. /**
  34817. * Sets a boolean on a uniform variable.
  34818. * @param uniformName Name of the variable.
  34819. * @param bool value to be set.
  34820. * @returns this effect.
  34821. */
  34822. setBool(uniformName: string, bool: boolean): Effect;
  34823. /**
  34824. * Sets a Vector2 on a uniform variable.
  34825. * @param uniformName Name of the variable.
  34826. * @param vector2 vector2 to be set.
  34827. * @returns this effect.
  34828. */
  34829. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34830. /**
  34831. * Sets a float2 on a uniform variable.
  34832. * @param uniformName Name of the variable.
  34833. * @param x First float in float2.
  34834. * @param y Second float in float2.
  34835. * @returns this effect.
  34836. */
  34837. setFloat2(uniformName: string, x: number, y: number): Effect;
  34838. /**
  34839. * Sets a Vector3 on a uniform variable.
  34840. * @param uniformName Name of the variable.
  34841. * @param vector3 Value to be set.
  34842. * @returns this effect.
  34843. */
  34844. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34845. /**
  34846. * Sets a float3 on a uniform variable.
  34847. * @param uniformName Name of the variable.
  34848. * @param x First float in float3.
  34849. * @param y Second float in float3.
  34850. * @param z Third float in float3.
  34851. * @returns this effect.
  34852. */
  34853. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34854. /**
  34855. * Sets a Vector4 on a uniform variable.
  34856. * @param uniformName Name of the variable.
  34857. * @param vector4 Value to be set.
  34858. * @returns this effect.
  34859. */
  34860. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34861. /**
  34862. * Sets a float4 on a uniform variable.
  34863. * @param uniformName Name of the variable.
  34864. * @param x First float in float4.
  34865. * @param y Second float in float4.
  34866. * @param z Third float in float4.
  34867. * @param w Fourth float in float4.
  34868. * @returns this effect.
  34869. */
  34870. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34871. /**
  34872. * Sets a Color3 on a uniform variable.
  34873. * @param uniformName Name of the variable.
  34874. * @param color3 Value to be set.
  34875. * @returns this effect.
  34876. */
  34877. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34878. /**
  34879. * Sets a Color4 on a uniform variable.
  34880. * @param uniformName Name of the variable.
  34881. * @param color3 Value to be set.
  34882. * @param alpha Alpha value to be set.
  34883. * @returns this effect.
  34884. */
  34885. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34886. /**
  34887. * Sets a Color4 on a uniform variable
  34888. * @param uniformName defines the name of the variable
  34889. * @param color4 defines the value to be set
  34890. * @returns this effect.
  34891. */
  34892. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34893. /** Release all associated resources */
  34894. dispose(): void;
  34895. /**
  34896. * This function will add a new shader to the shader store
  34897. * @param name the name of the shader
  34898. * @param pixelShader optional pixel shader content
  34899. * @param vertexShader optional vertex shader content
  34900. */
  34901. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34902. /**
  34903. * Store of each shader (The can be looked up using effect.key)
  34904. */
  34905. static ShadersStore: {
  34906. [key: string]: string;
  34907. };
  34908. /**
  34909. * Store of each included file for a shader (The can be looked up using effect.key)
  34910. */
  34911. static IncludesShadersStore: {
  34912. [key: string]: string;
  34913. };
  34914. /**
  34915. * Resets the cache of effects.
  34916. */
  34917. static ResetCache(): void;
  34918. }
  34919. }
  34920. declare module BABYLON {
  34921. /**
  34922. * Interface used to describe the capabilities of the engine relatively to the current browser
  34923. */
  34924. export interface EngineCapabilities {
  34925. /** Maximum textures units per fragment shader */
  34926. maxTexturesImageUnits: number;
  34927. /** Maximum texture units per vertex shader */
  34928. maxVertexTextureImageUnits: number;
  34929. /** Maximum textures units in the entire pipeline */
  34930. maxCombinedTexturesImageUnits: number;
  34931. /** Maximum texture size */
  34932. maxTextureSize: number;
  34933. /** Maximum texture samples */
  34934. maxSamples?: number;
  34935. /** Maximum cube texture size */
  34936. maxCubemapTextureSize: number;
  34937. /** Maximum render texture size */
  34938. maxRenderTextureSize: number;
  34939. /** Maximum number of vertex attributes */
  34940. maxVertexAttribs: number;
  34941. /** Maximum number of varyings */
  34942. maxVaryingVectors: number;
  34943. /** Maximum number of uniforms per vertex shader */
  34944. maxVertexUniformVectors: number;
  34945. /** Maximum number of uniforms per fragment shader */
  34946. maxFragmentUniformVectors: number;
  34947. /** Defines if standard derivates (dx/dy) are supported */
  34948. standardDerivatives: boolean;
  34949. /** Defines if s3tc texture compression is supported */
  34950. s3tc?: WEBGL_compressed_texture_s3tc;
  34951. /** Defines if pvrtc texture compression is supported */
  34952. pvrtc: any;
  34953. /** Defines if etc1 texture compression is supported */
  34954. etc1: any;
  34955. /** Defines if etc2 texture compression is supported */
  34956. etc2: any;
  34957. /** Defines if astc texture compression is supported */
  34958. astc: any;
  34959. /** Defines if bptc texture compression is supported */
  34960. bptc: any;
  34961. /** Defines if float textures are supported */
  34962. textureFloat: boolean;
  34963. /** Defines if vertex array objects are supported */
  34964. vertexArrayObject: boolean;
  34965. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34966. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34967. /** Gets the maximum level of anisotropy supported */
  34968. maxAnisotropy: number;
  34969. /** Defines if instancing is supported */
  34970. instancedArrays: boolean;
  34971. /** Defines if 32 bits indices are supported */
  34972. uintIndices: boolean;
  34973. /** Defines if high precision shaders are supported */
  34974. highPrecisionShaderSupported: boolean;
  34975. /** Defines if depth reading in the fragment shader is supported */
  34976. fragmentDepthSupported: boolean;
  34977. /** Defines if float texture linear filtering is supported*/
  34978. textureFloatLinearFiltering: boolean;
  34979. /** Defines if rendering to float textures is supported */
  34980. textureFloatRender: boolean;
  34981. /** Defines if half float textures are supported*/
  34982. textureHalfFloat: boolean;
  34983. /** Defines if half float texture linear filtering is supported*/
  34984. textureHalfFloatLinearFiltering: boolean;
  34985. /** Defines if rendering to half float textures is supported */
  34986. textureHalfFloatRender: boolean;
  34987. /** Defines if textureLOD shader command is supported */
  34988. textureLOD: boolean;
  34989. /** Defines if draw buffers extension is supported */
  34990. drawBuffersExtension: boolean;
  34991. /** Defines if depth textures are supported */
  34992. depthTextureExtension: boolean;
  34993. /** Defines if float color buffer are supported */
  34994. colorBufferFloat: boolean;
  34995. /** Gets disjoint timer query extension (null if not supported) */
  34996. timerQuery?: EXT_disjoint_timer_query;
  34997. /** Defines if timestamp can be used with timer query */
  34998. canUseTimestampForTimerQuery: boolean;
  34999. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35000. multiview?: any;
  35001. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35002. oculusMultiview?: any;
  35003. /** Function used to let the system compiles shaders in background */
  35004. parallelShaderCompile?: {
  35005. COMPLETION_STATUS_KHR: number;
  35006. };
  35007. /** Max number of texture samples for MSAA */
  35008. maxMSAASamples: number;
  35009. /** Defines if the blend min max extension is supported */
  35010. blendMinMax: boolean;
  35011. }
  35012. }
  35013. declare module BABYLON {
  35014. /**
  35015. * @hidden
  35016. **/
  35017. export class DepthCullingState {
  35018. private _isDepthTestDirty;
  35019. private _isDepthMaskDirty;
  35020. private _isDepthFuncDirty;
  35021. private _isCullFaceDirty;
  35022. private _isCullDirty;
  35023. private _isZOffsetDirty;
  35024. private _isFrontFaceDirty;
  35025. private _depthTest;
  35026. private _depthMask;
  35027. private _depthFunc;
  35028. private _cull;
  35029. private _cullFace;
  35030. private _zOffset;
  35031. private _frontFace;
  35032. /**
  35033. * Initializes the state.
  35034. */
  35035. constructor();
  35036. get isDirty(): boolean;
  35037. get zOffset(): number;
  35038. set zOffset(value: number);
  35039. get cullFace(): Nullable<number>;
  35040. set cullFace(value: Nullable<number>);
  35041. get cull(): Nullable<boolean>;
  35042. set cull(value: Nullable<boolean>);
  35043. get depthFunc(): Nullable<number>;
  35044. set depthFunc(value: Nullable<number>);
  35045. get depthMask(): boolean;
  35046. set depthMask(value: boolean);
  35047. get depthTest(): boolean;
  35048. set depthTest(value: boolean);
  35049. get frontFace(): Nullable<number>;
  35050. set frontFace(value: Nullable<number>);
  35051. reset(): void;
  35052. apply(gl: WebGLRenderingContext): void;
  35053. }
  35054. }
  35055. declare module BABYLON {
  35056. /**
  35057. * @hidden
  35058. **/
  35059. export class StencilState {
  35060. /** 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 */
  35061. static readonly ALWAYS: number;
  35062. /** Passed to stencilOperation to specify that stencil value must be kept */
  35063. static readonly KEEP: number;
  35064. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35065. static readonly REPLACE: number;
  35066. private _isStencilTestDirty;
  35067. private _isStencilMaskDirty;
  35068. private _isStencilFuncDirty;
  35069. private _isStencilOpDirty;
  35070. private _stencilTest;
  35071. private _stencilMask;
  35072. private _stencilFunc;
  35073. private _stencilFuncRef;
  35074. private _stencilFuncMask;
  35075. private _stencilOpStencilFail;
  35076. private _stencilOpDepthFail;
  35077. private _stencilOpStencilDepthPass;
  35078. get isDirty(): boolean;
  35079. get stencilFunc(): number;
  35080. set stencilFunc(value: number);
  35081. get stencilFuncRef(): number;
  35082. set stencilFuncRef(value: number);
  35083. get stencilFuncMask(): number;
  35084. set stencilFuncMask(value: number);
  35085. get stencilOpStencilFail(): number;
  35086. set stencilOpStencilFail(value: number);
  35087. get stencilOpDepthFail(): number;
  35088. set stencilOpDepthFail(value: number);
  35089. get stencilOpStencilDepthPass(): number;
  35090. set stencilOpStencilDepthPass(value: number);
  35091. get stencilMask(): number;
  35092. set stencilMask(value: number);
  35093. get stencilTest(): boolean;
  35094. set stencilTest(value: boolean);
  35095. constructor();
  35096. reset(): void;
  35097. apply(gl: WebGLRenderingContext): void;
  35098. }
  35099. }
  35100. declare module BABYLON {
  35101. /**
  35102. * @hidden
  35103. **/
  35104. export class AlphaState {
  35105. private _isAlphaBlendDirty;
  35106. private _isBlendFunctionParametersDirty;
  35107. private _isBlendEquationParametersDirty;
  35108. private _isBlendConstantsDirty;
  35109. private _alphaBlend;
  35110. private _blendFunctionParameters;
  35111. private _blendEquationParameters;
  35112. private _blendConstants;
  35113. /**
  35114. * Initializes the state.
  35115. */
  35116. constructor();
  35117. get isDirty(): boolean;
  35118. get alphaBlend(): boolean;
  35119. set alphaBlend(value: boolean);
  35120. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35121. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35122. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35123. reset(): void;
  35124. apply(gl: WebGLRenderingContext): void;
  35125. }
  35126. }
  35127. declare module BABYLON {
  35128. /** @hidden */
  35129. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35130. attributeProcessor(attribute: string): string;
  35131. varyingProcessor(varying: string, isFragment: boolean): string;
  35132. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35133. }
  35134. }
  35135. declare module BABYLON {
  35136. /**
  35137. * Interface for attribute information associated with buffer instanciation
  35138. */
  35139. export interface InstancingAttributeInfo {
  35140. /**
  35141. * Name of the GLSL attribute
  35142. * if attribute index is not specified, this is used to retrieve the index from the effect
  35143. */
  35144. attributeName: string;
  35145. /**
  35146. * Index/offset of the attribute in the vertex shader
  35147. * if not specified, this will be computes from the name.
  35148. */
  35149. index?: number;
  35150. /**
  35151. * size of the attribute, 1, 2, 3 or 4
  35152. */
  35153. attributeSize: number;
  35154. /**
  35155. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35156. */
  35157. offset: number;
  35158. /**
  35159. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35160. * default to 1
  35161. */
  35162. divisor?: number;
  35163. /**
  35164. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35165. * default is FLOAT
  35166. */
  35167. attributeType?: number;
  35168. /**
  35169. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35170. */
  35171. normalized?: boolean;
  35172. }
  35173. }
  35174. declare module BABYLON {
  35175. interface ThinEngine {
  35176. /**
  35177. * Update a video texture
  35178. * @param texture defines the texture to update
  35179. * @param video defines the video element to use
  35180. * @param invertY defines if data must be stored with Y axis inverted
  35181. */
  35182. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35183. }
  35184. }
  35185. declare module BABYLON {
  35186. interface ThinEngine {
  35187. /**
  35188. * Creates a dynamic texture
  35189. * @param width defines the width of the texture
  35190. * @param height defines the height of the texture
  35191. * @param generateMipMaps defines if the engine should generate the mip levels
  35192. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35193. * @returns the dynamic texture inside an InternalTexture
  35194. */
  35195. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35196. /**
  35197. * Update the content of a dynamic texture
  35198. * @param texture defines the texture to update
  35199. * @param canvas defines the canvas containing the source
  35200. * @param invertY defines if data must be stored with Y axis inverted
  35201. * @param premulAlpha defines if alpha is stored as premultiplied
  35202. * @param format defines the format of the data
  35203. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35204. */
  35205. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35206. }
  35207. }
  35208. declare module BABYLON {
  35209. /**
  35210. * Settings for finer control over video usage
  35211. */
  35212. export interface VideoTextureSettings {
  35213. /**
  35214. * Applies `autoplay` to video, if specified
  35215. */
  35216. autoPlay?: boolean;
  35217. /**
  35218. * Applies `loop` to video, if specified
  35219. */
  35220. loop?: boolean;
  35221. /**
  35222. * Automatically updates internal texture from video at every frame in the render loop
  35223. */
  35224. autoUpdateTexture: boolean;
  35225. /**
  35226. * Image src displayed during the video loading or until the user interacts with the video.
  35227. */
  35228. poster?: string;
  35229. }
  35230. /**
  35231. * If you want to display a video in your scene, this is the special texture for that.
  35232. * This special texture works similar to other textures, with the exception of a few parameters.
  35233. * @see https://doc.babylonjs.com/how_to/video_texture
  35234. */
  35235. export class VideoTexture extends Texture {
  35236. /**
  35237. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35238. */
  35239. readonly autoUpdateTexture: boolean;
  35240. /**
  35241. * The video instance used by the texture internally
  35242. */
  35243. readonly video: HTMLVideoElement;
  35244. private _onUserActionRequestedObservable;
  35245. /**
  35246. * Event triggerd when a dom action is required by the user to play the video.
  35247. * This happens due to recent changes in browser policies preventing video to auto start.
  35248. */
  35249. get onUserActionRequestedObservable(): Observable<Texture>;
  35250. private _generateMipMaps;
  35251. private _stillImageCaptured;
  35252. private _displayingPosterTexture;
  35253. private _settings;
  35254. private _createInternalTextureOnEvent;
  35255. private _frameId;
  35256. private _currentSrc;
  35257. /**
  35258. * Creates a video texture.
  35259. * If you want to display a video in your scene, this is the special texture for that.
  35260. * This special texture works similar to other textures, with the exception of a few parameters.
  35261. * @see https://doc.babylonjs.com/how_to/video_texture
  35262. * @param name optional name, will detect from video source, if not defined
  35263. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35264. * @param scene is obviously the current scene.
  35265. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35266. * @param invertY is false by default but can be used to invert video on Y axis
  35267. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35268. * @param settings allows finer control over video usage
  35269. */
  35270. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35271. private _getName;
  35272. private _getVideo;
  35273. private _createInternalTexture;
  35274. private reset;
  35275. /**
  35276. * @hidden Internal method to initiate `update`.
  35277. */
  35278. _rebuild(): void;
  35279. /**
  35280. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35281. */
  35282. update(): void;
  35283. /**
  35284. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35285. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35286. */
  35287. updateTexture(isVisible: boolean): void;
  35288. protected _updateInternalTexture: () => void;
  35289. /**
  35290. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35291. * @param url New url.
  35292. */
  35293. updateURL(url: string): void;
  35294. /**
  35295. * Clones the texture.
  35296. * @returns the cloned texture
  35297. */
  35298. clone(): VideoTexture;
  35299. /**
  35300. * Dispose the texture and release its associated resources.
  35301. */
  35302. dispose(): void;
  35303. /**
  35304. * Creates a video texture straight from a stream.
  35305. * @param scene Define the scene the texture should be created in
  35306. * @param stream Define the stream the texture should be created from
  35307. * @returns The created video texture as a promise
  35308. */
  35309. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35310. /**
  35311. * Creates a video texture straight from your WebCam video feed.
  35312. * @param scene Define the scene the texture should be created in
  35313. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35314. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35315. * @returns The created video texture as a promise
  35316. */
  35317. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35318. minWidth: number;
  35319. maxWidth: number;
  35320. minHeight: number;
  35321. maxHeight: number;
  35322. deviceId: string;
  35323. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35324. /**
  35325. * Creates a video texture straight from your WebCam video feed.
  35326. * @param scene Define the scene the texture should be created in
  35327. * @param onReady Define a callback to triggered once the texture will be ready
  35328. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35329. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35330. */
  35331. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35332. minWidth: number;
  35333. maxWidth: number;
  35334. minHeight: number;
  35335. maxHeight: number;
  35336. deviceId: string;
  35337. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35338. }
  35339. }
  35340. declare module BABYLON {
  35341. /**
  35342. * Defines the interface used by objects working like Scene
  35343. * @hidden
  35344. */
  35345. export interface ISceneLike {
  35346. _addPendingData(data: any): void;
  35347. _removePendingData(data: any): void;
  35348. offlineProvider: IOfflineProvider;
  35349. }
  35350. /**
  35351. * Information about the current host
  35352. */
  35353. export interface HostInformation {
  35354. /**
  35355. * Defines if the current host is a mobile
  35356. */
  35357. isMobile: boolean;
  35358. }
  35359. /** Interface defining initialization parameters for Engine class */
  35360. export interface EngineOptions extends WebGLContextAttributes {
  35361. /**
  35362. * Defines if the engine should no exceed a specified device ratio
  35363. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35364. */
  35365. limitDeviceRatio?: number;
  35366. /**
  35367. * Defines if webvr should be enabled automatically
  35368. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35369. */
  35370. autoEnableWebVR?: boolean;
  35371. /**
  35372. * Defines if webgl2 should be turned off even if supported
  35373. * @see https://doc.babylonjs.com/features/webgl2
  35374. */
  35375. disableWebGL2Support?: boolean;
  35376. /**
  35377. * Defines if webaudio should be initialized as well
  35378. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35379. */
  35380. audioEngine?: boolean;
  35381. /**
  35382. * Defines if animations should run using a deterministic lock step
  35383. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35384. */
  35385. deterministicLockstep?: boolean;
  35386. /** Defines the maximum steps to use with deterministic lock step mode */
  35387. lockstepMaxSteps?: number;
  35388. /** Defines the seconds between each deterministic lock step */
  35389. timeStep?: number;
  35390. /**
  35391. * Defines that engine should ignore context lost events
  35392. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35393. */
  35394. doNotHandleContextLost?: boolean;
  35395. /**
  35396. * Defines that engine should ignore modifying touch action attribute and style
  35397. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35398. */
  35399. doNotHandleTouchAction?: boolean;
  35400. /**
  35401. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35402. */
  35403. useHighPrecisionFloats?: boolean;
  35404. /**
  35405. * Make the canvas XR Compatible for XR sessions
  35406. */
  35407. xrCompatible?: boolean;
  35408. /**
  35409. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35410. */
  35411. useHighPrecisionMatrix?: boolean;
  35412. }
  35413. /**
  35414. * The base engine class (root of all engines)
  35415. */
  35416. export class ThinEngine {
  35417. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35418. static ExceptionList: ({
  35419. key: string;
  35420. capture: string;
  35421. captureConstraint: number;
  35422. targets: string[];
  35423. } | {
  35424. key: string;
  35425. capture: null;
  35426. captureConstraint: null;
  35427. targets: string[];
  35428. })[];
  35429. /** @hidden */
  35430. static _TextureLoaders: IInternalTextureLoader[];
  35431. /**
  35432. * Returns the current npm package of the sdk
  35433. */
  35434. static get NpmPackage(): string;
  35435. /**
  35436. * Returns the current version of the framework
  35437. */
  35438. static get Version(): string;
  35439. /**
  35440. * Returns a string describing the current engine
  35441. */
  35442. get description(): string;
  35443. /**
  35444. * Gets or sets the epsilon value used by collision engine
  35445. */
  35446. static CollisionsEpsilon: number;
  35447. /**
  35448. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35449. */
  35450. static get ShadersRepository(): string;
  35451. static set ShadersRepository(value: string);
  35452. /** @hidden */
  35453. _shaderProcessor: IShaderProcessor;
  35454. /**
  35455. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35456. */
  35457. forcePOTTextures: boolean;
  35458. /**
  35459. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35460. */
  35461. isFullscreen: boolean;
  35462. /**
  35463. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35464. */
  35465. cullBackFaces: boolean;
  35466. /**
  35467. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35468. */
  35469. renderEvenInBackground: boolean;
  35470. /**
  35471. * Gets or sets a boolean indicating that cache can be kept between frames
  35472. */
  35473. preventCacheWipeBetweenFrames: boolean;
  35474. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35475. validateShaderPrograms: boolean;
  35476. /**
  35477. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35478. * This can provide greater z depth for distant objects.
  35479. */
  35480. useReverseDepthBuffer: boolean;
  35481. /**
  35482. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35483. */
  35484. disableUniformBuffers: boolean;
  35485. /** @hidden */
  35486. _uniformBuffers: UniformBuffer[];
  35487. /**
  35488. * Gets a boolean indicating that the engine supports uniform buffers
  35489. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35490. */
  35491. get supportsUniformBuffers(): boolean;
  35492. /** @hidden */
  35493. _gl: WebGLRenderingContext;
  35494. /** @hidden */
  35495. _webGLVersion: number;
  35496. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35497. protected _windowIsBackground: boolean;
  35498. protected _creationOptions: EngineOptions;
  35499. protected _highPrecisionShadersAllowed: boolean;
  35500. /** @hidden */
  35501. get _shouldUseHighPrecisionShader(): boolean;
  35502. /**
  35503. * Gets a boolean indicating that only power of 2 textures are supported
  35504. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35505. */
  35506. get needPOTTextures(): boolean;
  35507. /** @hidden */
  35508. _badOS: boolean;
  35509. /** @hidden */
  35510. _badDesktopOS: boolean;
  35511. private _hardwareScalingLevel;
  35512. /** @hidden */
  35513. _caps: EngineCapabilities;
  35514. private _isStencilEnable;
  35515. private _glVersion;
  35516. private _glRenderer;
  35517. private _glVendor;
  35518. /** @hidden */
  35519. _videoTextureSupported: boolean;
  35520. protected _renderingQueueLaunched: boolean;
  35521. protected _activeRenderLoops: (() => void)[];
  35522. /**
  35523. * Observable signaled when a context lost event is raised
  35524. */
  35525. onContextLostObservable: Observable<ThinEngine>;
  35526. /**
  35527. * Observable signaled when a context restored event is raised
  35528. */
  35529. onContextRestoredObservable: Observable<ThinEngine>;
  35530. private _onContextLost;
  35531. private _onContextRestored;
  35532. protected _contextWasLost: boolean;
  35533. /** @hidden */
  35534. _doNotHandleContextLost: boolean;
  35535. /**
  35536. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35537. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35538. */
  35539. get doNotHandleContextLost(): boolean;
  35540. set doNotHandleContextLost(value: boolean);
  35541. /**
  35542. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35543. */
  35544. disableVertexArrayObjects: boolean;
  35545. /** @hidden */
  35546. protected _colorWrite: boolean;
  35547. /** @hidden */
  35548. protected _colorWriteChanged: boolean;
  35549. /** @hidden */
  35550. protected _depthCullingState: DepthCullingState;
  35551. /** @hidden */
  35552. protected _stencilState: StencilState;
  35553. /** @hidden */
  35554. _alphaState: AlphaState;
  35555. /** @hidden */
  35556. _alphaMode: number;
  35557. /** @hidden */
  35558. _alphaEquation: number;
  35559. /** @hidden */
  35560. _internalTexturesCache: InternalTexture[];
  35561. /** @hidden */
  35562. protected _activeChannel: number;
  35563. private _currentTextureChannel;
  35564. /** @hidden */
  35565. protected _boundTexturesCache: {
  35566. [key: string]: Nullable<InternalTexture>;
  35567. };
  35568. /** @hidden */
  35569. protected _currentEffect: Nullable<Effect>;
  35570. /** @hidden */
  35571. protected _currentProgram: Nullable<WebGLProgram>;
  35572. private _compiledEffects;
  35573. private _vertexAttribArraysEnabled;
  35574. /** @hidden */
  35575. protected _cachedViewport: Nullable<IViewportLike>;
  35576. private _cachedVertexArrayObject;
  35577. /** @hidden */
  35578. protected _cachedVertexBuffers: any;
  35579. /** @hidden */
  35580. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35581. /** @hidden */
  35582. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35583. /** @hidden */
  35584. _currentRenderTarget: Nullable<InternalTexture>;
  35585. private _uintIndicesCurrentlySet;
  35586. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35587. /** @hidden */
  35588. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35589. /** @hidden */
  35590. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35591. private _currentBufferPointers;
  35592. private _currentInstanceLocations;
  35593. private _currentInstanceBuffers;
  35594. private _textureUnits;
  35595. /** @hidden */
  35596. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35597. /** @hidden */
  35598. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35599. /** @hidden */
  35600. _boundRenderFunction: any;
  35601. private _vaoRecordInProgress;
  35602. private _mustWipeVertexAttributes;
  35603. private _emptyTexture;
  35604. private _emptyCubeTexture;
  35605. private _emptyTexture3D;
  35606. private _emptyTexture2DArray;
  35607. /** @hidden */
  35608. _frameHandler: number;
  35609. private _nextFreeTextureSlots;
  35610. private _maxSimultaneousTextures;
  35611. private _activeRequests;
  35612. /** @hidden */
  35613. _transformTextureUrl: Nullable<(url: string) => string>;
  35614. /**
  35615. * Gets information about the current host
  35616. */
  35617. hostInformation: HostInformation;
  35618. protected get _supportsHardwareTextureRescaling(): boolean;
  35619. private _framebufferDimensionsObject;
  35620. /**
  35621. * sets the object from which width and height will be taken from when getting render width and height
  35622. * Will fallback to the gl object
  35623. * @param dimensions the framebuffer width and height that will be used.
  35624. */
  35625. set framebufferDimensionsObject(dimensions: Nullable<{
  35626. framebufferWidth: number;
  35627. framebufferHeight: number;
  35628. }>);
  35629. /**
  35630. * Gets the current viewport
  35631. */
  35632. get currentViewport(): Nullable<IViewportLike>;
  35633. /**
  35634. * Gets the default empty texture
  35635. */
  35636. get emptyTexture(): InternalTexture;
  35637. /**
  35638. * Gets the default empty 3D texture
  35639. */
  35640. get emptyTexture3D(): InternalTexture;
  35641. /**
  35642. * Gets the default empty 2D array texture
  35643. */
  35644. get emptyTexture2DArray(): InternalTexture;
  35645. /**
  35646. * Gets the default empty cube texture
  35647. */
  35648. get emptyCubeTexture(): InternalTexture;
  35649. /**
  35650. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35651. */
  35652. readonly premultipliedAlpha: boolean;
  35653. /**
  35654. * Observable event triggered before each texture is initialized
  35655. */
  35656. onBeforeTextureInitObservable: Observable<Texture>;
  35657. /**
  35658. * Creates a new engine
  35659. * @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
  35660. * @param antialias defines enable antialiasing (default: false)
  35661. * @param options defines further options to be sent to the getContext() function
  35662. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35663. */
  35664. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35665. private _rebuildInternalTextures;
  35666. private _rebuildEffects;
  35667. /**
  35668. * Gets a boolean indicating if all created effects are ready
  35669. * @returns true if all effects are ready
  35670. */
  35671. areAllEffectsReady(): boolean;
  35672. protected _rebuildBuffers(): void;
  35673. protected _initGLContext(): void;
  35674. /**
  35675. * Gets version of the current webGL context
  35676. */
  35677. get webGLVersion(): number;
  35678. /**
  35679. * Gets a string identifying the name of the class
  35680. * @returns "Engine" string
  35681. */
  35682. getClassName(): string;
  35683. /**
  35684. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35685. */
  35686. get isStencilEnable(): boolean;
  35687. /** @hidden */
  35688. _prepareWorkingCanvas(): void;
  35689. /**
  35690. * Reset the texture cache to empty state
  35691. */
  35692. resetTextureCache(): void;
  35693. /**
  35694. * Gets an object containing information about the current webGL context
  35695. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35696. */
  35697. getGlInfo(): {
  35698. vendor: string;
  35699. renderer: string;
  35700. version: string;
  35701. };
  35702. /**
  35703. * Defines the hardware scaling level.
  35704. * By default the hardware scaling level is computed from the window device ratio.
  35705. * 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.
  35706. * @param level defines the level to use
  35707. */
  35708. setHardwareScalingLevel(level: number): void;
  35709. /**
  35710. * Gets the current hardware scaling level.
  35711. * By default the hardware scaling level is computed from the window device ratio.
  35712. * 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.
  35713. * @returns a number indicating the current hardware scaling level
  35714. */
  35715. getHardwareScalingLevel(): number;
  35716. /**
  35717. * Gets the list of loaded textures
  35718. * @returns an array containing all loaded textures
  35719. */
  35720. getLoadedTexturesCache(): InternalTexture[];
  35721. /**
  35722. * Gets the object containing all engine capabilities
  35723. * @returns the EngineCapabilities object
  35724. */
  35725. getCaps(): EngineCapabilities;
  35726. /**
  35727. * stop executing a render loop function and remove it from the execution array
  35728. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35729. */
  35730. stopRenderLoop(renderFunction?: () => void): void;
  35731. /** @hidden */
  35732. _renderLoop(): void;
  35733. /**
  35734. * Gets the HTML canvas attached with the current webGL context
  35735. * @returns a HTML canvas
  35736. */
  35737. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35738. /**
  35739. * Gets host window
  35740. * @returns the host window object
  35741. */
  35742. getHostWindow(): Nullable<Window>;
  35743. /**
  35744. * Gets the current render width
  35745. * @param useScreen defines if screen size must be used (or the current render target if any)
  35746. * @returns a number defining the current render width
  35747. */
  35748. getRenderWidth(useScreen?: boolean): number;
  35749. /**
  35750. * Gets the current render height
  35751. * @param useScreen defines if screen size must be used (or the current render target if any)
  35752. * @returns a number defining the current render height
  35753. */
  35754. getRenderHeight(useScreen?: boolean): number;
  35755. /**
  35756. * Can be used to override the current requestAnimationFrame requester.
  35757. * @hidden
  35758. */
  35759. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35760. /**
  35761. * Register and execute a render loop. The engine can have more than one render function
  35762. * @param renderFunction defines the function to continuously execute
  35763. */
  35764. runRenderLoop(renderFunction: () => void): void;
  35765. /**
  35766. * Clear the current render buffer or the current render target (if any is set up)
  35767. * @param color defines the color to use
  35768. * @param backBuffer defines if the back buffer must be cleared
  35769. * @param depth defines if the depth buffer must be cleared
  35770. * @param stencil defines if the stencil buffer must be cleared
  35771. */
  35772. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35773. private _viewportCached;
  35774. /** @hidden */
  35775. _viewport(x: number, y: number, width: number, height: number): void;
  35776. /**
  35777. * Set the WebGL's viewport
  35778. * @param viewport defines the viewport element to be used
  35779. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35780. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35781. */
  35782. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35783. /**
  35784. * Begin a new frame
  35785. */
  35786. beginFrame(): void;
  35787. /**
  35788. * Enf the current frame
  35789. */
  35790. endFrame(): void;
  35791. /**
  35792. * Resize the view according to the canvas' size
  35793. */
  35794. resize(): void;
  35795. /**
  35796. * Force a specific size of the canvas
  35797. * @param width defines the new canvas' width
  35798. * @param height defines the new canvas' height
  35799. * @returns true if the size was changed
  35800. */
  35801. setSize(width: number, height: number): boolean;
  35802. /**
  35803. * Binds the frame buffer to the specified texture.
  35804. * @param texture The texture to render to or null for the default canvas
  35805. * @param faceIndex The face of the texture to render to in case of cube texture
  35806. * @param requiredWidth The width of the target to render to
  35807. * @param requiredHeight The height of the target to render to
  35808. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35809. * @param lodLevel defines the lod level to bind to the frame buffer
  35810. * @param layer defines the 2d array index to bind to frame buffer to
  35811. */
  35812. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35813. /** @hidden */
  35814. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35815. /**
  35816. * Unbind the current render target texture from the webGL context
  35817. * @param texture defines the render target texture to unbind
  35818. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35819. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35820. */
  35821. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35822. /**
  35823. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35824. */
  35825. flushFramebuffer(): void;
  35826. /**
  35827. * Unbind the current render target and bind the default framebuffer
  35828. */
  35829. restoreDefaultFramebuffer(): void;
  35830. /** @hidden */
  35831. protected _resetVertexBufferBinding(): void;
  35832. /**
  35833. * Creates a vertex buffer
  35834. * @param data the data for the vertex buffer
  35835. * @returns the new WebGL static buffer
  35836. */
  35837. createVertexBuffer(data: DataArray): DataBuffer;
  35838. private _createVertexBuffer;
  35839. /**
  35840. * Creates a dynamic vertex buffer
  35841. * @param data the data for the dynamic vertex buffer
  35842. * @returns the new WebGL dynamic buffer
  35843. */
  35844. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35845. protected _resetIndexBufferBinding(): void;
  35846. /**
  35847. * Creates a new index buffer
  35848. * @param indices defines the content of the index buffer
  35849. * @param updatable defines if the index buffer must be updatable
  35850. * @returns a new webGL buffer
  35851. */
  35852. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35853. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35854. /**
  35855. * Bind a webGL buffer to the webGL context
  35856. * @param buffer defines the buffer to bind
  35857. */
  35858. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35859. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35860. private bindBuffer;
  35861. /**
  35862. * update the bound buffer with the given data
  35863. * @param data defines the data to update
  35864. */
  35865. updateArrayBuffer(data: Float32Array): void;
  35866. private _vertexAttribPointer;
  35867. /** @hidden */
  35868. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35869. private _bindVertexBuffersAttributes;
  35870. /**
  35871. * Records a vertex array object
  35872. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35873. * @param vertexBuffers defines the list of vertex buffers to store
  35874. * @param indexBuffer defines the index buffer to store
  35875. * @param effect defines the effect to store
  35876. * @returns the new vertex array object
  35877. */
  35878. recordVertexArrayObject(vertexBuffers: {
  35879. [key: string]: VertexBuffer;
  35880. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35881. /**
  35882. * Bind a specific vertex array object
  35883. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35884. * @param vertexArrayObject defines the vertex array object to bind
  35885. * @param indexBuffer defines the index buffer to bind
  35886. */
  35887. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35888. /**
  35889. * Bind webGl buffers directly to the webGL context
  35890. * @param vertexBuffer defines the vertex buffer to bind
  35891. * @param indexBuffer defines the index buffer to bind
  35892. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35893. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35894. * @param effect defines the effect associated with the vertex buffer
  35895. */
  35896. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35897. private _unbindVertexArrayObject;
  35898. /**
  35899. * Bind a list of vertex buffers to the webGL context
  35900. * @param vertexBuffers defines the list of vertex buffers to bind
  35901. * @param indexBuffer defines the index buffer to bind
  35902. * @param effect defines the effect associated with the vertex buffers
  35903. */
  35904. bindBuffers(vertexBuffers: {
  35905. [key: string]: Nullable<VertexBuffer>;
  35906. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35907. /**
  35908. * Unbind all instance attributes
  35909. */
  35910. unbindInstanceAttributes(): void;
  35911. /**
  35912. * Release and free the memory of a vertex array object
  35913. * @param vao defines the vertex array object to delete
  35914. */
  35915. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35916. /** @hidden */
  35917. _releaseBuffer(buffer: DataBuffer): boolean;
  35918. protected _deleteBuffer(buffer: DataBuffer): void;
  35919. /**
  35920. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35921. * @param instancesBuffer defines the webGL buffer to update and bind
  35922. * @param data defines the data to store in the buffer
  35923. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35924. */
  35925. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35926. /**
  35927. * Bind the content of a webGL buffer used with instantiation
  35928. * @param instancesBuffer defines the webGL buffer to bind
  35929. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35930. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35931. */
  35932. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35933. /**
  35934. * Disable the instance attribute corresponding to the name in parameter
  35935. * @param name defines the name of the attribute to disable
  35936. */
  35937. disableInstanceAttributeByName(name: string): void;
  35938. /**
  35939. * Disable the instance attribute corresponding to the location in parameter
  35940. * @param attributeLocation defines the attribute location of the attribute to disable
  35941. */
  35942. disableInstanceAttribute(attributeLocation: number): void;
  35943. /**
  35944. * Disable the attribute corresponding to the location in parameter
  35945. * @param attributeLocation defines the attribute location of the attribute to disable
  35946. */
  35947. disableAttributeByIndex(attributeLocation: number): void;
  35948. /**
  35949. * Send a draw order
  35950. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35951. * @param indexStart defines the starting index
  35952. * @param indexCount defines the number of index to draw
  35953. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35954. */
  35955. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35956. /**
  35957. * Draw a list of points
  35958. * @param verticesStart defines the index of first vertex to draw
  35959. * @param verticesCount defines the count of vertices to draw
  35960. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35961. */
  35962. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35963. /**
  35964. * Draw a list of unindexed primitives
  35965. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35966. * @param verticesStart defines the index of first vertex to draw
  35967. * @param verticesCount defines the count of vertices to draw
  35968. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35969. */
  35970. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35971. /**
  35972. * Draw a list of indexed primitives
  35973. * @param fillMode defines the primitive to use
  35974. * @param indexStart defines the starting index
  35975. * @param indexCount defines the number of index to draw
  35976. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35977. */
  35978. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35979. /**
  35980. * Draw a list of unindexed primitives
  35981. * @param fillMode defines the primitive to use
  35982. * @param verticesStart defines the index of first vertex to draw
  35983. * @param verticesCount defines the count of vertices to draw
  35984. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35985. */
  35986. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35987. private _drawMode;
  35988. /** @hidden */
  35989. protected _reportDrawCall(): void;
  35990. /** @hidden */
  35991. _releaseEffect(effect: Effect): void;
  35992. /** @hidden */
  35993. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35994. /**
  35995. * Create a new effect (used to store vertex/fragment shaders)
  35996. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35997. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35998. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35999. * @param samplers defines an array of string used to represent textures
  36000. * @param defines defines the string containing the defines to use to compile the shaders
  36001. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36002. * @param onCompiled defines a function to call when the effect creation is successful
  36003. * @param onError defines a function to call when the effect creation has failed
  36004. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36005. * @returns the new Effect
  36006. */
  36007. 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;
  36008. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36009. private _compileShader;
  36010. private _compileRawShader;
  36011. /** @hidden */
  36012. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36013. /**
  36014. * Directly creates a webGL program
  36015. * @param pipelineContext defines the pipeline context to attach to
  36016. * @param vertexCode defines the vertex shader code to use
  36017. * @param fragmentCode defines the fragment shader code to use
  36018. * @param context defines the webGL context to use (if not set, the current one will be used)
  36019. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36020. * @returns the new webGL program
  36021. */
  36022. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36023. /**
  36024. * Creates a webGL program
  36025. * @param pipelineContext defines the pipeline context to attach to
  36026. * @param vertexCode defines the vertex shader code to use
  36027. * @param fragmentCode defines the fragment shader code to use
  36028. * @param defines defines the string containing the defines to use to compile the shaders
  36029. * @param context defines the webGL context to use (if not set, the current one will be used)
  36030. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36031. * @returns the new webGL program
  36032. */
  36033. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36034. /**
  36035. * Creates a new pipeline context
  36036. * @returns the new pipeline
  36037. */
  36038. createPipelineContext(): IPipelineContext;
  36039. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36040. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36041. /** @hidden */
  36042. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36043. /** @hidden */
  36044. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36045. /** @hidden */
  36046. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36047. /**
  36048. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36049. * @param pipelineContext defines the pipeline context to use
  36050. * @param uniformsNames defines the list of uniform names
  36051. * @returns an array of webGL uniform locations
  36052. */
  36053. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36054. /**
  36055. * Gets the lsit of active attributes for a given webGL program
  36056. * @param pipelineContext defines the pipeline context to use
  36057. * @param attributesNames defines the list of attribute names to get
  36058. * @returns an array of indices indicating the offset of each attribute
  36059. */
  36060. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36061. /**
  36062. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36063. * @param effect defines the effect to activate
  36064. */
  36065. enableEffect(effect: Nullable<Effect>): void;
  36066. /**
  36067. * Set the value of an uniform to a number (int)
  36068. * @param uniform defines the webGL uniform location where to store the value
  36069. * @param value defines the int number to store
  36070. */
  36071. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36072. /**
  36073. * Set the value of an uniform to an array of int32
  36074. * @param uniform defines the webGL uniform location where to store the value
  36075. * @param array defines the array of int32 to store
  36076. */
  36077. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36078. /**
  36079. * Set the value of an uniform to an array of int32 (stored as vec2)
  36080. * @param uniform defines the webGL uniform location where to store the value
  36081. * @param array defines the array of int32 to store
  36082. */
  36083. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36084. /**
  36085. * Set the value of an uniform to an array of int32 (stored as vec3)
  36086. * @param uniform defines the webGL uniform location where to store the value
  36087. * @param array defines the array of int32 to store
  36088. */
  36089. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36090. /**
  36091. * Set the value of an uniform to an array of int32 (stored as vec4)
  36092. * @param uniform defines the webGL uniform location where to store the value
  36093. * @param array defines the array of int32 to store
  36094. */
  36095. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36096. /**
  36097. * Set the value of an uniform to an array of number
  36098. * @param uniform defines the webGL uniform location where to store the value
  36099. * @param array defines the array of number to store
  36100. */
  36101. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36102. /**
  36103. * Set the value of an uniform to an array of number (stored as vec2)
  36104. * @param uniform defines the webGL uniform location where to store the value
  36105. * @param array defines the array of number to store
  36106. */
  36107. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36108. /**
  36109. * Set the value of an uniform to an array of number (stored as vec3)
  36110. * @param uniform defines the webGL uniform location where to store the value
  36111. * @param array defines the array of number to store
  36112. */
  36113. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36114. /**
  36115. * Set the value of an uniform to an array of number (stored as vec4)
  36116. * @param uniform defines the webGL uniform location where to store the value
  36117. * @param array defines the array of number to store
  36118. */
  36119. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36120. /**
  36121. * Set the value of an uniform to an array of float32 (stored as matrices)
  36122. * @param uniform defines the webGL uniform location where to store the value
  36123. * @param matrices defines the array of float32 to store
  36124. */
  36125. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36126. /**
  36127. * Set the value of an uniform to a matrix (3x3)
  36128. * @param uniform defines the webGL uniform location where to store the value
  36129. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36130. */
  36131. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36132. /**
  36133. * Set the value of an uniform to a matrix (2x2)
  36134. * @param uniform defines the webGL uniform location where to store the value
  36135. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36136. */
  36137. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36138. /**
  36139. * Set the value of an uniform to a number (float)
  36140. * @param uniform defines the webGL uniform location where to store the value
  36141. * @param value defines the float number to store
  36142. */
  36143. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36144. /**
  36145. * Set the value of an uniform to a vec2
  36146. * @param uniform defines the webGL uniform location where to store the value
  36147. * @param x defines the 1st component of the value
  36148. * @param y defines the 2nd component of the value
  36149. */
  36150. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36151. /**
  36152. * Set the value of an uniform to a vec3
  36153. * @param uniform defines the webGL uniform location where to store the value
  36154. * @param x defines the 1st component of the value
  36155. * @param y defines the 2nd component of the value
  36156. * @param z defines the 3rd component of the value
  36157. */
  36158. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36159. /**
  36160. * Set the value of an uniform to a vec4
  36161. * @param uniform defines the webGL uniform location where to store the value
  36162. * @param x defines the 1st component of the value
  36163. * @param y defines the 2nd component of the value
  36164. * @param z defines the 3rd component of the value
  36165. * @param w defines the 4th component of the value
  36166. */
  36167. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36168. /**
  36169. * Apply all cached states (depth, culling, stencil and alpha)
  36170. */
  36171. applyStates(): void;
  36172. /**
  36173. * Enable or disable color writing
  36174. * @param enable defines the state to set
  36175. */
  36176. setColorWrite(enable: boolean): void;
  36177. /**
  36178. * Gets a boolean indicating if color writing is enabled
  36179. * @returns the current color writing state
  36180. */
  36181. getColorWrite(): boolean;
  36182. /**
  36183. * Gets the depth culling state manager
  36184. */
  36185. get depthCullingState(): DepthCullingState;
  36186. /**
  36187. * Gets the alpha state manager
  36188. */
  36189. get alphaState(): AlphaState;
  36190. /**
  36191. * Gets the stencil state manager
  36192. */
  36193. get stencilState(): StencilState;
  36194. /**
  36195. * Clears the list of texture accessible through engine.
  36196. * This can help preventing texture load conflict due to name collision.
  36197. */
  36198. clearInternalTexturesCache(): void;
  36199. /**
  36200. * Force the entire cache to be cleared
  36201. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36202. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36203. */
  36204. wipeCaches(bruteForce?: boolean): void;
  36205. /** @hidden */
  36206. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36207. min: number;
  36208. mag: number;
  36209. };
  36210. /** @hidden */
  36211. _createTexture(): WebGLTexture;
  36212. /**
  36213. * Usually called from Texture.ts.
  36214. * Passed information to create a WebGLTexture
  36215. * @param url defines a value which contains one of the following:
  36216. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36217. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36218. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36219. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36220. * @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)
  36221. * @param scene needed for loading to the correct scene
  36222. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36223. * @param onLoad optional callback to be called upon successful completion
  36224. * @param onError optional callback to be called upon failure
  36225. * @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
  36226. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36227. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36228. * @param forcedExtension defines the extension to use to pick the right loader
  36229. * @param mimeType defines an optional mime type
  36230. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36231. */
  36232. 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;
  36233. /**
  36234. * Loads an image as an HTMLImageElement.
  36235. * @param input url string, ArrayBuffer, or Blob to load
  36236. * @param onLoad callback called when the image successfully loads
  36237. * @param onError callback called when the image fails to load
  36238. * @param offlineProvider offline provider for caching
  36239. * @param mimeType optional mime type
  36240. * @returns the HTMLImageElement of the loaded image
  36241. * @hidden
  36242. */
  36243. 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>;
  36244. /**
  36245. * @hidden
  36246. */
  36247. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36248. private _unpackFlipYCached;
  36249. /**
  36250. * In case you are sharing the context with other applications, it might
  36251. * be interested to not cache the unpack flip y state to ensure a consistent
  36252. * value would be set.
  36253. */
  36254. enableUnpackFlipYCached: boolean;
  36255. /** @hidden */
  36256. _unpackFlipY(value: boolean): void;
  36257. /** @hidden */
  36258. _getUnpackAlignement(): number;
  36259. private _getTextureTarget;
  36260. /**
  36261. * Update the sampling mode of a given texture
  36262. * @param samplingMode defines the required sampling mode
  36263. * @param texture defines the texture to update
  36264. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36265. */
  36266. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36267. /**
  36268. * Update the sampling mode of a given texture
  36269. * @param texture defines the texture to update
  36270. * @param wrapU defines the texture wrap mode of the u coordinates
  36271. * @param wrapV defines the texture wrap mode of the v coordinates
  36272. * @param wrapR defines the texture wrap mode of the r coordinates
  36273. */
  36274. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36275. /** @hidden */
  36276. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36277. width: number;
  36278. height: number;
  36279. layers?: number;
  36280. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36281. /** @hidden */
  36282. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36283. /** @hidden */
  36284. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36285. /**
  36286. * Update a portion of an internal texture
  36287. * @param texture defines the texture to update
  36288. * @param imageData defines the data to store into the texture
  36289. * @param xOffset defines the x coordinates of the update rectangle
  36290. * @param yOffset defines the y coordinates of the update rectangle
  36291. * @param width defines the width of the update rectangle
  36292. * @param height defines the height of the update rectangle
  36293. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36294. * @param lod defines the lod level to update (0 by default)
  36295. */
  36296. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36297. /** @hidden */
  36298. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36299. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36300. private _prepareWebGLTexture;
  36301. /** @hidden */
  36302. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36303. private _getDepthStencilBuffer;
  36304. /** @hidden */
  36305. _releaseFramebufferObjects(texture: InternalTexture): void;
  36306. /** @hidden */
  36307. _releaseTexture(texture: InternalTexture): void;
  36308. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36309. protected _setProgram(program: WebGLProgram): void;
  36310. protected _boundUniforms: {
  36311. [key: number]: WebGLUniformLocation;
  36312. };
  36313. /**
  36314. * Binds an effect to the webGL context
  36315. * @param effect defines the effect to bind
  36316. */
  36317. bindSamplers(effect: Effect): void;
  36318. private _activateCurrentTexture;
  36319. /** @hidden */
  36320. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36321. /** @hidden */
  36322. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36323. /**
  36324. * Unbind all textures from the webGL context
  36325. */
  36326. unbindAllTextures(): void;
  36327. /**
  36328. * Sets a texture to the according uniform.
  36329. * @param channel The texture channel
  36330. * @param uniform The uniform to set
  36331. * @param texture The texture to apply
  36332. */
  36333. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36334. private _bindSamplerUniformToChannel;
  36335. private _getTextureWrapMode;
  36336. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36337. /**
  36338. * Sets an array of texture to the webGL context
  36339. * @param channel defines the channel where the texture array must be set
  36340. * @param uniform defines the associated uniform location
  36341. * @param textures defines the array of textures to bind
  36342. */
  36343. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36344. /** @hidden */
  36345. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36346. private _setTextureParameterFloat;
  36347. private _setTextureParameterInteger;
  36348. /**
  36349. * Unbind all vertex attributes from the webGL context
  36350. */
  36351. unbindAllAttributes(): void;
  36352. /**
  36353. * 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
  36354. */
  36355. releaseEffects(): void;
  36356. /**
  36357. * Dispose and release all associated resources
  36358. */
  36359. dispose(): void;
  36360. /**
  36361. * Attach a new callback raised when context lost event is fired
  36362. * @param callback defines the callback to call
  36363. */
  36364. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36365. /**
  36366. * Attach a new callback raised when context restored event is fired
  36367. * @param callback defines the callback to call
  36368. */
  36369. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36370. /**
  36371. * Get the current error code of the webGL context
  36372. * @returns the error code
  36373. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36374. */
  36375. getError(): number;
  36376. private _canRenderToFloatFramebuffer;
  36377. private _canRenderToHalfFloatFramebuffer;
  36378. private _canRenderToFramebuffer;
  36379. /** @hidden */
  36380. _getWebGLTextureType(type: number): number;
  36381. /** @hidden */
  36382. _getInternalFormat(format: number): number;
  36383. /** @hidden */
  36384. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36385. /** @hidden */
  36386. _getRGBAMultiSampleBufferFormat(type: number): number;
  36387. /** @hidden */
  36388. _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;
  36389. /**
  36390. * Loads a file from a url
  36391. * @param url url to load
  36392. * @param onSuccess callback called when the file successfully loads
  36393. * @param onProgress callback called while file is loading (if the server supports this mode)
  36394. * @param offlineProvider defines the offline provider for caching
  36395. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36396. * @param onError callback called when the file fails to load
  36397. * @returns a file request object
  36398. * @hidden
  36399. */
  36400. 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;
  36401. /**
  36402. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36403. * @param x defines the x coordinate of the rectangle where pixels must be read
  36404. * @param y defines the y coordinate of the rectangle where pixels must be read
  36405. * @param width defines the width of the rectangle where pixels must be read
  36406. * @param height defines the height of the rectangle where pixels must be read
  36407. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36408. * @returns a Uint8Array containing RGBA colors
  36409. */
  36410. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36411. private static _isSupported;
  36412. /**
  36413. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36414. * @returns true if the engine can be created
  36415. * @ignorenaming
  36416. */
  36417. static isSupported(): boolean;
  36418. /**
  36419. * Find the next highest power of two.
  36420. * @param x Number to start search from.
  36421. * @return Next highest power of two.
  36422. */
  36423. static CeilingPOT(x: number): number;
  36424. /**
  36425. * Find the next lowest power of two.
  36426. * @param x Number to start search from.
  36427. * @return Next lowest power of two.
  36428. */
  36429. static FloorPOT(x: number): number;
  36430. /**
  36431. * Find the nearest power of two.
  36432. * @param x Number to start search from.
  36433. * @return Next nearest power of two.
  36434. */
  36435. static NearestPOT(x: number): number;
  36436. /**
  36437. * Get the closest exponent of two
  36438. * @param value defines the value to approximate
  36439. * @param max defines the maximum value to return
  36440. * @param mode defines how to define the closest value
  36441. * @returns closest exponent of two of the given value
  36442. */
  36443. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36444. /**
  36445. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36446. * @param func - the function to be called
  36447. * @param requester - the object that will request the next frame. Falls back to window.
  36448. * @returns frame number
  36449. */
  36450. static QueueNewFrame(func: () => void, requester?: any): number;
  36451. /**
  36452. * Gets host document
  36453. * @returns the host document object
  36454. */
  36455. getHostDocument(): Nullable<Document>;
  36456. }
  36457. }
  36458. declare module BABYLON {
  36459. /**
  36460. * Class representing spherical harmonics coefficients to the 3rd degree
  36461. */
  36462. export class SphericalHarmonics {
  36463. /**
  36464. * Defines whether or not the harmonics have been prescaled for rendering.
  36465. */
  36466. preScaled: boolean;
  36467. /**
  36468. * The l0,0 coefficients of the spherical harmonics
  36469. */
  36470. l00: Vector3;
  36471. /**
  36472. * The l1,-1 coefficients of the spherical harmonics
  36473. */
  36474. l1_1: Vector3;
  36475. /**
  36476. * The l1,0 coefficients of the spherical harmonics
  36477. */
  36478. l10: Vector3;
  36479. /**
  36480. * The l1,1 coefficients of the spherical harmonics
  36481. */
  36482. l11: Vector3;
  36483. /**
  36484. * The l2,-2 coefficients of the spherical harmonics
  36485. */
  36486. l2_2: Vector3;
  36487. /**
  36488. * The l2,-1 coefficients of the spherical harmonics
  36489. */
  36490. l2_1: Vector3;
  36491. /**
  36492. * The l2,0 coefficients of the spherical harmonics
  36493. */
  36494. l20: Vector3;
  36495. /**
  36496. * The l2,1 coefficients of the spherical harmonics
  36497. */
  36498. l21: Vector3;
  36499. /**
  36500. * The l2,2 coefficients of the spherical harmonics
  36501. */
  36502. l22: Vector3;
  36503. /**
  36504. * Adds a light to the spherical harmonics
  36505. * @param direction the direction of the light
  36506. * @param color the color of the light
  36507. * @param deltaSolidAngle the delta solid angle of the light
  36508. */
  36509. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36510. /**
  36511. * Scales the spherical harmonics by the given amount
  36512. * @param scale the amount to scale
  36513. */
  36514. scaleInPlace(scale: number): void;
  36515. /**
  36516. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36517. *
  36518. * ```
  36519. * E_lm = A_l * L_lm
  36520. * ```
  36521. *
  36522. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36523. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36524. * the scaling factors are given in equation 9.
  36525. */
  36526. convertIncidentRadianceToIrradiance(): void;
  36527. /**
  36528. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36529. *
  36530. * ```
  36531. * L = (1/pi) * E * rho
  36532. * ```
  36533. *
  36534. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36535. */
  36536. convertIrradianceToLambertianRadiance(): void;
  36537. /**
  36538. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36539. * required operations at run time.
  36540. *
  36541. * This is simply done by scaling back the SH with Ylm constants parameter.
  36542. * The trigonometric part being applied by the shader at run time.
  36543. */
  36544. preScaleForRendering(): void;
  36545. /**
  36546. * Constructs a spherical harmonics from an array.
  36547. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36548. * @returns the spherical harmonics
  36549. */
  36550. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36551. /**
  36552. * Gets the spherical harmonics from polynomial
  36553. * @param polynomial the spherical polynomial
  36554. * @returns the spherical harmonics
  36555. */
  36556. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36557. }
  36558. /**
  36559. * Class representing spherical polynomial coefficients to the 3rd degree
  36560. */
  36561. export class SphericalPolynomial {
  36562. private _harmonics;
  36563. /**
  36564. * The spherical harmonics used to create the polynomials.
  36565. */
  36566. get preScaledHarmonics(): SphericalHarmonics;
  36567. /**
  36568. * The x coefficients of the spherical polynomial
  36569. */
  36570. x: Vector3;
  36571. /**
  36572. * The y coefficients of the spherical polynomial
  36573. */
  36574. y: Vector3;
  36575. /**
  36576. * The z coefficients of the spherical polynomial
  36577. */
  36578. z: Vector3;
  36579. /**
  36580. * The xx coefficients of the spherical polynomial
  36581. */
  36582. xx: Vector3;
  36583. /**
  36584. * The yy coefficients of the spherical polynomial
  36585. */
  36586. yy: Vector3;
  36587. /**
  36588. * The zz coefficients of the spherical polynomial
  36589. */
  36590. zz: Vector3;
  36591. /**
  36592. * The xy coefficients of the spherical polynomial
  36593. */
  36594. xy: Vector3;
  36595. /**
  36596. * The yz coefficients of the spherical polynomial
  36597. */
  36598. yz: Vector3;
  36599. /**
  36600. * The zx coefficients of the spherical polynomial
  36601. */
  36602. zx: Vector3;
  36603. /**
  36604. * Adds an ambient color to the spherical polynomial
  36605. * @param color the color to add
  36606. */
  36607. addAmbient(color: Color3): void;
  36608. /**
  36609. * Scales the spherical polynomial by the given amount
  36610. * @param scale the amount to scale
  36611. */
  36612. scaleInPlace(scale: number): void;
  36613. /**
  36614. * Gets the spherical polynomial from harmonics
  36615. * @param harmonics the spherical harmonics
  36616. * @returns the spherical polynomial
  36617. */
  36618. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36619. /**
  36620. * Constructs a spherical polynomial from an array.
  36621. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36622. * @returns the spherical polynomial
  36623. */
  36624. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36625. }
  36626. }
  36627. declare module BABYLON {
  36628. /**
  36629. * Defines the source of the internal texture
  36630. */
  36631. export enum InternalTextureSource {
  36632. /**
  36633. * The source of the texture data is unknown
  36634. */
  36635. Unknown = 0,
  36636. /**
  36637. * Texture data comes from an URL
  36638. */
  36639. Url = 1,
  36640. /**
  36641. * Texture data is only used for temporary storage
  36642. */
  36643. Temp = 2,
  36644. /**
  36645. * Texture data comes from raw data (ArrayBuffer)
  36646. */
  36647. Raw = 3,
  36648. /**
  36649. * Texture content is dynamic (video or dynamic texture)
  36650. */
  36651. Dynamic = 4,
  36652. /**
  36653. * Texture content is generated by rendering to it
  36654. */
  36655. RenderTarget = 5,
  36656. /**
  36657. * Texture content is part of a multi render target process
  36658. */
  36659. MultiRenderTarget = 6,
  36660. /**
  36661. * Texture data comes from a cube data file
  36662. */
  36663. Cube = 7,
  36664. /**
  36665. * Texture data comes from a raw cube data
  36666. */
  36667. CubeRaw = 8,
  36668. /**
  36669. * Texture data come from a prefiltered cube data file
  36670. */
  36671. CubePrefiltered = 9,
  36672. /**
  36673. * Texture content is raw 3D data
  36674. */
  36675. Raw3D = 10,
  36676. /**
  36677. * Texture content is raw 2D array data
  36678. */
  36679. Raw2DArray = 11,
  36680. /**
  36681. * Texture content is a depth texture
  36682. */
  36683. Depth = 12,
  36684. /**
  36685. * Texture data comes from a raw cube data encoded with RGBD
  36686. */
  36687. CubeRawRGBD = 13
  36688. }
  36689. /**
  36690. * Class used to store data associated with WebGL texture data for the engine
  36691. * This class should not be used directly
  36692. */
  36693. export class InternalTexture {
  36694. /** @hidden */
  36695. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36696. /**
  36697. * Defines if the texture is ready
  36698. */
  36699. isReady: boolean;
  36700. /**
  36701. * Defines if the texture is a cube texture
  36702. */
  36703. isCube: boolean;
  36704. /**
  36705. * Defines if the texture contains 3D data
  36706. */
  36707. is3D: boolean;
  36708. /**
  36709. * Defines if the texture contains 2D array data
  36710. */
  36711. is2DArray: boolean;
  36712. /**
  36713. * Defines if the texture contains multiview data
  36714. */
  36715. isMultiview: boolean;
  36716. /**
  36717. * Gets the URL used to load this texture
  36718. */
  36719. url: string;
  36720. /**
  36721. * Gets the sampling mode of the texture
  36722. */
  36723. samplingMode: number;
  36724. /**
  36725. * Gets a boolean indicating if the texture needs mipmaps generation
  36726. */
  36727. generateMipMaps: boolean;
  36728. /**
  36729. * Gets the number of samples used by the texture (WebGL2+ only)
  36730. */
  36731. samples: number;
  36732. /**
  36733. * Gets the type of the texture (int, float...)
  36734. */
  36735. type: number;
  36736. /**
  36737. * Gets the format of the texture (RGB, RGBA...)
  36738. */
  36739. format: number;
  36740. /**
  36741. * Observable called when the texture is loaded
  36742. */
  36743. onLoadedObservable: Observable<InternalTexture>;
  36744. /**
  36745. * Gets the width of the texture
  36746. */
  36747. width: number;
  36748. /**
  36749. * Gets the height of the texture
  36750. */
  36751. height: number;
  36752. /**
  36753. * Gets the depth of the texture
  36754. */
  36755. depth: number;
  36756. /**
  36757. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36758. */
  36759. baseWidth: number;
  36760. /**
  36761. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36762. */
  36763. baseHeight: number;
  36764. /**
  36765. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36766. */
  36767. baseDepth: number;
  36768. /**
  36769. * Gets a boolean indicating if the texture is inverted on Y axis
  36770. */
  36771. invertY: boolean;
  36772. /** @hidden */
  36773. _invertVScale: boolean;
  36774. /** @hidden */
  36775. _associatedChannel: number;
  36776. /** @hidden */
  36777. _source: InternalTextureSource;
  36778. /** @hidden */
  36779. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36780. /** @hidden */
  36781. _bufferView: Nullable<ArrayBufferView>;
  36782. /** @hidden */
  36783. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36784. /** @hidden */
  36785. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36786. /** @hidden */
  36787. _size: number;
  36788. /** @hidden */
  36789. _extension: string;
  36790. /** @hidden */
  36791. _files: Nullable<string[]>;
  36792. /** @hidden */
  36793. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36794. /** @hidden */
  36795. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36796. /** @hidden */
  36797. _framebuffer: Nullable<WebGLFramebuffer>;
  36798. /** @hidden */
  36799. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36800. /** @hidden */
  36801. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36802. /** @hidden */
  36803. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36804. /** @hidden */
  36805. _attachments: Nullable<number[]>;
  36806. /** @hidden */
  36807. _textureArray: Nullable<InternalTexture[]>;
  36808. /** @hidden */
  36809. _cachedCoordinatesMode: Nullable<number>;
  36810. /** @hidden */
  36811. _cachedWrapU: Nullable<number>;
  36812. /** @hidden */
  36813. _cachedWrapV: Nullable<number>;
  36814. /** @hidden */
  36815. _cachedWrapR: Nullable<number>;
  36816. /** @hidden */
  36817. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36818. /** @hidden */
  36819. _isDisabled: boolean;
  36820. /** @hidden */
  36821. _compression: Nullable<string>;
  36822. /** @hidden */
  36823. _generateStencilBuffer: boolean;
  36824. /** @hidden */
  36825. _generateDepthBuffer: boolean;
  36826. /** @hidden */
  36827. _comparisonFunction: number;
  36828. /** @hidden */
  36829. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36830. /** @hidden */
  36831. _lodGenerationScale: number;
  36832. /** @hidden */
  36833. _lodGenerationOffset: number;
  36834. /** @hidden */
  36835. _depthStencilTexture: Nullable<InternalTexture>;
  36836. /** @hidden */
  36837. _colorTextureArray: Nullable<WebGLTexture>;
  36838. /** @hidden */
  36839. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36840. /** @hidden */
  36841. _lodTextureHigh: Nullable<BaseTexture>;
  36842. /** @hidden */
  36843. _lodTextureMid: Nullable<BaseTexture>;
  36844. /** @hidden */
  36845. _lodTextureLow: Nullable<BaseTexture>;
  36846. /** @hidden */
  36847. _isRGBD: boolean;
  36848. /** @hidden */
  36849. _linearSpecularLOD: boolean;
  36850. /** @hidden */
  36851. _irradianceTexture: Nullable<BaseTexture>;
  36852. /** @hidden */
  36853. _webGLTexture: Nullable<WebGLTexture>;
  36854. /** @hidden */
  36855. _references: number;
  36856. /** @hidden */
  36857. _gammaSpace: Nullable<boolean>;
  36858. private _engine;
  36859. /**
  36860. * Gets the Engine the texture belongs to.
  36861. * @returns The babylon engine
  36862. */
  36863. getEngine(): ThinEngine;
  36864. /**
  36865. * Gets the data source type of the texture
  36866. */
  36867. get source(): InternalTextureSource;
  36868. /**
  36869. * Creates a new InternalTexture
  36870. * @param engine defines the engine to use
  36871. * @param source defines the type of data that will be used
  36872. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36873. */
  36874. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36875. /**
  36876. * Increments the number of references (ie. the number of Texture that point to it)
  36877. */
  36878. incrementReferences(): void;
  36879. /**
  36880. * Change the size of the texture (not the size of the content)
  36881. * @param width defines the new width
  36882. * @param height defines the new height
  36883. * @param depth defines the new depth (1 by default)
  36884. */
  36885. updateSize(width: int, height: int, depth?: int): void;
  36886. /** @hidden */
  36887. _rebuild(): void;
  36888. /** @hidden */
  36889. _swapAndDie(target: InternalTexture): void;
  36890. /**
  36891. * Dispose the current allocated resources
  36892. */
  36893. dispose(): void;
  36894. }
  36895. }
  36896. declare module BABYLON {
  36897. /**
  36898. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36899. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36900. */
  36901. export class Analyser {
  36902. /**
  36903. * Gets or sets the smoothing
  36904. * @ignorenaming
  36905. */
  36906. SMOOTHING: number;
  36907. /**
  36908. * Gets or sets the FFT table size
  36909. * @ignorenaming
  36910. */
  36911. FFT_SIZE: number;
  36912. /**
  36913. * Gets or sets the bar graph amplitude
  36914. * @ignorenaming
  36915. */
  36916. BARGRAPHAMPLITUDE: number;
  36917. /**
  36918. * Gets or sets the position of the debug canvas
  36919. * @ignorenaming
  36920. */
  36921. DEBUGCANVASPOS: {
  36922. x: number;
  36923. y: number;
  36924. };
  36925. /**
  36926. * Gets or sets the debug canvas size
  36927. * @ignorenaming
  36928. */
  36929. DEBUGCANVASSIZE: {
  36930. width: number;
  36931. height: number;
  36932. };
  36933. private _byteFreqs;
  36934. private _byteTime;
  36935. private _floatFreqs;
  36936. private _webAudioAnalyser;
  36937. private _debugCanvas;
  36938. private _debugCanvasContext;
  36939. private _scene;
  36940. private _registerFunc;
  36941. private _audioEngine;
  36942. /**
  36943. * Creates a new analyser
  36944. * @param scene defines hosting scene
  36945. */
  36946. constructor(scene: Scene);
  36947. /**
  36948. * Get the number of data values you will have to play with for the visualization
  36949. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36950. * @returns a number
  36951. */
  36952. getFrequencyBinCount(): number;
  36953. /**
  36954. * Gets the current frequency data as a byte array
  36955. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36956. * @returns a Uint8Array
  36957. */
  36958. getByteFrequencyData(): Uint8Array;
  36959. /**
  36960. * Gets the current waveform as a byte array
  36961. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36962. * @returns a Uint8Array
  36963. */
  36964. getByteTimeDomainData(): Uint8Array;
  36965. /**
  36966. * Gets the current frequency data as a float array
  36967. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36968. * @returns a Float32Array
  36969. */
  36970. getFloatFrequencyData(): Float32Array;
  36971. /**
  36972. * Renders the debug canvas
  36973. */
  36974. drawDebugCanvas(): void;
  36975. /**
  36976. * Stops rendering the debug canvas and removes it
  36977. */
  36978. stopDebugCanvas(): void;
  36979. /**
  36980. * Connects two audio nodes
  36981. * @param inputAudioNode defines first node to connect
  36982. * @param outputAudioNode defines second node to connect
  36983. */
  36984. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36985. /**
  36986. * Releases all associated resources
  36987. */
  36988. dispose(): void;
  36989. }
  36990. }
  36991. declare module BABYLON {
  36992. /**
  36993. * This represents an audio engine and it is responsible
  36994. * to play, synchronize and analyse sounds throughout the application.
  36995. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36996. */
  36997. export interface IAudioEngine extends IDisposable {
  36998. /**
  36999. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37000. */
  37001. readonly canUseWebAudio: boolean;
  37002. /**
  37003. * Gets the current AudioContext if available.
  37004. */
  37005. readonly audioContext: Nullable<AudioContext>;
  37006. /**
  37007. * The master gain node defines the global audio volume of your audio engine.
  37008. */
  37009. readonly masterGain: GainNode;
  37010. /**
  37011. * Gets whether or not mp3 are supported by your browser.
  37012. */
  37013. readonly isMP3supported: boolean;
  37014. /**
  37015. * Gets whether or not ogg are supported by your browser.
  37016. */
  37017. readonly isOGGsupported: boolean;
  37018. /**
  37019. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37020. * @ignoreNaming
  37021. */
  37022. WarnedWebAudioUnsupported: boolean;
  37023. /**
  37024. * Defines if the audio engine relies on a custom unlocked button.
  37025. * In this case, the embedded button will not be displayed.
  37026. */
  37027. useCustomUnlockedButton: boolean;
  37028. /**
  37029. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37030. */
  37031. readonly unlocked: boolean;
  37032. /**
  37033. * Event raised when audio has been unlocked on the browser.
  37034. */
  37035. onAudioUnlockedObservable: Observable<AudioEngine>;
  37036. /**
  37037. * Event raised when audio has been locked on the browser.
  37038. */
  37039. onAudioLockedObservable: Observable<AudioEngine>;
  37040. /**
  37041. * Flags the audio engine in Locked state.
  37042. * This happens due to new browser policies preventing audio to autoplay.
  37043. */
  37044. lock(): void;
  37045. /**
  37046. * Unlocks the audio engine once a user action has been done on the dom.
  37047. * This is helpful to resume play once browser policies have been satisfied.
  37048. */
  37049. unlock(): void;
  37050. /**
  37051. * Gets the global volume sets on the master gain.
  37052. * @returns the global volume if set or -1 otherwise
  37053. */
  37054. getGlobalVolume(): number;
  37055. /**
  37056. * Sets the global volume of your experience (sets on the master gain).
  37057. * @param newVolume Defines the new global volume of the application
  37058. */
  37059. setGlobalVolume(newVolume: number): void;
  37060. /**
  37061. * Connect the audio engine to an audio analyser allowing some amazing
  37062. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37063. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37064. * @param analyser The analyser to connect to the engine
  37065. */
  37066. connectToAnalyser(analyser: Analyser): void;
  37067. }
  37068. /**
  37069. * This represents the default audio engine used in babylon.
  37070. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37071. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37072. */
  37073. export class AudioEngine implements IAudioEngine {
  37074. private _audioContext;
  37075. private _audioContextInitialized;
  37076. private _muteButton;
  37077. private _hostElement;
  37078. /**
  37079. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37080. */
  37081. canUseWebAudio: boolean;
  37082. /**
  37083. * The master gain node defines the global audio volume of your audio engine.
  37084. */
  37085. masterGain: GainNode;
  37086. /**
  37087. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37088. * @ignoreNaming
  37089. */
  37090. WarnedWebAudioUnsupported: boolean;
  37091. /**
  37092. * Gets whether or not mp3 are supported by your browser.
  37093. */
  37094. isMP3supported: boolean;
  37095. /**
  37096. * Gets whether or not ogg are supported by your browser.
  37097. */
  37098. isOGGsupported: boolean;
  37099. /**
  37100. * Gets whether audio has been unlocked on the device.
  37101. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37102. * a user interaction has happened.
  37103. */
  37104. unlocked: boolean;
  37105. /**
  37106. * Defines if the audio engine relies on a custom unlocked button.
  37107. * In this case, the embedded button will not be displayed.
  37108. */
  37109. useCustomUnlockedButton: boolean;
  37110. /**
  37111. * Event raised when audio has been unlocked on the browser.
  37112. */
  37113. onAudioUnlockedObservable: Observable<AudioEngine>;
  37114. /**
  37115. * Event raised when audio has been locked on the browser.
  37116. */
  37117. onAudioLockedObservable: Observable<AudioEngine>;
  37118. /**
  37119. * Gets the current AudioContext if available.
  37120. */
  37121. get audioContext(): Nullable<AudioContext>;
  37122. private _connectedAnalyser;
  37123. /**
  37124. * Instantiates a new audio engine.
  37125. *
  37126. * There should be only one per page as some browsers restrict the number
  37127. * of audio contexts you can create.
  37128. * @param hostElement defines the host element where to display the mute icon if necessary
  37129. */
  37130. constructor(hostElement?: Nullable<HTMLElement>);
  37131. /**
  37132. * Flags the audio engine in Locked state.
  37133. * This happens due to new browser policies preventing audio to autoplay.
  37134. */
  37135. lock(): void;
  37136. /**
  37137. * Unlocks the audio engine once a user action has been done on the dom.
  37138. * This is helpful to resume play once browser policies have been satisfied.
  37139. */
  37140. unlock(): void;
  37141. private _resumeAudioContext;
  37142. private _initializeAudioContext;
  37143. private _tryToRun;
  37144. private _triggerRunningState;
  37145. private _triggerSuspendedState;
  37146. private _displayMuteButton;
  37147. private _moveButtonToTopLeft;
  37148. private _onResize;
  37149. private _hideMuteButton;
  37150. /**
  37151. * Destroy and release the resources associated with the audio ccontext.
  37152. */
  37153. dispose(): void;
  37154. /**
  37155. * Gets the global volume sets on the master gain.
  37156. * @returns the global volume if set or -1 otherwise
  37157. */
  37158. getGlobalVolume(): number;
  37159. /**
  37160. * Sets the global volume of your experience (sets on the master gain).
  37161. * @param newVolume Defines the new global volume of the application
  37162. */
  37163. setGlobalVolume(newVolume: number): void;
  37164. /**
  37165. * Connect the audio engine to an audio analyser allowing some amazing
  37166. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37167. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37168. * @param analyser The analyser to connect to the engine
  37169. */
  37170. connectToAnalyser(analyser: Analyser): void;
  37171. }
  37172. }
  37173. declare module BABYLON {
  37174. /**
  37175. * Interface used to present a loading screen while loading a scene
  37176. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37177. */
  37178. export interface ILoadingScreen {
  37179. /**
  37180. * Function called to display the loading screen
  37181. */
  37182. displayLoadingUI: () => void;
  37183. /**
  37184. * Function called to hide the loading screen
  37185. */
  37186. hideLoadingUI: () => void;
  37187. /**
  37188. * Gets or sets the color to use for the background
  37189. */
  37190. loadingUIBackgroundColor: string;
  37191. /**
  37192. * Gets or sets the text to display while loading
  37193. */
  37194. loadingUIText: string;
  37195. }
  37196. /**
  37197. * Class used for the default loading screen
  37198. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37199. */
  37200. export class DefaultLoadingScreen implements ILoadingScreen {
  37201. private _renderingCanvas;
  37202. private _loadingText;
  37203. private _loadingDivBackgroundColor;
  37204. private _loadingDiv;
  37205. private _loadingTextDiv;
  37206. /** Gets or sets the logo url to use for the default loading screen */
  37207. static DefaultLogoUrl: string;
  37208. /** Gets or sets the spinner url to use for the default loading screen */
  37209. static DefaultSpinnerUrl: string;
  37210. /**
  37211. * Creates a new default loading screen
  37212. * @param _renderingCanvas defines the canvas used to render the scene
  37213. * @param _loadingText defines the default text to display
  37214. * @param _loadingDivBackgroundColor defines the default background color
  37215. */
  37216. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37217. /**
  37218. * Function called to display the loading screen
  37219. */
  37220. displayLoadingUI(): void;
  37221. /**
  37222. * Function called to hide the loading screen
  37223. */
  37224. hideLoadingUI(): void;
  37225. /**
  37226. * Gets or sets the text to display while loading
  37227. */
  37228. set loadingUIText(text: string);
  37229. get loadingUIText(): string;
  37230. /**
  37231. * Gets or sets the color to use for the background
  37232. */
  37233. get loadingUIBackgroundColor(): string;
  37234. set loadingUIBackgroundColor(color: string);
  37235. private _resizeLoadingUI;
  37236. }
  37237. }
  37238. declare module BABYLON {
  37239. /**
  37240. * Interface for any object that can request an animation frame
  37241. */
  37242. export interface ICustomAnimationFrameRequester {
  37243. /**
  37244. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37245. */
  37246. renderFunction?: Function;
  37247. /**
  37248. * Called to request the next frame to render to
  37249. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37250. */
  37251. requestAnimationFrame: Function;
  37252. /**
  37253. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37254. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37255. */
  37256. requestID?: number;
  37257. }
  37258. }
  37259. declare module BABYLON {
  37260. /**
  37261. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37262. */
  37263. export class PerformanceMonitor {
  37264. private _enabled;
  37265. private _rollingFrameTime;
  37266. private _lastFrameTimeMs;
  37267. /**
  37268. * constructor
  37269. * @param frameSampleSize The number of samples required to saturate the sliding window
  37270. */
  37271. constructor(frameSampleSize?: number);
  37272. /**
  37273. * Samples current frame
  37274. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37275. */
  37276. sampleFrame(timeMs?: number): void;
  37277. /**
  37278. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37279. */
  37280. get averageFrameTime(): number;
  37281. /**
  37282. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37283. */
  37284. get averageFrameTimeVariance(): number;
  37285. /**
  37286. * Returns the frame time of the most recent frame
  37287. */
  37288. get instantaneousFrameTime(): number;
  37289. /**
  37290. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37291. */
  37292. get averageFPS(): number;
  37293. /**
  37294. * Returns the average framerate in frames per second using the most recent frame time
  37295. */
  37296. get instantaneousFPS(): number;
  37297. /**
  37298. * Returns true if enough samples have been taken to completely fill the sliding window
  37299. */
  37300. get isSaturated(): boolean;
  37301. /**
  37302. * Enables contributions to the sliding window sample set
  37303. */
  37304. enable(): void;
  37305. /**
  37306. * Disables contributions to the sliding window sample set
  37307. * Samples will not be interpolated over the disabled period
  37308. */
  37309. disable(): void;
  37310. /**
  37311. * Returns true if sampling is enabled
  37312. */
  37313. get isEnabled(): boolean;
  37314. /**
  37315. * Resets performance monitor
  37316. */
  37317. reset(): void;
  37318. }
  37319. /**
  37320. * RollingAverage
  37321. *
  37322. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37323. */
  37324. export class RollingAverage {
  37325. /**
  37326. * Current average
  37327. */
  37328. average: number;
  37329. /**
  37330. * Current variance
  37331. */
  37332. variance: number;
  37333. protected _samples: Array<number>;
  37334. protected _sampleCount: number;
  37335. protected _pos: number;
  37336. protected _m2: number;
  37337. /**
  37338. * constructor
  37339. * @param length The number of samples required to saturate the sliding window
  37340. */
  37341. constructor(length: number);
  37342. /**
  37343. * Adds a sample to the sample set
  37344. * @param v The sample value
  37345. */
  37346. add(v: number): void;
  37347. /**
  37348. * Returns previously added values or null if outside of history or outside the sliding window domain
  37349. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37350. * @return Value previously recorded with add() or null if outside of range
  37351. */
  37352. history(i: number): number;
  37353. /**
  37354. * Returns true if enough samples have been taken to completely fill the sliding window
  37355. * @return true if sample-set saturated
  37356. */
  37357. isSaturated(): boolean;
  37358. /**
  37359. * Resets the rolling average (equivalent to 0 samples taken so far)
  37360. */
  37361. reset(): void;
  37362. /**
  37363. * Wraps a value around the sample range boundaries
  37364. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37365. * @return Wrapped position in sample range
  37366. */
  37367. protected _wrapPosition(i: number): number;
  37368. }
  37369. }
  37370. declare module BABYLON {
  37371. /**
  37372. * This class is used to track a performance counter which is number based.
  37373. * The user has access to many properties which give statistics of different nature.
  37374. *
  37375. * The implementer can track two kinds of Performance Counter: time and count.
  37376. * 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.
  37377. * 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.
  37378. */
  37379. export class PerfCounter {
  37380. /**
  37381. * Gets or sets a global boolean to turn on and off all the counters
  37382. */
  37383. static Enabled: boolean;
  37384. /**
  37385. * Returns the smallest value ever
  37386. */
  37387. get min(): number;
  37388. /**
  37389. * Returns the biggest value ever
  37390. */
  37391. get max(): number;
  37392. /**
  37393. * Returns the average value since the performance counter is running
  37394. */
  37395. get average(): number;
  37396. /**
  37397. * Returns the average value of the last second the counter was monitored
  37398. */
  37399. get lastSecAverage(): number;
  37400. /**
  37401. * Returns the current value
  37402. */
  37403. get current(): number;
  37404. /**
  37405. * Gets the accumulated total
  37406. */
  37407. get total(): number;
  37408. /**
  37409. * Gets the total value count
  37410. */
  37411. get count(): number;
  37412. /**
  37413. * Creates a new counter
  37414. */
  37415. constructor();
  37416. /**
  37417. * Call this method to start monitoring a new frame.
  37418. * 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.
  37419. */
  37420. fetchNewFrame(): void;
  37421. /**
  37422. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37423. * @param newCount the count value to add to the monitored count
  37424. * @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.
  37425. */
  37426. addCount(newCount: number, fetchResult: boolean): void;
  37427. /**
  37428. * Start monitoring this performance counter
  37429. */
  37430. beginMonitoring(): void;
  37431. /**
  37432. * Compute the time lapsed since the previous beginMonitoring() call.
  37433. * @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
  37434. */
  37435. endMonitoring(newFrame?: boolean): void;
  37436. private _fetchResult;
  37437. private _startMonitoringTime;
  37438. private _min;
  37439. private _max;
  37440. private _average;
  37441. private _current;
  37442. private _totalValueCount;
  37443. private _totalAccumulated;
  37444. private _lastSecAverage;
  37445. private _lastSecAccumulated;
  37446. private _lastSecTime;
  37447. private _lastSecValueCount;
  37448. }
  37449. }
  37450. declare module BABYLON {
  37451. interface ThinEngine {
  37452. /** @hidden */
  37453. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37454. }
  37455. }
  37456. declare module BABYLON {
  37457. /**
  37458. * Defines the interface used by display changed events
  37459. */
  37460. export interface IDisplayChangedEventArgs {
  37461. /** Gets the vrDisplay object (if any) */
  37462. vrDisplay: Nullable<any>;
  37463. /** Gets a boolean indicating if webVR is supported */
  37464. vrSupported: boolean;
  37465. }
  37466. /**
  37467. * Defines the interface used by objects containing a viewport (like a camera)
  37468. */
  37469. interface IViewportOwnerLike {
  37470. /**
  37471. * Gets or sets the viewport
  37472. */
  37473. viewport: IViewportLike;
  37474. }
  37475. /**
  37476. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37477. */
  37478. export class Engine extends ThinEngine {
  37479. /** Defines that alpha blending is disabled */
  37480. static readonly ALPHA_DISABLE: number;
  37481. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37482. static readonly ALPHA_ADD: number;
  37483. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37484. static readonly ALPHA_COMBINE: number;
  37485. /** Defines that alpha blending to DEST - SRC * DEST */
  37486. static readonly ALPHA_SUBTRACT: number;
  37487. /** Defines that alpha blending to SRC * DEST */
  37488. static readonly ALPHA_MULTIPLY: number;
  37489. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37490. static readonly ALPHA_MAXIMIZED: number;
  37491. /** Defines that alpha blending to SRC + DEST */
  37492. static readonly ALPHA_ONEONE: number;
  37493. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37494. static readonly ALPHA_PREMULTIPLIED: number;
  37495. /**
  37496. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37497. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37498. */
  37499. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37500. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37501. static readonly ALPHA_INTERPOLATE: number;
  37502. /**
  37503. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37504. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37505. */
  37506. static readonly ALPHA_SCREENMODE: number;
  37507. /** Defines that the ressource is not delayed*/
  37508. static readonly DELAYLOADSTATE_NONE: number;
  37509. /** Defines that the ressource was successfully delay loaded */
  37510. static readonly DELAYLOADSTATE_LOADED: number;
  37511. /** Defines that the ressource is currently delay loading */
  37512. static readonly DELAYLOADSTATE_LOADING: number;
  37513. /** Defines that the ressource is delayed and has not started loading */
  37514. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37515. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37516. static readonly NEVER: number;
  37517. /** 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 */
  37518. static readonly ALWAYS: number;
  37519. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37520. static readonly LESS: number;
  37521. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37522. static readonly EQUAL: number;
  37523. /** 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 */
  37524. static readonly LEQUAL: number;
  37525. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37526. static readonly GREATER: number;
  37527. /** 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 */
  37528. static readonly GEQUAL: number;
  37529. /** 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 */
  37530. static readonly NOTEQUAL: number;
  37531. /** Passed to stencilOperation to specify that stencil value must be kept */
  37532. static readonly KEEP: number;
  37533. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37534. static readonly REPLACE: number;
  37535. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37536. static readonly INCR: number;
  37537. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37538. static readonly DECR: number;
  37539. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37540. static readonly INVERT: number;
  37541. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37542. static readonly INCR_WRAP: number;
  37543. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37544. static readonly DECR_WRAP: number;
  37545. /** Texture is not repeating outside of 0..1 UVs */
  37546. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37547. /** Texture is repeating outside of 0..1 UVs */
  37548. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37549. /** Texture is repeating and mirrored */
  37550. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37551. /** ALPHA */
  37552. static readonly TEXTUREFORMAT_ALPHA: number;
  37553. /** LUMINANCE */
  37554. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37555. /** LUMINANCE_ALPHA */
  37556. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37557. /** RGB */
  37558. static readonly TEXTUREFORMAT_RGB: number;
  37559. /** RGBA */
  37560. static readonly TEXTUREFORMAT_RGBA: number;
  37561. /** RED */
  37562. static readonly TEXTUREFORMAT_RED: number;
  37563. /** RED (2nd reference) */
  37564. static readonly TEXTUREFORMAT_R: number;
  37565. /** RG */
  37566. static readonly TEXTUREFORMAT_RG: number;
  37567. /** RED_INTEGER */
  37568. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37569. /** RED_INTEGER (2nd reference) */
  37570. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37571. /** RG_INTEGER */
  37572. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37573. /** RGB_INTEGER */
  37574. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37575. /** RGBA_INTEGER */
  37576. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37577. /** UNSIGNED_BYTE */
  37578. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37579. /** UNSIGNED_BYTE (2nd reference) */
  37580. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37581. /** FLOAT */
  37582. static readonly TEXTURETYPE_FLOAT: number;
  37583. /** HALF_FLOAT */
  37584. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37585. /** BYTE */
  37586. static readonly TEXTURETYPE_BYTE: number;
  37587. /** SHORT */
  37588. static readonly TEXTURETYPE_SHORT: number;
  37589. /** UNSIGNED_SHORT */
  37590. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37591. /** INT */
  37592. static readonly TEXTURETYPE_INT: number;
  37593. /** UNSIGNED_INT */
  37594. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37595. /** UNSIGNED_SHORT_4_4_4_4 */
  37596. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37597. /** UNSIGNED_SHORT_5_5_5_1 */
  37598. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37599. /** UNSIGNED_SHORT_5_6_5 */
  37600. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37601. /** UNSIGNED_INT_2_10_10_10_REV */
  37602. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37603. /** UNSIGNED_INT_24_8 */
  37604. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37605. /** UNSIGNED_INT_10F_11F_11F_REV */
  37606. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37607. /** UNSIGNED_INT_5_9_9_9_REV */
  37608. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37609. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37610. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37611. /** nearest is mag = nearest and min = nearest and mip = linear */
  37612. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37613. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37614. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37615. /** Trilinear is mag = linear and min = linear and mip = linear */
  37616. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37617. /** nearest is mag = nearest and min = nearest and mip = linear */
  37618. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37619. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37620. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37621. /** Trilinear is mag = linear and min = linear and mip = linear */
  37622. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37623. /** mag = nearest and min = nearest and mip = nearest */
  37624. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37625. /** mag = nearest and min = linear and mip = nearest */
  37626. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37627. /** mag = nearest and min = linear and mip = linear */
  37628. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37629. /** mag = nearest and min = linear and mip = none */
  37630. static readonly TEXTURE_NEAREST_LINEAR: number;
  37631. /** mag = nearest and min = nearest and mip = none */
  37632. static readonly TEXTURE_NEAREST_NEAREST: number;
  37633. /** mag = linear and min = nearest and mip = nearest */
  37634. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37635. /** mag = linear and min = nearest and mip = linear */
  37636. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37637. /** mag = linear and min = linear and mip = none */
  37638. static readonly TEXTURE_LINEAR_LINEAR: number;
  37639. /** mag = linear and min = nearest and mip = none */
  37640. static readonly TEXTURE_LINEAR_NEAREST: number;
  37641. /** Explicit coordinates mode */
  37642. static readonly TEXTURE_EXPLICIT_MODE: number;
  37643. /** Spherical coordinates mode */
  37644. static readonly TEXTURE_SPHERICAL_MODE: number;
  37645. /** Planar coordinates mode */
  37646. static readonly TEXTURE_PLANAR_MODE: number;
  37647. /** Cubic coordinates mode */
  37648. static readonly TEXTURE_CUBIC_MODE: number;
  37649. /** Projection coordinates mode */
  37650. static readonly TEXTURE_PROJECTION_MODE: number;
  37651. /** Skybox coordinates mode */
  37652. static readonly TEXTURE_SKYBOX_MODE: number;
  37653. /** Inverse Cubic coordinates mode */
  37654. static readonly TEXTURE_INVCUBIC_MODE: number;
  37655. /** Equirectangular coordinates mode */
  37656. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37657. /** Equirectangular Fixed coordinates mode */
  37658. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37659. /** Equirectangular Fixed Mirrored coordinates mode */
  37660. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37661. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37662. static readonly SCALEMODE_FLOOR: number;
  37663. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37664. static readonly SCALEMODE_NEAREST: number;
  37665. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37666. static readonly SCALEMODE_CEILING: number;
  37667. /**
  37668. * Returns the current npm package of the sdk
  37669. */
  37670. static get NpmPackage(): string;
  37671. /**
  37672. * Returns the current version of the framework
  37673. */
  37674. static get Version(): string;
  37675. /** Gets the list of created engines */
  37676. static get Instances(): Engine[];
  37677. /**
  37678. * Gets the latest created engine
  37679. */
  37680. static get LastCreatedEngine(): Nullable<Engine>;
  37681. /**
  37682. * Gets the latest created scene
  37683. */
  37684. static get LastCreatedScene(): Nullable<Scene>;
  37685. /**
  37686. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37687. * @param flag defines which part of the materials must be marked as dirty
  37688. * @param predicate defines a predicate used to filter which materials should be affected
  37689. */
  37690. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37691. /**
  37692. * Method called to create the default loading screen.
  37693. * This can be overriden in your own app.
  37694. * @param canvas The rendering canvas element
  37695. * @returns The loading screen
  37696. */
  37697. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37698. /**
  37699. * Method called to create the default rescale post process on each engine.
  37700. */
  37701. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37702. /**
  37703. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37704. **/
  37705. enableOfflineSupport: boolean;
  37706. /**
  37707. * 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)
  37708. **/
  37709. disableManifestCheck: boolean;
  37710. /**
  37711. * Gets the list of created scenes
  37712. */
  37713. scenes: Scene[];
  37714. /**
  37715. * Event raised when a new scene is created
  37716. */
  37717. onNewSceneAddedObservable: Observable<Scene>;
  37718. /**
  37719. * Gets the list of created postprocesses
  37720. */
  37721. postProcesses: PostProcess[];
  37722. /**
  37723. * Gets a boolean indicating if the pointer is currently locked
  37724. */
  37725. isPointerLock: boolean;
  37726. /**
  37727. * Observable event triggered each time the rendering canvas is resized
  37728. */
  37729. onResizeObservable: Observable<Engine>;
  37730. /**
  37731. * Observable event triggered each time the canvas loses focus
  37732. */
  37733. onCanvasBlurObservable: Observable<Engine>;
  37734. /**
  37735. * Observable event triggered each time the canvas gains focus
  37736. */
  37737. onCanvasFocusObservable: Observable<Engine>;
  37738. /**
  37739. * Observable event triggered each time the canvas receives pointerout event
  37740. */
  37741. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37742. /**
  37743. * Observable raised when the engine begins a new frame
  37744. */
  37745. onBeginFrameObservable: Observable<Engine>;
  37746. /**
  37747. * If set, will be used to request the next animation frame for the render loop
  37748. */
  37749. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37750. /**
  37751. * Observable raised when the engine ends the current frame
  37752. */
  37753. onEndFrameObservable: Observable<Engine>;
  37754. /**
  37755. * Observable raised when the engine is about to compile a shader
  37756. */
  37757. onBeforeShaderCompilationObservable: Observable<Engine>;
  37758. /**
  37759. * Observable raised when the engine has jsut compiled a shader
  37760. */
  37761. onAfterShaderCompilationObservable: Observable<Engine>;
  37762. /**
  37763. * Gets the audio engine
  37764. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37765. * @ignorenaming
  37766. */
  37767. static audioEngine: IAudioEngine;
  37768. /**
  37769. * Default AudioEngine factory responsible of creating the Audio Engine.
  37770. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37771. */
  37772. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37773. /**
  37774. * Default offline support factory responsible of creating a tool used to store data locally.
  37775. * By default, this will create a Database object if the workload has been embedded.
  37776. */
  37777. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37778. private _loadingScreen;
  37779. private _pointerLockRequested;
  37780. private _rescalePostProcess;
  37781. private _deterministicLockstep;
  37782. private _lockstepMaxSteps;
  37783. private _timeStep;
  37784. protected get _supportsHardwareTextureRescaling(): boolean;
  37785. private _fps;
  37786. private _deltaTime;
  37787. /** @hidden */
  37788. _drawCalls: PerfCounter;
  37789. /** 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 */
  37790. canvasTabIndex: number;
  37791. /**
  37792. * Turn this value on if you want to pause FPS computation when in background
  37793. */
  37794. disablePerformanceMonitorInBackground: boolean;
  37795. private _performanceMonitor;
  37796. /**
  37797. * Gets the performance monitor attached to this engine
  37798. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37799. */
  37800. get performanceMonitor(): PerformanceMonitor;
  37801. private _onFocus;
  37802. private _onBlur;
  37803. private _onCanvasPointerOut;
  37804. private _onCanvasBlur;
  37805. private _onCanvasFocus;
  37806. private _onFullscreenChange;
  37807. private _onPointerLockChange;
  37808. /**
  37809. * Gets the HTML element used to attach event listeners
  37810. * @returns a HTML element
  37811. */
  37812. getInputElement(): Nullable<HTMLElement>;
  37813. /**
  37814. * Creates a new engine
  37815. * @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
  37816. * @param antialias defines enable antialiasing (default: false)
  37817. * @param options defines further options to be sent to the getContext() function
  37818. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37819. */
  37820. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37821. /**
  37822. * Gets current aspect ratio
  37823. * @param viewportOwner defines the camera to use to get the aspect ratio
  37824. * @param useScreen defines if screen size must be used (or the current render target if any)
  37825. * @returns a number defining the aspect ratio
  37826. */
  37827. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37828. /**
  37829. * Gets current screen aspect ratio
  37830. * @returns a number defining the aspect ratio
  37831. */
  37832. getScreenAspectRatio(): number;
  37833. /**
  37834. * Gets the client rect of the HTML canvas attached with the current webGL context
  37835. * @returns a client rectanglee
  37836. */
  37837. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37838. /**
  37839. * Gets the client rect of the HTML element used for events
  37840. * @returns a client rectanglee
  37841. */
  37842. getInputElementClientRect(): Nullable<ClientRect>;
  37843. /**
  37844. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37845. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37846. * @returns true if engine is in deterministic lock step mode
  37847. */
  37848. isDeterministicLockStep(): boolean;
  37849. /**
  37850. * Gets the max steps when engine is running in deterministic lock step
  37851. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37852. * @returns the max steps
  37853. */
  37854. getLockstepMaxSteps(): number;
  37855. /**
  37856. * Returns the time in ms between steps when using deterministic lock step.
  37857. * @returns time step in (ms)
  37858. */
  37859. getTimeStep(): number;
  37860. /**
  37861. * Force the mipmap generation for the given render target texture
  37862. * @param texture defines the render target texture to use
  37863. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37864. */
  37865. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37866. /** States */
  37867. /**
  37868. * Set various states to the webGL context
  37869. * @param culling defines backface culling state
  37870. * @param zOffset defines the value to apply to zOffset (0 by default)
  37871. * @param force defines if states must be applied even if cache is up to date
  37872. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37873. */
  37874. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37875. /**
  37876. * Set the z offset to apply to current rendering
  37877. * @param value defines the offset to apply
  37878. */
  37879. setZOffset(value: number): void;
  37880. /**
  37881. * Gets the current value of the zOffset
  37882. * @returns the current zOffset state
  37883. */
  37884. getZOffset(): number;
  37885. /**
  37886. * Enable or disable depth buffering
  37887. * @param enable defines the state to set
  37888. */
  37889. setDepthBuffer(enable: boolean): void;
  37890. /**
  37891. * Gets a boolean indicating if depth writing is enabled
  37892. * @returns the current depth writing state
  37893. */
  37894. getDepthWrite(): boolean;
  37895. /**
  37896. * Enable or disable depth writing
  37897. * @param enable defines the state to set
  37898. */
  37899. setDepthWrite(enable: boolean): void;
  37900. /**
  37901. * Gets a boolean indicating if stencil buffer is enabled
  37902. * @returns the current stencil buffer state
  37903. */
  37904. getStencilBuffer(): boolean;
  37905. /**
  37906. * Enable or disable the stencil buffer
  37907. * @param enable defines if the stencil buffer must be enabled or disabled
  37908. */
  37909. setStencilBuffer(enable: boolean): void;
  37910. /**
  37911. * Gets the current stencil mask
  37912. * @returns a number defining the new stencil mask to use
  37913. */
  37914. getStencilMask(): number;
  37915. /**
  37916. * Sets the current stencil mask
  37917. * @param mask defines the new stencil mask to use
  37918. */
  37919. setStencilMask(mask: number): void;
  37920. /**
  37921. * Gets the current stencil function
  37922. * @returns a number defining the stencil function to use
  37923. */
  37924. getStencilFunction(): number;
  37925. /**
  37926. * Gets the current stencil reference value
  37927. * @returns a number defining the stencil reference value to use
  37928. */
  37929. getStencilFunctionReference(): number;
  37930. /**
  37931. * Gets the current stencil mask
  37932. * @returns a number defining the stencil mask to use
  37933. */
  37934. getStencilFunctionMask(): number;
  37935. /**
  37936. * Sets the current stencil function
  37937. * @param stencilFunc defines the new stencil function to use
  37938. */
  37939. setStencilFunction(stencilFunc: number): void;
  37940. /**
  37941. * Sets the current stencil reference
  37942. * @param reference defines the new stencil reference to use
  37943. */
  37944. setStencilFunctionReference(reference: number): void;
  37945. /**
  37946. * Sets the current stencil mask
  37947. * @param mask defines the new stencil mask to use
  37948. */
  37949. setStencilFunctionMask(mask: number): void;
  37950. /**
  37951. * Gets the current stencil operation when stencil fails
  37952. * @returns a number defining stencil operation to use when stencil fails
  37953. */
  37954. getStencilOperationFail(): number;
  37955. /**
  37956. * Gets the current stencil operation when depth fails
  37957. * @returns a number defining stencil operation to use when depth fails
  37958. */
  37959. getStencilOperationDepthFail(): number;
  37960. /**
  37961. * Gets the current stencil operation when stencil passes
  37962. * @returns a number defining stencil operation to use when stencil passes
  37963. */
  37964. getStencilOperationPass(): number;
  37965. /**
  37966. * Sets the stencil operation to use when stencil fails
  37967. * @param operation defines the stencil operation to use when stencil fails
  37968. */
  37969. setStencilOperationFail(operation: number): void;
  37970. /**
  37971. * Sets the stencil operation to use when depth fails
  37972. * @param operation defines the stencil operation to use when depth fails
  37973. */
  37974. setStencilOperationDepthFail(operation: number): void;
  37975. /**
  37976. * Sets the stencil operation to use when stencil passes
  37977. * @param operation defines the stencil operation to use when stencil passes
  37978. */
  37979. setStencilOperationPass(operation: number): void;
  37980. /**
  37981. * Sets a boolean indicating if the dithering state is enabled or disabled
  37982. * @param value defines the dithering state
  37983. */
  37984. setDitheringState(value: boolean): void;
  37985. /**
  37986. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37987. * @param value defines the rasterizer state
  37988. */
  37989. setRasterizerState(value: boolean): void;
  37990. /**
  37991. * Gets the current depth function
  37992. * @returns a number defining the depth function
  37993. */
  37994. getDepthFunction(): Nullable<number>;
  37995. /**
  37996. * Sets the current depth function
  37997. * @param depthFunc defines the function to use
  37998. */
  37999. setDepthFunction(depthFunc: number): void;
  38000. /**
  38001. * Sets the current depth function to GREATER
  38002. */
  38003. setDepthFunctionToGreater(): void;
  38004. /**
  38005. * Sets the current depth function to GEQUAL
  38006. */
  38007. setDepthFunctionToGreaterOrEqual(): void;
  38008. /**
  38009. * Sets the current depth function to LESS
  38010. */
  38011. setDepthFunctionToLess(): void;
  38012. /**
  38013. * Sets the current depth function to LEQUAL
  38014. */
  38015. setDepthFunctionToLessOrEqual(): void;
  38016. private _cachedStencilBuffer;
  38017. private _cachedStencilFunction;
  38018. private _cachedStencilMask;
  38019. private _cachedStencilOperationPass;
  38020. private _cachedStencilOperationFail;
  38021. private _cachedStencilOperationDepthFail;
  38022. private _cachedStencilReference;
  38023. /**
  38024. * Caches the the state of the stencil buffer
  38025. */
  38026. cacheStencilState(): void;
  38027. /**
  38028. * Restores the state of the stencil buffer
  38029. */
  38030. restoreStencilState(): void;
  38031. /**
  38032. * Directly set the WebGL Viewport
  38033. * @param x defines the x coordinate of the viewport (in screen space)
  38034. * @param y defines the y coordinate of the viewport (in screen space)
  38035. * @param width defines the width of the viewport (in screen space)
  38036. * @param height defines the height of the viewport (in screen space)
  38037. * @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
  38038. */
  38039. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38040. /**
  38041. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38042. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38043. * @param y defines the y-coordinate of the corner of the clear rectangle
  38044. * @param width defines the width of the clear rectangle
  38045. * @param height defines the height of the clear rectangle
  38046. * @param clearColor defines the clear color
  38047. */
  38048. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38049. /**
  38050. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38051. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38052. * @param y defines the y-coordinate of the corner of the clear rectangle
  38053. * @param width defines the width of the clear rectangle
  38054. * @param height defines the height of the clear rectangle
  38055. */
  38056. enableScissor(x: number, y: number, width: number, height: number): void;
  38057. /**
  38058. * Disable previously set scissor test rectangle
  38059. */
  38060. disableScissor(): void;
  38061. protected _reportDrawCall(): void;
  38062. /**
  38063. * Initializes a webVR display and starts listening to display change events
  38064. * The onVRDisplayChangedObservable will be notified upon these changes
  38065. * @returns The onVRDisplayChangedObservable
  38066. */
  38067. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38068. /** @hidden */
  38069. _prepareVRComponent(): void;
  38070. /** @hidden */
  38071. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38072. /** @hidden */
  38073. _submitVRFrame(): void;
  38074. /**
  38075. * Call this function to leave webVR mode
  38076. * Will do nothing if webVR is not supported or if there is no webVR device
  38077. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38078. */
  38079. disableVR(): void;
  38080. /**
  38081. * Gets a boolean indicating that the system is in VR mode and is presenting
  38082. * @returns true if VR mode is engaged
  38083. */
  38084. isVRPresenting(): boolean;
  38085. /** @hidden */
  38086. _requestVRFrame(): void;
  38087. /** @hidden */
  38088. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38089. /**
  38090. * Gets the source code of the vertex shader associated with a specific webGL program
  38091. * @param program defines the program to use
  38092. * @returns a string containing the source code of the vertex shader associated with the program
  38093. */
  38094. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38095. /**
  38096. * Gets the source code of the fragment shader associated with a specific webGL program
  38097. * @param program defines the program to use
  38098. * @returns a string containing the source code of the fragment shader associated with the program
  38099. */
  38100. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38101. /**
  38102. * Sets a depth stencil texture from a render target to the according uniform.
  38103. * @param channel The texture channel
  38104. * @param uniform The uniform to set
  38105. * @param texture The render target texture containing the depth stencil texture to apply
  38106. */
  38107. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38108. /**
  38109. * Sets a texture to the webGL context from a postprocess
  38110. * @param channel defines the channel to use
  38111. * @param postProcess defines the source postprocess
  38112. */
  38113. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38114. /**
  38115. * Binds the output of the passed in post process to the texture channel specified
  38116. * @param channel The channel the texture should be bound to
  38117. * @param postProcess The post process which's output should be bound
  38118. */
  38119. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38120. protected _rebuildBuffers(): void;
  38121. /** @hidden */
  38122. _renderFrame(): void;
  38123. _renderLoop(): void;
  38124. /** @hidden */
  38125. _renderViews(): boolean;
  38126. /**
  38127. * Toggle full screen mode
  38128. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38129. */
  38130. switchFullscreen(requestPointerLock: boolean): void;
  38131. /**
  38132. * Enters full screen mode
  38133. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38134. */
  38135. enterFullscreen(requestPointerLock: boolean): void;
  38136. /**
  38137. * Exits full screen mode
  38138. */
  38139. exitFullscreen(): void;
  38140. /**
  38141. * Enters Pointerlock mode
  38142. */
  38143. enterPointerlock(): void;
  38144. /**
  38145. * Exits Pointerlock mode
  38146. */
  38147. exitPointerlock(): void;
  38148. /**
  38149. * Begin a new frame
  38150. */
  38151. beginFrame(): void;
  38152. /**
  38153. * Enf the current frame
  38154. */
  38155. endFrame(): void;
  38156. resize(): void;
  38157. /**
  38158. * Force a specific size of the canvas
  38159. * @param width defines the new canvas' width
  38160. * @param height defines the new canvas' height
  38161. * @returns true if the size was changed
  38162. */
  38163. setSize(width: number, height: number): boolean;
  38164. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38165. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38166. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38167. _releaseTexture(texture: InternalTexture): void;
  38168. /**
  38169. * @hidden
  38170. * Rescales a texture
  38171. * @param source input texutre
  38172. * @param destination destination texture
  38173. * @param scene scene to use to render the resize
  38174. * @param internalFormat format to use when resizing
  38175. * @param onComplete callback to be called when resize has completed
  38176. */
  38177. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38178. /**
  38179. * Gets the current framerate
  38180. * @returns a number representing the framerate
  38181. */
  38182. getFps(): number;
  38183. /**
  38184. * Gets the time spent between current and previous frame
  38185. * @returns a number representing the delta time in ms
  38186. */
  38187. getDeltaTime(): number;
  38188. private _measureFps;
  38189. /** @hidden */
  38190. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38191. /**
  38192. * Updates the sample count of a render target texture
  38193. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38194. * @param texture defines the texture to update
  38195. * @param samples defines the sample count to set
  38196. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38197. */
  38198. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38199. /**
  38200. * Updates a depth texture Comparison Mode and Function.
  38201. * If the comparison Function is equal to 0, the mode will be set to none.
  38202. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38203. * @param texture The texture to set the comparison function for
  38204. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38205. */
  38206. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38207. /**
  38208. * Creates a webGL buffer to use with instanciation
  38209. * @param capacity defines the size of the buffer
  38210. * @returns the webGL buffer
  38211. */
  38212. createInstancesBuffer(capacity: number): DataBuffer;
  38213. /**
  38214. * Delete a webGL buffer used with instanciation
  38215. * @param buffer defines the webGL buffer to delete
  38216. */
  38217. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38218. private _clientWaitAsync;
  38219. /** @hidden */
  38220. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38221. dispose(): void;
  38222. private _disableTouchAction;
  38223. /**
  38224. * Display the loading screen
  38225. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38226. */
  38227. displayLoadingUI(): void;
  38228. /**
  38229. * Hide the loading screen
  38230. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38231. */
  38232. hideLoadingUI(): void;
  38233. /**
  38234. * Gets the current loading screen object
  38235. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38236. */
  38237. get loadingScreen(): ILoadingScreen;
  38238. /**
  38239. * Sets the current loading screen object
  38240. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38241. */
  38242. set loadingScreen(loadingScreen: ILoadingScreen);
  38243. /**
  38244. * Sets the current loading screen text
  38245. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38246. */
  38247. set loadingUIText(text: string);
  38248. /**
  38249. * Sets the current loading screen background color
  38250. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38251. */
  38252. set loadingUIBackgroundColor(color: string);
  38253. /** Pointerlock and fullscreen */
  38254. /**
  38255. * Ask the browser to promote the current element to pointerlock mode
  38256. * @param element defines the DOM element to promote
  38257. */
  38258. static _RequestPointerlock(element: HTMLElement): void;
  38259. /**
  38260. * Asks the browser to exit pointerlock mode
  38261. */
  38262. static _ExitPointerlock(): void;
  38263. /**
  38264. * Ask the browser to promote the current element to fullscreen rendering mode
  38265. * @param element defines the DOM element to promote
  38266. */
  38267. static _RequestFullscreen(element: HTMLElement): void;
  38268. /**
  38269. * Asks the browser to exit fullscreen mode
  38270. */
  38271. static _ExitFullscreen(): void;
  38272. }
  38273. }
  38274. declare module BABYLON {
  38275. /**
  38276. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38277. * during the life time of the application.
  38278. */
  38279. export class EngineStore {
  38280. /** Gets the list of created engines */
  38281. static Instances: Engine[];
  38282. /** @hidden */
  38283. static _LastCreatedScene: Nullable<Scene>;
  38284. /**
  38285. * Gets the latest created engine
  38286. */
  38287. static get LastCreatedEngine(): Nullable<Engine>;
  38288. /**
  38289. * Gets the latest created scene
  38290. */
  38291. static get LastCreatedScene(): Nullable<Scene>;
  38292. /**
  38293. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38294. * @ignorenaming
  38295. */
  38296. static UseFallbackTexture: boolean;
  38297. /**
  38298. * Texture content used if a texture cannot loaded
  38299. * @ignorenaming
  38300. */
  38301. static FallbackTexture: string;
  38302. }
  38303. }
  38304. declare module BABYLON {
  38305. /**
  38306. * Helper class that provides a small promise polyfill
  38307. */
  38308. export class PromisePolyfill {
  38309. /**
  38310. * Static function used to check if the polyfill is required
  38311. * If this is the case then the function will inject the polyfill to window.Promise
  38312. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38313. */
  38314. static Apply(force?: boolean): void;
  38315. }
  38316. }
  38317. declare module BABYLON {
  38318. /**
  38319. * Interface for screenshot methods with describe argument called `size` as object with options
  38320. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38321. */
  38322. export interface IScreenshotSize {
  38323. /**
  38324. * number in pixels for canvas height
  38325. */
  38326. height?: number;
  38327. /**
  38328. * multiplier allowing render at a higher or lower resolution
  38329. * If value is defined then height and width will be ignored and taken from camera
  38330. */
  38331. precision?: number;
  38332. /**
  38333. * number in pixels for canvas width
  38334. */
  38335. width?: number;
  38336. }
  38337. }
  38338. declare module BABYLON {
  38339. interface IColor4Like {
  38340. r: float;
  38341. g: float;
  38342. b: float;
  38343. a: float;
  38344. }
  38345. /**
  38346. * Class containing a set of static utilities functions
  38347. */
  38348. export class Tools {
  38349. /**
  38350. * Gets or sets the base URL to use to load assets
  38351. */
  38352. static get BaseUrl(): string;
  38353. static set BaseUrl(value: string);
  38354. /**
  38355. * Enable/Disable Custom HTTP Request Headers globally.
  38356. * default = false
  38357. * @see CustomRequestHeaders
  38358. */
  38359. static UseCustomRequestHeaders: boolean;
  38360. /**
  38361. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38362. * i.e. when loading files, where the server/service expects an Authorization header
  38363. */
  38364. static CustomRequestHeaders: {
  38365. [key: string]: string;
  38366. };
  38367. /**
  38368. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38369. */
  38370. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38371. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38372. /**
  38373. * Default behaviour for cors in the application.
  38374. * It can be a string if the expected behavior is identical in the entire app.
  38375. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38376. */
  38377. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38378. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38379. /**
  38380. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38381. * @ignorenaming
  38382. */
  38383. static get UseFallbackTexture(): boolean;
  38384. static set UseFallbackTexture(value: boolean);
  38385. /**
  38386. * Use this object to register external classes like custom textures or material
  38387. * to allow the laoders to instantiate them
  38388. */
  38389. static get RegisteredExternalClasses(): {
  38390. [key: string]: Object;
  38391. };
  38392. static set RegisteredExternalClasses(classes: {
  38393. [key: string]: Object;
  38394. });
  38395. /**
  38396. * Texture content used if a texture cannot loaded
  38397. * @ignorenaming
  38398. */
  38399. static get fallbackTexture(): string;
  38400. static set fallbackTexture(value: string);
  38401. /**
  38402. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38403. * @param u defines the coordinate on X axis
  38404. * @param v defines the coordinate on Y axis
  38405. * @param width defines the width of the source data
  38406. * @param height defines the height of the source data
  38407. * @param pixels defines the source byte array
  38408. * @param color defines the output color
  38409. */
  38410. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38411. /**
  38412. * Interpolates between a and b via alpha
  38413. * @param a The lower value (returned when alpha = 0)
  38414. * @param b The upper value (returned when alpha = 1)
  38415. * @param alpha The interpolation-factor
  38416. * @return The mixed value
  38417. */
  38418. static Mix(a: number, b: number, alpha: number): number;
  38419. /**
  38420. * Tries to instantiate a new object from a given class name
  38421. * @param className defines the class name to instantiate
  38422. * @returns the new object or null if the system was not able to do the instantiation
  38423. */
  38424. static Instantiate(className: string): any;
  38425. /**
  38426. * Provides a slice function that will work even on IE
  38427. * @param data defines the array to slice
  38428. * @param start defines the start of the data (optional)
  38429. * @param end defines the end of the data (optional)
  38430. * @returns the new sliced array
  38431. */
  38432. static Slice<T>(data: T, start?: number, end?: number): T;
  38433. /**
  38434. * Polyfill for setImmediate
  38435. * @param action defines the action to execute after the current execution block
  38436. */
  38437. static SetImmediate(action: () => void): void;
  38438. /**
  38439. * Function indicating if a number is an exponent of 2
  38440. * @param value defines the value to test
  38441. * @returns true if the value is an exponent of 2
  38442. */
  38443. static IsExponentOfTwo(value: number): boolean;
  38444. private static _tmpFloatArray;
  38445. /**
  38446. * Returns the nearest 32-bit single precision float representation of a Number
  38447. * @param value A Number. If the parameter is of a different type, it will get converted
  38448. * to a number or to NaN if it cannot be converted
  38449. * @returns number
  38450. */
  38451. static FloatRound(value: number): number;
  38452. /**
  38453. * Extracts the filename from a path
  38454. * @param path defines the path to use
  38455. * @returns the filename
  38456. */
  38457. static GetFilename(path: string): string;
  38458. /**
  38459. * Extracts the "folder" part of a path (everything before the filename).
  38460. * @param uri The URI to extract the info from
  38461. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38462. * @returns The "folder" part of the path
  38463. */
  38464. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38465. /**
  38466. * Extracts text content from a DOM element hierarchy
  38467. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38468. */
  38469. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38470. /**
  38471. * Convert an angle in radians to degrees
  38472. * @param angle defines the angle to convert
  38473. * @returns the angle in degrees
  38474. */
  38475. static ToDegrees(angle: number): number;
  38476. /**
  38477. * Convert an angle in degrees to radians
  38478. * @param angle defines the angle to convert
  38479. * @returns the angle in radians
  38480. */
  38481. static ToRadians(angle: number): number;
  38482. /**
  38483. * Returns an array if obj is not an array
  38484. * @param obj defines the object to evaluate as an array
  38485. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38486. * @returns either obj directly if obj is an array or a new array containing obj
  38487. */
  38488. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38489. /**
  38490. * Gets the pointer prefix to use
  38491. * @param engine defines the engine we are finding the prefix for
  38492. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38493. */
  38494. static GetPointerPrefix(engine: Engine): string;
  38495. /**
  38496. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38497. * @param url define the url we are trying
  38498. * @param element define the dom element where to configure the cors policy
  38499. */
  38500. static SetCorsBehavior(url: string | string[], element: {
  38501. crossOrigin: string | null;
  38502. }): void;
  38503. /**
  38504. * Removes unwanted characters from an url
  38505. * @param url defines the url to clean
  38506. * @returns the cleaned url
  38507. */
  38508. static CleanUrl(url: string): string;
  38509. /**
  38510. * Gets or sets a function used to pre-process url before using them to load assets
  38511. */
  38512. static get PreprocessUrl(): (url: string) => string;
  38513. static set PreprocessUrl(processor: (url: string) => string);
  38514. /**
  38515. * Loads an image as an HTMLImageElement.
  38516. * @param input url string, ArrayBuffer, or Blob to load
  38517. * @param onLoad callback called when the image successfully loads
  38518. * @param onError callback called when the image fails to load
  38519. * @param offlineProvider offline provider for caching
  38520. * @param mimeType optional mime type
  38521. * @returns the HTMLImageElement of the loaded image
  38522. */
  38523. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38524. /**
  38525. * Loads a file from a url
  38526. * @param url url string, ArrayBuffer, or Blob to load
  38527. * @param onSuccess callback called when the file successfully loads
  38528. * @param onProgress callback called while file is loading (if the server supports this mode)
  38529. * @param offlineProvider defines the offline provider for caching
  38530. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38531. * @param onError callback called when the file fails to load
  38532. * @returns a file request object
  38533. */
  38534. 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;
  38535. /**
  38536. * Loads a file from a url
  38537. * @param url the file url to load
  38538. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38539. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38540. */
  38541. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38542. /**
  38543. * Load a script (identified by an url). When the url returns, the
  38544. * content of this file is added into a new script element, attached to the DOM (body element)
  38545. * @param scriptUrl defines the url of the script to laod
  38546. * @param onSuccess defines the callback called when the script is loaded
  38547. * @param onError defines the callback to call if an error occurs
  38548. * @param scriptId defines the id of the script element
  38549. */
  38550. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38551. /**
  38552. * Load an asynchronous script (identified by an url). When the url returns, the
  38553. * content of this file is added into a new script element, attached to the DOM (body element)
  38554. * @param scriptUrl defines the url of the script to laod
  38555. * @param scriptId defines the id of the script element
  38556. * @returns a promise request object
  38557. */
  38558. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38559. /**
  38560. * Loads a file from a blob
  38561. * @param fileToLoad defines the blob to use
  38562. * @param callback defines the callback to call when data is loaded
  38563. * @param progressCallback defines the callback to call during loading process
  38564. * @returns a file request object
  38565. */
  38566. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38567. /**
  38568. * Reads a file from a File object
  38569. * @param file defines the file to load
  38570. * @param onSuccess defines the callback to call when data is loaded
  38571. * @param onProgress defines the callback to call during loading process
  38572. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38573. * @param onError defines the callback to call when an error occurs
  38574. * @returns a file request object
  38575. */
  38576. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38577. /**
  38578. * Creates a data url from a given string content
  38579. * @param content defines the content to convert
  38580. * @returns the new data url link
  38581. */
  38582. static FileAsURL(content: string): string;
  38583. /**
  38584. * Format the given number to a specific decimal format
  38585. * @param value defines the number to format
  38586. * @param decimals defines the number of decimals to use
  38587. * @returns the formatted string
  38588. */
  38589. static Format(value: number, decimals?: number): string;
  38590. /**
  38591. * Tries to copy an object by duplicating every property
  38592. * @param source defines the source object
  38593. * @param destination defines the target object
  38594. * @param doNotCopyList defines a list of properties to avoid
  38595. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38596. */
  38597. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38598. /**
  38599. * Gets a boolean indicating if the given object has no own property
  38600. * @param obj defines the object to test
  38601. * @returns true if object has no own property
  38602. */
  38603. static IsEmpty(obj: any): boolean;
  38604. /**
  38605. * Function used to register events at window level
  38606. * @param windowElement defines the Window object to use
  38607. * @param events defines the events to register
  38608. */
  38609. static RegisterTopRootEvents(windowElement: Window, events: {
  38610. name: string;
  38611. handler: Nullable<(e: FocusEvent) => any>;
  38612. }[]): void;
  38613. /**
  38614. * Function used to unregister events from window level
  38615. * @param windowElement defines the Window object to use
  38616. * @param events defines the events to unregister
  38617. */
  38618. static UnregisterTopRootEvents(windowElement: Window, events: {
  38619. name: string;
  38620. handler: Nullable<(e: FocusEvent) => any>;
  38621. }[]): void;
  38622. /**
  38623. * @ignore
  38624. */
  38625. static _ScreenshotCanvas: HTMLCanvasElement;
  38626. /**
  38627. * Dumps the current bound framebuffer
  38628. * @param width defines the rendering width
  38629. * @param height defines the rendering height
  38630. * @param engine defines the hosting engine
  38631. * @param successCallback defines the callback triggered once the data are available
  38632. * @param mimeType defines the mime type of the result
  38633. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38634. */
  38635. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38636. /**
  38637. * Converts the canvas data to blob.
  38638. * This acts as a polyfill for browsers not supporting the to blob function.
  38639. * @param canvas Defines the canvas to extract the data from
  38640. * @param successCallback Defines the callback triggered once the data are available
  38641. * @param mimeType Defines the mime type of the result
  38642. */
  38643. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38644. /**
  38645. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38646. * @param successCallback defines the callback triggered once the data are available
  38647. * @param mimeType defines the mime type of the result
  38648. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38649. */
  38650. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38651. /**
  38652. * Downloads a blob in the browser
  38653. * @param blob defines the blob to download
  38654. * @param fileName defines the name of the downloaded file
  38655. */
  38656. static Download(blob: Blob, fileName: string): void;
  38657. /**
  38658. * Captures a screenshot of the current rendering
  38659. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38660. * @param engine defines the rendering engine
  38661. * @param camera defines the source camera
  38662. * @param size This parameter can be set to a single number or to an object with the
  38663. * following (optional) properties: precision, width, height. If a single number is passed,
  38664. * it will be used for both width and height. If an object is passed, the screenshot size
  38665. * will be derived from the parameters. The precision property is a multiplier allowing
  38666. * rendering at a higher or lower resolution
  38667. * @param successCallback defines the callback receives a single parameter which contains the
  38668. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38669. * src parameter of an <img> to display it
  38670. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38671. * Check your browser for supported MIME types
  38672. */
  38673. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38674. /**
  38675. * Captures a screenshot of the current rendering
  38676. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38677. * @param engine defines the rendering engine
  38678. * @param camera defines the source camera
  38679. * @param size This parameter can be set to a single number or to an object with the
  38680. * following (optional) properties: precision, width, height. If a single number is passed,
  38681. * it will be used for both width and height. If an object is passed, the screenshot size
  38682. * will be derived from the parameters. The precision property is a multiplier allowing
  38683. * rendering at a higher or lower resolution
  38684. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38685. * Check your browser for supported MIME types
  38686. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38687. * to the src parameter of an <img> to display it
  38688. */
  38689. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38690. /**
  38691. * Generates an image screenshot from the specified camera.
  38692. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38693. * @param engine The engine to use for rendering
  38694. * @param camera The camera to use for rendering
  38695. * @param size This parameter can be set to a single number or to an object with the
  38696. * following (optional) properties: precision, width, height. If a single number is passed,
  38697. * it will be used for both width and height. If an object is passed, the screenshot size
  38698. * will be derived from the parameters. The precision property is a multiplier allowing
  38699. * rendering at a higher or lower resolution
  38700. * @param successCallback The callback receives a single parameter which contains the
  38701. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38702. * src parameter of an <img> to display it
  38703. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38704. * Check your browser for supported MIME types
  38705. * @param samples Texture samples (default: 1)
  38706. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38707. * @param fileName A name for for the downloaded file.
  38708. */
  38709. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38710. /**
  38711. * Generates an image screenshot from the specified camera.
  38712. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38713. * @param engine The engine to use for rendering
  38714. * @param camera The camera to use for rendering
  38715. * @param size This parameter can be set to a single number or to an object with the
  38716. * following (optional) properties: precision, width, height. If a single number is passed,
  38717. * it will be used for both width and height. If an object is passed, the screenshot size
  38718. * will be derived from the parameters. The precision property is a multiplier allowing
  38719. * rendering at a higher or lower resolution
  38720. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38721. * Check your browser for supported MIME types
  38722. * @param samples Texture samples (default: 1)
  38723. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38724. * @param fileName A name for for the downloaded file.
  38725. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38726. * to the src parameter of an <img> to display it
  38727. */
  38728. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38729. /**
  38730. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38731. * Be aware Math.random() could cause collisions, but:
  38732. * "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"
  38733. * @returns a pseudo random id
  38734. */
  38735. static RandomId(): string;
  38736. /**
  38737. * Test if the given uri is a base64 string
  38738. * @param uri The uri to test
  38739. * @return True if the uri is a base64 string or false otherwise
  38740. */
  38741. static IsBase64(uri: string): boolean;
  38742. /**
  38743. * Decode the given base64 uri.
  38744. * @param uri The uri to decode
  38745. * @return The decoded base64 data.
  38746. */
  38747. static DecodeBase64(uri: string): ArrayBuffer;
  38748. /**
  38749. * Gets the absolute url.
  38750. * @param url the input url
  38751. * @return the absolute url
  38752. */
  38753. static GetAbsoluteUrl(url: string): string;
  38754. /**
  38755. * No log
  38756. */
  38757. static readonly NoneLogLevel: number;
  38758. /**
  38759. * Only message logs
  38760. */
  38761. static readonly MessageLogLevel: number;
  38762. /**
  38763. * Only warning logs
  38764. */
  38765. static readonly WarningLogLevel: number;
  38766. /**
  38767. * Only error logs
  38768. */
  38769. static readonly ErrorLogLevel: number;
  38770. /**
  38771. * All logs
  38772. */
  38773. static readonly AllLogLevel: number;
  38774. /**
  38775. * Gets a value indicating the number of loading errors
  38776. * @ignorenaming
  38777. */
  38778. static get errorsCount(): number;
  38779. /**
  38780. * Callback called when a new log is added
  38781. */
  38782. static OnNewCacheEntry: (entry: string) => void;
  38783. /**
  38784. * Log a message to the console
  38785. * @param message defines the message to log
  38786. */
  38787. static Log(message: string): void;
  38788. /**
  38789. * Write a warning message to the console
  38790. * @param message defines the message to log
  38791. */
  38792. static Warn(message: string): void;
  38793. /**
  38794. * Write an error message to the console
  38795. * @param message defines the message to log
  38796. */
  38797. static Error(message: string): void;
  38798. /**
  38799. * Gets current log cache (list of logs)
  38800. */
  38801. static get LogCache(): string;
  38802. /**
  38803. * Clears the log cache
  38804. */
  38805. static ClearLogCache(): void;
  38806. /**
  38807. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38808. */
  38809. static set LogLevels(level: number);
  38810. /**
  38811. * Checks if the window object exists
  38812. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38813. */
  38814. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38815. /**
  38816. * No performance log
  38817. */
  38818. static readonly PerformanceNoneLogLevel: number;
  38819. /**
  38820. * Use user marks to log performance
  38821. */
  38822. static readonly PerformanceUserMarkLogLevel: number;
  38823. /**
  38824. * Log performance to the console
  38825. */
  38826. static readonly PerformanceConsoleLogLevel: number;
  38827. private static _performance;
  38828. /**
  38829. * Sets the current performance log level
  38830. */
  38831. static set PerformanceLogLevel(level: number);
  38832. private static _StartPerformanceCounterDisabled;
  38833. private static _EndPerformanceCounterDisabled;
  38834. private static _StartUserMark;
  38835. private static _EndUserMark;
  38836. private static _StartPerformanceConsole;
  38837. private static _EndPerformanceConsole;
  38838. /**
  38839. * Starts a performance counter
  38840. */
  38841. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38842. /**
  38843. * Ends a specific performance coutner
  38844. */
  38845. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38846. /**
  38847. * Gets either window.performance.now() if supported or Date.now() else
  38848. */
  38849. static get Now(): number;
  38850. /**
  38851. * This method will return the name of the class used to create the instance of the given object.
  38852. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38853. * @param object the object to get the class name from
  38854. * @param isType defines if the object is actually a type
  38855. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38856. */
  38857. static GetClassName(object: any, isType?: boolean): string;
  38858. /**
  38859. * Gets the first element of an array satisfying a given predicate
  38860. * @param array defines the array to browse
  38861. * @param predicate defines the predicate to use
  38862. * @returns null if not found or the element
  38863. */
  38864. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38865. /**
  38866. * This method will return the name of the full name of the class, including its owning module (if any).
  38867. * 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).
  38868. * @param object the object to get the class name from
  38869. * @param isType defines if the object is actually a type
  38870. * @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.
  38871. * @ignorenaming
  38872. */
  38873. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38874. /**
  38875. * Returns a promise that resolves after the given amount of time.
  38876. * @param delay Number of milliseconds to delay
  38877. * @returns Promise that resolves after the given amount of time
  38878. */
  38879. static DelayAsync(delay: number): Promise<void>;
  38880. /**
  38881. * Utility function to detect if the current user agent is Safari
  38882. * @returns whether or not the current user agent is safari
  38883. */
  38884. static IsSafari(): boolean;
  38885. }
  38886. /**
  38887. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38888. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38889. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38890. * @param name The name of the class, case should be preserved
  38891. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38892. */
  38893. export function className(name: string, module?: string): (target: Object) => void;
  38894. /**
  38895. * An implementation of a loop for asynchronous functions.
  38896. */
  38897. export class AsyncLoop {
  38898. /**
  38899. * Defines the number of iterations for the loop
  38900. */
  38901. iterations: number;
  38902. /**
  38903. * Defines the current index of the loop.
  38904. */
  38905. index: number;
  38906. private _done;
  38907. private _fn;
  38908. private _successCallback;
  38909. /**
  38910. * Constructor.
  38911. * @param iterations the number of iterations.
  38912. * @param func the function to run each iteration
  38913. * @param successCallback the callback that will be called upon succesful execution
  38914. * @param offset starting offset.
  38915. */
  38916. constructor(
  38917. /**
  38918. * Defines the number of iterations for the loop
  38919. */
  38920. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38921. /**
  38922. * Execute the next iteration. Must be called after the last iteration was finished.
  38923. */
  38924. executeNext(): void;
  38925. /**
  38926. * Break the loop and run the success callback.
  38927. */
  38928. breakLoop(): void;
  38929. /**
  38930. * Create and run an async loop.
  38931. * @param iterations the number of iterations.
  38932. * @param fn the function to run each iteration
  38933. * @param successCallback the callback that will be called upon succesful execution
  38934. * @param offset starting offset.
  38935. * @returns the created async loop object
  38936. */
  38937. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38938. /**
  38939. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38940. * @param iterations total number of iterations
  38941. * @param syncedIterations number of synchronous iterations in each async iteration.
  38942. * @param fn the function to call each iteration.
  38943. * @param callback a success call back that will be called when iterating stops.
  38944. * @param breakFunction a break condition (optional)
  38945. * @param timeout timeout settings for the setTimeout function. default - 0.
  38946. * @returns the created async loop object
  38947. */
  38948. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38949. }
  38950. }
  38951. declare module BABYLON {
  38952. /**
  38953. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38954. * The underlying implementation relies on an associative array to ensure the best performances.
  38955. * The value can be anything including 'null' but except 'undefined'
  38956. */
  38957. export class StringDictionary<T> {
  38958. /**
  38959. * This will clear this dictionary and copy the content from the 'source' one.
  38960. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38961. * @param source the dictionary to take the content from and copy to this dictionary
  38962. */
  38963. copyFrom(source: StringDictionary<T>): void;
  38964. /**
  38965. * Get a value based from its key
  38966. * @param key the given key to get the matching value from
  38967. * @return the value if found, otherwise undefined is returned
  38968. */
  38969. get(key: string): T | undefined;
  38970. /**
  38971. * Get a value from its key or add it if it doesn't exist.
  38972. * This method will ensure you that a given key/data will be present in the dictionary.
  38973. * @param key the given key to get the matching value from
  38974. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38975. * The factory will only be invoked if there's no data for the given key.
  38976. * @return the value corresponding to the key.
  38977. */
  38978. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38979. /**
  38980. * Get a value from its key if present in the dictionary otherwise add it
  38981. * @param key the key to get the value from
  38982. * @param val if there's no such key/value pair in the dictionary add it with this value
  38983. * @return the value corresponding to the key
  38984. */
  38985. getOrAdd(key: string, val: T): T;
  38986. /**
  38987. * Check if there's a given key in the dictionary
  38988. * @param key the key to check for
  38989. * @return true if the key is present, false otherwise
  38990. */
  38991. contains(key: string): boolean;
  38992. /**
  38993. * Add a new key and its corresponding value
  38994. * @param key the key to add
  38995. * @param value the value corresponding to the key
  38996. * @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
  38997. */
  38998. add(key: string, value: T): boolean;
  38999. /**
  39000. * Update a specific value associated to a key
  39001. * @param key defines the key to use
  39002. * @param value defines the value to store
  39003. * @returns true if the value was updated (or false if the key was not found)
  39004. */
  39005. set(key: string, value: T): boolean;
  39006. /**
  39007. * Get the element of the given key and remove it from the dictionary
  39008. * @param key defines the key to search
  39009. * @returns the value associated with the key or null if not found
  39010. */
  39011. getAndRemove(key: string): Nullable<T>;
  39012. /**
  39013. * Remove a key/value from the dictionary.
  39014. * @param key the key to remove
  39015. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39016. */
  39017. remove(key: string): boolean;
  39018. /**
  39019. * Clear the whole content of the dictionary
  39020. */
  39021. clear(): void;
  39022. /**
  39023. * Gets the current count
  39024. */
  39025. get count(): number;
  39026. /**
  39027. * Execute a callback on each key/val of the dictionary.
  39028. * Note that you can remove any element in this dictionary in the callback implementation
  39029. * @param callback the callback to execute on a given key/value pair
  39030. */
  39031. forEach(callback: (key: string, val: T) => void): void;
  39032. /**
  39033. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39034. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39035. * Note that you can remove any element in this dictionary in the callback implementation
  39036. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39037. * @returns the first item
  39038. */
  39039. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39040. private _count;
  39041. private _data;
  39042. }
  39043. }
  39044. declare module BABYLON {
  39045. /** @hidden */
  39046. export interface ICollisionCoordinator {
  39047. createCollider(): Collider;
  39048. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39049. init(scene: Scene): void;
  39050. }
  39051. /** @hidden */
  39052. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39053. private _scene;
  39054. private _scaledPosition;
  39055. private _scaledVelocity;
  39056. private _finalPosition;
  39057. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39058. createCollider(): Collider;
  39059. init(scene: Scene): void;
  39060. private _collideWithWorld;
  39061. }
  39062. }
  39063. declare module BABYLON {
  39064. /**
  39065. * Class used to manage all inputs for the scene.
  39066. */
  39067. export class InputManager {
  39068. /** The distance in pixel that you have to move to prevent some events */
  39069. static DragMovementThreshold: number;
  39070. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39071. static LongPressDelay: number;
  39072. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39073. static DoubleClickDelay: number;
  39074. /** If you need to check double click without raising a single click at first click, enable this flag */
  39075. static ExclusiveDoubleClickMode: boolean;
  39076. /** 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. */
  39077. private _alreadyAttached;
  39078. private _wheelEventName;
  39079. private _onPointerMove;
  39080. private _onPointerDown;
  39081. private _onPointerUp;
  39082. private _initClickEvent;
  39083. private _initActionManager;
  39084. private _delayedSimpleClick;
  39085. private _delayedSimpleClickTimeout;
  39086. private _previousDelayedSimpleClickTimeout;
  39087. private _meshPickProceed;
  39088. private _previousButtonPressed;
  39089. private _currentPickResult;
  39090. private _previousPickResult;
  39091. private _totalPointersPressed;
  39092. private _doubleClickOccured;
  39093. private _pointerOverMesh;
  39094. private _pickedDownMesh;
  39095. private _pickedUpMesh;
  39096. private _pointerX;
  39097. private _pointerY;
  39098. private _unTranslatedPointerX;
  39099. private _unTranslatedPointerY;
  39100. private _startingPointerPosition;
  39101. private _previousStartingPointerPosition;
  39102. private _startingPointerTime;
  39103. private _previousStartingPointerTime;
  39104. private _pointerCaptures;
  39105. private _meshUnderPointerId;
  39106. private _onKeyDown;
  39107. private _onKeyUp;
  39108. private _onCanvasFocusObserver;
  39109. private _onCanvasBlurObserver;
  39110. private _scene;
  39111. /**
  39112. * Creates a new InputManager
  39113. * @param scene defines the hosting scene
  39114. */
  39115. constructor(scene: Scene);
  39116. /**
  39117. * Gets the mesh that is currently under the pointer
  39118. */
  39119. get meshUnderPointer(): Nullable<AbstractMesh>;
  39120. /**
  39121. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  39122. * @param pointerId the pointer id to use
  39123. * @returns The mesh under this pointer id or null if not found
  39124. */
  39125. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  39126. /**
  39127. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39128. */
  39129. get unTranslatedPointer(): Vector2;
  39130. /**
  39131. * Gets or sets the current on-screen X position of the pointer
  39132. */
  39133. get pointerX(): number;
  39134. set pointerX(value: number);
  39135. /**
  39136. * Gets or sets the current on-screen Y position of the pointer
  39137. */
  39138. get pointerY(): number;
  39139. set pointerY(value: number);
  39140. private _updatePointerPosition;
  39141. private _processPointerMove;
  39142. private _setRayOnPointerInfo;
  39143. private _checkPrePointerObservable;
  39144. /**
  39145. * Use this method to simulate a pointer move on a mesh
  39146. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39147. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39148. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39149. */
  39150. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39151. /**
  39152. * Use this method to simulate a pointer down on a mesh
  39153. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39154. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39155. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39156. */
  39157. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39158. private _processPointerDown;
  39159. /** @hidden */
  39160. _isPointerSwiping(): boolean;
  39161. /**
  39162. * Use this method to simulate a pointer up on a mesh
  39163. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39164. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39165. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39166. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39167. */
  39168. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39169. private _processPointerUp;
  39170. /**
  39171. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39172. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39173. * @returns true if the pointer was captured
  39174. */
  39175. isPointerCaptured(pointerId?: number): boolean;
  39176. /**
  39177. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39178. * @param attachUp defines if you want to attach events to pointerup
  39179. * @param attachDown defines if you want to attach events to pointerdown
  39180. * @param attachMove defines if you want to attach events to pointermove
  39181. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39182. */
  39183. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39184. /**
  39185. * Detaches all event handlers
  39186. */
  39187. detachControl(): void;
  39188. /**
  39189. * Force the value of meshUnderPointer
  39190. * @param mesh defines the mesh to use
  39191. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  39192. */
  39193. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  39194. /**
  39195. * Gets the mesh under the pointer
  39196. * @returns a Mesh or null if no mesh is under the pointer
  39197. */
  39198. getPointerOverMesh(): Nullable<AbstractMesh>;
  39199. }
  39200. }
  39201. declare module BABYLON {
  39202. /**
  39203. * This class defines the direct association between an animation and a target
  39204. */
  39205. export class TargetedAnimation {
  39206. /**
  39207. * Animation to perform
  39208. */
  39209. animation: Animation;
  39210. /**
  39211. * Target to animate
  39212. */
  39213. target: any;
  39214. /**
  39215. * Returns the string "TargetedAnimation"
  39216. * @returns "TargetedAnimation"
  39217. */
  39218. getClassName(): string;
  39219. /**
  39220. * Serialize the object
  39221. * @returns the JSON object representing the current entity
  39222. */
  39223. serialize(): any;
  39224. }
  39225. /**
  39226. * Use this class to create coordinated animations on multiple targets
  39227. */
  39228. export class AnimationGroup implements IDisposable {
  39229. /** The name of the animation group */
  39230. name: string;
  39231. private _scene;
  39232. private _targetedAnimations;
  39233. private _animatables;
  39234. private _from;
  39235. private _to;
  39236. private _isStarted;
  39237. private _isPaused;
  39238. private _speedRatio;
  39239. private _loopAnimation;
  39240. private _isAdditive;
  39241. /**
  39242. * Gets or sets the unique id of the node
  39243. */
  39244. uniqueId: number;
  39245. /**
  39246. * This observable will notify when one animation have ended
  39247. */
  39248. onAnimationEndObservable: Observable<TargetedAnimation>;
  39249. /**
  39250. * Observer raised when one animation loops
  39251. */
  39252. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39253. /**
  39254. * Observer raised when all animations have looped
  39255. */
  39256. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39257. /**
  39258. * This observable will notify when all animations have ended.
  39259. */
  39260. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39261. /**
  39262. * This observable will notify when all animations have paused.
  39263. */
  39264. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39265. /**
  39266. * This observable will notify when all animations are playing.
  39267. */
  39268. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39269. /**
  39270. * Gets the first frame
  39271. */
  39272. get from(): number;
  39273. /**
  39274. * Gets the last frame
  39275. */
  39276. get to(): number;
  39277. /**
  39278. * Define if the animations are started
  39279. */
  39280. get isStarted(): boolean;
  39281. /**
  39282. * Gets a value indicating that the current group is playing
  39283. */
  39284. get isPlaying(): boolean;
  39285. /**
  39286. * Gets or sets the speed ratio to use for all animations
  39287. */
  39288. get speedRatio(): number;
  39289. /**
  39290. * Gets or sets the speed ratio to use for all animations
  39291. */
  39292. set speedRatio(value: number);
  39293. /**
  39294. * Gets or sets if all animations should loop or not
  39295. */
  39296. get loopAnimation(): boolean;
  39297. set loopAnimation(value: boolean);
  39298. /**
  39299. * Gets or sets if all animations should be evaluated additively
  39300. */
  39301. get isAdditive(): boolean;
  39302. set isAdditive(value: boolean);
  39303. /**
  39304. * Gets the targeted animations for this animation group
  39305. */
  39306. get targetedAnimations(): Array<TargetedAnimation>;
  39307. /**
  39308. * returning the list of animatables controlled by this animation group.
  39309. */
  39310. get animatables(): Array<Animatable>;
  39311. /**
  39312. * Gets the list of target animations
  39313. */
  39314. get children(): TargetedAnimation[];
  39315. /**
  39316. * Instantiates a new Animation Group.
  39317. * This helps managing several animations at once.
  39318. * @see https://doc.babylonjs.com/how_to/group
  39319. * @param name Defines the name of the group
  39320. * @param scene Defines the scene the group belongs to
  39321. */
  39322. constructor(
  39323. /** The name of the animation group */
  39324. name: string, scene?: Nullable<Scene>);
  39325. /**
  39326. * Add an animation (with its target) in the group
  39327. * @param animation defines the animation we want to add
  39328. * @param target defines the target of the animation
  39329. * @returns the TargetedAnimation object
  39330. */
  39331. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39332. /**
  39333. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39334. * It can add constant keys at begin or end
  39335. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39336. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39337. * @returns the animation group
  39338. */
  39339. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39340. private _animationLoopCount;
  39341. private _animationLoopFlags;
  39342. private _processLoop;
  39343. /**
  39344. * Start all animations on given targets
  39345. * @param loop defines if animations must loop
  39346. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39347. * @param from defines the from key (optional)
  39348. * @param to defines the to key (optional)
  39349. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39350. * @returns the current animation group
  39351. */
  39352. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39353. /**
  39354. * Pause all animations
  39355. * @returns the animation group
  39356. */
  39357. pause(): AnimationGroup;
  39358. /**
  39359. * Play all animations to initial state
  39360. * This function will start() the animations if they were not started or will restart() them if they were paused
  39361. * @param loop defines if animations must loop
  39362. * @returns the animation group
  39363. */
  39364. play(loop?: boolean): AnimationGroup;
  39365. /**
  39366. * Reset all animations to initial state
  39367. * @returns the animation group
  39368. */
  39369. reset(): AnimationGroup;
  39370. /**
  39371. * Restart animations from key 0
  39372. * @returns the animation group
  39373. */
  39374. restart(): AnimationGroup;
  39375. /**
  39376. * Stop all animations
  39377. * @returns the animation group
  39378. */
  39379. stop(): AnimationGroup;
  39380. /**
  39381. * Set animation weight for all animatables
  39382. * @param weight defines the weight to use
  39383. * @return the animationGroup
  39384. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39385. */
  39386. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39387. /**
  39388. * Synchronize and normalize all animatables with a source animatable
  39389. * @param root defines the root animatable to synchronize with
  39390. * @return the animationGroup
  39391. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39392. */
  39393. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39394. /**
  39395. * Goes to a specific frame in this animation group
  39396. * @param frame the frame number to go to
  39397. * @return the animationGroup
  39398. */
  39399. goToFrame(frame: number): AnimationGroup;
  39400. /**
  39401. * Dispose all associated resources
  39402. */
  39403. dispose(): void;
  39404. private _checkAnimationGroupEnded;
  39405. /**
  39406. * Clone the current animation group and returns a copy
  39407. * @param newName defines the name of the new group
  39408. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39409. * @returns the new aniamtion group
  39410. */
  39411. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39412. /**
  39413. * Serializes the animationGroup to an object
  39414. * @returns Serialized object
  39415. */
  39416. serialize(): any;
  39417. /**
  39418. * Returns a new AnimationGroup object parsed from the source provided.
  39419. * @param parsedAnimationGroup defines the source
  39420. * @param scene defines the scene that will receive the animationGroup
  39421. * @returns a new AnimationGroup
  39422. */
  39423. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39424. /**
  39425. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39426. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39427. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39428. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39429. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39430. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39431. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39432. */
  39433. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39434. /**
  39435. * Returns the string "AnimationGroup"
  39436. * @returns "AnimationGroup"
  39437. */
  39438. getClassName(): string;
  39439. /**
  39440. * Creates a detailled string about the object
  39441. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39442. * @returns a string representing the object
  39443. */
  39444. toString(fullDetails?: boolean): string;
  39445. }
  39446. }
  39447. declare module BABYLON {
  39448. /**
  39449. * Define an interface for all classes that will hold resources
  39450. */
  39451. export interface IDisposable {
  39452. /**
  39453. * Releases all held resources
  39454. */
  39455. dispose(): void;
  39456. }
  39457. /** Interface defining initialization parameters for Scene class */
  39458. export interface SceneOptions {
  39459. /**
  39460. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39461. * It will improve performance when the number of geometries becomes important.
  39462. */
  39463. useGeometryUniqueIdsMap?: boolean;
  39464. /**
  39465. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39466. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39467. */
  39468. useMaterialMeshMap?: boolean;
  39469. /**
  39470. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39471. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39472. */
  39473. useClonedMeshMap?: boolean;
  39474. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39475. virtual?: boolean;
  39476. }
  39477. /**
  39478. * Represents a scene to be rendered by the engine.
  39479. * @see https://doc.babylonjs.com/features/scene
  39480. */
  39481. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39482. /** The fog is deactivated */
  39483. static readonly FOGMODE_NONE: number;
  39484. /** The fog density is following an exponential function */
  39485. static readonly FOGMODE_EXP: number;
  39486. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39487. static readonly FOGMODE_EXP2: number;
  39488. /** The fog density is following a linear function. */
  39489. static readonly FOGMODE_LINEAR: number;
  39490. /**
  39491. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39492. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39493. */
  39494. static MinDeltaTime: number;
  39495. /**
  39496. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39497. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39498. */
  39499. static MaxDeltaTime: number;
  39500. /**
  39501. * Factory used to create the default material.
  39502. * @param name The name of the material to create
  39503. * @param scene The scene to create the material for
  39504. * @returns The default material
  39505. */
  39506. static DefaultMaterialFactory(scene: Scene): Material;
  39507. /**
  39508. * Factory used to create the a collision coordinator.
  39509. * @returns The collision coordinator
  39510. */
  39511. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39512. /** @hidden */
  39513. _inputManager: InputManager;
  39514. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39515. cameraToUseForPointers: Nullable<Camera>;
  39516. /** @hidden */
  39517. readonly _isScene: boolean;
  39518. /** @hidden */
  39519. _blockEntityCollection: boolean;
  39520. /**
  39521. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39522. */
  39523. autoClear: boolean;
  39524. /**
  39525. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39526. */
  39527. autoClearDepthAndStencil: boolean;
  39528. /**
  39529. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39530. */
  39531. clearColor: Color4;
  39532. /**
  39533. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39534. */
  39535. ambientColor: Color3;
  39536. /**
  39537. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39538. * It should only be one of the following (if not the default embedded one):
  39539. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39540. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39541. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39542. * The material properties need to be setup according to the type of texture in use.
  39543. */
  39544. environmentBRDFTexture: BaseTexture;
  39545. /**
  39546. * Texture used in all pbr material as the reflection texture.
  39547. * As in the majority of the scene they are the same (exception for multi room and so on),
  39548. * this is easier to reference from here than from all the materials.
  39549. */
  39550. get environmentTexture(): Nullable<BaseTexture>;
  39551. /**
  39552. * Texture used in all pbr material as the reflection texture.
  39553. * As in the majority of the scene they are the same (exception for multi room and so on),
  39554. * this is easier to set here than in all the materials.
  39555. */
  39556. set environmentTexture(value: Nullable<BaseTexture>);
  39557. /** @hidden */
  39558. protected _environmentIntensity: number;
  39559. /**
  39560. * Intensity of the environment in all pbr material.
  39561. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39562. * As in the majority of the scene they are the same (exception for multi room and so on),
  39563. * this is easier to reference from here than from all the materials.
  39564. */
  39565. get environmentIntensity(): number;
  39566. /**
  39567. * Intensity of the environment in all pbr material.
  39568. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39569. * As in the majority of the scene they are the same (exception for multi room and so on),
  39570. * this is easier to set here than in all the materials.
  39571. */
  39572. set environmentIntensity(value: number);
  39573. /** @hidden */
  39574. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39575. /**
  39576. * Default image processing configuration used either in the rendering
  39577. * Forward main pass or through the imageProcessingPostProcess if present.
  39578. * As in the majority of the scene they are the same (exception for multi camera),
  39579. * this is easier to reference from here than from all the materials and post process.
  39580. *
  39581. * No setter as we it is a shared configuration, you can set the values instead.
  39582. */
  39583. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39584. private _forceWireframe;
  39585. /**
  39586. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39587. */
  39588. set forceWireframe(value: boolean);
  39589. get forceWireframe(): boolean;
  39590. private _skipFrustumClipping;
  39591. /**
  39592. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39593. */
  39594. set skipFrustumClipping(value: boolean);
  39595. get skipFrustumClipping(): boolean;
  39596. private _forcePointsCloud;
  39597. /**
  39598. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39599. */
  39600. set forcePointsCloud(value: boolean);
  39601. get forcePointsCloud(): boolean;
  39602. /**
  39603. * Gets or sets the active clipplane 1
  39604. */
  39605. clipPlane: Nullable<Plane>;
  39606. /**
  39607. * Gets or sets the active clipplane 2
  39608. */
  39609. clipPlane2: Nullable<Plane>;
  39610. /**
  39611. * Gets or sets the active clipplane 3
  39612. */
  39613. clipPlane3: Nullable<Plane>;
  39614. /**
  39615. * Gets or sets the active clipplane 4
  39616. */
  39617. clipPlane4: Nullable<Plane>;
  39618. /**
  39619. * Gets or sets the active clipplane 5
  39620. */
  39621. clipPlane5: Nullable<Plane>;
  39622. /**
  39623. * Gets or sets the active clipplane 6
  39624. */
  39625. clipPlane6: Nullable<Plane>;
  39626. /**
  39627. * Gets or sets a boolean indicating if animations are enabled
  39628. */
  39629. animationsEnabled: boolean;
  39630. private _animationPropertiesOverride;
  39631. /**
  39632. * Gets or sets the animation properties override
  39633. */
  39634. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39635. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39636. /**
  39637. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39638. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39639. */
  39640. useConstantAnimationDeltaTime: boolean;
  39641. /**
  39642. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39643. * Please note that it requires to run a ray cast through the scene on every frame
  39644. */
  39645. constantlyUpdateMeshUnderPointer: boolean;
  39646. /**
  39647. * Defines the HTML cursor to use when hovering over interactive elements
  39648. */
  39649. hoverCursor: string;
  39650. /**
  39651. * Defines the HTML default cursor to use (empty by default)
  39652. */
  39653. defaultCursor: string;
  39654. /**
  39655. * Defines whether cursors are handled by the scene.
  39656. */
  39657. doNotHandleCursors: boolean;
  39658. /**
  39659. * This is used to call preventDefault() on pointer down
  39660. * in order to block unwanted artifacts like system double clicks
  39661. */
  39662. preventDefaultOnPointerDown: boolean;
  39663. /**
  39664. * This is used to call preventDefault() on pointer up
  39665. * in order to block unwanted artifacts like system double clicks
  39666. */
  39667. preventDefaultOnPointerUp: boolean;
  39668. /**
  39669. * Gets or sets user defined metadata
  39670. */
  39671. metadata: any;
  39672. /**
  39673. * For internal use only. Please do not use.
  39674. */
  39675. reservedDataStore: any;
  39676. /**
  39677. * Gets the name of the plugin used to load this scene (null by default)
  39678. */
  39679. loadingPluginName: string;
  39680. /**
  39681. * Use this array to add regular expressions used to disable offline support for specific urls
  39682. */
  39683. disableOfflineSupportExceptionRules: RegExp[];
  39684. /**
  39685. * An event triggered when the scene is disposed.
  39686. */
  39687. onDisposeObservable: Observable<Scene>;
  39688. private _onDisposeObserver;
  39689. /** Sets a function to be executed when this scene is disposed. */
  39690. set onDispose(callback: () => void);
  39691. /**
  39692. * An event triggered before rendering the scene (right after animations and physics)
  39693. */
  39694. onBeforeRenderObservable: Observable<Scene>;
  39695. private _onBeforeRenderObserver;
  39696. /** Sets a function to be executed before rendering this scene */
  39697. set beforeRender(callback: Nullable<() => void>);
  39698. /**
  39699. * An event triggered after rendering the scene
  39700. */
  39701. onAfterRenderObservable: Observable<Scene>;
  39702. /**
  39703. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39704. */
  39705. onAfterRenderCameraObservable: Observable<Camera>;
  39706. private _onAfterRenderObserver;
  39707. /** Sets a function to be executed after rendering this scene */
  39708. set afterRender(callback: Nullable<() => void>);
  39709. /**
  39710. * An event triggered before animating the scene
  39711. */
  39712. onBeforeAnimationsObservable: Observable<Scene>;
  39713. /**
  39714. * An event triggered after animations processing
  39715. */
  39716. onAfterAnimationsObservable: Observable<Scene>;
  39717. /**
  39718. * An event triggered before draw calls are ready to be sent
  39719. */
  39720. onBeforeDrawPhaseObservable: Observable<Scene>;
  39721. /**
  39722. * An event triggered after draw calls have been sent
  39723. */
  39724. onAfterDrawPhaseObservable: Observable<Scene>;
  39725. /**
  39726. * An event triggered when the scene is ready
  39727. */
  39728. onReadyObservable: Observable<Scene>;
  39729. /**
  39730. * An event triggered before rendering a camera
  39731. */
  39732. onBeforeCameraRenderObservable: Observable<Camera>;
  39733. private _onBeforeCameraRenderObserver;
  39734. /** Sets a function to be executed before rendering a camera*/
  39735. set beforeCameraRender(callback: () => void);
  39736. /**
  39737. * An event triggered after rendering a camera
  39738. */
  39739. onAfterCameraRenderObservable: Observable<Camera>;
  39740. private _onAfterCameraRenderObserver;
  39741. /** Sets a function to be executed after rendering a camera*/
  39742. set afterCameraRender(callback: () => void);
  39743. /**
  39744. * An event triggered when active meshes evaluation is about to start
  39745. */
  39746. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39747. /**
  39748. * An event triggered when active meshes evaluation is done
  39749. */
  39750. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39751. /**
  39752. * An event triggered when particles rendering is about to start
  39753. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39754. */
  39755. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39756. /**
  39757. * An event triggered when particles rendering is done
  39758. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39759. */
  39760. onAfterParticlesRenderingObservable: Observable<Scene>;
  39761. /**
  39762. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39763. */
  39764. onDataLoadedObservable: Observable<Scene>;
  39765. /**
  39766. * An event triggered when a camera is created
  39767. */
  39768. onNewCameraAddedObservable: Observable<Camera>;
  39769. /**
  39770. * An event triggered when a camera is removed
  39771. */
  39772. onCameraRemovedObservable: Observable<Camera>;
  39773. /**
  39774. * An event triggered when a light is created
  39775. */
  39776. onNewLightAddedObservable: Observable<Light>;
  39777. /**
  39778. * An event triggered when a light is removed
  39779. */
  39780. onLightRemovedObservable: Observable<Light>;
  39781. /**
  39782. * An event triggered when a geometry is created
  39783. */
  39784. onNewGeometryAddedObservable: Observable<Geometry>;
  39785. /**
  39786. * An event triggered when a geometry is removed
  39787. */
  39788. onGeometryRemovedObservable: Observable<Geometry>;
  39789. /**
  39790. * An event triggered when a transform node is created
  39791. */
  39792. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39793. /**
  39794. * An event triggered when a transform node is removed
  39795. */
  39796. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39797. /**
  39798. * An event triggered when a mesh is created
  39799. */
  39800. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39801. /**
  39802. * An event triggered when a mesh is removed
  39803. */
  39804. onMeshRemovedObservable: Observable<AbstractMesh>;
  39805. /**
  39806. * An event triggered when a skeleton is created
  39807. */
  39808. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39809. /**
  39810. * An event triggered when a skeleton is removed
  39811. */
  39812. onSkeletonRemovedObservable: Observable<Skeleton>;
  39813. /**
  39814. * An event triggered when a material is created
  39815. */
  39816. onNewMaterialAddedObservable: Observable<Material>;
  39817. /**
  39818. * An event triggered when a material is removed
  39819. */
  39820. onMaterialRemovedObservable: Observable<Material>;
  39821. /**
  39822. * An event triggered when a texture is created
  39823. */
  39824. onNewTextureAddedObservable: Observable<BaseTexture>;
  39825. /**
  39826. * An event triggered when a texture is removed
  39827. */
  39828. onTextureRemovedObservable: Observable<BaseTexture>;
  39829. /**
  39830. * An event triggered when render targets are about to be rendered
  39831. * Can happen multiple times per frame.
  39832. */
  39833. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39834. /**
  39835. * An event triggered when render targets were rendered.
  39836. * Can happen multiple times per frame.
  39837. */
  39838. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39839. /**
  39840. * An event triggered before calculating deterministic simulation step
  39841. */
  39842. onBeforeStepObservable: Observable<Scene>;
  39843. /**
  39844. * An event triggered after calculating deterministic simulation step
  39845. */
  39846. onAfterStepObservable: Observable<Scene>;
  39847. /**
  39848. * An event triggered when the activeCamera property is updated
  39849. */
  39850. onActiveCameraChanged: Observable<Scene>;
  39851. /**
  39852. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39853. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39854. * 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)
  39855. */
  39856. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39857. /**
  39858. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39859. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39860. * 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)
  39861. */
  39862. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39863. /**
  39864. * This Observable will when a mesh has been imported into the scene.
  39865. */
  39866. onMeshImportedObservable: Observable<AbstractMesh>;
  39867. /**
  39868. * This Observable will when an animation file has been imported into the scene.
  39869. */
  39870. onAnimationFileImportedObservable: Observable<Scene>;
  39871. /**
  39872. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39873. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39874. */
  39875. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39876. /** @hidden */
  39877. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39878. /**
  39879. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39880. */
  39881. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39882. /**
  39883. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39884. */
  39885. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39886. /**
  39887. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39888. */
  39889. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39890. /** Callback called when a pointer move is detected */
  39891. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39892. /** Callback called when a pointer down is detected */
  39893. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39894. /** Callback called when a pointer up is detected */
  39895. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39896. /** Callback called when a pointer pick is detected */
  39897. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39898. /**
  39899. * 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).
  39900. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39901. */
  39902. onPrePointerObservable: Observable<PointerInfoPre>;
  39903. /**
  39904. * Observable event triggered each time an input event is received from the rendering canvas
  39905. */
  39906. onPointerObservable: Observable<PointerInfo>;
  39907. /**
  39908. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39909. */
  39910. get unTranslatedPointer(): Vector2;
  39911. /**
  39912. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39913. */
  39914. static get DragMovementThreshold(): number;
  39915. static set DragMovementThreshold(value: number);
  39916. /**
  39917. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39918. */
  39919. static get LongPressDelay(): number;
  39920. static set LongPressDelay(value: number);
  39921. /**
  39922. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39923. */
  39924. static get DoubleClickDelay(): number;
  39925. static set DoubleClickDelay(value: number);
  39926. /** If you need to check double click without raising a single click at first click, enable this flag */
  39927. static get ExclusiveDoubleClickMode(): boolean;
  39928. static set ExclusiveDoubleClickMode(value: boolean);
  39929. /** @hidden */
  39930. _mirroredCameraPosition: Nullable<Vector3>;
  39931. /**
  39932. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39933. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39934. */
  39935. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39936. /**
  39937. * Observable event triggered each time an keyboard event is received from the hosting window
  39938. */
  39939. onKeyboardObservable: Observable<KeyboardInfo>;
  39940. private _useRightHandedSystem;
  39941. /**
  39942. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39943. */
  39944. set useRightHandedSystem(value: boolean);
  39945. get useRightHandedSystem(): boolean;
  39946. private _timeAccumulator;
  39947. private _currentStepId;
  39948. private _currentInternalStep;
  39949. /**
  39950. * Sets the step Id used by deterministic lock step
  39951. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39952. * @param newStepId defines the step Id
  39953. */
  39954. setStepId(newStepId: number): void;
  39955. /**
  39956. * Gets the step Id used by deterministic lock step
  39957. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39958. * @returns the step Id
  39959. */
  39960. getStepId(): number;
  39961. /**
  39962. * Gets the internal step used by deterministic lock step
  39963. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39964. * @returns the internal step
  39965. */
  39966. getInternalStep(): number;
  39967. private _fogEnabled;
  39968. /**
  39969. * Gets or sets a boolean indicating if fog is enabled on this scene
  39970. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39971. * (Default is true)
  39972. */
  39973. set fogEnabled(value: boolean);
  39974. get fogEnabled(): boolean;
  39975. private _fogMode;
  39976. /**
  39977. * Gets or sets the fog mode to use
  39978. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39979. * | mode | value |
  39980. * | --- | --- |
  39981. * | FOGMODE_NONE | 0 |
  39982. * | FOGMODE_EXP | 1 |
  39983. * | FOGMODE_EXP2 | 2 |
  39984. * | FOGMODE_LINEAR | 3 |
  39985. */
  39986. set fogMode(value: number);
  39987. get fogMode(): number;
  39988. /**
  39989. * Gets or sets the fog color to use
  39990. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39991. * (Default is Color3(0.2, 0.2, 0.3))
  39992. */
  39993. fogColor: Color3;
  39994. /**
  39995. * Gets or sets the fog density to use
  39996. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39997. * (Default is 0.1)
  39998. */
  39999. fogDensity: number;
  40000. /**
  40001. * Gets or sets the fog start distance to use
  40002. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40003. * (Default is 0)
  40004. */
  40005. fogStart: number;
  40006. /**
  40007. * Gets or sets the fog end distance to use
  40008. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40009. * (Default is 1000)
  40010. */
  40011. fogEnd: number;
  40012. /**
  40013. * Flag indicating that the frame buffer binding is handled by another component
  40014. */
  40015. prePass: boolean;
  40016. private _shadowsEnabled;
  40017. /**
  40018. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40019. */
  40020. set shadowsEnabled(value: boolean);
  40021. get shadowsEnabled(): boolean;
  40022. private _lightsEnabled;
  40023. /**
  40024. * Gets or sets a boolean indicating if lights are enabled on this scene
  40025. */
  40026. set lightsEnabled(value: boolean);
  40027. get lightsEnabled(): boolean;
  40028. /** All of the active cameras added to this scene. */
  40029. activeCameras: Camera[];
  40030. /** @hidden */
  40031. _activeCamera: Nullable<Camera>;
  40032. /** Gets or sets the current active camera */
  40033. get activeCamera(): Nullable<Camera>;
  40034. set activeCamera(value: Nullable<Camera>);
  40035. private _defaultMaterial;
  40036. /** The default material used on meshes when no material is affected */
  40037. get defaultMaterial(): Material;
  40038. /** The default material used on meshes when no material is affected */
  40039. set defaultMaterial(value: Material);
  40040. private _texturesEnabled;
  40041. /**
  40042. * Gets or sets a boolean indicating if textures are enabled on this scene
  40043. */
  40044. set texturesEnabled(value: boolean);
  40045. get texturesEnabled(): boolean;
  40046. /**
  40047. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40048. */
  40049. physicsEnabled: boolean;
  40050. /**
  40051. * Gets or sets a boolean indicating if particles are enabled on this scene
  40052. */
  40053. particlesEnabled: boolean;
  40054. /**
  40055. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40056. */
  40057. spritesEnabled: boolean;
  40058. private _skeletonsEnabled;
  40059. /**
  40060. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40061. */
  40062. set skeletonsEnabled(value: boolean);
  40063. get skeletonsEnabled(): boolean;
  40064. /**
  40065. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40066. */
  40067. lensFlaresEnabled: boolean;
  40068. /**
  40069. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40070. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40071. */
  40072. collisionsEnabled: boolean;
  40073. private _collisionCoordinator;
  40074. /** @hidden */
  40075. get collisionCoordinator(): ICollisionCoordinator;
  40076. /**
  40077. * Defines the gravity applied to this scene (used only for collisions)
  40078. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40079. */
  40080. gravity: Vector3;
  40081. /**
  40082. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40083. */
  40084. postProcessesEnabled: boolean;
  40085. /**
  40086. * Gets the current postprocess manager
  40087. */
  40088. postProcessManager: PostProcessManager;
  40089. /**
  40090. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40091. */
  40092. renderTargetsEnabled: boolean;
  40093. /**
  40094. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40095. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40096. */
  40097. dumpNextRenderTargets: boolean;
  40098. /**
  40099. * The list of user defined render targets added to the scene
  40100. */
  40101. customRenderTargets: RenderTargetTexture[];
  40102. /**
  40103. * Defines if texture loading must be delayed
  40104. * If true, textures will only be loaded when they need to be rendered
  40105. */
  40106. useDelayedTextureLoading: boolean;
  40107. /**
  40108. * Gets the list of meshes imported to the scene through SceneLoader
  40109. */
  40110. importedMeshesFiles: String[];
  40111. /**
  40112. * Gets or sets a boolean indicating if probes are enabled on this scene
  40113. */
  40114. probesEnabled: boolean;
  40115. /**
  40116. * Gets or sets the current offline provider to use to store scene data
  40117. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40118. */
  40119. offlineProvider: IOfflineProvider;
  40120. /**
  40121. * Gets or sets the action manager associated with the scene
  40122. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40123. */
  40124. actionManager: AbstractActionManager;
  40125. private _meshesForIntersections;
  40126. /**
  40127. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40128. */
  40129. proceduralTexturesEnabled: boolean;
  40130. private _engine;
  40131. private _totalVertices;
  40132. /** @hidden */
  40133. _activeIndices: PerfCounter;
  40134. /** @hidden */
  40135. _activeParticles: PerfCounter;
  40136. /** @hidden */
  40137. _activeBones: PerfCounter;
  40138. private _animationRatio;
  40139. /** @hidden */
  40140. _animationTimeLast: number;
  40141. /** @hidden */
  40142. _animationTime: number;
  40143. /**
  40144. * Gets or sets a general scale for animation speed
  40145. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40146. */
  40147. animationTimeScale: number;
  40148. /** @hidden */
  40149. _cachedMaterial: Nullable<Material>;
  40150. /** @hidden */
  40151. _cachedEffect: Nullable<Effect>;
  40152. /** @hidden */
  40153. _cachedVisibility: Nullable<number>;
  40154. private _renderId;
  40155. private _frameId;
  40156. private _executeWhenReadyTimeoutId;
  40157. private _intermediateRendering;
  40158. private _viewUpdateFlag;
  40159. private _projectionUpdateFlag;
  40160. /** @hidden */
  40161. _toBeDisposed: Nullable<IDisposable>[];
  40162. private _activeRequests;
  40163. /** @hidden */
  40164. _pendingData: any[];
  40165. private _isDisposed;
  40166. /**
  40167. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40168. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40169. */
  40170. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40171. private _activeMeshes;
  40172. private _processedMaterials;
  40173. private _renderTargets;
  40174. /** @hidden */
  40175. _activeParticleSystems: SmartArray<IParticleSystem>;
  40176. private _activeSkeletons;
  40177. private _softwareSkinnedMeshes;
  40178. private _renderingManager;
  40179. /** @hidden */
  40180. _activeAnimatables: Animatable[];
  40181. private _transformMatrix;
  40182. private _sceneUbo;
  40183. /** @hidden */
  40184. _viewMatrix: Matrix;
  40185. private _projectionMatrix;
  40186. /** @hidden */
  40187. _forcedViewPosition: Nullable<Vector3>;
  40188. /** @hidden */
  40189. _frustumPlanes: Plane[];
  40190. /**
  40191. * Gets the list of frustum planes (built from the active camera)
  40192. */
  40193. get frustumPlanes(): Plane[];
  40194. /**
  40195. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40196. * This is useful if there are more lights that the maximum simulteanous authorized
  40197. */
  40198. requireLightSorting: boolean;
  40199. /** @hidden */
  40200. readonly useMaterialMeshMap: boolean;
  40201. /** @hidden */
  40202. readonly useClonedMeshMap: boolean;
  40203. private _externalData;
  40204. private _uid;
  40205. /**
  40206. * @hidden
  40207. * Backing store of defined scene components.
  40208. */
  40209. _components: ISceneComponent[];
  40210. /**
  40211. * @hidden
  40212. * Backing store of defined scene components.
  40213. */
  40214. _serializableComponents: ISceneSerializableComponent[];
  40215. /**
  40216. * List of components to register on the next registration step.
  40217. */
  40218. private _transientComponents;
  40219. /**
  40220. * Registers the transient components if needed.
  40221. */
  40222. private _registerTransientComponents;
  40223. /**
  40224. * @hidden
  40225. * Add a component to the scene.
  40226. * Note that the ccomponent could be registered on th next frame if this is called after
  40227. * the register component stage.
  40228. * @param component Defines the component to add to the scene
  40229. */
  40230. _addComponent(component: ISceneComponent): void;
  40231. /**
  40232. * @hidden
  40233. * Gets a component from the scene.
  40234. * @param name defines the name of the component to retrieve
  40235. * @returns the component or null if not present
  40236. */
  40237. _getComponent(name: string): Nullable<ISceneComponent>;
  40238. /**
  40239. * @hidden
  40240. * Defines the actions happening before camera updates.
  40241. */
  40242. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40243. /**
  40244. * @hidden
  40245. * Defines the actions happening before clear the canvas.
  40246. */
  40247. _beforeClearStage: Stage<SimpleStageAction>;
  40248. /**
  40249. * @hidden
  40250. * Defines the actions when collecting render targets for the frame.
  40251. */
  40252. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40253. /**
  40254. * @hidden
  40255. * Defines the actions happening for one camera in the frame.
  40256. */
  40257. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40258. /**
  40259. * @hidden
  40260. * Defines the actions happening during the per mesh ready checks.
  40261. */
  40262. _isReadyForMeshStage: Stage<MeshStageAction>;
  40263. /**
  40264. * @hidden
  40265. * Defines the actions happening before evaluate active mesh checks.
  40266. */
  40267. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40268. /**
  40269. * @hidden
  40270. * Defines the actions happening during the evaluate sub mesh checks.
  40271. */
  40272. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40273. /**
  40274. * @hidden
  40275. * Defines the actions happening during the active mesh stage.
  40276. */
  40277. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40278. /**
  40279. * @hidden
  40280. * Defines the actions happening during the per camera render target step.
  40281. */
  40282. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40283. /**
  40284. * @hidden
  40285. * Defines the actions happening just before the active camera is drawing.
  40286. */
  40287. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40288. /**
  40289. * @hidden
  40290. * Defines the actions happening just before a render target is drawing.
  40291. */
  40292. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40293. /**
  40294. * @hidden
  40295. * Defines the actions happening just before a rendering group is drawing.
  40296. */
  40297. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40298. /**
  40299. * @hidden
  40300. * Defines the actions happening just before a mesh is drawing.
  40301. */
  40302. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40303. /**
  40304. * @hidden
  40305. * Defines the actions happening just after a mesh has been drawn.
  40306. */
  40307. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40308. /**
  40309. * @hidden
  40310. * Defines the actions happening just after a rendering group has been drawn.
  40311. */
  40312. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40313. /**
  40314. * @hidden
  40315. * Defines the actions happening just after the active camera has been drawn.
  40316. */
  40317. _afterCameraDrawStage: Stage<CameraStageAction>;
  40318. /**
  40319. * @hidden
  40320. * Defines the actions happening just after a render target has been drawn.
  40321. */
  40322. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40323. /**
  40324. * @hidden
  40325. * Defines the actions happening just after rendering all cameras and computing intersections.
  40326. */
  40327. _afterRenderStage: Stage<SimpleStageAction>;
  40328. /**
  40329. * @hidden
  40330. * Defines the actions happening when a pointer move event happens.
  40331. */
  40332. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40333. /**
  40334. * @hidden
  40335. * Defines the actions happening when a pointer down event happens.
  40336. */
  40337. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40338. /**
  40339. * @hidden
  40340. * Defines the actions happening when a pointer up event happens.
  40341. */
  40342. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40343. /**
  40344. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40345. */
  40346. private geometriesByUniqueId;
  40347. /**
  40348. * Creates a new Scene
  40349. * @param engine defines the engine to use to render this scene
  40350. * @param options defines the scene options
  40351. */
  40352. constructor(engine: Engine, options?: SceneOptions);
  40353. /**
  40354. * Gets a string identifying the name of the class
  40355. * @returns "Scene" string
  40356. */
  40357. getClassName(): string;
  40358. private _defaultMeshCandidates;
  40359. /**
  40360. * @hidden
  40361. */
  40362. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40363. private _defaultSubMeshCandidates;
  40364. /**
  40365. * @hidden
  40366. */
  40367. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40368. /**
  40369. * Sets the default candidate providers for the scene.
  40370. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40371. * and getCollidingSubMeshCandidates to their default function
  40372. */
  40373. setDefaultCandidateProviders(): void;
  40374. /**
  40375. * Gets the mesh that is currently under the pointer
  40376. */
  40377. get meshUnderPointer(): Nullable<AbstractMesh>;
  40378. /**
  40379. * Gets or sets the current on-screen X position of the pointer
  40380. */
  40381. get pointerX(): number;
  40382. set pointerX(value: number);
  40383. /**
  40384. * Gets or sets the current on-screen Y position of the pointer
  40385. */
  40386. get pointerY(): number;
  40387. set pointerY(value: number);
  40388. /**
  40389. * Gets the cached material (ie. the latest rendered one)
  40390. * @returns the cached material
  40391. */
  40392. getCachedMaterial(): Nullable<Material>;
  40393. /**
  40394. * Gets the cached effect (ie. the latest rendered one)
  40395. * @returns the cached effect
  40396. */
  40397. getCachedEffect(): Nullable<Effect>;
  40398. /**
  40399. * Gets the cached visibility state (ie. the latest rendered one)
  40400. * @returns the cached visibility state
  40401. */
  40402. getCachedVisibility(): Nullable<number>;
  40403. /**
  40404. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40405. * @param material defines the current material
  40406. * @param effect defines the current effect
  40407. * @param visibility defines the current visibility state
  40408. * @returns true if one parameter is not cached
  40409. */
  40410. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40411. /**
  40412. * Gets the engine associated with the scene
  40413. * @returns an Engine
  40414. */
  40415. getEngine(): Engine;
  40416. /**
  40417. * Gets the total number of vertices rendered per frame
  40418. * @returns the total number of vertices rendered per frame
  40419. */
  40420. getTotalVertices(): number;
  40421. /**
  40422. * Gets the performance counter for total vertices
  40423. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40424. */
  40425. get totalVerticesPerfCounter(): PerfCounter;
  40426. /**
  40427. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40428. * @returns the total number of active indices rendered per frame
  40429. */
  40430. getActiveIndices(): number;
  40431. /**
  40432. * Gets the performance counter for active indices
  40433. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40434. */
  40435. get totalActiveIndicesPerfCounter(): PerfCounter;
  40436. /**
  40437. * Gets the total number of active particles rendered per frame
  40438. * @returns the total number of active particles rendered per frame
  40439. */
  40440. getActiveParticles(): number;
  40441. /**
  40442. * Gets the performance counter for active particles
  40443. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40444. */
  40445. get activeParticlesPerfCounter(): PerfCounter;
  40446. /**
  40447. * Gets the total number of active bones rendered per frame
  40448. * @returns the total number of active bones rendered per frame
  40449. */
  40450. getActiveBones(): number;
  40451. /**
  40452. * Gets the performance counter for active bones
  40453. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40454. */
  40455. get activeBonesPerfCounter(): PerfCounter;
  40456. /**
  40457. * Gets the array of active meshes
  40458. * @returns an array of AbstractMesh
  40459. */
  40460. getActiveMeshes(): SmartArray<AbstractMesh>;
  40461. /**
  40462. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40463. * @returns a number
  40464. */
  40465. getAnimationRatio(): number;
  40466. /**
  40467. * Gets an unique Id for the current render phase
  40468. * @returns a number
  40469. */
  40470. getRenderId(): number;
  40471. /**
  40472. * Gets an unique Id for the current frame
  40473. * @returns a number
  40474. */
  40475. getFrameId(): number;
  40476. /** Call this function if you want to manually increment the render Id*/
  40477. incrementRenderId(): void;
  40478. private _createUbo;
  40479. /**
  40480. * Use this method to simulate a pointer move on a mesh
  40481. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40482. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40483. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40484. * @returns the current scene
  40485. */
  40486. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40487. /**
  40488. * Use this method to simulate a pointer down on a mesh
  40489. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40490. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40491. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40492. * @returns the current scene
  40493. */
  40494. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40495. /**
  40496. * Use this method to simulate a pointer up on a mesh
  40497. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40498. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40499. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40500. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40501. * @returns the current scene
  40502. */
  40503. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40504. /**
  40505. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40506. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40507. * @returns true if the pointer was captured
  40508. */
  40509. isPointerCaptured(pointerId?: number): boolean;
  40510. /**
  40511. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40512. * @param attachUp defines if you want to attach events to pointerup
  40513. * @param attachDown defines if you want to attach events to pointerdown
  40514. * @param attachMove defines if you want to attach events to pointermove
  40515. */
  40516. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40517. /** Detaches all event handlers*/
  40518. detachControl(): void;
  40519. /**
  40520. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40521. * Delay loaded resources are not taking in account
  40522. * @return true if all required resources are ready
  40523. */
  40524. isReady(): boolean;
  40525. /** Resets all cached information relative to material (including effect and visibility) */
  40526. resetCachedMaterial(): void;
  40527. /**
  40528. * Registers a function to be called before every frame render
  40529. * @param func defines the function to register
  40530. */
  40531. registerBeforeRender(func: () => void): void;
  40532. /**
  40533. * Unregisters a function called before every frame render
  40534. * @param func defines the function to unregister
  40535. */
  40536. unregisterBeforeRender(func: () => void): void;
  40537. /**
  40538. * Registers a function to be called after every frame render
  40539. * @param func defines the function to register
  40540. */
  40541. registerAfterRender(func: () => void): void;
  40542. /**
  40543. * Unregisters a function called after every frame render
  40544. * @param func defines the function to unregister
  40545. */
  40546. unregisterAfterRender(func: () => void): void;
  40547. private _executeOnceBeforeRender;
  40548. /**
  40549. * The provided function will run before render once and will be disposed afterwards.
  40550. * A timeout delay can be provided so that the function will be executed in N ms.
  40551. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40552. * @param func The function to be executed.
  40553. * @param timeout optional delay in ms
  40554. */
  40555. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40556. /** @hidden */
  40557. _addPendingData(data: any): void;
  40558. /** @hidden */
  40559. _removePendingData(data: any): void;
  40560. /**
  40561. * Returns the number of items waiting to be loaded
  40562. * @returns the number of items waiting to be loaded
  40563. */
  40564. getWaitingItemsCount(): number;
  40565. /**
  40566. * Returns a boolean indicating if the scene is still loading data
  40567. */
  40568. get isLoading(): boolean;
  40569. /**
  40570. * Registers a function to be executed when the scene is ready
  40571. * @param {Function} func - the function to be executed
  40572. */
  40573. executeWhenReady(func: () => void): void;
  40574. /**
  40575. * Returns a promise that resolves when the scene is ready
  40576. * @returns A promise that resolves when the scene is ready
  40577. */
  40578. whenReadyAsync(): Promise<void>;
  40579. /** @hidden */
  40580. _checkIsReady(): void;
  40581. /**
  40582. * Gets all animatable attached to the scene
  40583. */
  40584. get animatables(): Animatable[];
  40585. /**
  40586. * Resets the last animation time frame.
  40587. * Useful to override when animations start running when loading a scene for the first time.
  40588. */
  40589. resetLastAnimationTimeFrame(): void;
  40590. /**
  40591. * Gets the current view matrix
  40592. * @returns a Matrix
  40593. */
  40594. getViewMatrix(): Matrix;
  40595. /**
  40596. * Gets the current projection matrix
  40597. * @returns a Matrix
  40598. */
  40599. getProjectionMatrix(): Matrix;
  40600. /**
  40601. * Gets the current transform matrix
  40602. * @returns a Matrix made of View * Projection
  40603. */
  40604. getTransformMatrix(): Matrix;
  40605. /**
  40606. * Sets the current transform matrix
  40607. * @param viewL defines the View matrix to use
  40608. * @param projectionL defines the Projection matrix to use
  40609. * @param viewR defines the right View matrix to use (if provided)
  40610. * @param projectionR defines the right Projection matrix to use (if provided)
  40611. */
  40612. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40613. /**
  40614. * Gets the uniform buffer used to store scene data
  40615. * @returns a UniformBuffer
  40616. */
  40617. getSceneUniformBuffer(): UniformBuffer;
  40618. /**
  40619. * Gets an unique (relatively to the current scene) Id
  40620. * @returns an unique number for the scene
  40621. */
  40622. getUniqueId(): number;
  40623. /**
  40624. * Add a mesh to the list of scene's meshes
  40625. * @param newMesh defines the mesh to add
  40626. * @param recursive if all child meshes should also be added to the scene
  40627. */
  40628. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40629. /**
  40630. * Remove a mesh for the list of scene's meshes
  40631. * @param toRemove defines the mesh to remove
  40632. * @param recursive if all child meshes should also be removed from the scene
  40633. * @returns the index where the mesh was in the mesh list
  40634. */
  40635. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40636. /**
  40637. * Add a transform node to the list of scene's transform nodes
  40638. * @param newTransformNode defines the transform node to add
  40639. */
  40640. addTransformNode(newTransformNode: TransformNode): void;
  40641. /**
  40642. * Remove a transform node for the list of scene's transform nodes
  40643. * @param toRemove defines the transform node to remove
  40644. * @returns the index where the transform node was in the transform node list
  40645. */
  40646. removeTransformNode(toRemove: TransformNode): number;
  40647. /**
  40648. * Remove a skeleton for the list of scene's skeletons
  40649. * @param toRemove defines the skeleton to remove
  40650. * @returns the index where the skeleton was in the skeleton list
  40651. */
  40652. removeSkeleton(toRemove: Skeleton): number;
  40653. /**
  40654. * Remove a morph target for the list of scene's morph targets
  40655. * @param toRemove defines the morph target to remove
  40656. * @returns the index where the morph target was in the morph target list
  40657. */
  40658. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40659. /**
  40660. * Remove a light for the list of scene's lights
  40661. * @param toRemove defines the light to remove
  40662. * @returns the index where the light was in the light list
  40663. */
  40664. removeLight(toRemove: Light): number;
  40665. /**
  40666. * Remove a camera for the list of scene's cameras
  40667. * @param toRemove defines the camera to remove
  40668. * @returns the index where the camera was in the camera list
  40669. */
  40670. removeCamera(toRemove: Camera): number;
  40671. /**
  40672. * Remove a particle system for the list of scene's particle systems
  40673. * @param toRemove defines the particle system to remove
  40674. * @returns the index where the particle system was in the particle system list
  40675. */
  40676. removeParticleSystem(toRemove: IParticleSystem): number;
  40677. /**
  40678. * Remove a animation for the list of scene's animations
  40679. * @param toRemove defines the animation to remove
  40680. * @returns the index where the animation was in the animation list
  40681. */
  40682. removeAnimation(toRemove: Animation): number;
  40683. /**
  40684. * Will stop the animation of the given target
  40685. * @param target - the target
  40686. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40687. * @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)
  40688. */
  40689. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40690. /**
  40691. * Removes the given animation group from this scene.
  40692. * @param toRemove The animation group to remove
  40693. * @returns The index of the removed animation group
  40694. */
  40695. removeAnimationGroup(toRemove: AnimationGroup): number;
  40696. /**
  40697. * Removes the given multi-material from this scene.
  40698. * @param toRemove The multi-material to remove
  40699. * @returns The index of the removed multi-material
  40700. */
  40701. removeMultiMaterial(toRemove: MultiMaterial): number;
  40702. /**
  40703. * Removes the given material from this scene.
  40704. * @param toRemove The material to remove
  40705. * @returns The index of the removed material
  40706. */
  40707. removeMaterial(toRemove: Material): number;
  40708. /**
  40709. * Removes the given action manager from this scene.
  40710. * @param toRemove The action manager to remove
  40711. * @returns The index of the removed action manager
  40712. */
  40713. removeActionManager(toRemove: AbstractActionManager): number;
  40714. /**
  40715. * Removes the given texture from this scene.
  40716. * @param toRemove The texture to remove
  40717. * @returns The index of the removed texture
  40718. */
  40719. removeTexture(toRemove: BaseTexture): number;
  40720. /**
  40721. * Adds the given light to this scene
  40722. * @param newLight The light to add
  40723. */
  40724. addLight(newLight: Light): void;
  40725. /**
  40726. * Sorts the list list based on light priorities
  40727. */
  40728. sortLightsByPriority(): void;
  40729. /**
  40730. * Adds the given camera to this scene
  40731. * @param newCamera The camera to add
  40732. */
  40733. addCamera(newCamera: Camera): void;
  40734. /**
  40735. * Adds the given skeleton to this scene
  40736. * @param newSkeleton The skeleton to add
  40737. */
  40738. addSkeleton(newSkeleton: Skeleton): void;
  40739. /**
  40740. * Adds the given particle system to this scene
  40741. * @param newParticleSystem The particle system to add
  40742. */
  40743. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40744. /**
  40745. * Adds the given animation to this scene
  40746. * @param newAnimation The animation to add
  40747. */
  40748. addAnimation(newAnimation: Animation): void;
  40749. /**
  40750. * Adds the given animation group to this scene.
  40751. * @param newAnimationGroup The animation group to add
  40752. */
  40753. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40754. /**
  40755. * Adds the given multi-material to this scene
  40756. * @param newMultiMaterial The multi-material to add
  40757. */
  40758. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40759. /**
  40760. * Adds the given material to this scene
  40761. * @param newMaterial The material to add
  40762. */
  40763. addMaterial(newMaterial: Material): void;
  40764. /**
  40765. * Adds the given morph target to this scene
  40766. * @param newMorphTargetManager The morph target to add
  40767. */
  40768. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40769. /**
  40770. * Adds the given geometry to this scene
  40771. * @param newGeometry The geometry to add
  40772. */
  40773. addGeometry(newGeometry: Geometry): void;
  40774. /**
  40775. * Adds the given action manager to this scene
  40776. * @param newActionManager The action manager to add
  40777. */
  40778. addActionManager(newActionManager: AbstractActionManager): void;
  40779. /**
  40780. * Adds the given texture to this scene.
  40781. * @param newTexture The texture to add
  40782. */
  40783. addTexture(newTexture: BaseTexture): void;
  40784. /**
  40785. * Switch active camera
  40786. * @param newCamera defines the new active camera
  40787. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40788. */
  40789. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40790. /**
  40791. * sets the active camera of the scene using its ID
  40792. * @param id defines the camera's ID
  40793. * @return the new active camera or null if none found.
  40794. */
  40795. setActiveCameraByID(id: string): Nullable<Camera>;
  40796. /**
  40797. * sets the active camera of the scene using its name
  40798. * @param name defines the camera's name
  40799. * @returns the new active camera or null if none found.
  40800. */
  40801. setActiveCameraByName(name: string): Nullable<Camera>;
  40802. /**
  40803. * get an animation group using its name
  40804. * @param name defines the material's name
  40805. * @return the animation group or null if none found.
  40806. */
  40807. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40808. /**
  40809. * Get a material using its unique id
  40810. * @param uniqueId defines the material's unique id
  40811. * @return the material or null if none found.
  40812. */
  40813. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40814. /**
  40815. * get a material using its id
  40816. * @param id defines the material's ID
  40817. * @return the material or null if none found.
  40818. */
  40819. getMaterialByID(id: string): Nullable<Material>;
  40820. /**
  40821. * Gets a the last added material using a given id
  40822. * @param id defines the material's ID
  40823. * @return the last material with the given id or null if none found.
  40824. */
  40825. getLastMaterialByID(id: string): Nullable<Material>;
  40826. /**
  40827. * Gets a material using its name
  40828. * @param name defines the material's name
  40829. * @return the material or null if none found.
  40830. */
  40831. getMaterialByName(name: string): Nullable<Material>;
  40832. /**
  40833. * Get a texture using its unique id
  40834. * @param uniqueId defines the texture's unique id
  40835. * @return the texture or null if none found.
  40836. */
  40837. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40838. /**
  40839. * Gets a camera using its id
  40840. * @param id defines the id to look for
  40841. * @returns the camera or null if not found
  40842. */
  40843. getCameraByID(id: string): Nullable<Camera>;
  40844. /**
  40845. * Gets a camera using its unique id
  40846. * @param uniqueId defines the unique id to look for
  40847. * @returns the camera or null if not found
  40848. */
  40849. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40850. /**
  40851. * Gets a camera using its name
  40852. * @param name defines the camera's name
  40853. * @return the camera or null if none found.
  40854. */
  40855. getCameraByName(name: string): Nullable<Camera>;
  40856. /**
  40857. * Gets a bone using its id
  40858. * @param id defines the bone's id
  40859. * @return the bone or null if not found
  40860. */
  40861. getBoneByID(id: string): Nullable<Bone>;
  40862. /**
  40863. * Gets a bone using its id
  40864. * @param name defines the bone's name
  40865. * @return the bone or null if not found
  40866. */
  40867. getBoneByName(name: string): Nullable<Bone>;
  40868. /**
  40869. * Gets a light node using its name
  40870. * @param name defines the the light's name
  40871. * @return the light or null if none found.
  40872. */
  40873. getLightByName(name: string): Nullable<Light>;
  40874. /**
  40875. * Gets a light node using its id
  40876. * @param id defines the light's id
  40877. * @return the light or null if none found.
  40878. */
  40879. getLightByID(id: string): Nullable<Light>;
  40880. /**
  40881. * Gets a light node using its scene-generated unique ID
  40882. * @param uniqueId defines the light's unique id
  40883. * @return the light or null if none found.
  40884. */
  40885. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40886. /**
  40887. * Gets a particle system by id
  40888. * @param id defines the particle system id
  40889. * @return the corresponding system or null if none found
  40890. */
  40891. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40892. /**
  40893. * Gets a geometry using its ID
  40894. * @param id defines the geometry's id
  40895. * @return the geometry or null if none found.
  40896. */
  40897. getGeometryByID(id: string): Nullable<Geometry>;
  40898. private _getGeometryByUniqueID;
  40899. /**
  40900. * Add a new geometry to this scene
  40901. * @param geometry defines the geometry to be added to the scene.
  40902. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40903. * @return a boolean defining if the geometry was added or not
  40904. */
  40905. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40906. /**
  40907. * Removes an existing geometry
  40908. * @param geometry defines the geometry to be removed from the scene
  40909. * @return a boolean defining if the geometry was removed or not
  40910. */
  40911. removeGeometry(geometry: Geometry): boolean;
  40912. /**
  40913. * Gets the list of geometries attached to the scene
  40914. * @returns an array of Geometry
  40915. */
  40916. getGeometries(): Geometry[];
  40917. /**
  40918. * Gets the first added mesh found of a given ID
  40919. * @param id defines the id to search for
  40920. * @return the mesh found or null if not found at all
  40921. */
  40922. getMeshByID(id: string): Nullable<AbstractMesh>;
  40923. /**
  40924. * Gets a list of meshes using their id
  40925. * @param id defines the id to search for
  40926. * @returns a list of meshes
  40927. */
  40928. getMeshesByID(id: string): Array<AbstractMesh>;
  40929. /**
  40930. * Gets the first added transform node found of a given ID
  40931. * @param id defines the id to search for
  40932. * @return the found transform node or null if not found at all.
  40933. */
  40934. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40935. /**
  40936. * Gets a transform node with its auto-generated unique id
  40937. * @param uniqueId efines the unique id to search for
  40938. * @return the found transform node or null if not found at all.
  40939. */
  40940. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40941. /**
  40942. * Gets a list of transform nodes using their id
  40943. * @param id defines the id to search for
  40944. * @returns a list of transform nodes
  40945. */
  40946. getTransformNodesByID(id: string): Array<TransformNode>;
  40947. /**
  40948. * Gets a mesh with its auto-generated unique id
  40949. * @param uniqueId defines the unique id to search for
  40950. * @return the found mesh or null if not found at all.
  40951. */
  40952. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40953. /**
  40954. * Gets a the last added mesh using a given id
  40955. * @param id defines the id to search for
  40956. * @return the found mesh or null if not found at all.
  40957. */
  40958. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40959. /**
  40960. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40961. * @param id defines the id to search for
  40962. * @return the found node or null if not found at all
  40963. */
  40964. getLastEntryByID(id: string): Nullable<Node>;
  40965. /**
  40966. * Gets a node (Mesh, Camera, Light) using a given id
  40967. * @param id defines the id to search for
  40968. * @return the found node or null if not found at all
  40969. */
  40970. getNodeByID(id: string): Nullable<Node>;
  40971. /**
  40972. * Gets a node (Mesh, Camera, Light) using a given name
  40973. * @param name defines the name to search for
  40974. * @return the found node or null if not found at all.
  40975. */
  40976. getNodeByName(name: string): Nullable<Node>;
  40977. /**
  40978. * Gets a mesh using a given name
  40979. * @param name defines the name to search for
  40980. * @return the found mesh or null if not found at all.
  40981. */
  40982. getMeshByName(name: string): Nullable<AbstractMesh>;
  40983. /**
  40984. * Gets a transform node using a given name
  40985. * @param name defines the name to search for
  40986. * @return the found transform node or null if not found at all.
  40987. */
  40988. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40989. /**
  40990. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40991. * @param id defines the id to search for
  40992. * @return the found skeleton or null if not found at all.
  40993. */
  40994. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40995. /**
  40996. * Gets a skeleton using a given auto generated unique id
  40997. * @param uniqueId defines the unique id to search for
  40998. * @return the found skeleton or null if not found at all.
  40999. */
  41000. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41001. /**
  41002. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41003. * @param id defines the id to search for
  41004. * @return the found skeleton or null if not found at all.
  41005. */
  41006. getSkeletonById(id: string): Nullable<Skeleton>;
  41007. /**
  41008. * Gets a skeleton using a given name
  41009. * @param name defines the name to search for
  41010. * @return the found skeleton or null if not found at all.
  41011. */
  41012. getSkeletonByName(name: string): Nullable<Skeleton>;
  41013. /**
  41014. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41015. * @param id defines the id to search for
  41016. * @return the found morph target manager or null if not found at all.
  41017. */
  41018. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41019. /**
  41020. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41021. * @param id defines the id to search for
  41022. * @return the found morph target or null if not found at all.
  41023. */
  41024. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41025. /**
  41026. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41027. * @param name defines the name to search for
  41028. * @return the found morph target or null if not found at all.
  41029. */
  41030. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41031. /**
  41032. * Gets a post process using a given name (if many are found, this function will pick the first one)
  41033. * @param name defines the name to search for
  41034. * @return the found post process or null if not found at all.
  41035. */
  41036. getPostProcessByName(name: string): Nullable<PostProcess>;
  41037. /**
  41038. * Gets a boolean indicating if the given mesh is active
  41039. * @param mesh defines the mesh to look for
  41040. * @returns true if the mesh is in the active list
  41041. */
  41042. isActiveMesh(mesh: AbstractMesh): boolean;
  41043. /**
  41044. * Return a unique id as a string which can serve as an identifier for the scene
  41045. */
  41046. get uid(): string;
  41047. /**
  41048. * Add an externaly attached data from its key.
  41049. * This method call will fail and return false, if such key already exists.
  41050. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41051. * @param key the unique key that identifies the data
  41052. * @param data the data object to associate to the key for this Engine instance
  41053. * @return true if no such key were already present and the data was added successfully, false otherwise
  41054. */
  41055. addExternalData<T>(key: string, data: T): boolean;
  41056. /**
  41057. * Get an externaly attached data from its key
  41058. * @param key the unique key that identifies the data
  41059. * @return the associated data, if present (can be null), or undefined if not present
  41060. */
  41061. getExternalData<T>(key: string): Nullable<T>;
  41062. /**
  41063. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41064. * @param key the unique key that identifies the data
  41065. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41066. * @return the associated data, can be null if the factory returned null.
  41067. */
  41068. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41069. /**
  41070. * Remove an externaly attached data from the Engine instance
  41071. * @param key the unique key that identifies the data
  41072. * @return true if the data was successfully removed, false if it doesn't exist
  41073. */
  41074. removeExternalData(key: string): boolean;
  41075. private _evaluateSubMesh;
  41076. /**
  41077. * Clear the processed materials smart array preventing retention point in material dispose.
  41078. */
  41079. freeProcessedMaterials(): void;
  41080. private _preventFreeActiveMeshesAndRenderingGroups;
  41081. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41082. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41083. * when disposing several meshes in a row or a hierarchy of meshes.
  41084. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41085. */
  41086. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41087. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41088. /**
  41089. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41090. */
  41091. freeActiveMeshes(): void;
  41092. /**
  41093. * Clear the info related to rendering groups preventing retention points during dispose.
  41094. */
  41095. freeRenderingGroups(): void;
  41096. /** @hidden */
  41097. _isInIntermediateRendering(): boolean;
  41098. /**
  41099. * Lambda returning the list of potentially active meshes.
  41100. */
  41101. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41102. /**
  41103. * Lambda returning the list of potentially active sub meshes.
  41104. */
  41105. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41106. /**
  41107. * Lambda returning the list of potentially intersecting sub meshes.
  41108. */
  41109. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41110. /**
  41111. * Lambda returning the list of potentially colliding sub meshes.
  41112. */
  41113. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41114. private _activeMeshesFrozen;
  41115. private _skipEvaluateActiveMeshesCompletely;
  41116. /**
  41117. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41118. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41119. * @returns the current scene
  41120. */
  41121. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41122. /**
  41123. * Use this function to restart evaluating active meshes on every frame
  41124. * @returns the current scene
  41125. */
  41126. unfreezeActiveMeshes(): Scene;
  41127. private _evaluateActiveMeshes;
  41128. private _activeMesh;
  41129. /**
  41130. * Update the transform matrix to update from the current active camera
  41131. * @param force defines a boolean used to force the update even if cache is up to date
  41132. */
  41133. updateTransformMatrix(force?: boolean): void;
  41134. private _bindFrameBuffer;
  41135. /** @hidden */
  41136. _allowPostProcessClearColor: boolean;
  41137. /** @hidden */
  41138. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41139. private _processSubCameras;
  41140. private _checkIntersections;
  41141. /** @hidden */
  41142. _advancePhysicsEngineStep(step: number): void;
  41143. /**
  41144. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41145. */
  41146. getDeterministicFrameTime: () => number;
  41147. /** @hidden */
  41148. _animate(): void;
  41149. /** Execute all animations (for a frame) */
  41150. animate(): void;
  41151. /**
  41152. * Render the scene
  41153. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41154. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41155. */
  41156. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41157. /**
  41158. * Freeze all materials
  41159. * A frozen material will not be updatable but should be faster to render
  41160. */
  41161. freezeMaterials(): void;
  41162. /**
  41163. * Unfreeze all materials
  41164. * A frozen material will not be updatable but should be faster to render
  41165. */
  41166. unfreezeMaterials(): void;
  41167. /**
  41168. * Releases all held ressources
  41169. */
  41170. dispose(): void;
  41171. /**
  41172. * Gets if the scene is already disposed
  41173. */
  41174. get isDisposed(): boolean;
  41175. /**
  41176. * Call this function to reduce memory footprint of the scene.
  41177. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41178. */
  41179. clearCachedVertexData(): void;
  41180. /**
  41181. * This function will remove the local cached buffer data from texture.
  41182. * It will save memory but will prevent the texture from being rebuilt
  41183. */
  41184. cleanCachedTextureBuffer(): void;
  41185. /**
  41186. * Get the world extend vectors with an optional filter
  41187. *
  41188. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41189. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41190. */
  41191. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41192. min: Vector3;
  41193. max: Vector3;
  41194. };
  41195. /**
  41196. * Creates a ray that can be used to pick in the scene
  41197. * @param x defines the x coordinate of the origin (on-screen)
  41198. * @param y defines the y coordinate of the origin (on-screen)
  41199. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41200. * @param camera defines the camera to use for the picking
  41201. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41202. * @returns a Ray
  41203. */
  41204. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41205. /**
  41206. * Creates a ray that can be used to pick in the scene
  41207. * @param x defines the x coordinate of the origin (on-screen)
  41208. * @param y defines the y coordinate of the origin (on-screen)
  41209. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41210. * @param result defines the ray where to store the picking ray
  41211. * @param camera defines the camera to use for the picking
  41212. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41213. * @returns the current scene
  41214. */
  41215. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41216. /**
  41217. * Creates a ray that can be used to pick in the scene
  41218. * @param x defines the x coordinate of the origin (on-screen)
  41219. * @param y defines the y coordinate of the origin (on-screen)
  41220. * @param camera defines the camera to use for the picking
  41221. * @returns a Ray
  41222. */
  41223. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41224. /**
  41225. * Creates a ray that can be used to pick in the scene
  41226. * @param x defines the x coordinate of the origin (on-screen)
  41227. * @param y defines the y coordinate of the origin (on-screen)
  41228. * @param result defines the ray where to store the picking ray
  41229. * @param camera defines the camera to use for the picking
  41230. * @returns the current scene
  41231. */
  41232. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41233. /** Launch a ray to try to pick a mesh in the scene
  41234. * @param x position on screen
  41235. * @param y position on screen
  41236. * @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
  41237. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41238. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41239. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41240. * @returns a PickingInfo
  41241. */
  41242. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41243. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41244. * @param x position on screen
  41245. * @param y position on screen
  41246. * @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
  41247. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41248. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41249. * @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)
  41250. */
  41251. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41252. /** Use the given ray to pick a mesh in the scene
  41253. * @param ray The ray to use to pick meshes
  41254. * @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
  41255. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41256. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41257. * @returns a PickingInfo
  41258. */
  41259. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41260. /**
  41261. * Launch a ray to try to pick a mesh in the scene
  41262. * @param x X position on screen
  41263. * @param y Y position on screen
  41264. * @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
  41265. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41266. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41267. * @returns an array of PickingInfo
  41268. */
  41269. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41270. /**
  41271. * Launch a ray to try to pick a mesh in the scene
  41272. * @param ray Ray to use
  41273. * @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
  41274. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41275. * @returns an array of PickingInfo
  41276. */
  41277. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41278. /**
  41279. * Force the value of meshUnderPointer
  41280. * @param mesh defines the mesh to use
  41281. * @param pointerId optional pointer id when using more than one pointer
  41282. */
  41283. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  41284. /**
  41285. * Gets the mesh under the pointer
  41286. * @returns a Mesh or null if no mesh is under the pointer
  41287. */
  41288. getPointerOverMesh(): Nullable<AbstractMesh>;
  41289. /** @hidden */
  41290. _rebuildGeometries(): void;
  41291. /** @hidden */
  41292. _rebuildTextures(): void;
  41293. private _getByTags;
  41294. /**
  41295. * Get a list of meshes by tags
  41296. * @param tagsQuery defines the tags query to use
  41297. * @param forEach defines a predicate used to filter results
  41298. * @returns an array of Mesh
  41299. */
  41300. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41301. /**
  41302. * Get a list of cameras by tags
  41303. * @param tagsQuery defines the tags query to use
  41304. * @param forEach defines a predicate used to filter results
  41305. * @returns an array of Camera
  41306. */
  41307. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41308. /**
  41309. * Get a list of lights by tags
  41310. * @param tagsQuery defines the tags query to use
  41311. * @param forEach defines a predicate used to filter results
  41312. * @returns an array of Light
  41313. */
  41314. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41315. /**
  41316. * Get a list of materials by tags
  41317. * @param tagsQuery defines the tags query to use
  41318. * @param forEach defines a predicate used to filter results
  41319. * @returns an array of Material
  41320. */
  41321. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41322. /**
  41323. * Get a list of transform nodes by tags
  41324. * @param tagsQuery defines the tags query to use
  41325. * @param forEach defines a predicate used to filter results
  41326. * @returns an array of TransformNode
  41327. */
  41328. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  41329. /**
  41330. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41331. * This allowed control for front to back rendering or reversly depending of the special needs.
  41332. *
  41333. * @param renderingGroupId The rendering group id corresponding to its index
  41334. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41335. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41336. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41337. */
  41338. 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;
  41339. /**
  41340. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41341. *
  41342. * @param renderingGroupId The rendering group id corresponding to its index
  41343. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41344. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41345. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41346. */
  41347. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41348. /**
  41349. * Gets the current auto clear configuration for one rendering group of the rendering
  41350. * manager.
  41351. * @param index the rendering group index to get the information for
  41352. * @returns The auto clear setup for the requested rendering group
  41353. */
  41354. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41355. private _blockMaterialDirtyMechanism;
  41356. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41357. get blockMaterialDirtyMechanism(): boolean;
  41358. set blockMaterialDirtyMechanism(value: boolean);
  41359. /**
  41360. * Will flag all materials as dirty to trigger new shader compilation
  41361. * @param flag defines the flag used to specify which material part must be marked as dirty
  41362. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41363. */
  41364. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41365. /** @hidden */
  41366. _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;
  41367. /** @hidden */
  41368. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41369. /** @hidden */
  41370. _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;
  41371. /** @hidden */
  41372. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41373. /** @hidden */
  41374. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41375. /** @hidden */
  41376. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41377. }
  41378. }
  41379. declare module BABYLON {
  41380. /**
  41381. * Set of assets to keep when moving a scene into an asset container.
  41382. */
  41383. export class KeepAssets extends AbstractScene {
  41384. }
  41385. /**
  41386. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41387. */
  41388. export class InstantiatedEntries {
  41389. /**
  41390. * List of new root nodes (eg. nodes with no parent)
  41391. */
  41392. rootNodes: TransformNode[];
  41393. /**
  41394. * List of new skeletons
  41395. */
  41396. skeletons: Skeleton[];
  41397. /**
  41398. * List of new animation groups
  41399. */
  41400. animationGroups: AnimationGroup[];
  41401. }
  41402. /**
  41403. * Container with a set of assets that can be added or removed from a scene.
  41404. */
  41405. export class AssetContainer extends AbstractScene {
  41406. private _wasAddedToScene;
  41407. /**
  41408. * The scene the AssetContainer belongs to.
  41409. */
  41410. scene: Scene;
  41411. /**
  41412. * Instantiates an AssetContainer.
  41413. * @param scene The scene the AssetContainer belongs to.
  41414. */
  41415. constructor(scene: Scene);
  41416. /**
  41417. * Instantiate or clone all meshes and add the new ones to the scene.
  41418. * Skeletons and animation groups will all be cloned
  41419. * @param nameFunction defines an optional function used to get new names for clones
  41420. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41421. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41422. */
  41423. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41424. /**
  41425. * Adds all the assets from the container to the scene.
  41426. */
  41427. addAllToScene(): void;
  41428. /**
  41429. * Removes all the assets in the container from the scene
  41430. */
  41431. removeAllFromScene(): void;
  41432. /**
  41433. * Disposes all the assets in the container
  41434. */
  41435. dispose(): void;
  41436. private _moveAssets;
  41437. /**
  41438. * Removes all the assets contained in the scene and adds them to the container.
  41439. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41440. */
  41441. moveAllFromScene(keepAssets?: KeepAssets): void;
  41442. /**
  41443. * 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.
  41444. * @returns the root mesh
  41445. */
  41446. createRootMesh(): Mesh;
  41447. /**
  41448. * Merge animations (direct and animation groups) from this asset container into a scene
  41449. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41450. * @param animatables set of animatables to retarget to a node from the scene
  41451. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41452. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41453. */
  41454. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41455. }
  41456. }
  41457. declare module BABYLON {
  41458. /**
  41459. * Defines how the parser contract is defined.
  41460. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41461. */
  41462. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41463. /**
  41464. * Defines how the individual parser contract is defined.
  41465. * These parser can parse an individual asset
  41466. */
  41467. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41468. /**
  41469. * Base class of the scene acting as a container for the different elements composing a scene.
  41470. * This class is dynamically extended by the different components of the scene increasing
  41471. * flexibility and reducing coupling
  41472. */
  41473. export abstract class AbstractScene {
  41474. /**
  41475. * Stores the list of available parsers in the application.
  41476. */
  41477. private static _BabylonFileParsers;
  41478. /**
  41479. * Stores the list of available individual parsers in the application.
  41480. */
  41481. private static _IndividualBabylonFileParsers;
  41482. /**
  41483. * Adds a parser in the list of available ones
  41484. * @param name Defines the name of the parser
  41485. * @param parser Defines the parser to add
  41486. */
  41487. static AddParser(name: string, parser: BabylonFileParser): void;
  41488. /**
  41489. * Gets a general parser from the list of avaialble ones
  41490. * @param name Defines the name of the parser
  41491. * @returns the requested parser or null
  41492. */
  41493. static GetParser(name: string): Nullable<BabylonFileParser>;
  41494. /**
  41495. * Adds n individual parser in the list of available ones
  41496. * @param name Defines the name of the parser
  41497. * @param parser Defines the parser to add
  41498. */
  41499. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41500. /**
  41501. * Gets an individual parser from the list of avaialble ones
  41502. * @param name Defines the name of the parser
  41503. * @returns the requested parser or null
  41504. */
  41505. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41506. /**
  41507. * Parser json data and populate both a scene and its associated container object
  41508. * @param jsonData Defines the data to parse
  41509. * @param scene Defines the scene to parse the data for
  41510. * @param container Defines the container attached to the parsing sequence
  41511. * @param rootUrl Defines the root url of the data
  41512. */
  41513. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41514. /**
  41515. * Gets the list of root nodes (ie. nodes with no parent)
  41516. */
  41517. rootNodes: Node[];
  41518. /** All of the cameras added to this scene
  41519. * @see https://doc.babylonjs.com/babylon101/cameras
  41520. */
  41521. cameras: Camera[];
  41522. /**
  41523. * All of the lights added to this scene
  41524. * @see https://doc.babylonjs.com/babylon101/lights
  41525. */
  41526. lights: Light[];
  41527. /**
  41528. * All of the (abstract) meshes added to this scene
  41529. */
  41530. meshes: AbstractMesh[];
  41531. /**
  41532. * The list of skeletons added to the scene
  41533. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41534. */
  41535. skeletons: Skeleton[];
  41536. /**
  41537. * All of the particle systems added to this scene
  41538. * @see https://doc.babylonjs.com/babylon101/particles
  41539. */
  41540. particleSystems: IParticleSystem[];
  41541. /**
  41542. * Gets a list of Animations associated with the scene
  41543. */
  41544. animations: Animation[];
  41545. /**
  41546. * All of the animation groups added to this scene
  41547. * @see https://doc.babylonjs.com/how_to/group
  41548. */
  41549. animationGroups: AnimationGroup[];
  41550. /**
  41551. * All of the multi-materials added to this scene
  41552. * @see https://doc.babylonjs.com/how_to/multi_materials
  41553. */
  41554. multiMaterials: MultiMaterial[];
  41555. /**
  41556. * All of the materials added to this scene
  41557. * In the context of a Scene, it is not supposed to be modified manually.
  41558. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41559. * Note also that the order of the Material within the array is not significant and might change.
  41560. * @see https://doc.babylonjs.com/babylon101/materials
  41561. */
  41562. materials: Material[];
  41563. /**
  41564. * The list of morph target managers added to the scene
  41565. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41566. */
  41567. morphTargetManagers: MorphTargetManager[];
  41568. /**
  41569. * The list of geometries used in the scene.
  41570. */
  41571. geometries: Geometry[];
  41572. /**
  41573. * All of the tranform nodes added to this scene
  41574. * In the context of a Scene, it is not supposed to be modified manually.
  41575. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41576. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41577. * @see https://doc.babylonjs.com/how_to/transformnode
  41578. */
  41579. transformNodes: TransformNode[];
  41580. /**
  41581. * ActionManagers available on the scene.
  41582. */
  41583. actionManagers: AbstractActionManager[];
  41584. /**
  41585. * Textures to keep.
  41586. */
  41587. textures: BaseTexture[];
  41588. /** @hidden */
  41589. protected _environmentTexture: Nullable<BaseTexture>;
  41590. /**
  41591. * Texture used in all pbr material as the reflection texture.
  41592. * As in the majority of the scene they are the same (exception for multi room and so on),
  41593. * this is easier to reference from here than from all the materials.
  41594. */
  41595. get environmentTexture(): Nullable<BaseTexture>;
  41596. set environmentTexture(value: Nullable<BaseTexture>);
  41597. /**
  41598. * The list of postprocesses added to the scene
  41599. */
  41600. postProcesses: PostProcess[];
  41601. /**
  41602. * @returns all meshes, lights, cameras, transformNodes and bones
  41603. */
  41604. getNodes(): Array<Node>;
  41605. }
  41606. }
  41607. declare module BABYLON {
  41608. /**
  41609. * Interface used to define options for Sound class
  41610. */
  41611. export interface ISoundOptions {
  41612. /**
  41613. * Does the sound autoplay once loaded.
  41614. */
  41615. autoplay?: boolean;
  41616. /**
  41617. * Does the sound loop after it finishes playing once.
  41618. */
  41619. loop?: boolean;
  41620. /**
  41621. * Sound's volume
  41622. */
  41623. volume?: number;
  41624. /**
  41625. * Is it a spatial sound?
  41626. */
  41627. spatialSound?: boolean;
  41628. /**
  41629. * Maximum distance to hear that sound
  41630. */
  41631. maxDistance?: number;
  41632. /**
  41633. * Uses user defined attenuation function
  41634. */
  41635. useCustomAttenuation?: boolean;
  41636. /**
  41637. * Define the roll off factor of spatial sounds.
  41638. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41639. */
  41640. rolloffFactor?: number;
  41641. /**
  41642. * Define the reference distance the sound should be heard perfectly.
  41643. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41644. */
  41645. refDistance?: number;
  41646. /**
  41647. * Define the distance attenuation model the sound will follow.
  41648. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41649. */
  41650. distanceModel?: string;
  41651. /**
  41652. * Defines the playback speed (1 by default)
  41653. */
  41654. playbackRate?: number;
  41655. /**
  41656. * Defines if the sound is from a streaming source
  41657. */
  41658. streaming?: boolean;
  41659. /**
  41660. * Defines an optional length (in seconds) inside the sound file
  41661. */
  41662. length?: number;
  41663. /**
  41664. * Defines an optional offset (in seconds) inside the sound file
  41665. */
  41666. offset?: number;
  41667. /**
  41668. * If true, URLs will not be required to state the audio file codec to use.
  41669. */
  41670. skipCodecCheck?: boolean;
  41671. }
  41672. /**
  41673. * Defines a sound that can be played in the application.
  41674. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41675. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41676. */
  41677. export class Sound {
  41678. /**
  41679. * The name of the sound in the scene.
  41680. */
  41681. name: string;
  41682. /**
  41683. * Does the sound autoplay once loaded.
  41684. */
  41685. autoplay: boolean;
  41686. /**
  41687. * Does the sound loop after it finishes playing once.
  41688. */
  41689. loop: boolean;
  41690. /**
  41691. * Does the sound use a custom attenuation curve to simulate the falloff
  41692. * happening when the source gets further away from the camera.
  41693. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41694. */
  41695. useCustomAttenuation: boolean;
  41696. /**
  41697. * The sound track id this sound belongs to.
  41698. */
  41699. soundTrackId: number;
  41700. /**
  41701. * Is this sound currently played.
  41702. */
  41703. isPlaying: boolean;
  41704. /**
  41705. * Is this sound currently paused.
  41706. */
  41707. isPaused: boolean;
  41708. /**
  41709. * Does this sound enables spatial sound.
  41710. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41711. */
  41712. spatialSound: boolean;
  41713. /**
  41714. * Define the reference distance the sound should be heard perfectly.
  41715. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41716. */
  41717. refDistance: number;
  41718. /**
  41719. * Define the roll off factor of spatial sounds.
  41720. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41721. */
  41722. rolloffFactor: number;
  41723. /**
  41724. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41725. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41726. */
  41727. maxDistance: number;
  41728. /**
  41729. * Define the distance attenuation model the sound will follow.
  41730. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41731. */
  41732. distanceModel: string;
  41733. /**
  41734. * @hidden
  41735. * Back Compat
  41736. **/
  41737. onended: () => any;
  41738. /**
  41739. * Gets or sets an object used to store user defined information for the sound.
  41740. */
  41741. metadata: any;
  41742. /**
  41743. * Observable event when the current playing sound finishes.
  41744. */
  41745. onEndedObservable: Observable<Sound>;
  41746. private _panningModel;
  41747. private _playbackRate;
  41748. private _streaming;
  41749. private _startTime;
  41750. private _startOffset;
  41751. private _position;
  41752. /** @hidden */
  41753. _positionInEmitterSpace: boolean;
  41754. private _localDirection;
  41755. private _volume;
  41756. private _isReadyToPlay;
  41757. private _isDirectional;
  41758. private _readyToPlayCallback;
  41759. private _audioBuffer;
  41760. private _soundSource;
  41761. private _streamingSource;
  41762. private _soundPanner;
  41763. private _soundGain;
  41764. private _inputAudioNode;
  41765. private _outputAudioNode;
  41766. private _coneInnerAngle;
  41767. private _coneOuterAngle;
  41768. private _coneOuterGain;
  41769. private _scene;
  41770. private _connectedTransformNode;
  41771. private _customAttenuationFunction;
  41772. private _registerFunc;
  41773. private _isOutputConnected;
  41774. private _htmlAudioElement;
  41775. private _urlType;
  41776. private _length?;
  41777. private _offset?;
  41778. /** @hidden */
  41779. static _SceneComponentInitialization: (scene: Scene) => void;
  41780. /**
  41781. * Create a sound and attach it to a scene
  41782. * @param name Name of your sound
  41783. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41784. * @param scene defines the scene the sound belongs to
  41785. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41786. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41787. */
  41788. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41789. /**
  41790. * Release the sound and its associated resources
  41791. */
  41792. dispose(): void;
  41793. /**
  41794. * Gets if the sounds is ready to be played or not.
  41795. * @returns true if ready, otherwise false
  41796. */
  41797. isReady(): boolean;
  41798. private _soundLoaded;
  41799. /**
  41800. * Sets the data of the sound from an audiobuffer
  41801. * @param audioBuffer The audioBuffer containing the data
  41802. */
  41803. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41804. /**
  41805. * Updates the current sounds options such as maxdistance, loop...
  41806. * @param options A JSON object containing values named as the object properties
  41807. */
  41808. updateOptions(options: ISoundOptions): void;
  41809. private _createSpatialParameters;
  41810. private _updateSpatialParameters;
  41811. /**
  41812. * Switch the panning model to HRTF:
  41813. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41814. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41815. */
  41816. switchPanningModelToHRTF(): void;
  41817. /**
  41818. * Switch the panning model to Equal Power:
  41819. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41820. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41821. */
  41822. switchPanningModelToEqualPower(): void;
  41823. private _switchPanningModel;
  41824. /**
  41825. * Connect this sound to a sound track audio node like gain...
  41826. * @param soundTrackAudioNode the sound track audio node to connect to
  41827. */
  41828. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41829. /**
  41830. * Transform this sound into a directional source
  41831. * @param coneInnerAngle Size of the inner cone in degree
  41832. * @param coneOuterAngle Size of the outer cone in degree
  41833. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41834. */
  41835. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41836. /**
  41837. * Gets or sets the inner angle for the directional cone.
  41838. */
  41839. get directionalConeInnerAngle(): number;
  41840. /**
  41841. * Gets or sets the inner angle for the directional cone.
  41842. */
  41843. set directionalConeInnerAngle(value: number);
  41844. /**
  41845. * Gets or sets the outer angle for the directional cone.
  41846. */
  41847. get directionalConeOuterAngle(): number;
  41848. /**
  41849. * Gets or sets the outer angle for the directional cone.
  41850. */
  41851. set directionalConeOuterAngle(value: number);
  41852. /**
  41853. * Sets the position of the emitter if spatial sound is enabled
  41854. * @param newPosition Defines the new posisiton
  41855. */
  41856. setPosition(newPosition: Vector3): void;
  41857. /**
  41858. * Sets the local direction of the emitter if spatial sound is enabled
  41859. * @param newLocalDirection Defines the new local direction
  41860. */
  41861. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41862. private _updateDirection;
  41863. /** @hidden */
  41864. updateDistanceFromListener(): void;
  41865. /**
  41866. * Sets a new custom attenuation function for the sound.
  41867. * @param callback Defines the function used for the attenuation
  41868. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41869. */
  41870. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41871. /**
  41872. * Play the sound
  41873. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41874. * @param offset (optional) Start the sound at a specific time in seconds
  41875. * @param length (optional) Sound duration (in seconds)
  41876. */
  41877. play(time?: number, offset?: number, length?: number): void;
  41878. private _onended;
  41879. /**
  41880. * Stop the sound
  41881. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41882. */
  41883. stop(time?: number): void;
  41884. /**
  41885. * Put the sound in pause
  41886. */
  41887. pause(): void;
  41888. /**
  41889. * Sets a dedicated volume for this sounds
  41890. * @param newVolume Define the new volume of the sound
  41891. * @param time Define time for gradual change to new volume
  41892. */
  41893. setVolume(newVolume: number, time?: number): void;
  41894. /**
  41895. * Set the sound play back rate
  41896. * @param newPlaybackRate Define the playback rate the sound should be played at
  41897. */
  41898. setPlaybackRate(newPlaybackRate: number): void;
  41899. /**
  41900. * Gets the volume of the sound.
  41901. * @returns the volume of the sound
  41902. */
  41903. getVolume(): number;
  41904. /**
  41905. * Attach the sound to a dedicated mesh
  41906. * @param transformNode The transform node to connect the sound with
  41907. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41908. */
  41909. attachToMesh(transformNode: TransformNode): void;
  41910. /**
  41911. * Detach the sound from the previously attached mesh
  41912. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41913. */
  41914. detachFromMesh(): void;
  41915. private _onRegisterAfterWorldMatrixUpdate;
  41916. /**
  41917. * Clone the current sound in the scene.
  41918. * @returns the new sound clone
  41919. */
  41920. clone(): Nullable<Sound>;
  41921. /**
  41922. * Gets the current underlying audio buffer containing the data
  41923. * @returns the audio buffer
  41924. */
  41925. getAudioBuffer(): Nullable<AudioBuffer>;
  41926. /**
  41927. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41928. * @returns the source node
  41929. */
  41930. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41931. /**
  41932. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41933. * @returns the gain node
  41934. */
  41935. getSoundGain(): Nullable<GainNode>;
  41936. /**
  41937. * Serializes the Sound in a JSON representation
  41938. * @returns the JSON representation of the sound
  41939. */
  41940. serialize(): any;
  41941. /**
  41942. * Parse a JSON representation of a sound to innstantiate in a given scene
  41943. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41944. * @param scene Define the scene the new parsed sound should be created in
  41945. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41946. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41947. * @returns the newly parsed sound
  41948. */
  41949. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41950. }
  41951. }
  41952. declare module BABYLON {
  41953. /**
  41954. * This defines an action helpful to play a defined sound on a triggered action.
  41955. */
  41956. export class PlaySoundAction extends Action {
  41957. private _sound;
  41958. /**
  41959. * Instantiate the action
  41960. * @param triggerOptions defines the trigger options
  41961. * @param sound defines the sound to play
  41962. * @param condition defines the trigger related conditions
  41963. */
  41964. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41965. /** @hidden */
  41966. _prepare(): void;
  41967. /**
  41968. * Execute the action and play the sound.
  41969. */
  41970. execute(): void;
  41971. /**
  41972. * Serializes the actions and its related information.
  41973. * @param parent defines the object to serialize in
  41974. * @returns the serialized object
  41975. */
  41976. serialize(parent: any): any;
  41977. }
  41978. /**
  41979. * This defines an action helpful to stop a defined sound on a triggered action.
  41980. */
  41981. export class StopSoundAction extends Action {
  41982. private _sound;
  41983. /**
  41984. * Instantiate the action
  41985. * @param triggerOptions defines the trigger options
  41986. * @param sound defines the sound to stop
  41987. * @param condition defines the trigger related conditions
  41988. */
  41989. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41990. /** @hidden */
  41991. _prepare(): void;
  41992. /**
  41993. * Execute the action and stop the sound.
  41994. */
  41995. execute(): void;
  41996. /**
  41997. * Serializes the actions and its related information.
  41998. * @param parent defines the object to serialize in
  41999. * @returns the serialized object
  42000. */
  42001. serialize(parent: any): any;
  42002. }
  42003. }
  42004. declare module BABYLON {
  42005. /**
  42006. * This defines an action responsible to change the value of a property
  42007. * by interpolating between its current value and the newly set one once triggered.
  42008. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  42009. */
  42010. export class InterpolateValueAction extends Action {
  42011. /**
  42012. * Defines the path of the property where the value should be interpolated
  42013. */
  42014. propertyPath: string;
  42015. /**
  42016. * Defines the target value at the end of the interpolation.
  42017. */
  42018. value: any;
  42019. /**
  42020. * Defines the time it will take for the property to interpolate to the value.
  42021. */
  42022. duration: number;
  42023. /**
  42024. * Defines if the other scene animations should be stopped when the action has been triggered
  42025. */
  42026. stopOtherAnimations?: boolean;
  42027. /**
  42028. * Defines a callback raised once the interpolation animation has been done.
  42029. */
  42030. onInterpolationDone?: () => void;
  42031. /**
  42032. * Observable triggered once the interpolation animation has been done.
  42033. */
  42034. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42035. private _target;
  42036. private _effectiveTarget;
  42037. private _property;
  42038. /**
  42039. * Instantiate the action
  42040. * @param triggerOptions defines the trigger options
  42041. * @param target defines the object containing the value to interpolate
  42042. * @param propertyPath defines the path to the property in the target object
  42043. * @param value defines the target value at the end of the interpolation
  42044. * @param duration deines the time it will take for the property to interpolate to the value.
  42045. * @param condition defines the trigger related conditions
  42046. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42047. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42048. */
  42049. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42050. /** @hidden */
  42051. _prepare(): void;
  42052. /**
  42053. * Execute the action starts the value interpolation.
  42054. */
  42055. execute(): void;
  42056. /**
  42057. * Serializes the actions and its related information.
  42058. * @param parent defines the object to serialize in
  42059. * @returns the serialized object
  42060. */
  42061. serialize(parent: any): any;
  42062. }
  42063. }
  42064. declare module BABYLON {
  42065. /**
  42066. * Options allowed during the creation of a sound track.
  42067. */
  42068. export interface ISoundTrackOptions {
  42069. /**
  42070. * The volume the sound track should take during creation
  42071. */
  42072. volume?: number;
  42073. /**
  42074. * Define if the sound track is the main sound track of the scene
  42075. */
  42076. mainTrack?: boolean;
  42077. }
  42078. /**
  42079. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42080. * It will be also used in a future release to apply effects on a specific track.
  42081. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42082. */
  42083. export class SoundTrack {
  42084. /**
  42085. * The unique identifier of the sound track in the scene.
  42086. */
  42087. id: number;
  42088. /**
  42089. * The list of sounds included in the sound track.
  42090. */
  42091. soundCollection: Array<Sound>;
  42092. private _outputAudioNode;
  42093. private _scene;
  42094. private _connectedAnalyser;
  42095. private _options;
  42096. private _isInitialized;
  42097. /**
  42098. * Creates a new sound track.
  42099. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42100. * @param scene Define the scene the sound track belongs to
  42101. * @param options
  42102. */
  42103. constructor(scene: Scene, options?: ISoundTrackOptions);
  42104. private _initializeSoundTrackAudioGraph;
  42105. /**
  42106. * Release the sound track and its associated resources
  42107. */
  42108. dispose(): void;
  42109. /**
  42110. * Adds a sound to this sound track
  42111. * @param sound define the cound to add
  42112. * @ignoreNaming
  42113. */
  42114. AddSound(sound: Sound): void;
  42115. /**
  42116. * Removes a sound to this sound track
  42117. * @param sound define the cound to remove
  42118. * @ignoreNaming
  42119. */
  42120. RemoveSound(sound: Sound): void;
  42121. /**
  42122. * Set a global volume for the full sound track.
  42123. * @param newVolume Define the new volume of the sound track
  42124. */
  42125. setVolume(newVolume: number): void;
  42126. /**
  42127. * Switch the panning model to HRTF:
  42128. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42129. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42130. */
  42131. switchPanningModelToHRTF(): void;
  42132. /**
  42133. * Switch the panning model to Equal Power:
  42134. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42135. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42136. */
  42137. switchPanningModelToEqualPower(): void;
  42138. /**
  42139. * Connect the sound track to an audio analyser allowing some amazing
  42140. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42141. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42142. * @param analyser The analyser to connect to the engine
  42143. */
  42144. connectToAnalyser(analyser: Analyser): void;
  42145. }
  42146. }
  42147. declare module BABYLON {
  42148. interface AbstractScene {
  42149. /**
  42150. * The list of sounds used in the scene.
  42151. */
  42152. sounds: Nullable<Array<Sound>>;
  42153. }
  42154. interface Scene {
  42155. /**
  42156. * @hidden
  42157. * Backing field
  42158. */
  42159. _mainSoundTrack: SoundTrack;
  42160. /**
  42161. * The main sound track played by the scene.
  42162. * It cotains your primary collection of sounds.
  42163. */
  42164. mainSoundTrack: SoundTrack;
  42165. /**
  42166. * The list of sound tracks added to the scene
  42167. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42168. */
  42169. soundTracks: Nullable<Array<SoundTrack>>;
  42170. /**
  42171. * Gets a sound using a given name
  42172. * @param name defines the name to search for
  42173. * @return the found sound or null if not found at all.
  42174. */
  42175. getSoundByName(name: string): Nullable<Sound>;
  42176. /**
  42177. * Gets or sets if audio support is enabled
  42178. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42179. */
  42180. audioEnabled: boolean;
  42181. /**
  42182. * Gets or sets if audio will be output to headphones
  42183. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42184. */
  42185. headphone: boolean;
  42186. /**
  42187. * Gets or sets custom audio listener position provider
  42188. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42189. */
  42190. audioListenerPositionProvider: Nullable<() => Vector3>;
  42191. /**
  42192. * Gets or sets a refresh rate when using 3D audio positioning
  42193. */
  42194. audioPositioningRefreshRate: number;
  42195. }
  42196. /**
  42197. * Defines the sound scene component responsible to manage any sounds
  42198. * in a given scene.
  42199. */
  42200. export class AudioSceneComponent implements ISceneSerializableComponent {
  42201. private static _CameraDirectionLH;
  42202. private static _CameraDirectionRH;
  42203. /**
  42204. * The component name helpfull to identify the component in the list of scene components.
  42205. */
  42206. readonly name: string;
  42207. /**
  42208. * The scene the component belongs to.
  42209. */
  42210. scene: Scene;
  42211. private _audioEnabled;
  42212. /**
  42213. * Gets whether audio is enabled or not.
  42214. * Please use related enable/disable method to switch state.
  42215. */
  42216. get audioEnabled(): boolean;
  42217. private _headphone;
  42218. /**
  42219. * Gets whether audio is outputing to headphone or not.
  42220. * Please use the according Switch methods to change output.
  42221. */
  42222. get headphone(): boolean;
  42223. /**
  42224. * Gets or sets a refresh rate when using 3D audio positioning
  42225. */
  42226. audioPositioningRefreshRate: number;
  42227. private _audioListenerPositionProvider;
  42228. /**
  42229. * Gets the current audio listener position provider
  42230. */
  42231. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42232. /**
  42233. * Sets a custom listener position for all sounds in the scene
  42234. * By default, this is the position of the first active camera
  42235. */
  42236. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42237. /**
  42238. * Creates a new instance of the component for the given scene
  42239. * @param scene Defines the scene to register the component in
  42240. */
  42241. constructor(scene: Scene);
  42242. /**
  42243. * Registers the component in a given scene
  42244. */
  42245. register(): void;
  42246. /**
  42247. * Rebuilds the elements related to this component in case of
  42248. * context lost for instance.
  42249. */
  42250. rebuild(): void;
  42251. /**
  42252. * Serializes the component data to the specified json object
  42253. * @param serializationObject The object to serialize to
  42254. */
  42255. serialize(serializationObject: any): void;
  42256. /**
  42257. * Adds all the elements from the container to the scene
  42258. * @param container the container holding the elements
  42259. */
  42260. addFromContainer(container: AbstractScene): void;
  42261. /**
  42262. * Removes all the elements in the container from the scene
  42263. * @param container contains the elements to remove
  42264. * @param dispose if the removed element should be disposed (default: false)
  42265. */
  42266. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42267. /**
  42268. * Disposes the component and the associated ressources.
  42269. */
  42270. dispose(): void;
  42271. /**
  42272. * Disables audio in the associated scene.
  42273. */
  42274. disableAudio(): void;
  42275. /**
  42276. * Enables audio in the associated scene.
  42277. */
  42278. enableAudio(): void;
  42279. /**
  42280. * Switch audio to headphone output.
  42281. */
  42282. switchAudioModeForHeadphones(): void;
  42283. /**
  42284. * Switch audio to normal speakers.
  42285. */
  42286. switchAudioModeForNormalSpeakers(): void;
  42287. private _cachedCameraDirection;
  42288. private _cachedCameraPosition;
  42289. private _lastCheck;
  42290. private _afterRender;
  42291. }
  42292. }
  42293. declare module BABYLON {
  42294. /**
  42295. * Wraps one or more Sound objects and selects one with random weight for playback.
  42296. */
  42297. export class WeightedSound {
  42298. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42299. loop: boolean;
  42300. private _coneInnerAngle;
  42301. private _coneOuterAngle;
  42302. private _volume;
  42303. /** A Sound is currently playing. */
  42304. isPlaying: boolean;
  42305. /** A Sound is currently paused. */
  42306. isPaused: boolean;
  42307. private _sounds;
  42308. private _weights;
  42309. private _currentIndex?;
  42310. /**
  42311. * Creates a new WeightedSound from the list of sounds given.
  42312. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42313. * @param sounds Array of Sounds that will be selected from.
  42314. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42315. */
  42316. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42317. /**
  42318. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42319. */
  42320. get directionalConeInnerAngle(): number;
  42321. /**
  42322. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42323. */
  42324. set directionalConeInnerAngle(value: number);
  42325. /**
  42326. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42327. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42328. */
  42329. get directionalConeOuterAngle(): number;
  42330. /**
  42331. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42332. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42333. */
  42334. set directionalConeOuterAngle(value: number);
  42335. /**
  42336. * Playback volume.
  42337. */
  42338. get volume(): number;
  42339. /**
  42340. * Playback volume.
  42341. */
  42342. set volume(value: number);
  42343. private _onended;
  42344. /**
  42345. * Suspend playback
  42346. */
  42347. pause(): void;
  42348. /**
  42349. * Stop playback
  42350. */
  42351. stop(): void;
  42352. /**
  42353. * Start playback.
  42354. * @param startOffset Position the clip head at a specific time in seconds.
  42355. */
  42356. play(startOffset?: number): void;
  42357. }
  42358. }
  42359. declare module BABYLON {
  42360. /**
  42361. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42362. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42363. */
  42364. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42365. /**
  42366. * Gets the name of the behavior.
  42367. */
  42368. get name(): string;
  42369. /**
  42370. * The easing function used by animations
  42371. */
  42372. static EasingFunction: BackEase;
  42373. /**
  42374. * The easing mode used by animations
  42375. */
  42376. static EasingMode: number;
  42377. /**
  42378. * The duration of the animation, in milliseconds
  42379. */
  42380. transitionDuration: number;
  42381. /**
  42382. * Length of the distance animated by the transition when lower radius is reached
  42383. */
  42384. lowerRadiusTransitionRange: number;
  42385. /**
  42386. * Length of the distance animated by the transition when upper radius is reached
  42387. */
  42388. upperRadiusTransitionRange: number;
  42389. private _autoTransitionRange;
  42390. /**
  42391. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42392. */
  42393. get autoTransitionRange(): boolean;
  42394. /**
  42395. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42396. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42397. */
  42398. set autoTransitionRange(value: boolean);
  42399. private _attachedCamera;
  42400. private _onAfterCheckInputsObserver;
  42401. private _onMeshTargetChangedObserver;
  42402. /**
  42403. * Initializes the behavior.
  42404. */
  42405. init(): void;
  42406. /**
  42407. * Attaches the behavior to its arc rotate camera.
  42408. * @param camera Defines the camera to attach the behavior to
  42409. */
  42410. attach(camera: ArcRotateCamera): void;
  42411. /**
  42412. * Detaches the behavior from its current arc rotate camera.
  42413. */
  42414. detach(): void;
  42415. private _radiusIsAnimating;
  42416. private _radiusBounceTransition;
  42417. private _animatables;
  42418. private _cachedWheelPrecision;
  42419. /**
  42420. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42421. * @param radiusLimit The limit to check against.
  42422. * @return Bool to indicate if at limit.
  42423. */
  42424. private _isRadiusAtLimit;
  42425. /**
  42426. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42427. * @param radiusDelta The delta by which to animate to. Can be negative.
  42428. */
  42429. private _applyBoundRadiusAnimation;
  42430. /**
  42431. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42432. */
  42433. protected _clearAnimationLocks(): void;
  42434. /**
  42435. * Stops and removes all animations that have been applied to the camera
  42436. */
  42437. stopAllAnimations(): void;
  42438. }
  42439. }
  42440. declare module BABYLON {
  42441. /**
  42442. * 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.
  42443. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42444. */
  42445. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42446. /**
  42447. * Gets the name of the behavior.
  42448. */
  42449. get name(): string;
  42450. private _mode;
  42451. private _radiusScale;
  42452. private _positionScale;
  42453. private _defaultElevation;
  42454. private _elevationReturnTime;
  42455. private _elevationReturnWaitTime;
  42456. private _zoomStopsAnimation;
  42457. private _framingTime;
  42458. /**
  42459. * The easing function used by animations
  42460. */
  42461. static EasingFunction: ExponentialEase;
  42462. /**
  42463. * The easing mode used by animations
  42464. */
  42465. static EasingMode: number;
  42466. /**
  42467. * Sets the current mode used by the behavior
  42468. */
  42469. set mode(mode: number);
  42470. /**
  42471. * Gets current mode used by the behavior.
  42472. */
  42473. get mode(): number;
  42474. /**
  42475. * Sets the scale applied to the radius (1 by default)
  42476. */
  42477. set radiusScale(radius: number);
  42478. /**
  42479. * Gets the scale applied to the radius
  42480. */
  42481. get radiusScale(): number;
  42482. /**
  42483. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42484. */
  42485. set positionScale(scale: number);
  42486. /**
  42487. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42488. */
  42489. get positionScale(): number;
  42490. /**
  42491. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42492. * behaviour is triggered, in radians.
  42493. */
  42494. set defaultElevation(elevation: number);
  42495. /**
  42496. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42497. * behaviour is triggered, in radians.
  42498. */
  42499. get defaultElevation(): number;
  42500. /**
  42501. * Sets the time (in milliseconds) taken to return to the default beta position.
  42502. * Negative value indicates camera should not return to default.
  42503. */
  42504. set elevationReturnTime(speed: number);
  42505. /**
  42506. * Gets the time (in milliseconds) taken to return to the default beta position.
  42507. * Negative value indicates camera should not return to default.
  42508. */
  42509. get elevationReturnTime(): number;
  42510. /**
  42511. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42512. */
  42513. set elevationReturnWaitTime(time: number);
  42514. /**
  42515. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42516. */
  42517. get elevationReturnWaitTime(): number;
  42518. /**
  42519. * Sets the flag that indicates if user zooming should stop animation.
  42520. */
  42521. set zoomStopsAnimation(flag: boolean);
  42522. /**
  42523. * Gets the flag that indicates if user zooming should stop animation.
  42524. */
  42525. get zoomStopsAnimation(): boolean;
  42526. /**
  42527. * Sets the transition time when framing the mesh, in milliseconds
  42528. */
  42529. set framingTime(time: number);
  42530. /**
  42531. * Gets the transition time when framing the mesh, in milliseconds
  42532. */
  42533. get framingTime(): number;
  42534. /**
  42535. * Define if the behavior should automatically change the configured
  42536. * camera limits and sensibilities.
  42537. */
  42538. autoCorrectCameraLimitsAndSensibility: boolean;
  42539. private _onPrePointerObservableObserver;
  42540. private _onAfterCheckInputsObserver;
  42541. private _onMeshTargetChangedObserver;
  42542. private _attachedCamera;
  42543. private _isPointerDown;
  42544. private _lastInteractionTime;
  42545. /**
  42546. * Initializes the behavior.
  42547. */
  42548. init(): void;
  42549. /**
  42550. * Attaches the behavior to its arc rotate camera.
  42551. * @param camera Defines the camera to attach the behavior to
  42552. */
  42553. attach(camera: ArcRotateCamera): void;
  42554. /**
  42555. * Detaches the behavior from its current arc rotate camera.
  42556. */
  42557. detach(): void;
  42558. private _animatables;
  42559. private _betaIsAnimating;
  42560. private _betaTransition;
  42561. private _radiusTransition;
  42562. private _vectorTransition;
  42563. /**
  42564. * Targets the given mesh and updates zoom level accordingly.
  42565. * @param mesh The mesh to target.
  42566. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42567. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42568. */
  42569. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42570. /**
  42571. * Targets the given mesh with its children and updates zoom level accordingly.
  42572. * @param mesh The mesh to target.
  42573. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42574. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42575. */
  42576. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42577. /**
  42578. * Targets the given meshes with their children and updates zoom level accordingly.
  42579. * @param meshes The mesh to target.
  42580. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42581. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42582. */
  42583. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42584. /**
  42585. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42586. * @param minimumWorld Determines the smaller position of the bounding box extend
  42587. * @param maximumWorld Determines the bigger position of the bounding box extend
  42588. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42589. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42590. */
  42591. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42592. /**
  42593. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42594. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42595. * frustum width.
  42596. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42597. * to fully enclose the mesh in the viewing frustum.
  42598. */
  42599. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42600. /**
  42601. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42602. * is automatically returned to its default position (expected to be above ground plane).
  42603. */
  42604. private _maintainCameraAboveGround;
  42605. /**
  42606. * Returns the frustum slope based on the canvas ratio and camera FOV
  42607. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42608. */
  42609. private _getFrustumSlope;
  42610. /**
  42611. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42612. */
  42613. private _clearAnimationLocks;
  42614. /**
  42615. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42616. */
  42617. private _applyUserInteraction;
  42618. /**
  42619. * Stops and removes all animations that have been applied to the camera
  42620. */
  42621. stopAllAnimations(): void;
  42622. /**
  42623. * Gets a value indicating if the user is moving the camera
  42624. */
  42625. get isUserIsMoving(): boolean;
  42626. /**
  42627. * The camera can move all the way towards the mesh.
  42628. */
  42629. static IgnoreBoundsSizeMode: number;
  42630. /**
  42631. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42632. */
  42633. static FitFrustumSidesMode: number;
  42634. }
  42635. }
  42636. declare module BABYLON {
  42637. /**
  42638. * Base class for Camera Pointer Inputs.
  42639. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42640. * for example usage.
  42641. */
  42642. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42643. /**
  42644. * Defines the camera the input is attached to.
  42645. */
  42646. abstract camera: Camera;
  42647. /**
  42648. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42649. */
  42650. protected _altKey: boolean;
  42651. protected _ctrlKey: boolean;
  42652. protected _metaKey: boolean;
  42653. protected _shiftKey: boolean;
  42654. /**
  42655. * Which mouse buttons were pressed at time of last mouse event.
  42656. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42657. */
  42658. protected _buttonsPressed: number;
  42659. /**
  42660. * Defines the buttons associated with the input to handle camera move.
  42661. */
  42662. buttons: number[];
  42663. /**
  42664. * Attach the input controls to a specific dom element to get the input from.
  42665. * @param element Defines the element the controls should be listened from
  42666. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42667. */
  42668. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42669. /**
  42670. * Detach the current controls from the specified dom element.
  42671. * @param element Defines the element to stop listening the inputs from
  42672. */
  42673. detachControl(element: Nullable<HTMLElement>): void;
  42674. /**
  42675. * Gets the class name of the current input.
  42676. * @returns the class name
  42677. */
  42678. getClassName(): string;
  42679. /**
  42680. * Get the friendly name associated with the input class.
  42681. * @returns the input friendly name
  42682. */
  42683. getSimpleName(): string;
  42684. /**
  42685. * Called on pointer POINTERDOUBLETAP event.
  42686. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42687. */
  42688. protected onDoubleTap(type: string): void;
  42689. /**
  42690. * Called on pointer POINTERMOVE event if only a single touch is active.
  42691. * Override this method to provide functionality.
  42692. */
  42693. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42694. /**
  42695. * Called on pointer POINTERMOVE event if multiple touches are active.
  42696. * Override this method to provide functionality.
  42697. */
  42698. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42699. /**
  42700. * Called on JS contextmenu event.
  42701. * Override this method to provide functionality.
  42702. */
  42703. protected onContextMenu(evt: PointerEvent): void;
  42704. /**
  42705. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42706. * press.
  42707. * Override this method to provide functionality.
  42708. */
  42709. protected onButtonDown(evt: PointerEvent): void;
  42710. /**
  42711. * Called each time a new POINTERUP event occurs. Ie, for each button
  42712. * release.
  42713. * Override this method to provide functionality.
  42714. */
  42715. protected onButtonUp(evt: PointerEvent): void;
  42716. /**
  42717. * Called when window becomes inactive.
  42718. * Override this method to provide functionality.
  42719. */
  42720. protected onLostFocus(): void;
  42721. private _pointerInput;
  42722. private _observer;
  42723. private _onLostFocus;
  42724. private pointA;
  42725. private pointB;
  42726. }
  42727. }
  42728. declare module BABYLON {
  42729. /**
  42730. * Manage the pointers inputs to control an arc rotate camera.
  42731. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42732. */
  42733. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42734. /**
  42735. * Defines the camera the input is attached to.
  42736. */
  42737. camera: ArcRotateCamera;
  42738. /**
  42739. * Gets the class name of the current input.
  42740. * @returns the class name
  42741. */
  42742. getClassName(): string;
  42743. /**
  42744. * Defines the buttons associated with the input to handle camera move.
  42745. */
  42746. buttons: number[];
  42747. /**
  42748. * Defines the pointer angular sensibility along the X axis or how fast is
  42749. * the camera rotating.
  42750. */
  42751. angularSensibilityX: number;
  42752. /**
  42753. * Defines the pointer angular sensibility along the Y axis or how fast is
  42754. * the camera rotating.
  42755. */
  42756. angularSensibilityY: number;
  42757. /**
  42758. * Defines the pointer pinch precision or how fast is the camera zooming.
  42759. */
  42760. pinchPrecision: number;
  42761. /**
  42762. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42763. * from 0.
  42764. * It defines the percentage of current camera.radius to use as delta when
  42765. * pinch zoom is used.
  42766. */
  42767. pinchDeltaPercentage: number;
  42768. /**
  42769. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42770. * that any object in the plane at the camera's target point will scale
  42771. * perfectly with finger motion.
  42772. * Overrides pinchDeltaPercentage and pinchPrecision.
  42773. */
  42774. useNaturalPinchZoom: boolean;
  42775. /**
  42776. * Defines the pointer panning sensibility or how fast is the camera moving.
  42777. */
  42778. panningSensibility: number;
  42779. /**
  42780. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42781. */
  42782. multiTouchPanning: boolean;
  42783. /**
  42784. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42785. * zoom (pinch) through multitouch.
  42786. */
  42787. multiTouchPanAndZoom: boolean;
  42788. /**
  42789. * Revers pinch action direction.
  42790. */
  42791. pinchInwards: boolean;
  42792. private _isPanClick;
  42793. private _twoFingerActivityCount;
  42794. private _isPinching;
  42795. /**
  42796. * Called on pointer POINTERMOVE event if only a single touch is active.
  42797. */
  42798. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42799. /**
  42800. * Called on pointer POINTERDOUBLETAP event.
  42801. */
  42802. protected onDoubleTap(type: string): void;
  42803. /**
  42804. * Called on pointer POINTERMOVE event if multiple touches are active.
  42805. */
  42806. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42807. /**
  42808. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42809. * press.
  42810. */
  42811. protected onButtonDown(evt: PointerEvent): void;
  42812. /**
  42813. * Called each time a new POINTERUP event occurs. Ie, for each button
  42814. * release.
  42815. */
  42816. protected onButtonUp(evt: PointerEvent): void;
  42817. /**
  42818. * Called when window becomes inactive.
  42819. */
  42820. protected onLostFocus(): void;
  42821. }
  42822. }
  42823. declare module BABYLON {
  42824. /**
  42825. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42826. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42827. */
  42828. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42829. /**
  42830. * Defines the camera the input is attached to.
  42831. */
  42832. camera: ArcRotateCamera;
  42833. /**
  42834. * Defines the list of key codes associated with the up action (increase alpha)
  42835. */
  42836. keysUp: number[];
  42837. /**
  42838. * Defines the list of key codes associated with the down action (decrease alpha)
  42839. */
  42840. keysDown: number[];
  42841. /**
  42842. * Defines the list of key codes associated with the left action (increase beta)
  42843. */
  42844. keysLeft: number[];
  42845. /**
  42846. * Defines the list of key codes associated with the right action (decrease beta)
  42847. */
  42848. keysRight: number[];
  42849. /**
  42850. * Defines the list of key codes associated with the reset action.
  42851. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42852. */
  42853. keysReset: number[];
  42854. /**
  42855. * Defines the panning sensibility of the inputs.
  42856. * (How fast is the camera panning)
  42857. */
  42858. panningSensibility: number;
  42859. /**
  42860. * Defines the zooming sensibility of the inputs.
  42861. * (How fast is the camera zooming)
  42862. */
  42863. zoomingSensibility: number;
  42864. /**
  42865. * Defines whether maintaining the alt key down switch the movement mode from
  42866. * orientation to zoom.
  42867. */
  42868. useAltToZoom: boolean;
  42869. /**
  42870. * Rotation speed of the camera
  42871. */
  42872. angularSpeed: number;
  42873. private _keys;
  42874. private _ctrlPressed;
  42875. private _altPressed;
  42876. private _onCanvasBlurObserver;
  42877. private _onKeyboardObserver;
  42878. private _engine;
  42879. private _scene;
  42880. /**
  42881. * Attach the input controls to a specific dom element to get the input from.
  42882. * @param element Defines the element the controls should be listened from
  42883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42884. */
  42885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42886. /**
  42887. * Detach the current controls from the specified dom element.
  42888. * @param element Defines the element to stop listening the inputs from
  42889. */
  42890. detachControl(element: Nullable<HTMLElement>): void;
  42891. /**
  42892. * Update the current camera state depending on the inputs that have been used this frame.
  42893. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42894. */
  42895. checkInputs(): void;
  42896. /**
  42897. * Gets the class name of the current intput.
  42898. * @returns the class name
  42899. */
  42900. getClassName(): string;
  42901. /**
  42902. * Get the friendly name associated with the input class.
  42903. * @returns the input friendly name
  42904. */
  42905. getSimpleName(): string;
  42906. }
  42907. }
  42908. declare module BABYLON {
  42909. /**
  42910. * Manage the mouse wheel inputs to control an arc rotate camera.
  42911. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42912. */
  42913. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42914. /**
  42915. * Defines the camera the input is attached to.
  42916. */
  42917. camera: ArcRotateCamera;
  42918. /**
  42919. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42920. */
  42921. wheelPrecision: number;
  42922. /**
  42923. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42924. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42925. */
  42926. wheelDeltaPercentage: number;
  42927. private _wheel;
  42928. private _observer;
  42929. private computeDeltaFromMouseWheelLegacyEvent;
  42930. /**
  42931. * Attach the input controls to a specific dom element to get the input from.
  42932. * @param element Defines the element the controls should be listened from
  42933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42934. */
  42935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42936. /**
  42937. * Detach the current controls from the specified dom element.
  42938. * @param element Defines the element to stop listening the inputs from
  42939. */
  42940. detachControl(element: Nullable<HTMLElement>): void;
  42941. /**
  42942. * Gets the class name of the current intput.
  42943. * @returns the class name
  42944. */
  42945. getClassName(): string;
  42946. /**
  42947. * Get the friendly name associated with the input class.
  42948. * @returns the input friendly name
  42949. */
  42950. getSimpleName(): string;
  42951. }
  42952. }
  42953. declare module BABYLON {
  42954. /**
  42955. * Default Inputs manager for the ArcRotateCamera.
  42956. * It groups all the default supported inputs for ease of use.
  42957. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42958. */
  42959. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42960. /**
  42961. * Instantiates a new ArcRotateCameraInputsManager.
  42962. * @param camera Defines the camera the inputs belong to
  42963. */
  42964. constructor(camera: ArcRotateCamera);
  42965. /**
  42966. * Add mouse wheel input support to the input manager.
  42967. * @returns the current input manager
  42968. */
  42969. addMouseWheel(): ArcRotateCameraInputsManager;
  42970. /**
  42971. * Add pointers input support to the input manager.
  42972. * @returns the current input manager
  42973. */
  42974. addPointers(): ArcRotateCameraInputsManager;
  42975. /**
  42976. * Add keyboard input support to the input manager.
  42977. * @returns the current input manager
  42978. */
  42979. addKeyboard(): ArcRotateCameraInputsManager;
  42980. }
  42981. }
  42982. declare module BABYLON {
  42983. /**
  42984. * This represents an orbital type of camera.
  42985. *
  42986. * 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.
  42987. * 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.
  42988. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42989. */
  42990. export class ArcRotateCamera extends TargetCamera {
  42991. /**
  42992. * Defines the rotation angle of the camera along the longitudinal axis.
  42993. */
  42994. alpha: number;
  42995. /**
  42996. * Defines the rotation angle of the camera along the latitudinal axis.
  42997. */
  42998. beta: number;
  42999. /**
  43000. * Defines the radius of the camera from it s target point.
  43001. */
  43002. radius: number;
  43003. protected _target: Vector3;
  43004. protected _targetHost: Nullable<AbstractMesh>;
  43005. /**
  43006. * Defines the target point of the camera.
  43007. * The camera looks towards it form the radius distance.
  43008. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  43009. */
  43010. get target(): Vector3;
  43011. set target(value: Vector3);
  43012. /**
  43013. * Define the current local position of the camera in the scene
  43014. */
  43015. get position(): Vector3;
  43016. set position(newPosition: Vector3);
  43017. protected _upToYMatrix: Matrix;
  43018. protected _YToUpMatrix: Matrix;
  43019. /**
  43020. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43021. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43022. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43023. */
  43024. set upVector(vec: Vector3);
  43025. get upVector(): Vector3;
  43026. /**
  43027. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43028. */
  43029. setMatUp(): void;
  43030. /**
  43031. * Current inertia value on the longitudinal axis.
  43032. * The bigger this number the longer it will take for the camera to stop.
  43033. */
  43034. inertialAlphaOffset: number;
  43035. /**
  43036. * Current inertia value on the latitudinal axis.
  43037. * The bigger this number the longer it will take for the camera to stop.
  43038. */
  43039. inertialBetaOffset: number;
  43040. /**
  43041. * Current inertia value on the radius axis.
  43042. * The bigger this number the longer it will take for the camera to stop.
  43043. */
  43044. inertialRadiusOffset: number;
  43045. /**
  43046. * Minimum allowed angle on the longitudinal axis.
  43047. * This can help limiting how the Camera is able to move in the scene.
  43048. */
  43049. lowerAlphaLimit: Nullable<number>;
  43050. /**
  43051. * Maximum allowed angle on the longitudinal axis.
  43052. * This can help limiting how the Camera is able to move in the scene.
  43053. */
  43054. upperAlphaLimit: Nullable<number>;
  43055. /**
  43056. * Minimum allowed angle on the latitudinal axis.
  43057. * This can help limiting how the Camera is able to move in the scene.
  43058. */
  43059. lowerBetaLimit: number;
  43060. /**
  43061. * Maximum allowed angle on the latitudinal axis.
  43062. * This can help limiting how the Camera is able to move in the scene.
  43063. */
  43064. upperBetaLimit: number;
  43065. /**
  43066. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43067. * This can help limiting how the Camera is able to move in the scene.
  43068. */
  43069. lowerRadiusLimit: Nullable<number>;
  43070. /**
  43071. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43072. * This can help limiting how the Camera is able to move in the scene.
  43073. */
  43074. upperRadiusLimit: Nullable<number>;
  43075. /**
  43076. * Defines the current inertia value used during panning of the camera along the X axis.
  43077. */
  43078. inertialPanningX: number;
  43079. /**
  43080. * Defines the current inertia value used during panning of the camera along the Y axis.
  43081. */
  43082. inertialPanningY: number;
  43083. /**
  43084. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43085. * Basically if your fingers moves away from more than this distance you will be considered
  43086. * in pinch mode.
  43087. */
  43088. pinchToPanMaxDistance: number;
  43089. /**
  43090. * Defines the maximum distance the camera can pan.
  43091. * This could help keeping the cammera always in your scene.
  43092. */
  43093. panningDistanceLimit: Nullable<number>;
  43094. /**
  43095. * Defines the target of the camera before paning.
  43096. */
  43097. panningOriginTarget: Vector3;
  43098. /**
  43099. * Defines the value of the inertia used during panning.
  43100. * 0 would mean stop inertia and one would mean no decelleration at all.
  43101. */
  43102. panningInertia: number;
  43103. /**
  43104. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43105. */
  43106. get angularSensibilityX(): number;
  43107. set angularSensibilityX(value: number);
  43108. /**
  43109. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43110. */
  43111. get angularSensibilityY(): number;
  43112. set angularSensibilityY(value: number);
  43113. /**
  43114. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43115. */
  43116. get pinchPrecision(): number;
  43117. set pinchPrecision(value: number);
  43118. /**
  43119. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43120. * It will be used instead of pinchDeltaPrecision if different from 0.
  43121. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43122. */
  43123. get pinchDeltaPercentage(): number;
  43124. set pinchDeltaPercentage(value: number);
  43125. /**
  43126. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43127. * and pinch delta percentage.
  43128. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43129. * that any object in the plane at the camera's target point will scale
  43130. * perfectly with finger motion.
  43131. */
  43132. get useNaturalPinchZoom(): boolean;
  43133. set useNaturalPinchZoom(value: boolean);
  43134. /**
  43135. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43136. */
  43137. get panningSensibility(): number;
  43138. set panningSensibility(value: number);
  43139. /**
  43140. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43141. */
  43142. get keysUp(): number[];
  43143. set keysUp(value: number[]);
  43144. /**
  43145. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43146. */
  43147. get keysDown(): number[];
  43148. set keysDown(value: number[]);
  43149. /**
  43150. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43151. */
  43152. get keysLeft(): number[];
  43153. set keysLeft(value: number[]);
  43154. /**
  43155. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43156. */
  43157. get keysRight(): number[];
  43158. set keysRight(value: number[]);
  43159. /**
  43160. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43161. */
  43162. get wheelPrecision(): number;
  43163. set wheelPrecision(value: number);
  43164. /**
  43165. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43166. * It will be used instead of pinchDeltaPrecision if different from 0.
  43167. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43168. */
  43169. get wheelDeltaPercentage(): number;
  43170. set wheelDeltaPercentage(value: number);
  43171. /**
  43172. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43173. */
  43174. zoomOnFactor: number;
  43175. /**
  43176. * Defines a screen offset for the camera position.
  43177. */
  43178. targetScreenOffset: Vector2;
  43179. /**
  43180. * Allows the camera to be completely reversed.
  43181. * If false the camera can not arrive upside down.
  43182. */
  43183. allowUpsideDown: boolean;
  43184. /**
  43185. * Define if double tap/click is used to restore the previously saved state of the camera.
  43186. */
  43187. useInputToRestoreState: boolean;
  43188. /** @hidden */
  43189. _viewMatrix: Matrix;
  43190. /** @hidden */
  43191. _useCtrlForPanning: boolean;
  43192. /** @hidden */
  43193. _panningMouseButton: number;
  43194. /**
  43195. * Defines the input associated to the camera.
  43196. */
  43197. inputs: ArcRotateCameraInputsManager;
  43198. /** @hidden */
  43199. _reset: () => void;
  43200. /**
  43201. * Defines the allowed panning axis.
  43202. */
  43203. panningAxis: Vector3;
  43204. protected _localDirection: Vector3;
  43205. protected _transformedDirection: Vector3;
  43206. private _bouncingBehavior;
  43207. /**
  43208. * Gets the bouncing behavior of the camera if it has been enabled.
  43209. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43210. */
  43211. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43212. /**
  43213. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43214. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43215. */
  43216. get useBouncingBehavior(): boolean;
  43217. set useBouncingBehavior(value: boolean);
  43218. private _framingBehavior;
  43219. /**
  43220. * Gets the framing behavior of the camera if it has been enabled.
  43221. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43222. */
  43223. get framingBehavior(): Nullable<FramingBehavior>;
  43224. /**
  43225. * Defines if the framing behavior of the camera is enabled on the camera.
  43226. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43227. */
  43228. get useFramingBehavior(): boolean;
  43229. set useFramingBehavior(value: boolean);
  43230. private _autoRotationBehavior;
  43231. /**
  43232. * Gets the auto rotation behavior of the camera if it has been enabled.
  43233. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43234. */
  43235. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43236. /**
  43237. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43238. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43239. */
  43240. get useAutoRotationBehavior(): boolean;
  43241. set useAutoRotationBehavior(value: boolean);
  43242. /**
  43243. * Observable triggered when the mesh target has been changed on the camera.
  43244. */
  43245. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43246. /**
  43247. * Event raised when the camera is colliding with a mesh.
  43248. */
  43249. onCollide: (collidedMesh: AbstractMesh) => void;
  43250. /**
  43251. * Defines whether the camera should check collision with the objects oh the scene.
  43252. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43253. */
  43254. checkCollisions: boolean;
  43255. /**
  43256. * Defines the collision radius of the camera.
  43257. * This simulates a sphere around the camera.
  43258. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43259. */
  43260. collisionRadius: Vector3;
  43261. protected _collider: Collider;
  43262. protected _previousPosition: Vector3;
  43263. protected _collisionVelocity: Vector3;
  43264. protected _newPosition: Vector3;
  43265. protected _previousAlpha: number;
  43266. protected _previousBeta: number;
  43267. protected _previousRadius: number;
  43268. protected _collisionTriggered: boolean;
  43269. protected _targetBoundingCenter: Nullable<Vector3>;
  43270. private _computationVector;
  43271. /**
  43272. * Instantiates a new ArcRotateCamera in a given scene
  43273. * @param name Defines the name of the camera
  43274. * @param alpha Defines the camera rotation along the logitudinal axis
  43275. * @param beta Defines the camera rotation along the latitudinal axis
  43276. * @param radius Defines the camera distance from its target
  43277. * @param target Defines the camera target
  43278. * @param scene Defines the scene the camera belongs to
  43279. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43280. */
  43281. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43282. /** @hidden */
  43283. _initCache(): void;
  43284. /** @hidden */
  43285. _updateCache(ignoreParentClass?: boolean): void;
  43286. protected _getTargetPosition(): Vector3;
  43287. private _storedAlpha;
  43288. private _storedBeta;
  43289. private _storedRadius;
  43290. private _storedTarget;
  43291. private _storedTargetScreenOffset;
  43292. /**
  43293. * Stores the current state of the camera (alpha, beta, radius and target)
  43294. * @returns the camera itself
  43295. */
  43296. storeState(): Camera;
  43297. /**
  43298. * @hidden
  43299. * Restored camera state. You must call storeState() first
  43300. */
  43301. _restoreStateValues(): boolean;
  43302. /** @hidden */
  43303. _isSynchronizedViewMatrix(): boolean;
  43304. /**
  43305. * Attached controls to the current camera.
  43306. * @param element Defines the element the controls should be listened from
  43307. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43308. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43309. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43310. */
  43311. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43312. /**
  43313. * Detach the current controls from the camera.
  43314. * The camera will stop reacting to inputs.
  43315. * @param element Defines the element to stop listening the inputs from
  43316. */
  43317. detachControl(element: HTMLElement): void;
  43318. /** @hidden */
  43319. _checkInputs(): void;
  43320. protected _checkLimits(): void;
  43321. /**
  43322. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43323. */
  43324. rebuildAnglesAndRadius(): void;
  43325. /**
  43326. * Use a position to define the current camera related information like alpha, beta and radius
  43327. * @param position Defines the position to set the camera at
  43328. */
  43329. setPosition(position: Vector3): void;
  43330. /**
  43331. * Defines the target the camera should look at.
  43332. * This will automatically adapt alpha beta and radius to fit within the new target.
  43333. * @param target Defines the new target as a Vector or a mesh
  43334. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43335. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43336. */
  43337. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43338. /** @hidden */
  43339. _getViewMatrix(): Matrix;
  43340. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43341. /**
  43342. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43343. * @param meshes Defines the mesh to zoom on
  43344. * @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)
  43345. */
  43346. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43347. /**
  43348. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43349. * The target will be changed but the radius
  43350. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43351. * @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)
  43352. */
  43353. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43354. min: Vector3;
  43355. max: Vector3;
  43356. distance: number;
  43357. }, doNotUpdateMaxZ?: boolean): void;
  43358. /**
  43359. * @override
  43360. * Override Camera.createRigCamera
  43361. */
  43362. createRigCamera(name: string, cameraIndex: number): Camera;
  43363. /**
  43364. * @hidden
  43365. * @override
  43366. * Override Camera._updateRigCameras
  43367. */
  43368. _updateRigCameras(): void;
  43369. /**
  43370. * Destroy the camera and release the current resources hold by it.
  43371. */
  43372. dispose(): void;
  43373. /**
  43374. * Gets the current object class name.
  43375. * @return the class name
  43376. */
  43377. getClassName(): string;
  43378. }
  43379. }
  43380. declare module BABYLON {
  43381. /**
  43382. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43383. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43384. */
  43385. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43386. /**
  43387. * Gets the name of the behavior.
  43388. */
  43389. get name(): string;
  43390. private _zoomStopsAnimation;
  43391. private _idleRotationSpeed;
  43392. private _idleRotationWaitTime;
  43393. private _idleRotationSpinupTime;
  43394. /**
  43395. * Sets the flag that indicates if user zooming should stop animation.
  43396. */
  43397. set zoomStopsAnimation(flag: boolean);
  43398. /**
  43399. * Gets the flag that indicates if user zooming should stop animation.
  43400. */
  43401. get zoomStopsAnimation(): boolean;
  43402. /**
  43403. * Sets the default speed at which the camera rotates around the model.
  43404. */
  43405. set idleRotationSpeed(speed: number);
  43406. /**
  43407. * Gets the default speed at which the camera rotates around the model.
  43408. */
  43409. get idleRotationSpeed(): number;
  43410. /**
  43411. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43412. */
  43413. set idleRotationWaitTime(time: number);
  43414. /**
  43415. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43416. */
  43417. get idleRotationWaitTime(): number;
  43418. /**
  43419. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43420. */
  43421. set idleRotationSpinupTime(time: number);
  43422. /**
  43423. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43424. */
  43425. get idleRotationSpinupTime(): number;
  43426. /**
  43427. * Gets a value indicating if the camera is currently rotating because of this behavior
  43428. */
  43429. get rotationInProgress(): boolean;
  43430. private _onPrePointerObservableObserver;
  43431. private _onAfterCheckInputsObserver;
  43432. private _attachedCamera;
  43433. private _isPointerDown;
  43434. private _lastFrameTime;
  43435. private _lastInteractionTime;
  43436. private _cameraRotationSpeed;
  43437. /**
  43438. * Initializes the behavior.
  43439. */
  43440. init(): void;
  43441. /**
  43442. * Attaches the behavior to its arc rotate camera.
  43443. * @param camera Defines the camera to attach the behavior to
  43444. */
  43445. attach(camera: ArcRotateCamera): void;
  43446. /**
  43447. * Detaches the behavior from its current arc rotate camera.
  43448. */
  43449. detach(): void;
  43450. /**
  43451. * Returns true if user is scrolling.
  43452. * @return true if user is scrolling.
  43453. */
  43454. private _userIsZooming;
  43455. private _lastFrameRadius;
  43456. private _shouldAnimationStopForInteraction;
  43457. /**
  43458. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43459. */
  43460. private _applyUserInteraction;
  43461. private _userIsMoving;
  43462. }
  43463. }
  43464. declare module BABYLON {
  43465. /**
  43466. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43467. */
  43468. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43469. private ui;
  43470. /**
  43471. * The name of the behavior
  43472. */
  43473. name: string;
  43474. /**
  43475. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43476. */
  43477. distanceAwayFromFace: number;
  43478. /**
  43479. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43480. */
  43481. distanceAwayFromBottomOfFace: number;
  43482. private _faceVectors;
  43483. private _target;
  43484. private _scene;
  43485. private _onRenderObserver;
  43486. private _tmpMatrix;
  43487. private _tmpVector;
  43488. /**
  43489. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43490. * @param ui The transform node that should be attched to the mesh
  43491. */
  43492. constructor(ui: TransformNode);
  43493. /**
  43494. * Initializes the behavior
  43495. */
  43496. init(): void;
  43497. private _closestFace;
  43498. private _zeroVector;
  43499. private _lookAtTmpMatrix;
  43500. private _lookAtToRef;
  43501. /**
  43502. * Attaches the AttachToBoxBehavior to the passed in mesh
  43503. * @param target The mesh that the specified node will be attached to
  43504. */
  43505. attach(target: Mesh): void;
  43506. /**
  43507. * Detaches the behavior from the mesh
  43508. */
  43509. detach(): void;
  43510. }
  43511. }
  43512. declare module BABYLON {
  43513. /**
  43514. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43515. */
  43516. export class FadeInOutBehavior implements Behavior<Mesh> {
  43517. /**
  43518. * Time in milliseconds to delay before fading in (Default: 0)
  43519. */
  43520. delay: number;
  43521. /**
  43522. * Time in milliseconds for the mesh to fade in (Default: 300)
  43523. */
  43524. fadeInTime: number;
  43525. private _millisecondsPerFrame;
  43526. private _hovered;
  43527. private _hoverValue;
  43528. private _ownerNode;
  43529. /**
  43530. * Instatiates the FadeInOutBehavior
  43531. */
  43532. constructor();
  43533. /**
  43534. * The name of the behavior
  43535. */
  43536. get name(): string;
  43537. /**
  43538. * Initializes the behavior
  43539. */
  43540. init(): void;
  43541. /**
  43542. * Attaches the fade behavior on the passed in mesh
  43543. * @param ownerNode The mesh that will be faded in/out once attached
  43544. */
  43545. attach(ownerNode: Mesh): void;
  43546. /**
  43547. * Detaches the behavior from the mesh
  43548. */
  43549. detach(): void;
  43550. /**
  43551. * Triggers the mesh to begin fading in or out
  43552. * @param value if the object should fade in or out (true to fade in)
  43553. */
  43554. fadeIn(value: boolean): void;
  43555. private _update;
  43556. private _setAllVisibility;
  43557. }
  43558. }
  43559. declare module BABYLON {
  43560. /**
  43561. * Class containing a set of static utilities functions for managing Pivots
  43562. * @hidden
  43563. */
  43564. export class PivotTools {
  43565. private static _PivotCached;
  43566. private static _OldPivotPoint;
  43567. private static _PivotTranslation;
  43568. private static _PivotTmpVector;
  43569. private static _PivotPostMultiplyPivotMatrix;
  43570. /** @hidden */
  43571. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43572. /** @hidden */
  43573. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43574. }
  43575. }
  43576. declare module BABYLON {
  43577. /**
  43578. * Class containing static functions to help procedurally build meshes
  43579. */
  43580. export class PlaneBuilder {
  43581. /**
  43582. * Creates a plane mesh
  43583. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43584. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43585. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43587. * * 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
  43588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43589. * @param name defines the name of the mesh
  43590. * @param options defines the options used to create the mesh
  43591. * @param scene defines the hosting scene
  43592. * @returns the plane mesh
  43593. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43594. */
  43595. static CreatePlane(name: string, options: {
  43596. size?: number;
  43597. width?: number;
  43598. height?: number;
  43599. sideOrientation?: number;
  43600. frontUVs?: Vector4;
  43601. backUVs?: Vector4;
  43602. updatable?: boolean;
  43603. sourcePlane?: Plane;
  43604. }, scene?: Nullable<Scene>): Mesh;
  43605. }
  43606. }
  43607. declare module BABYLON {
  43608. /**
  43609. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43610. */
  43611. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43612. private static _AnyMouseID;
  43613. /**
  43614. * Abstract mesh the behavior is set on
  43615. */
  43616. attachedNode: AbstractMesh;
  43617. private _dragPlane;
  43618. private _scene;
  43619. private _pointerObserver;
  43620. private _beforeRenderObserver;
  43621. private static _planeScene;
  43622. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43623. /**
  43624. * 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)
  43625. */
  43626. maxDragAngle: number;
  43627. /**
  43628. * @hidden
  43629. */
  43630. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43631. /**
  43632. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43633. */
  43634. currentDraggingPointerID: number;
  43635. /**
  43636. * The last position where the pointer hit the drag plane in world space
  43637. */
  43638. lastDragPosition: Vector3;
  43639. /**
  43640. * If the behavior is currently in a dragging state
  43641. */
  43642. dragging: boolean;
  43643. /**
  43644. * 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)
  43645. */
  43646. dragDeltaRatio: number;
  43647. /**
  43648. * If the drag plane orientation should be updated during the dragging (Default: true)
  43649. */
  43650. updateDragPlane: boolean;
  43651. private _debugMode;
  43652. private _moving;
  43653. /**
  43654. * Fires each time the attached mesh is dragged with the pointer
  43655. * * delta between last drag position and current drag position in world space
  43656. * * dragDistance along the drag axis
  43657. * * dragPlaneNormal normal of the current drag plane used during the drag
  43658. * * dragPlanePoint in world space where the drag intersects the drag plane
  43659. */
  43660. onDragObservable: Observable<{
  43661. delta: Vector3;
  43662. dragPlanePoint: Vector3;
  43663. dragPlaneNormal: Vector3;
  43664. dragDistance: number;
  43665. pointerId: number;
  43666. }>;
  43667. /**
  43668. * Fires each time a drag begins (eg. mouse down on mesh)
  43669. */
  43670. onDragStartObservable: Observable<{
  43671. dragPlanePoint: Vector3;
  43672. pointerId: number;
  43673. }>;
  43674. /**
  43675. * Fires each time a drag ends (eg. mouse release after drag)
  43676. */
  43677. onDragEndObservable: Observable<{
  43678. dragPlanePoint: Vector3;
  43679. pointerId: number;
  43680. }>;
  43681. /**
  43682. * If the attached mesh should be moved when dragged
  43683. */
  43684. moveAttached: boolean;
  43685. /**
  43686. * If the drag behavior will react to drag events (Default: true)
  43687. */
  43688. enabled: boolean;
  43689. /**
  43690. * If pointer events should start and release the drag (Default: true)
  43691. */
  43692. startAndReleaseDragOnPointerEvents: boolean;
  43693. /**
  43694. * If camera controls should be detached during the drag
  43695. */
  43696. detachCameraControls: boolean;
  43697. /**
  43698. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43699. */
  43700. useObjectOrientationForDragging: boolean;
  43701. private _options;
  43702. /**
  43703. * Gets the options used by the behavior
  43704. */
  43705. get options(): {
  43706. dragAxis?: Vector3;
  43707. dragPlaneNormal?: Vector3;
  43708. };
  43709. /**
  43710. * Sets the options used by the behavior
  43711. */
  43712. set options(options: {
  43713. dragAxis?: Vector3;
  43714. dragPlaneNormal?: Vector3;
  43715. });
  43716. /**
  43717. * Creates a pointer drag behavior that can be attached to a mesh
  43718. * @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)
  43719. */
  43720. constructor(options?: {
  43721. dragAxis?: Vector3;
  43722. dragPlaneNormal?: Vector3;
  43723. });
  43724. /**
  43725. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43726. */
  43727. validateDrag: (targetPosition: Vector3) => boolean;
  43728. /**
  43729. * The name of the behavior
  43730. */
  43731. get name(): string;
  43732. /**
  43733. * Initializes the behavior
  43734. */
  43735. init(): void;
  43736. private _tmpVector;
  43737. private _alternatePickedPoint;
  43738. private _worldDragAxis;
  43739. private _targetPosition;
  43740. private _attachedElement;
  43741. /**
  43742. * Attaches the drag behavior the passed in mesh
  43743. * @param ownerNode The mesh that will be dragged around once attached
  43744. * @param predicate Predicate to use for pick filtering
  43745. */
  43746. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43747. /**
  43748. * Force relase the drag action by code.
  43749. */
  43750. releaseDrag(): void;
  43751. private _startDragRay;
  43752. private _lastPointerRay;
  43753. /**
  43754. * Simulates the start of a pointer drag event on the behavior
  43755. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43756. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43757. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43758. */
  43759. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43760. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43761. private _dragDelta;
  43762. protected _moveDrag(ray: Ray): void;
  43763. private _pickWithRayOnDragPlane;
  43764. private _pointA;
  43765. private _pointC;
  43766. private _localAxis;
  43767. private _lookAt;
  43768. private _updateDragPlanePosition;
  43769. /**
  43770. * Detaches the behavior from the mesh
  43771. */
  43772. detach(): void;
  43773. }
  43774. }
  43775. declare module BABYLON {
  43776. /**
  43777. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43778. */
  43779. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43780. private _dragBehaviorA;
  43781. private _dragBehaviorB;
  43782. private _startDistance;
  43783. private _initialScale;
  43784. private _targetScale;
  43785. private _ownerNode;
  43786. private _sceneRenderObserver;
  43787. /**
  43788. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43789. */
  43790. constructor();
  43791. /**
  43792. * The name of the behavior
  43793. */
  43794. get name(): string;
  43795. /**
  43796. * Initializes the behavior
  43797. */
  43798. init(): void;
  43799. private _getCurrentDistance;
  43800. /**
  43801. * Attaches the scale behavior the passed in mesh
  43802. * @param ownerNode The mesh that will be scaled around once attached
  43803. */
  43804. attach(ownerNode: Mesh): void;
  43805. /**
  43806. * Detaches the behavior from the mesh
  43807. */
  43808. detach(): void;
  43809. }
  43810. }
  43811. declare module BABYLON {
  43812. /**
  43813. * 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
  43814. */
  43815. export class SixDofDragBehavior implements Behavior<Mesh> {
  43816. private static _virtualScene;
  43817. private _ownerNode;
  43818. private _sceneRenderObserver;
  43819. private _scene;
  43820. private _targetPosition;
  43821. private _virtualOriginMesh;
  43822. private _virtualDragMesh;
  43823. private _pointerObserver;
  43824. private _moving;
  43825. private _startingOrientation;
  43826. private _attachedElement;
  43827. /**
  43828. * 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)
  43829. */
  43830. private zDragFactor;
  43831. /**
  43832. * If the object should rotate to face the drag origin
  43833. */
  43834. rotateDraggedObject: boolean;
  43835. /**
  43836. * If the behavior is currently in a dragging state
  43837. */
  43838. dragging: boolean;
  43839. /**
  43840. * 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)
  43841. */
  43842. dragDeltaRatio: number;
  43843. /**
  43844. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43845. */
  43846. currentDraggingPointerID: number;
  43847. /**
  43848. * If camera controls should be detached during the drag
  43849. */
  43850. detachCameraControls: boolean;
  43851. /**
  43852. * Fires each time a drag starts
  43853. */
  43854. onDragStartObservable: Observable<{}>;
  43855. /**
  43856. * Fires each time a drag ends (eg. mouse release after drag)
  43857. */
  43858. onDragEndObservable: Observable<{}>;
  43859. /**
  43860. * 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
  43861. */
  43862. constructor();
  43863. /**
  43864. * The name of the behavior
  43865. */
  43866. get name(): string;
  43867. /**
  43868. * Initializes the behavior
  43869. */
  43870. init(): void;
  43871. /**
  43872. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43873. */
  43874. private get _pointerCamera();
  43875. /**
  43876. * Attaches the scale behavior the passed in mesh
  43877. * @param ownerNode The mesh that will be scaled around once attached
  43878. */
  43879. attach(ownerNode: Mesh): void;
  43880. /**
  43881. * Detaches the behavior from the mesh
  43882. */
  43883. detach(): void;
  43884. }
  43885. }
  43886. declare module BABYLON {
  43887. /**
  43888. * Class used to apply inverse kinematics to bones
  43889. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43890. */
  43891. export class BoneIKController {
  43892. private static _tmpVecs;
  43893. private static _tmpQuat;
  43894. private static _tmpMats;
  43895. /**
  43896. * Gets or sets the target mesh
  43897. */
  43898. targetMesh: AbstractMesh;
  43899. /** Gets or sets the mesh used as pole */
  43900. poleTargetMesh: AbstractMesh;
  43901. /**
  43902. * Gets or sets the bone used as pole
  43903. */
  43904. poleTargetBone: Nullable<Bone>;
  43905. /**
  43906. * Gets or sets the target position
  43907. */
  43908. targetPosition: Vector3;
  43909. /**
  43910. * Gets or sets the pole target position
  43911. */
  43912. poleTargetPosition: Vector3;
  43913. /**
  43914. * Gets or sets the pole target local offset
  43915. */
  43916. poleTargetLocalOffset: Vector3;
  43917. /**
  43918. * Gets or sets the pole angle
  43919. */
  43920. poleAngle: number;
  43921. /**
  43922. * Gets or sets the mesh associated with the controller
  43923. */
  43924. mesh: AbstractMesh;
  43925. /**
  43926. * 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)
  43927. */
  43928. slerpAmount: number;
  43929. private _bone1Quat;
  43930. private _bone1Mat;
  43931. private _bone2Ang;
  43932. private _bone1;
  43933. private _bone2;
  43934. private _bone1Length;
  43935. private _bone2Length;
  43936. private _maxAngle;
  43937. private _maxReach;
  43938. private _rightHandedSystem;
  43939. private _bendAxis;
  43940. private _slerping;
  43941. private _adjustRoll;
  43942. /**
  43943. * Gets or sets maximum allowed angle
  43944. */
  43945. get maxAngle(): number;
  43946. set maxAngle(value: number);
  43947. /**
  43948. * Creates a new BoneIKController
  43949. * @param mesh defines the mesh to control
  43950. * @param bone defines the bone to control
  43951. * @param options defines options to set up the controller
  43952. */
  43953. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43954. targetMesh?: AbstractMesh;
  43955. poleTargetMesh?: AbstractMesh;
  43956. poleTargetBone?: Bone;
  43957. poleTargetLocalOffset?: Vector3;
  43958. poleAngle?: number;
  43959. bendAxis?: Vector3;
  43960. maxAngle?: number;
  43961. slerpAmount?: number;
  43962. });
  43963. private _setMaxAngle;
  43964. /**
  43965. * Force the controller to update the bones
  43966. */
  43967. update(): void;
  43968. }
  43969. }
  43970. declare module BABYLON {
  43971. /**
  43972. * Class used to make a bone look toward a point in space
  43973. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43974. */
  43975. export class BoneLookController {
  43976. private static _tmpVecs;
  43977. private static _tmpQuat;
  43978. private static _tmpMats;
  43979. /**
  43980. * The target Vector3 that the bone will look at
  43981. */
  43982. target: Vector3;
  43983. /**
  43984. * The mesh that the bone is attached to
  43985. */
  43986. mesh: AbstractMesh;
  43987. /**
  43988. * The bone that will be looking to the target
  43989. */
  43990. bone: Bone;
  43991. /**
  43992. * The up axis of the coordinate system that is used when the bone is rotated
  43993. */
  43994. upAxis: Vector3;
  43995. /**
  43996. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43997. */
  43998. upAxisSpace: Space;
  43999. /**
  44000. * Used to make an adjustment to the yaw of the bone
  44001. */
  44002. adjustYaw: number;
  44003. /**
  44004. * Used to make an adjustment to the pitch of the bone
  44005. */
  44006. adjustPitch: number;
  44007. /**
  44008. * Used to make an adjustment to the roll of the bone
  44009. */
  44010. adjustRoll: number;
  44011. /**
  44012. * 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)
  44013. */
  44014. slerpAmount: number;
  44015. private _minYaw;
  44016. private _maxYaw;
  44017. private _minPitch;
  44018. private _maxPitch;
  44019. private _minYawSin;
  44020. private _minYawCos;
  44021. private _maxYawSin;
  44022. private _maxYawCos;
  44023. private _midYawConstraint;
  44024. private _minPitchTan;
  44025. private _maxPitchTan;
  44026. private _boneQuat;
  44027. private _slerping;
  44028. private _transformYawPitch;
  44029. private _transformYawPitchInv;
  44030. private _firstFrameSkipped;
  44031. private _yawRange;
  44032. private _fowardAxis;
  44033. /**
  44034. * Gets or sets the minimum yaw angle that the bone can look to
  44035. */
  44036. get minYaw(): number;
  44037. set minYaw(value: number);
  44038. /**
  44039. * Gets or sets the maximum yaw angle that the bone can look to
  44040. */
  44041. get maxYaw(): number;
  44042. set maxYaw(value: number);
  44043. /**
  44044. * Gets or sets the minimum pitch angle that the bone can look to
  44045. */
  44046. get minPitch(): number;
  44047. set minPitch(value: number);
  44048. /**
  44049. * Gets or sets the maximum pitch angle that the bone can look to
  44050. */
  44051. get maxPitch(): number;
  44052. set maxPitch(value: number);
  44053. /**
  44054. * Create a BoneLookController
  44055. * @param mesh the mesh that the bone belongs to
  44056. * @param bone the bone that will be looking to the target
  44057. * @param target the target Vector3 to look at
  44058. * @param options optional settings:
  44059. * * maxYaw: the maximum angle the bone will yaw to
  44060. * * minYaw: the minimum angle the bone will yaw to
  44061. * * maxPitch: the maximum angle the bone will pitch to
  44062. * * minPitch: the minimum angle the bone will yaw to
  44063. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44064. * * upAxis: the up axis of the coordinate system
  44065. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44066. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44067. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44068. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44069. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44070. * * adjustRoll: used to make an adjustment to the roll of the bone
  44071. **/
  44072. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44073. maxYaw?: number;
  44074. minYaw?: number;
  44075. maxPitch?: number;
  44076. minPitch?: number;
  44077. slerpAmount?: number;
  44078. upAxis?: Vector3;
  44079. upAxisSpace?: Space;
  44080. yawAxis?: Vector3;
  44081. pitchAxis?: Vector3;
  44082. adjustYaw?: number;
  44083. adjustPitch?: number;
  44084. adjustRoll?: number;
  44085. });
  44086. /**
  44087. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44088. */
  44089. update(): void;
  44090. private _getAngleDiff;
  44091. private _getAngleBetween;
  44092. private _isAngleBetween;
  44093. }
  44094. }
  44095. declare module BABYLON {
  44096. /**
  44097. * Manage the gamepad inputs to control an arc rotate camera.
  44098. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44099. */
  44100. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44101. /**
  44102. * Defines the camera the input is attached to.
  44103. */
  44104. camera: ArcRotateCamera;
  44105. /**
  44106. * Defines the gamepad the input is gathering event from.
  44107. */
  44108. gamepad: Nullable<Gamepad>;
  44109. /**
  44110. * Defines the gamepad rotation sensiblity.
  44111. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44112. */
  44113. gamepadRotationSensibility: number;
  44114. /**
  44115. * Defines the gamepad move sensiblity.
  44116. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44117. */
  44118. gamepadMoveSensibility: number;
  44119. private _yAxisScale;
  44120. /**
  44121. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44122. */
  44123. get invertYAxis(): boolean;
  44124. set invertYAxis(value: boolean);
  44125. private _onGamepadConnectedObserver;
  44126. private _onGamepadDisconnectedObserver;
  44127. /**
  44128. * Attach the input controls to a specific dom element to get the input from.
  44129. * @param element Defines the element the controls should be listened from
  44130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44131. */
  44132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44133. /**
  44134. * Detach the current controls from the specified dom element.
  44135. * @param element Defines the element to stop listening the inputs from
  44136. */
  44137. detachControl(element: Nullable<HTMLElement>): void;
  44138. /**
  44139. * Update the current camera state depending on the inputs that have been used this frame.
  44140. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44141. */
  44142. checkInputs(): void;
  44143. /**
  44144. * Gets the class name of the current intput.
  44145. * @returns the class name
  44146. */
  44147. getClassName(): string;
  44148. /**
  44149. * Get the friendly name associated with the input class.
  44150. * @returns the input friendly name
  44151. */
  44152. getSimpleName(): string;
  44153. }
  44154. }
  44155. declare module BABYLON {
  44156. interface ArcRotateCameraInputsManager {
  44157. /**
  44158. * Add orientation input support to the input manager.
  44159. * @returns the current input manager
  44160. */
  44161. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44162. }
  44163. /**
  44164. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44165. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44166. */
  44167. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44168. /**
  44169. * Defines the camera the input is attached to.
  44170. */
  44171. camera: ArcRotateCamera;
  44172. /**
  44173. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44174. */
  44175. alphaCorrection: number;
  44176. /**
  44177. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44178. */
  44179. gammaCorrection: number;
  44180. private _alpha;
  44181. private _gamma;
  44182. private _dirty;
  44183. private _deviceOrientationHandler;
  44184. /**
  44185. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44186. */
  44187. constructor();
  44188. /**
  44189. * Attach the input controls to a specific dom element to get the input from.
  44190. * @param element Defines the element the controls should be listened from
  44191. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44192. */
  44193. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44194. /** @hidden */
  44195. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44196. /**
  44197. * Update the current camera state depending on the inputs that have been used this frame.
  44198. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44199. */
  44200. checkInputs(): void;
  44201. /**
  44202. * Detach the current controls from the specified dom element.
  44203. * @param element Defines the element to stop listening the inputs from
  44204. */
  44205. detachControl(element: Nullable<HTMLElement>): void;
  44206. /**
  44207. * Gets the class name of the current intput.
  44208. * @returns the class name
  44209. */
  44210. getClassName(): string;
  44211. /**
  44212. * Get the friendly name associated with the input class.
  44213. * @returns the input friendly name
  44214. */
  44215. getSimpleName(): string;
  44216. }
  44217. }
  44218. declare module BABYLON {
  44219. /**
  44220. * Listen to mouse events to control the camera.
  44221. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44222. */
  44223. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44224. /**
  44225. * Defines the camera the input is attached to.
  44226. */
  44227. camera: FlyCamera;
  44228. /**
  44229. * Defines if touch is enabled. (Default is true.)
  44230. */
  44231. touchEnabled: boolean;
  44232. /**
  44233. * Defines the buttons associated with the input to handle camera rotation.
  44234. */
  44235. buttons: number[];
  44236. /**
  44237. * Assign buttons for Yaw control.
  44238. */
  44239. buttonsYaw: number[];
  44240. /**
  44241. * Assign buttons for Pitch control.
  44242. */
  44243. buttonsPitch: number[];
  44244. /**
  44245. * Assign buttons for Roll control.
  44246. */
  44247. buttonsRoll: number[];
  44248. /**
  44249. * Detect if any button is being pressed while mouse is moved.
  44250. * -1 = Mouse locked.
  44251. * 0 = Left button.
  44252. * 1 = Middle Button.
  44253. * 2 = Right Button.
  44254. */
  44255. activeButton: number;
  44256. /**
  44257. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44258. * Higher values reduce its sensitivity.
  44259. */
  44260. angularSensibility: number;
  44261. private _mousemoveCallback;
  44262. private _observer;
  44263. private _rollObserver;
  44264. private previousPosition;
  44265. private noPreventDefault;
  44266. private element;
  44267. /**
  44268. * Listen to mouse events to control the camera.
  44269. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44270. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44271. */
  44272. constructor(touchEnabled?: boolean);
  44273. /**
  44274. * Attach the mouse control to the HTML DOM element.
  44275. * @param element Defines the element that listens to the input events.
  44276. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44277. */
  44278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44279. /**
  44280. * Detach the current controls from the specified dom element.
  44281. * @param element Defines the element to stop listening the inputs from
  44282. */
  44283. detachControl(element: Nullable<HTMLElement>): void;
  44284. /**
  44285. * Gets the class name of the current input.
  44286. * @returns the class name.
  44287. */
  44288. getClassName(): string;
  44289. /**
  44290. * Get the friendly name associated with the input class.
  44291. * @returns the input's friendly name.
  44292. */
  44293. getSimpleName(): string;
  44294. private _pointerInput;
  44295. private _onMouseMove;
  44296. /**
  44297. * Rotate camera by mouse offset.
  44298. */
  44299. private rotateCamera;
  44300. }
  44301. }
  44302. declare module BABYLON {
  44303. /**
  44304. * Default Inputs manager for the FlyCamera.
  44305. * It groups all the default supported inputs for ease of use.
  44306. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44307. */
  44308. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44309. /**
  44310. * Instantiates a new FlyCameraInputsManager.
  44311. * @param camera Defines the camera the inputs belong to.
  44312. */
  44313. constructor(camera: FlyCamera);
  44314. /**
  44315. * Add keyboard input support to the input manager.
  44316. * @returns the new FlyCameraKeyboardMoveInput().
  44317. */
  44318. addKeyboard(): FlyCameraInputsManager;
  44319. /**
  44320. * Add mouse input support to the input manager.
  44321. * @param touchEnabled Enable touch screen support.
  44322. * @returns the new FlyCameraMouseInput().
  44323. */
  44324. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44325. }
  44326. }
  44327. declare module BABYLON {
  44328. /**
  44329. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44330. * such as in a 3D Space Shooter or a Flight Simulator.
  44331. */
  44332. export class FlyCamera extends TargetCamera {
  44333. /**
  44334. * Define the collision ellipsoid of the camera.
  44335. * This is helpful for simulating a camera body, like a player's body.
  44336. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44337. */
  44338. ellipsoid: Vector3;
  44339. /**
  44340. * Define an offset for the position of the ellipsoid around the camera.
  44341. * This can be helpful if the camera is attached away from the player's body center,
  44342. * such as at its head.
  44343. */
  44344. ellipsoidOffset: Vector3;
  44345. /**
  44346. * Enable or disable collisions of the camera with the rest of the scene objects.
  44347. */
  44348. checkCollisions: boolean;
  44349. /**
  44350. * Enable or disable gravity on the camera.
  44351. */
  44352. applyGravity: boolean;
  44353. /**
  44354. * Define the current direction the camera is moving to.
  44355. */
  44356. cameraDirection: Vector3;
  44357. /**
  44358. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44359. * This overrides and empties cameraRotation.
  44360. */
  44361. rotationQuaternion: Quaternion;
  44362. /**
  44363. * Track Roll to maintain the wanted Rolling when looking around.
  44364. */
  44365. _trackRoll: number;
  44366. /**
  44367. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44368. */
  44369. rollCorrect: number;
  44370. /**
  44371. * Mimic a banked turn, Rolling the camera when Yawing.
  44372. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44373. */
  44374. bankedTurn: boolean;
  44375. /**
  44376. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44377. */
  44378. bankedTurnLimit: number;
  44379. /**
  44380. * Value of 0 disables the banked Roll.
  44381. * Value of 1 is equal to the Yaw angle in radians.
  44382. */
  44383. bankedTurnMultiplier: number;
  44384. /**
  44385. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44386. */
  44387. inputs: FlyCameraInputsManager;
  44388. /**
  44389. * Gets the input sensibility for mouse input.
  44390. * Higher values reduce sensitivity.
  44391. */
  44392. get angularSensibility(): number;
  44393. /**
  44394. * Sets the input sensibility for a mouse input.
  44395. * Higher values reduce sensitivity.
  44396. */
  44397. set angularSensibility(value: number);
  44398. /**
  44399. * Get the keys for camera movement forward.
  44400. */
  44401. get keysForward(): number[];
  44402. /**
  44403. * Set the keys for camera movement forward.
  44404. */
  44405. set keysForward(value: number[]);
  44406. /**
  44407. * Get the keys for camera movement backward.
  44408. */
  44409. get keysBackward(): number[];
  44410. set keysBackward(value: number[]);
  44411. /**
  44412. * Get the keys for camera movement up.
  44413. */
  44414. get keysUp(): number[];
  44415. /**
  44416. * Set the keys for camera movement up.
  44417. */
  44418. set keysUp(value: number[]);
  44419. /**
  44420. * Get the keys for camera movement down.
  44421. */
  44422. get keysDown(): number[];
  44423. /**
  44424. * Set the keys for camera movement down.
  44425. */
  44426. set keysDown(value: number[]);
  44427. /**
  44428. * Get the keys for camera movement left.
  44429. */
  44430. get keysLeft(): number[];
  44431. /**
  44432. * Set the keys for camera movement left.
  44433. */
  44434. set keysLeft(value: number[]);
  44435. /**
  44436. * Set the keys for camera movement right.
  44437. */
  44438. get keysRight(): number[];
  44439. /**
  44440. * Set the keys for camera movement right.
  44441. */
  44442. set keysRight(value: number[]);
  44443. /**
  44444. * Event raised when the camera collides with a mesh in the scene.
  44445. */
  44446. onCollide: (collidedMesh: AbstractMesh) => void;
  44447. private _collider;
  44448. private _needMoveForGravity;
  44449. private _oldPosition;
  44450. private _diffPosition;
  44451. private _newPosition;
  44452. /** @hidden */
  44453. _localDirection: Vector3;
  44454. /** @hidden */
  44455. _transformedDirection: Vector3;
  44456. /**
  44457. * Instantiates a FlyCamera.
  44458. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44459. * such as in a 3D Space Shooter or a Flight Simulator.
  44460. * @param name Define the name of the camera in the scene.
  44461. * @param position Define the starting position of the camera in the scene.
  44462. * @param scene Define the scene the camera belongs to.
  44463. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44464. */
  44465. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44466. /**
  44467. * Attach a control to the HTML DOM element.
  44468. * @param element Defines the element that listens to the input events.
  44469. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44470. */
  44471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44472. /**
  44473. * Detach a control from the HTML DOM element.
  44474. * The camera will stop reacting to that input.
  44475. * @param element Defines the element that listens to the input events.
  44476. */
  44477. detachControl(element: HTMLElement): void;
  44478. private _collisionMask;
  44479. /**
  44480. * Get the mask that the camera ignores in collision events.
  44481. */
  44482. get collisionMask(): number;
  44483. /**
  44484. * Set the mask that the camera ignores in collision events.
  44485. */
  44486. set collisionMask(mask: number);
  44487. /** @hidden */
  44488. _collideWithWorld(displacement: Vector3): void;
  44489. /** @hidden */
  44490. private _onCollisionPositionChange;
  44491. /** @hidden */
  44492. _checkInputs(): void;
  44493. /** @hidden */
  44494. _decideIfNeedsToMove(): boolean;
  44495. /** @hidden */
  44496. _updatePosition(): void;
  44497. /**
  44498. * Restore the Roll to its target value at the rate specified.
  44499. * @param rate - Higher means slower restoring.
  44500. * @hidden
  44501. */
  44502. restoreRoll(rate: number): void;
  44503. /**
  44504. * Destroy the camera and release the current resources held by it.
  44505. */
  44506. dispose(): void;
  44507. /**
  44508. * Get the current object class name.
  44509. * @returns the class name.
  44510. */
  44511. getClassName(): string;
  44512. }
  44513. }
  44514. declare module BABYLON {
  44515. /**
  44516. * Listen to keyboard events to control the camera.
  44517. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44518. */
  44519. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44520. /**
  44521. * Defines the camera the input is attached to.
  44522. */
  44523. camera: FlyCamera;
  44524. /**
  44525. * The list of keyboard keys used to control the forward move of the camera.
  44526. */
  44527. keysForward: number[];
  44528. /**
  44529. * The list of keyboard keys used to control the backward move of the camera.
  44530. */
  44531. keysBackward: number[];
  44532. /**
  44533. * The list of keyboard keys used to control the forward move of the camera.
  44534. */
  44535. keysUp: number[];
  44536. /**
  44537. * The list of keyboard keys used to control the backward move of the camera.
  44538. */
  44539. keysDown: number[];
  44540. /**
  44541. * The list of keyboard keys used to control the right strafe move of the camera.
  44542. */
  44543. keysRight: number[];
  44544. /**
  44545. * The list of keyboard keys used to control the left strafe move of the camera.
  44546. */
  44547. keysLeft: number[];
  44548. private _keys;
  44549. private _onCanvasBlurObserver;
  44550. private _onKeyboardObserver;
  44551. private _engine;
  44552. private _scene;
  44553. /**
  44554. * Attach the input controls to a specific dom element to get the input from.
  44555. * @param element Defines the element the controls should be listened from
  44556. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44557. */
  44558. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44559. /**
  44560. * Detach the current controls from the specified dom element.
  44561. * @param element Defines the element to stop listening the inputs from
  44562. */
  44563. detachControl(element: Nullable<HTMLElement>): void;
  44564. /**
  44565. * Gets the class name of the current intput.
  44566. * @returns the class name
  44567. */
  44568. getClassName(): string;
  44569. /** @hidden */
  44570. _onLostFocus(e: FocusEvent): void;
  44571. /**
  44572. * Get the friendly name associated with the input class.
  44573. * @returns the input friendly name
  44574. */
  44575. getSimpleName(): string;
  44576. /**
  44577. * Update the current camera state depending on the inputs that have been used this frame.
  44578. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44579. */
  44580. checkInputs(): void;
  44581. }
  44582. }
  44583. declare module BABYLON {
  44584. /**
  44585. * Manage the mouse wheel inputs to control a follow camera.
  44586. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44587. */
  44588. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44589. /**
  44590. * Defines the camera the input is attached to.
  44591. */
  44592. camera: FollowCamera;
  44593. /**
  44594. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44595. */
  44596. axisControlRadius: boolean;
  44597. /**
  44598. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44599. */
  44600. axisControlHeight: boolean;
  44601. /**
  44602. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44603. */
  44604. axisControlRotation: boolean;
  44605. /**
  44606. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44607. * relation to mouseWheel events.
  44608. */
  44609. wheelPrecision: number;
  44610. /**
  44611. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44612. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44613. */
  44614. wheelDeltaPercentage: number;
  44615. private _wheel;
  44616. private _observer;
  44617. /**
  44618. * Attach the input controls to a specific dom element to get the input from.
  44619. * @param element Defines the element the controls should be listened from
  44620. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44621. */
  44622. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44623. /**
  44624. * Detach the current controls from the specified dom element.
  44625. * @param element Defines the element to stop listening the inputs from
  44626. */
  44627. detachControl(element: Nullable<HTMLElement>): void;
  44628. /**
  44629. * Gets the class name of the current intput.
  44630. * @returns the class name
  44631. */
  44632. getClassName(): string;
  44633. /**
  44634. * Get the friendly name associated with the input class.
  44635. * @returns the input friendly name
  44636. */
  44637. getSimpleName(): string;
  44638. }
  44639. }
  44640. declare module BABYLON {
  44641. /**
  44642. * Manage the pointers inputs to control an follow camera.
  44643. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44644. */
  44645. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44646. /**
  44647. * Defines the camera the input is attached to.
  44648. */
  44649. camera: FollowCamera;
  44650. /**
  44651. * Gets the class name of the current input.
  44652. * @returns the class name
  44653. */
  44654. getClassName(): string;
  44655. /**
  44656. * Defines the pointer angular sensibility along the X axis or how fast is
  44657. * the camera rotating.
  44658. * A negative number will reverse the axis direction.
  44659. */
  44660. angularSensibilityX: number;
  44661. /**
  44662. * Defines the pointer angular sensibility along the Y axis or how fast is
  44663. * the camera rotating.
  44664. * A negative number will reverse the axis direction.
  44665. */
  44666. angularSensibilityY: number;
  44667. /**
  44668. * Defines the pointer pinch precision or how fast is the camera zooming.
  44669. * A negative number will reverse the axis direction.
  44670. */
  44671. pinchPrecision: number;
  44672. /**
  44673. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44674. * from 0.
  44675. * It defines the percentage of current camera.radius to use as delta when
  44676. * pinch zoom is used.
  44677. */
  44678. pinchDeltaPercentage: number;
  44679. /**
  44680. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44681. */
  44682. axisXControlRadius: boolean;
  44683. /**
  44684. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44685. */
  44686. axisXControlHeight: boolean;
  44687. /**
  44688. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44689. */
  44690. axisXControlRotation: boolean;
  44691. /**
  44692. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44693. */
  44694. axisYControlRadius: boolean;
  44695. /**
  44696. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44697. */
  44698. axisYControlHeight: boolean;
  44699. /**
  44700. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44701. */
  44702. axisYControlRotation: boolean;
  44703. /**
  44704. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44705. */
  44706. axisPinchControlRadius: boolean;
  44707. /**
  44708. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44709. */
  44710. axisPinchControlHeight: boolean;
  44711. /**
  44712. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44713. */
  44714. axisPinchControlRotation: boolean;
  44715. /**
  44716. * Log error messages if basic misconfiguration has occurred.
  44717. */
  44718. warningEnable: boolean;
  44719. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44720. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44721. private _warningCounter;
  44722. private _warning;
  44723. }
  44724. }
  44725. declare module BABYLON {
  44726. /**
  44727. * Default Inputs manager for the FollowCamera.
  44728. * It groups all the default supported inputs for ease of use.
  44729. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44730. */
  44731. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44732. /**
  44733. * Instantiates a new FollowCameraInputsManager.
  44734. * @param camera Defines the camera the inputs belong to
  44735. */
  44736. constructor(camera: FollowCamera);
  44737. /**
  44738. * Add keyboard input support to the input manager.
  44739. * @returns the current input manager
  44740. */
  44741. addKeyboard(): FollowCameraInputsManager;
  44742. /**
  44743. * Add mouse wheel input support to the input manager.
  44744. * @returns the current input manager
  44745. */
  44746. addMouseWheel(): FollowCameraInputsManager;
  44747. /**
  44748. * Add pointers input support to the input manager.
  44749. * @returns the current input manager
  44750. */
  44751. addPointers(): FollowCameraInputsManager;
  44752. /**
  44753. * Add orientation input support to the input manager.
  44754. * @returns the current input manager
  44755. */
  44756. addVRDeviceOrientation(): FollowCameraInputsManager;
  44757. }
  44758. }
  44759. declare module BABYLON {
  44760. /**
  44761. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44762. * an arc rotate version arcFollowCamera are available.
  44763. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44764. */
  44765. export class FollowCamera extends TargetCamera {
  44766. /**
  44767. * Distance the follow camera should follow an object at
  44768. */
  44769. radius: number;
  44770. /**
  44771. * Minimum allowed distance of the camera to the axis of rotation
  44772. * (The camera can not get closer).
  44773. * This can help limiting how the Camera is able to move in the scene.
  44774. */
  44775. lowerRadiusLimit: Nullable<number>;
  44776. /**
  44777. * Maximum allowed distance of the camera to the axis of rotation
  44778. * (The camera can not get further).
  44779. * This can help limiting how the Camera is able to move in the scene.
  44780. */
  44781. upperRadiusLimit: Nullable<number>;
  44782. /**
  44783. * Define a rotation offset between the camera and the object it follows
  44784. */
  44785. rotationOffset: number;
  44786. /**
  44787. * Minimum allowed angle to camera position relative to target object.
  44788. * This can help limiting how the Camera is able to move in the scene.
  44789. */
  44790. lowerRotationOffsetLimit: Nullable<number>;
  44791. /**
  44792. * Maximum allowed angle to camera position relative to target object.
  44793. * This can help limiting how the Camera is able to move in the scene.
  44794. */
  44795. upperRotationOffsetLimit: Nullable<number>;
  44796. /**
  44797. * Define a height offset between the camera and the object it follows.
  44798. * It can help following an object from the top (like a car chaing a plane)
  44799. */
  44800. heightOffset: number;
  44801. /**
  44802. * Minimum allowed height of camera position relative to target object.
  44803. * This can help limiting how the Camera is able to move in the scene.
  44804. */
  44805. lowerHeightOffsetLimit: Nullable<number>;
  44806. /**
  44807. * Maximum allowed height of camera position relative to target object.
  44808. * This can help limiting how the Camera is able to move in the scene.
  44809. */
  44810. upperHeightOffsetLimit: Nullable<number>;
  44811. /**
  44812. * Define how fast the camera can accelerate to follow it s target.
  44813. */
  44814. cameraAcceleration: number;
  44815. /**
  44816. * Define the speed limit of the camera following an object.
  44817. */
  44818. maxCameraSpeed: number;
  44819. /**
  44820. * Define the target of the camera.
  44821. */
  44822. lockedTarget: Nullable<AbstractMesh>;
  44823. /**
  44824. * Defines the input associated with the camera.
  44825. */
  44826. inputs: FollowCameraInputsManager;
  44827. /**
  44828. * Instantiates the follow camera.
  44829. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44830. * @param name Define the name of the camera in the scene
  44831. * @param position Define the position of the camera
  44832. * @param scene Define the scene the camera belong to
  44833. * @param lockedTarget Define the target of the camera
  44834. */
  44835. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44836. private _follow;
  44837. /**
  44838. * Attached controls to the current camera.
  44839. * @param element Defines the element the controls should be listened from
  44840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44841. */
  44842. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44843. /**
  44844. * Detach the current controls from the camera.
  44845. * The camera will stop reacting to inputs.
  44846. * @param element Defines the element to stop listening the inputs from
  44847. */
  44848. detachControl(element: HTMLElement): void;
  44849. /** @hidden */
  44850. _checkInputs(): void;
  44851. private _checkLimits;
  44852. /**
  44853. * Gets the camera class name.
  44854. * @returns the class name
  44855. */
  44856. getClassName(): string;
  44857. }
  44858. /**
  44859. * Arc Rotate version of the follow camera.
  44860. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44861. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44862. */
  44863. export class ArcFollowCamera extends TargetCamera {
  44864. /** The longitudinal angle of the camera */
  44865. alpha: number;
  44866. /** The latitudinal angle of the camera */
  44867. beta: number;
  44868. /** The radius of the camera from its target */
  44869. radius: number;
  44870. private _cartesianCoordinates;
  44871. /** Define the camera target (the mesh it should follow) */
  44872. private _meshTarget;
  44873. /**
  44874. * Instantiates a new ArcFollowCamera
  44875. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44876. * @param name Define the name of the camera
  44877. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44878. * @param beta Define the rotation angle of the camera around the elevation axis
  44879. * @param radius Define the radius of the camera from its target point
  44880. * @param target Define the target of the camera
  44881. * @param scene Define the scene the camera belongs to
  44882. */
  44883. constructor(name: string,
  44884. /** The longitudinal angle of the camera */
  44885. alpha: number,
  44886. /** The latitudinal angle of the camera */
  44887. beta: number,
  44888. /** The radius of the camera from its target */
  44889. radius: number,
  44890. /** Define the camera target (the mesh it should follow) */
  44891. target: Nullable<AbstractMesh>, scene: Scene);
  44892. private _follow;
  44893. /** @hidden */
  44894. _checkInputs(): void;
  44895. /**
  44896. * Returns the class name of the object.
  44897. * It is mostly used internally for serialization purposes.
  44898. */
  44899. getClassName(): string;
  44900. }
  44901. }
  44902. declare module BABYLON {
  44903. /**
  44904. * Manage the keyboard inputs to control the movement of a follow camera.
  44905. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44906. */
  44907. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44908. /**
  44909. * Defines the camera the input is attached to.
  44910. */
  44911. camera: FollowCamera;
  44912. /**
  44913. * Defines the list of key codes associated with the up action (increase heightOffset)
  44914. */
  44915. keysHeightOffsetIncr: number[];
  44916. /**
  44917. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44918. */
  44919. keysHeightOffsetDecr: number[];
  44920. /**
  44921. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44922. */
  44923. keysHeightOffsetModifierAlt: boolean;
  44924. /**
  44925. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44926. */
  44927. keysHeightOffsetModifierCtrl: boolean;
  44928. /**
  44929. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44930. */
  44931. keysHeightOffsetModifierShift: boolean;
  44932. /**
  44933. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44934. */
  44935. keysRotationOffsetIncr: number[];
  44936. /**
  44937. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44938. */
  44939. keysRotationOffsetDecr: number[];
  44940. /**
  44941. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44942. */
  44943. keysRotationOffsetModifierAlt: boolean;
  44944. /**
  44945. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44946. */
  44947. keysRotationOffsetModifierCtrl: boolean;
  44948. /**
  44949. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44950. */
  44951. keysRotationOffsetModifierShift: boolean;
  44952. /**
  44953. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44954. */
  44955. keysRadiusIncr: number[];
  44956. /**
  44957. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44958. */
  44959. keysRadiusDecr: number[];
  44960. /**
  44961. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44962. */
  44963. keysRadiusModifierAlt: boolean;
  44964. /**
  44965. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44966. */
  44967. keysRadiusModifierCtrl: boolean;
  44968. /**
  44969. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44970. */
  44971. keysRadiusModifierShift: boolean;
  44972. /**
  44973. * Defines the rate of change of heightOffset.
  44974. */
  44975. heightSensibility: number;
  44976. /**
  44977. * Defines the rate of change of rotationOffset.
  44978. */
  44979. rotationSensibility: number;
  44980. /**
  44981. * Defines the rate of change of radius.
  44982. */
  44983. radiusSensibility: number;
  44984. private _keys;
  44985. private _ctrlPressed;
  44986. private _altPressed;
  44987. private _shiftPressed;
  44988. private _onCanvasBlurObserver;
  44989. private _onKeyboardObserver;
  44990. private _engine;
  44991. private _scene;
  44992. /**
  44993. * Attach the input controls to a specific dom element to get the input from.
  44994. * @param element Defines the element the controls should be listened from
  44995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44996. */
  44997. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44998. /**
  44999. * Detach the current controls from the specified dom element.
  45000. * @param element Defines the element to stop listening the inputs from
  45001. */
  45002. detachControl(element: Nullable<HTMLElement>): void;
  45003. /**
  45004. * Update the current camera state depending on the inputs that have been used this frame.
  45005. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45006. */
  45007. checkInputs(): void;
  45008. /**
  45009. * Gets the class name of the current input.
  45010. * @returns the class name
  45011. */
  45012. getClassName(): string;
  45013. /**
  45014. * Get the friendly name associated with the input class.
  45015. * @returns the input friendly name
  45016. */
  45017. getSimpleName(): string;
  45018. /**
  45019. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45020. * allow modification of the heightOffset value.
  45021. */
  45022. private _modifierHeightOffset;
  45023. /**
  45024. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45025. * allow modification of the rotationOffset value.
  45026. */
  45027. private _modifierRotationOffset;
  45028. /**
  45029. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45030. * allow modification of the radius value.
  45031. */
  45032. private _modifierRadius;
  45033. }
  45034. }
  45035. declare module BABYLON {
  45036. interface FreeCameraInputsManager {
  45037. /**
  45038. * @hidden
  45039. */
  45040. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45041. /**
  45042. * Add orientation input support to the input manager.
  45043. * @returns the current input manager
  45044. */
  45045. addDeviceOrientation(): FreeCameraInputsManager;
  45046. }
  45047. /**
  45048. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45049. * Screen rotation is taken into account.
  45050. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45051. */
  45052. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45053. private _camera;
  45054. private _screenOrientationAngle;
  45055. private _constantTranform;
  45056. private _screenQuaternion;
  45057. private _alpha;
  45058. private _beta;
  45059. private _gamma;
  45060. /**
  45061. * Can be used to detect if a device orientation sensor is available on a device
  45062. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45063. * @returns a promise that will resolve on orientation change
  45064. */
  45065. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45066. /**
  45067. * @hidden
  45068. */
  45069. _onDeviceOrientationChangedObservable: Observable<void>;
  45070. /**
  45071. * Instantiates a new input
  45072. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45073. */
  45074. constructor();
  45075. /**
  45076. * Define the camera controlled by the input.
  45077. */
  45078. get camera(): FreeCamera;
  45079. set camera(camera: FreeCamera);
  45080. /**
  45081. * Attach the input controls to a specific dom element to get the input from.
  45082. * @param element Defines the element the controls should be listened from
  45083. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45084. */
  45085. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45086. private _orientationChanged;
  45087. private _deviceOrientation;
  45088. /**
  45089. * Detach the current controls from the specified dom element.
  45090. * @param element Defines the element to stop listening the inputs from
  45091. */
  45092. detachControl(element: Nullable<HTMLElement>): void;
  45093. /**
  45094. * Update the current camera state depending on the inputs that have been used this frame.
  45095. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45096. */
  45097. checkInputs(): void;
  45098. /**
  45099. * Gets the class name of the current intput.
  45100. * @returns the class name
  45101. */
  45102. getClassName(): string;
  45103. /**
  45104. * Get the friendly name associated with the input class.
  45105. * @returns the input friendly name
  45106. */
  45107. getSimpleName(): string;
  45108. }
  45109. }
  45110. declare module BABYLON {
  45111. /**
  45112. * Manage the gamepad inputs to control a free camera.
  45113. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45114. */
  45115. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45116. /**
  45117. * Define the camera the input is attached to.
  45118. */
  45119. camera: FreeCamera;
  45120. /**
  45121. * Define the Gamepad controlling the input
  45122. */
  45123. gamepad: Nullable<Gamepad>;
  45124. /**
  45125. * Defines the gamepad rotation sensiblity.
  45126. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45127. */
  45128. gamepadAngularSensibility: number;
  45129. /**
  45130. * Defines the gamepad move sensiblity.
  45131. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45132. */
  45133. gamepadMoveSensibility: number;
  45134. private _yAxisScale;
  45135. /**
  45136. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45137. */
  45138. get invertYAxis(): boolean;
  45139. set invertYAxis(value: boolean);
  45140. private _onGamepadConnectedObserver;
  45141. private _onGamepadDisconnectedObserver;
  45142. private _cameraTransform;
  45143. private _deltaTransform;
  45144. private _vector3;
  45145. private _vector2;
  45146. /**
  45147. * Attach the input controls to a specific dom element to get the input from.
  45148. * @param element Defines the element the controls should be listened from
  45149. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45150. */
  45151. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45152. /**
  45153. * Detach the current controls from the specified dom element.
  45154. * @param element Defines the element to stop listening the inputs from
  45155. */
  45156. detachControl(element: Nullable<HTMLElement>): void;
  45157. /**
  45158. * Update the current camera state depending on the inputs that have been used this frame.
  45159. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45160. */
  45161. checkInputs(): void;
  45162. /**
  45163. * Gets the class name of the current intput.
  45164. * @returns the class name
  45165. */
  45166. getClassName(): string;
  45167. /**
  45168. * Get the friendly name associated with the input class.
  45169. * @returns the input friendly name
  45170. */
  45171. getSimpleName(): string;
  45172. }
  45173. }
  45174. declare module BABYLON {
  45175. /**
  45176. * Defines the potential axis of a Joystick
  45177. */
  45178. export enum JoystickAxis {
  45179. /** X axis */
  45180. X = 0,
  45181. /** Y axis */
  45182. Y = 1,
  45183. /** Z axis */
  45184. Z = 2
  45185. }
  45186. /**
  45187. * Represents the different customization options available
  45188. * for VirtualJoystick
  45189. */
  45190. interface VirtualJoystickCustomizations {
  45191. /**
  45192. * Size of the joystick's puck
  45193. */
  45194. puckSize: number;
  45195. /**
  45196. * Size of the joystick's container
  45197. */
  45198. containerSize: number;
  45199. /**
  45200. * Color of the joystick && puck
  45201. */
  45202. color: string;
  45203. /**
  45204. * Image URL for the joystick's puck
  45205. */
  45206. puckImage?: string;
  45207. /**
  45208. * Image URL for the joystick's container
  45209. */
  45210. containerImage?: string;
  45211. /**
  45212. * Defines the unmoving position of the joystick container
  45213. */
  45214. position?: {
  45215. x: number;
  45216. y: number;
  45217. };
  45218. /**
  45219. * Defines whether or not the joystick container is always visible
  45220. */
  45221. alwaysVisible: boolean;
  45222. /**
  45223. * Defines whether or not to limit the movement of the puck to the joystick's container
  45224. */
  45225. limitToContainer: boolean;
  45226. }
  45227. /**
  45228. * Class used to define virtual joystick (used in touch mode)
  45229. */
  45230. export class VirtualJoystick {
  45231. /**
  45232. * Gets or sets a boolean indicating that left and right values must be inverted
  45233. */
  45234. reverseLeftRight: boolean;
  45235. /**
  45236. * Gets or sets a boolean indicating that up and down values must be inverted
  45237. */
  45238. reverseUpDown: boolean;
  45239. /**
  45240. * Gets the offset value for the position (ie. the change of the position value)
  45241. */
  45242. deltaPosition: Vector3;
  45243. /**
  45244. * Gets a boolean indicating if the virtual joystick was pressed
  45245. */
  45246. pressed: boolean;
  45247. /**
  45248. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45249. */
  45250. static Canvas: Nullable<HTMLCanvasElement>;
  45251. /**
  45252. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45253. */
  45254. limitToContainer: boolean;
  45255. private static _globalJoystickIndex;
  45256. private static _alwaysVisibleSticks;
  45257. private static vjCanvasContext;
  45258. private static vjCanvasWidth;
  45259. private static vjCanvasHeight;
  45260. private static halfWidth;
  45261. private static _GetDefaultOptions;
  45262. private _action;
  45263. private _axisTargetedByLeftAndRight;
  45264. private _axisTargetedByUpAndDown;
  45265. private _joystickSensibility;
  45266. private _inversedSensibility;
  45267. private _joystickPointerID;
  45268. private _joystickColor;
  45269. private _joystickPointerPos;
  45270. private _joystickPreviousPointerPos;
  45271. private _joystickPointerStartPos;
  45272. private _deltaJoystickVector;
  45273. private _leftJoystick;
  45274. private _touches;
  45275. private _joystickPosition;
  45276. private _alwaysVisible;
  45277. private _puckImage;
  45278. private _containerImage;
  45279. private _joystickPuckSize;
  45280. private _joystickContainerSize;
  45281. private _clearPuckSize;
  45282. private _clearContainerSize;
  45283. private _clearPuckSizeOffset;
  45284. private _clearContainerSizeOffset;
  45285. private _onPointerDownHandlerRef;
  45286. private _onPointerMoveHandlerRef;
  45287. private _onPointerUpHandlerRef;
  45288. private _onResize;
  45289. /**
  45290. * Creates a new virtual joystick
  45291. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45292. * @param customizations Defines the options we want to customize the VirtualJoystick
  45293. */
  45294. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45295. /**
  45296. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45297. * @param newJoystickSensibility defines the new sensibility
  45298. */
  45299. setJoystickSensibility(newJoystickSensibility: number): void;
  45300. private _onPointerDown;
  45301. private _onPointerMove;
  45302. private _onPointerUp;
  45303. /**
  45304. * Change the color of the virtual joystick
  45305. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45306. */
  45307. setJoystickColor(newColor: string): void;
  45308. /**
  45309. * Size of the joystick's container
  45310. */
  45311. set containerSize(newSize: number);
  45312. get containerSize(): number;
  45313. /**
  45314. * Size of the joystick's puck
  45315. */
  45316. set puckSize(newSize: number);
  45317. get puckSize(): number;
  45318. /**
  45319. * Clears the set position of the joystick
  45320. */
  45321. clearPosition(): void;
  45322. /**
  45323. * Defines whether or not the joystick container is always visible
  45324. */
  45325. set alwaysVisible(value: boolean);
  45326. get alwaysVisible(): boolean;
  45327. /**
  45328. * Sets the constant position of the Joystick container
  45329. * @param x X axis coordinate
  45330. * @param y Y axis coordinate
  45331. */
  45332. setPosition(x: number, y: number): void;
  45333. /**
  45334. * Defines a callback to call when the joystick is touched
  45335. * @param action defines the callback
  45336. */
  45337. setActionOnTouch(action: () => any): void;
  45338. /**
  45339. * Defines which axis you'd like to control for left & right
  45340. * @param axis defines the axis to use
  45341. */
  45342. setAxisForLeftRight(axis: JoystickAxis): void;
  45343. /**
  45344. * Defines which axis you'd like to control for up & down
  45345. * @param axis defines the axis to use
  45346. */
  45347. setAxisForUpDown(axis: JoystickAxis): void;
  45348. /**
  45349. * Clears the canvas from the previous puck / container draw
  45350. */
  45351. private _clearPreviousDraw;
  45352. /**
  45353. * Loads `urlPath` to be used for the container's image
  45354. * @param urlPath defines the urlPath of an image to use
  45355. */
  45356. setContainerImage(urlPath: string): void;
  45357. /**
  45358. * Loads `urlPath` to be used for the puck's image
  45359. * @param urlPath defines the urlPath of an image to use
  45360. */
  45361. setPuckImage(urlPath: string): void;
  45362. /**
  45363. * Draws the Virtual Joystick's container
  45364. */
  45365. private _drawContainer;
  45366. /**
  45367. * Draws the Virtual Joystick's puck
  45368. */
  45369. private _drawPuck;
  45370. private _drawVirtualJoystick;
  45371. /**
  45372. * Release internal HTML canvas
  45373. */
  45374. releaseCanvas(): void;
  45375. }
  45376. }
  45377. declare module BABYLON {
  45378. interface FreeCameraInputsManager {
  45379. /**
  45380. * Add virtual joystick input support to the input manager.
  45381. * @returns the current input manager
  45382. */
  45383. addVirtualJoystick(): FreeCameraInputsManager;
  45384. }
  45385. /**
  45386. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45387. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45388. */
  45389. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45390. /**
  45391. * Defines the camera the input is attached to.
  45392. */
  45393. camera: FreeCamera;
  45394. private _leftjoystick;
  45395. private _rightjoystick;
  45396. /**
  45397. * Gets the left stick of the virtual joystick.
  45398. * @returns The virtual Joystick
  45399. */
  45400. getLeftJoystick(): VirtualJoystick;
  45401. /**
  45402. * Gets the right stick of the virtual joystick.
  45403. * @returns The virtual Joystick
  45404. */
  45405. getRightJoystick(): VirtualJoystick;
  45406. /**
  45407. * Update the current camera state depending on the inputs that have been used this frame.
  45408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45409. */
  45410. checkInputs(): void;
  45411. /**
  45412. * Attach the input controls to a specific dom element to get the input from.
  45413. * @param element Defines the element the controls should be listened from
  45414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45415. */
  45416. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45417. /**
  45418. * Detach the current controls from the specified dom element.
  45419. * @param element Defines the element to stop listening the inputs from
  45420. */
  45421. detachControl(element: Nullable<HTMLElement>): void;
  45422. /**
  45423. * Gets the class name of the current intput.
  45424. * @returns the class name
  45425. */
  45426. getClassName(): string;
  45427. /**
  45428. * Get the friendly name associated with the input class.
  45429. * @returns the input friendly name
  45430. */
  45431. getSimpleName(): string;
  45432. }
  45433. }
  45434. declare module BABYLON {
  45435. /**
  45436. * This represents a FPS type of camera controlled by touch.
  45437. * This is like a universal camera minus the Gamepad controls.
  45438. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45439. */
  45440. export class TouchCamera extends FreeCamera {
  45441. /**
  45442. * Defines the touch sensibility for rotation.
  45443. * The higher the faster.
  45444. */
  45445. get touchAngularSensibility(): number;
  45446. set touchAngularSensibility(value: number);
  45447. /**
  45448. * Defines the touch sensibility for move.
  45449. * The higher the faster.
  45450. */
  45451. get touchMoveSensibility(): number;
  45452. set touchMoveSensibility(value: number);
  45453. /**
  45454. * Instantiates a new touch camera.
  45455. * This represents a FPS type of camera controlled by touch.
  45456. * This is like a universal camera minus the Gamepad controls.
  45457. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45458. * @param name Define the name of the camera in the scene
  45459. * @param position Define the start position of the camera in the scene
  45460. * @param scene Define the scene the camera belongs to
  45461. */
  45462. constructor(name: string, position: Vector3, scene: Scene);
  45463. /**
  45464. * Gets the current object class name.
  45465. * @return the class name
  45466. */
  45467. getClassName(): string;
  45468. /** @hidden */
  45469. _setupInputs(): void;
  45470. }
  45471. }
  45472. declare module BABYLON {
  45473. /**
  45474. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45475. * being tilted forward or back and left or right.
  45476. */
  45477. export class DeviceOrientationCamera extends FreeCamera {
  45478. private _initialQuaternion;
  45479. private _quaternionCache;
  45480. private _tmpDragQuaternion;
  45481. private _disablePointerInputWhenUsingDeviceOrientation;
  45482. /**
  45483. * Creates a new device orientation camera
  45484. * @param name The name of the camera
  45485. * @param position The start position camera
  45486. * @param scene The scene the camera belongs to
  45487. */
  45488. constructor(name: string, position: Vector3, scene: Scene);
  45489. /**
  45490. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45491. */
  45492. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45493. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45494. private _dragFactor;
  45495. /**
  45496. * Enabled turning on the y axis when the orientation sensor is active
  45497. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45498. */
  45499. enableHorizontalDragging(dragFactor?: number): void;
  45500. /**
  45501. * Gets the current instance class name ("DeviceOrientationCamera").
  45502. * This helps avoiding instanceof at run time.
  45503. * @returns the class name
  45504. */
  45505. getClassName(): string;
  45506. /**
  45507. * @hidden
  45508. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45509. */
  45510. _checkInputs(): void;
  45511. /**
  45512. * Reset the camera to its default orientation on the specified axis only.
  45513. * @param axis The axis to reset
  45514. */
  45515. resetToCurrentRotation(axis?: Axis): void;
  45516. }
  45517. }
  45518. declare module BABYLON {
  45519. /**
  45520. * Defines supported buttons for XBox360 compatible gamepads
  45521. */
  45522. export enum Xbox360Button {
  45523. /** A */
  45524. A = 0,
  45525. /** B */
  45526. B = 1,
  45527. /** X */
  45528. X = 2,
  45529. /** Y */
  45530. Y = 3,
  45531. /** Left button */
  45532. LB = 4,
  45533. /** Right button */
  45534. RB = 5,
  45535. /** Back */
  45536. Back = 8,
  45537. /** Start */
  45538. Start = 9,
  45539. /** Left stick */
  45540. LeftStick = 10,
  45541. /** Right stick */
  45542. RightStick = 11
  45543. }
  45544. /** Defines values for XBox360 DPad */
  45545. export enum Xbox360Dpad {
  45546. /** Up */
  45547. Up = 12,
  45548. /** Down */
  45549. Down = 13,
  45550. /** Left */
  45551. Left = 14,
  45552. /** Right */
  45553. Right = 15
  45554. }
  45555. /**
  45556. * Defines a XBox360 gamepad
  45557. */
  45558. export class Xbox360Pad extends Gamepad {
  45559. private _leftTrigger;
  45560. private _rightTrigger;
  45561. private _onlefttriggerchanged;
  45562. private _onrighttriggerchanged;
  45563. private _onbuttondown;
  45564. private _onbuttonup;
  45565. private _ondpaddown;
  45566. private _ondpadup;
  45567. /** Observable raised when a button is pressed */
  45568. onButtonDownObservable: Observable<Xbox360Button>;
  45569. /** Observable raised when a button is released */
  45570. onButtonUpObservable: Observable<Xbox360Button>;
  45571. /** Observable raised when a pad is pressed */
  45572. onPadDownObservable: Observable<Xbox360Dpad>;
  45573. /** Observable raised when a pad is released */
  45574. onPadUpObservable: Observable<Xbox360Dpad>;
  45575. private _buttonA;
  45576. private _buttonB;
  45577. private _buttonX;
  45578. private _buttonY;
  45579. private _buttonBack;
  45580. private _buttonStart;
  45581. private _buttonLB;
  45582. private _buttonRB;
  45583. private _buttonLeftStick;
  45584. private _buttonRightStick;
  45585. private _dPadUp;
  45586. private _dPadDown;
  45587. private _dPadLeft;
  45588. private _dPadRight;
  45589. private _isXboxOnePad;
  45590. /**
  45591. * Creates a new XBox360 gamepad object
  45592. * @param id defines the id of this gamepad
  45593. * @param index defines its index
  45594. * @param gamepad defines the internal HTML gamepad object
  45595. * @param xboxOne defines if it is a XBox One gamepad
  45596. */
  45597. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45598. /**
  45599. * Defines the callback to call when left trigger is pressed
  45600. * @param callback defines the callback to use
  45601. */
  45602. onlefttriggerchanged(callback: (value: number) => void): void;
  45603. /**
  45604. * Defines the callback to call when right trigger is pressed
  45605. * @param callback defines the callback to use
  45606. */
  45607. onrighttriggerchanged(callback: (value: number) => void): void;
  45608. /**
  45609. * Gets the left trigger value
  45610. */
  45611. get leftTrigger(): number;
  45612. /**
  45613. * Sets the left trigger value
  45614. */
  45615. set leftTrigger(newValue: number);
  45616. /**
  45617. * Gets the right trigger value
  45618. */
  45619. get rightTrigger(): number;
  45620. /**
  45621. * Sets the right trigger value
  45622. */
  45623. set rightTrigger(newValue: number);
  45624. /**
  45625. * Defines the callback to call when a button is pressed
  45626. * @param callback defines the callback to use
  45627. */
  45628. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45629. /**
  45630. * Defines the callback to call when a button is released
  45631. * @param callback defines the callback to use
  45632. */
  45633. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45634. /**
  45635. * Defines the callback to call when a pad is pressed
  45636. * @param callback defines the callback to use
  45637. */
  45638. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45639. /**
  45640. * Defines the callback to call when a pad is released
  45641. * @param callback defines the callback to use
  45642. */
  45643. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45644. private _setButtonValue;
  45645. private _setDPadValue;
  45646. /**
  45647. * Gets the value of the `A` button
  45648. */
  45649. get buttonA(): number;
  45650. /**
  45651. * Sets the value of the `A` button
  45652. */
  45653. set buttonA(value: number);
  45654. /**
  45655. * Gets the value of the `B` button
  45656. */
  45657. get buttonB(): number;
  45658. /**
  45659. * Sets the value of the `B` button
  45660. */
  45661. set buttonB(value: number);
  45662. /**
  45663. * Gets the value of the `X` button
  45664. */
  45665. get buttonX(): number;
  45666. /**
  45667. * Sets the value of the `X` button
  45668. */
  45669. set buttonX(value: number);
  45670. /**
  45671. * Gets the value of the `Y` button
  45672. */
  45673. get buttonY(): number;
  45674. /**
  45675. * Sets the value of the `Y` button
  45676. */
  45677. set buttonY(value: number);
  45678. /**
  45679. * Gets the value of the `Start` button
  45680. */
  45681. get buttonStart(): number;
  45682. /**
  45683. * Sets the value of the `Start` button
  45684. */
  45685. set buttonStart(value: number);
  45686. /**
  45687. * Gets the value of the `Back` button
  45688. */
  45689. get buttonBack(): number;
  45690. /**
  45691. * Sets the value of the `Back` button
  45692. */
  45693. set buttonBack(value: number);
  45694. /**
  45695. * Gets the value of the `Left` button
  45696. */
  45697. get buttonLB(): number;
  45698. /**
  45699. * Sets the value of the `Left` button
  45700. */
  45701. set buttonLB(value: number);
  45702. /**
  45703. * Gets the value of the `Right` button
  45704. */
  45705. get buttonRB(): number;
  45706. /**
  45707. * Sets the value of the `Right` button
  45708. */
  45709. set buttonRB(value: number);
  45710. /**
  45711. * Gets the value of the Left joystick
  45712. */
  45713. get buttonLeftStick(): number;
  45714. /**
  45715. * Sets the value of the Left joystick
  45716. */
  45717. set buttonLeftStick(value: number);
  45718. /**
  45719. * Gets the value of the Right joystick
  45720. */
  45721. get buttonRightStick(): number;
  45722. /**
  45723. * Sets the value of the Right joystick
  45724. */
  45725. set buttonRightStick(value: number);
  45726. /**
  45727. * Gets the value of D-pad up
  45728. */
  45729. get dPadUp(): number;
  45730. /**
  45731. * Sets the value of D-pad up
  45732. */
  45733. set dPadUp(value: number);
  45734. /**
  45735. * Gets the value of D-pad down
  45736. */
  45737. get dPadDown(): number;
  45738. /**
  45739. * Sets the value of D-pad down
  45740. */
  45741. set dPadDown(value: number);
  45742. /**
  45743. * Gets the value of D-pad left
  45744. */
  45745. get dPadLeft(): number;
  45746. /**
  45747. * Sets the value of D-pad left
  45748. */
  45749. set dPadLeft(value: number);
  45750. /**
  45751. * Gets the value of D-pad right
  45752. */
  45753. get dPadRight(): number;
  45754. /**
  45755. * Sets the value of D-pad right
  45756. */
  45757. set dPadRight(value: number);
  45758. /**
  45759. * Force the gamepad to synchronize with device values
  45760. */
  45761. update(): void;
  45762. /**
  45763. * Disposes the gamepad
  45764. */
  45765. dispose(): void;
  45766. }
  45767. }
  45768. declare module BABYLON {
  45769. /**
  45770. * Defines supported buttons for DualShock compatible gamepads
  45771. */
  45772. export enum DualShockButton {
  45773. /** Cross */
  45774. Cross = 0,
  45775. /** Circle */
  45776. Circle = 1,
  45777. /** Square */
  45778. Square = 2,
  45779. /** Triangle */
  45780. Triangle = 3,
  45781. /** L1 */
  45782. L1 = 4,
  45783. /** R1 */
  45784. R1 = 5,
  45785. /** Share */
  45786. Share = 8,
  45787. /** Options */
  45788. Options = 9,
  45789. /** Left stick */
  45790. LeftStick = 10,
  45791. /** Right stick */
  45792. RightStick = 11
  45793. }
  45794. /** Defines values for DualShock DPad */
  45795. export enum DualShockDpad {
  45796. /** Up */
  45797. Up = 12,
  45798. /** Down */
  45799. Down = 13,
  45800. /** Left */
  45801. Left = 14,
  45802. /** Right */
  45803. Right = 15
  45804. }
  45805. /**
  45806. * Defines a DualShock gamepad
  45807. */
  45808. export class DualShockPad extends Gamepad {
  45809. private _leftTrigger;
  45810. private _rightTrigger;
  45811. private _onlefttriggerchanged;
  45812. private _onrighttriggerchanged;
  45813. private _onbuttondown;
  45814. private _onbuttonup;
  45815. private _ondpaddown;
  45816. private _ondpadup;
  45817. /** Observable raised when a button is pressed */
  45818. onButtonDownObservable: Observable<DualShockButton>;
  45819. /** Observable raised when a button is released */
  45820. onButtonUpObservable: Observable<DualShockButton>;
  45821. /** Observable raised when a pad is pressed */
  45822. onPadDownObservable: Observable<DualShockDpad>;
  45823. /** Observable raised when a pad is released */
  45824. onPadUpObservable: Observable<DualShockDpad>;
  45825. private _buttonCross;
  45826. private _buttonCircle;
  45827. private _buttonSquare;
  45828. private _buttonTriangle;
  45829. private _buttonShare;
  45830. private _buttonOptions;
  45831. private _buttonL1;
  45832. private _buttonR1;
  45833. private _buttonLeftStick;
  45834. private _buttonRightStick;
  45835. private _dPadUp;
  45836. private _dPadDown;
  45837. private _dPadLeft;
  45838. private _dPadRight;
  45839. /**
  45840. * Creates a new DualShock gamepad object
  45841. * @param id defines the id of this gamepad
  45842. * @param index defines its index
  45843. * @param gamepad defines the internal HTML gamepad object
  45844. */
  45845. constructor(id: string, index: number, gamepad: any);
  45846. /**
  45847. * Defines the callback to call when left trigger is pressed
  45848. * @param callback defines the callback to use
  45849. */
  45850. onlefttriggerchanged(callback: (value: number) => void): void;
  45851. /**
  45852. * Defines the callback to call when right trigger is pressed
  45853. * @param callback defines the callback to use
  45854. */
  45855. onrighttriggerchanged(callback: (value: number) => void): void;
  45856. /**
  45857. * Gets the left trigger value
  45858. */
  45859. get leftTrigger(): number;
  45860. /**
  45861. * Sets the left trigger value
  45862. */
  45863. set leftTrigger(newValue: number);
  45864. /**
  45865. * Gets the right trigger value
  45866. */
  45867. get rightTrigger(): number;
  45868. /**
  45869. * Sets the right trigger value
  45870. */
  45871. set rightTrigger(newValue: number);
  45872. /**
  45873. * Defines the callback to call when a button is pressed
  45874. * @param callback defines the callback to use
  45875. */
  45876. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45877. /**
  45878. * Defines the callback to call when a button is released
  45879. * @param callback defines the callback to use
  45880. */
  45881. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45882. /**
  45883. * Defines the callback to call when a pad is pressed
  45884. * @param callback defines the callback to use
  45885. */
  45886. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45887. /**
  45888. * Defines the callback to call when a pad is released
  45889. * @param callback defines the callback to use
  45890. */
  45891. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45892. private _setButtonValue;
  45893. private _setDPadValue;
  45894. /**
  45895. * Gets the value of the `Cross` button
  45896. */
  45897. get buttonCross(): number;
  45898. /**
  45899. * Sets the value of the `Cross` button
  45900. */
  45901. set buttonCross(value: number);
  45902. /**
  45903. * Gets the value of the `Circle` button
  45904. */
  45905. get buttonCircle(): number;
  45906. /**
  45907. * Sets the value of the `Circle` button
  45908. */
  45909. set buttonCircle(value: number);
  45910. /**
  45911. * Gets the value of the `Square` button
  45912. */
  45913. get buttonSquare(): number;
  45914. /**
  45915. * Sets the value of the `Square` button
  45916. */
  45917. set buttonSquare(value: number);
  45918. /**
  45919. * Gets the value of the `Triangle` button
  45920. */
  45921. get buttonTriangle(): number;
  45922. /**
  45923. * Sets the value of the `Triangle` button
  45924. */
  45925. set buttonTriangle(value: number);
  45926. /**
  45927. * Gets the value of the `Options` button
  45928. */
  45929. get buttonOptions(): number;
  45930. /**
  45931. * Sets the value of the `Options` button
  45932. */
  45933. set buttonOptions(value: number);
  45934. /**
  45935. * Gets the value of the `Share` button
  45936. */
  45937. get buttonShare(): number;
  45938. /**
  45939. * Sets the value of the `Share` button
  45940. */
  45941. set buttonShare(value: number);
  45942. /**
  45943. * Gets the value of the `L1` button
  45944. */
  45945. get buttonL1(): number;
  45946. /**
  45947. * Sets the value of the `L1` button
  45948. */
  45949. set buttonL1(value: number);
  45950. /**
  45951. * Gets the value of the `R1` button
  45952. */
  45953. get buttonR1(): number;
  45954. /**
  45955. * Sets the value of the `R1` button
  45956. */
  45957. set buttonR1(value: number);
  45958. /**
  45959. * Gets the value of the Left joystick
  45960. */
  45961. get buttonLeftStick(): number;
  45962. /**
  45963. * Sets the value of the Left joystick
  45964. */
  45965. set buttonLeftStick(value: number);
  45966. /**
  45967. * Gets the value of the Right joystick
  45968. */
  45969. get buttonRightStick(): number;
  45970. /**
  45971. * Sets the value of the Right joystick
  45972. */
  45973. set buttonRightStick(value: number);
  45974. /**
  45975. * Gets the value of D-pad up
  45976. */
  45977. get dPadUp(): number;
  45978. /**
  45979. * Sets the value of D-pad up
  45980. */
  45981. set dPadUp(value: number);
  45982. /**
  45983. * Gets the value of D-pad down
  45984. */
  45985. get dPadDown(): number;
  45986. /**
  45987. * Sets the value of D-pad down
  45988. */
  45989. set dPadDown(value: number);
  45990. /**
  45991. * Gets the value of D-pad left
  45992. */
  45993. get dPadLeft(): number;
  45994. /**
  45995. * Sets the value of D-pad left
  45996. */
  45997. set dPadLeft(value: number);
  45998. /**
  45999. * Gets the value of D-pad right
  46000. */
  46001. get dPadRight(): number;
  46002. /**
  46003. * Sets the value of D-pad right
  46004. */
  46005. set dPadRight(value: number);
  46006. /**
  46007. * Force the gamepad to synchronize with device values
  46008. */
  46009. update(): void;
  46010. /**
  46011. * Disposes the gamepad
  46012. */
  46013. dispose(): void;
  46014. }
  46015. }
  46016. declare module BABYLON {
  46017. /**
  46018. * Manager for handling gamepads
  46019. */
  46020. export class GamepadManager {
  46021. private _scene?;
  46022. private _babylonGamepads;
  46023. private _oneGamepadConnected;
  46024. /** @hidden */
  46025. _isMonitoring: boolean;
  46026. private _gamepadEventSupported;
  46027. private _gamepadSupport?;
  46028. /**
  46029. * observable to be triggered when the gamepad controller has been connected
  46030. */
  46031. onGamepadConnectedObservable: Observable<Gamepad>;
  46032. /**
  46033. * observable to be triggered when the gamepad controller has been disconnected
  46034. */
  46035. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46036. private _onGamepadConnectedEvent;
  46037. private _onGamepadDisconnectedEvent;
  46038. /**
  46039. * Initializes the gamepad manager
  46040. * @param _scene BabylonJS scene
  46041. */
  46042. constructor(_scene?: Scene | undefined);
  46043. /**
  46044. * The gamepads in the game pad manager
  46045. */
  46046. get gamepads(): Gamepad[];
  46047. /**
  46048. * Get the gamepad controllers based on type
  46049. * @param type The type of gamepad controller
  46050. * @returns Nullable gamepad
  46051. */
  46052. getGamepadByType(type?: number): Nullable<Gamepad>;
  46053. /**
  46054. * Disposes the gamepad manager
  46055. */
  46056. dispose(): void;
  46057. private _addNewGamepad;
  46058. private _startMonitoringGamepads;
  46059. private _stopMonitoringGamepads;
  46060. /** @hidden */
  46061. _checkGamepadsStatus(): void;
  46062. private _updateGamepadObjects;
  46063. }
  46064. }
  46065. declare module BABYLON {
  46066. interface Scene {
  46067. /** @hidden */
  46068. _gamepadManager: Nullable<GamepadManager>;
  46069. /**
  46070. * Gets the gamepad manager associated with the scene
  46071. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  46072. */
  46073. gamepadManager: GamepadManager;
  46074. }
  46075. /**
  46076. * Interface representing a free camera inputs manager
  46077. */
  46078. interface FreeCameraInputsManager {
  46079. /**
  46080. * Adds gamepad input support to the FreeCameraInputsManager.
  46081. * @returns the FreeCameraInputsManager
  46082. */
  46083. addGamepad(): FreeCameraInputsManager;
  46084. }
  46085. /**
  46086. * Interface representing an arc rotate camera inputs manager
  46087. */
  46088. interface ArcRotateCameraInputsManager {
  46089. /**
  46090. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46091. * @returns the camera inputs manager
  46092. */
  46093. addGamepad(): ArcRotateCameraInputsManager;
  46094. }
  46095. /**
  46096. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46097. */
  46098. export class GamepadSystemSceneComponent implements ISceneComponent {
  46099. /**
  46100. * The component name helpfull to identify the component in the list of scene components.
  46101. */
  46102. readonly name: string;
  46103. /**
  46104. * The scene the component belongs to.
  46105. */
  46106. scene: Scene;
  46107. /**
  46108. * Creates a new instance of the component for the given scene
  46109. * @param scene Defines the scene to register the component in
  46110. */
  46111. constructor(scene: Scene);
  46112. /**
  46113. * Registers the component in a given scene
  46114. */
  46115. register(): void;
  46116. /**
  46117. * Rebuilds the elements related to this component in case of
  46118. * context lost for instance.
  46119. */
  46120. rebuild(): void;
  46121. /**
  46122. * Disposes the component and the associated ressources
  46123. */
  46124. dispose(): void;
  46125. private _beforeCameraUpdate;
  46126. }
  46127. }
  46128. declare module BABYLON {
  46129. /**
  46130. * 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,
  46131. * which still works and will still be found in many Playgrounds.
  46132. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46133. */
  46134. export class UniversalCamera extends TouchCamera {
  46135. /**
  46136. * Defines the gamepad rotation sensiblity.
  46137. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46138. */
  46139. get gamepadAngularSensibility(): number;
  46140. set gamepadAngularSensibility(value: number);
  46141. /**
  46142. * Defines the gamepad move sensiblity.
  46143. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46144. */
  46145. get gamepadMoveSensibility(): number;
  46146. set gamepadMoveSensibility(value: number);
  46147. /**
  46148. * 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,
  46149. * which still works and will still be found in many Playgrounds.
  46150. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46151. * @param name Define the name of the camera in the scene
  46152. * @param position Define the start position of the camera in the scene
  46153. * @param scene Define the scene the camera belongs to
  46154. */
  46155. constructor(name: string, position: Vector3, scene: Scene);
  46156. /**
  46157. * Gets the current object class name.
  46158. * @return the class name
  46159. */
  46160. getClassName(): string;
  46161. }
  46162. }
  46163. declare module BABYLON {
  46164. /**
  46165. * This represents a FPS type of camera. This is only here for back compat purpose.
  46166. * Please use the UniversalCamera instead as both are identical.
  46167. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46168. */
  46169. export class GamepadCamera extends UniversalCamera {
  46170. /**
  46171. * Instantiates a new Gamepad Camera
  46172. * This represents a FPS type of camera. This is only here for back compat purpose.
  46173. * Please use the UniversalCamera instead as both are identical.
  46174. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46175. * @param name Define the name of the camera in the scene
  46176. * @param position Define the start position of the camera in the scene
  46177. * @param scene Define the scene the camera belongs to
  46178. */
  46179. constructor(name: string, position: Vector3, scene: Scene);
  46180. /**
  46181. * Gets the current object class name.
  46182. * @return the class name
  46183. */
  46184. getClassName(): string;
  46185. }
  46186. }
  46187. declare module BABYLON {
  46188. /** @hidden */
  46189. export var passPixelShader: {
  46190. name: string;
  46191. shader: string;
  46192. };
  46193. }
  46194. declare module BABYLON {
  46195. /** @hidden */
  46196. export var passCubePixelShader: {
  46197. name: string;
  46198. shader: string;
  46199. };
  46200. }
  46201. declare module BABYLON {
  46202. /**
  46203. * PassPostProcess which produces an output the same as it's input
  46204. */
  46205. export class PassPostProcess extends PostProcess {
  46206. /**
  46207. * Gets a string identifying the name of the class
  46208. * @returns "PassPostProcess" string
  46209. */
  46210. getClassName(): string;
  46211. /**
  46212. * Creates the PassPostProcess
  46213. * @param name The name of the effect.
  46214. * @param options The required width/height ratio to downsize to before computing the render pass.
  46215. * @param camera The camera to apply the render pass to.
  46216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46217. * @param engine The engine which the post process will be applied. (default: current engine)
  46218. * @param reusable If the post process can be reused on the same frame. (default: false)
  46219. * @param textureType The type of texture to be used when performing the post processing.
  46220. * @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)
  46221. */
  46222. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46223. /** @hidden */
  46224. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46225. }
  46226. /**
  46227. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46228. */
  46229. export class PassCubePostProcess extends PostProcess {
  46230. private _face;
  46231. /**
  46232. * Gets or sets the cube face to display.
  46233. * * 0 is +X
  46234. * * 1 is -X
  46235. * * 2 is +Y
  46236. * * 3 is -Y
  46237. * * 4 is +Z
  46238. * * 5 is -Z
  46239. */
  46240. get face(): number;
  46241. set face(value: number);
  46242. /**
  46243. * Gets a string identifying the name of the class
  46244. * @returns "PassCubePostProcess" string
  46245. */
  46246. getClassName(): string;
  46247. /**
  46248. * Creates the PassCubePostProcess
  46249. * @param name The name of the effect.
  46250. * @param options The required width/height ratio to downsize to before computing the render pass.
  46251. * @param camera The camera to apply the render pass to.
  46252. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46253. * @param engine The engine which the post process will be applied. (default: current engine)
  46254. * @param reusable If the post process can be reused on the same frame. (default: false)
  46255. * @param textureType The type of texture to be used when performing the post processing.
  46256. * @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)
  46257. */
  46258. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46259. /** @hidden */
  46260. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46261. }
  46262. }
  46263. declare module BABYLON {
  46264. /** @hidden */
  46265. export var anaglyphPixelShader: {
  46266. name: string;
  46267. shader: string;
  46268. };
  46269. }
  46270. declare module BABYLON {
  46271. /**
  46272. * Postprocess used to generate anaglyphic rendering
  46273. */
  46274. export class AnaglyphPostProcess extends PostProcess {
  46275. private _passedProcess;
  46276. /**
  46277. * Gets a string identifying the name of the class
  46278. * @returns "AnaglyphPostProcess" string
  46279. */
  46280. getClassName(): string;
  46281. /**
  46282. * Creates a new AnaglyphPostProcess
  46283. * @param name defines postprocess name
  46284. * @param options defines creation options or target ratio scale
  46285. * @param rigCameras defines cameras using this postprocess
  46286. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46287. * @param engine defines hosting engine
  46288. * @param reusable defines if the postprocess will be reused multiple times per frame
  46289. */
  46290. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46291. }
  46292. }
  46293. declare module BABYLON {
  46294. /**
  46295. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46296. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46297. */
  46298. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46299. /**
  46300. * Creates a new AnaglyphArcRotateCamera
  46301. * @param name defines camera name
  46302. * @param alpha defines alpha angle (in radians)
  46303. * @param beta defines beta angle (in radians)
  46304. * @param radius defines radius
  46305. * @param target defines camera target
  46306. * @param interaxialDistance defines distance between each color axis
  46307. * @param scene defines the hosting scene
  46308. */
  46309. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46310. /**
  46311. * Gets camera class name
  46312. * @returns AnaglyphArcRotateCamera
  46313. */
  46314. getClassName(): string;
  46315. }
  46316. }
  46317. declare module BABYLON {
  46318. /**
  46319. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46320. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46321. */
  46322. export class AnaglyphFreeCamera extends FreeCamera {
  46323. /**
  46324. * Creates a new AnaglyphFreeCamera
  46325. * @param name defines camera name
  46326. * @param position defines initial position
  46327. * @param interaxialDistance defines distance between each color axis
  46328. * @param scene defines the hosting scene
  46329. */
  46330. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46331. /**
  46332. * Gets camera class name
  46333. * @returns AnaglyphFreeCamera
  46334. */
  46335. getClassName(): string;
  46336. }
  46337. }
  46338. declare module BABYLON {
  46339. /**
  46340. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46341. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46342. */
  46343. export class AnaglyphGamepadCamera extends GamepadCamera {
  46344. /**
  46345. * Creates a new AnaglyphGamepadCamera
  46346. * @param name defines camera name
  46347. * @param position defines initial position
  46348. * @param interaxialDistance defines distance between each color axis
  46349. * @param scene defines the hosting scene
  46350. */
  46351. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46352. /**
  46353. * Gets camera class name
  46354. * @returns AnaglyphGamepadCamera
  46355. */
  46356. getClassName(): string;
  46357. }
  46358. }
  46359. declare module BABYLON {
  46360. /**
  46361. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46362. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46363. */
  46364. export class AnaglyphUniversalCamera extends UniversalCamera {
  46365. /**
  46366. * Creates a new AnaglyphUniversalCamera
  46367. * @param name defines camera name
  46368. * @param position defines initial position
  46369. * @param interaxialDistance defines distance between each color axis
  46370. * @param scene defines the hosting scene
  46371. */
  46372. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46373. /**
  46374. * Gets camera class name
  46375. * @returns AnaglyphUniversalCamera
  46376. */
  46377. getClassName(): string;
  46378. }
  46379. }
  46380. declare module BABYLON {
  46381. /**
  46382. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46383. * @see https://doc.babylonjs.com/features/cameras
  46384. */
  46385. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46386. /**
  46387. * Creates a new StereoscopicArcRotateCamera
  46388. * @param name defines camera name
  46389. * @param alpha defines alpha angle (in radians)
  46390. * @param beta defines beta angle (in radians)
  46391. * @param radius defines radius
  46392. * @param target defines camera target
  46393. * @param interaxialDistance defines distance between each color axis
  46394. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46395. * @param scene defines the hosting scene
  46396. */
  46397. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46398. /**
  46399. * Gets camera class name
  46400. * @returns StereoscopicArcRotateCamera
  46401. */
  46402. getClassName(): string;
  46403. }
  46404. }
  46405. declare module BABYLON {
  46406. /**
  46407. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46408. * @see https://doc.babylonjs.com/features/cameras
  46409. */
  46410. export class StereoscopicFreeCamera extends FreeCamera {
  46411. /**
  46412. * Creates a new StereoscopicFreeCamera
  46413. * @param name defines camera name
  46414. * @param position defines initial position
  46415. * @param interaxialDistance defines distance between each color axis
  46416. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46417. * @param scene defines the hosting scene
  46418. */
  46419. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46420. /**
  46421. * Gets camera class name
  46422. * @returns StereoscopicFreeCamera
  46423. */
  46424. getClassName(): string;
  46425. }
  46426. }
  46427. declare module BABYLON {
  46428. /**
  46429. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46430. * @see https://doc.babylonjs.com/features/cameras
  46431. */
  46432. export class StereoscopicGamepadCamera extends GamepadCamera {
  46433. /**
  46434. * Creates a new StereoscopicGamepadCamera
  46435. * @param name defines camera name
  46436. * @param position defines initial position
  46437. * @param interaxialDistance defines distance between each color axis
  46438. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46439. * @param scene defines the hosting scene
  46440. */
  46441. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46442. /**
  46443. * Gets camera class name
  46444. * @returns StereoscopicGamepadCamera
  46445. */
  46446. getClassName(): string;
  46447. }
  46448. }
  46449. declare module BABYLON {
  46450. /**
  46451. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46452. * @see https://doc.babylonjs.com/features/cameras
  46453. */
  46454. export class StereoscopicUniversalCamera extends UniversalCamera {
  46455. /**
  46456. * Creates a new StereoscopicUniversalCamera
  46457. * @param name defines camera name
  46458. * @param position defines initial position
  46459. * @param interaxialDistance defines distance between each color axis
  46460. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46461. * @param scene defines the hosting scene
  46462. */
  46463. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46464. /**
  46465. * Gets camera class name
  46466. * @returns StereoscopicUniversalCamera
  46467. */
  46468. getClassName(): string;
  46469. }
  46470. }
  46471. declare module BABYLON {
  46472. /**
  46473. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46474. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46475. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46476. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46477. */
  46478. export class VirtualJoysticksCamera extends FreeCamera {
  46479. /**
  46480. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46481. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46482. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46483. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46484. * @param name Define the name of the camera in the scene
  46485. * @param position Define the start position of the camera in the scene
  46486. * @param scene Define the scene the camera belongs to
  46487. */
  46488. constructor(name: string, position: Vector3, scene: Scene);
  46489. /**
  46490. * Gets the current object class name.
  46491. * @return the class name
  46492. */
  46493. getClassName(): string;
  46494. }
  46495. }
  46496. declare module BABYLON {
  46497. /**
  46498. * This represents all the required metrics to create a VR camera.
  46499. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46500. */
  46501. export class VRCameraMetrics {
  46502. /**
  46503. * Define the horizontal resolution off the screen.
  46504. */
  46505. hResolution: number;
  46506. /**
  46507. * Define the vertical resolution off the screen.
  46508. */
  46509. vResolution: number;
  46510. /**
  46511. * Define the horizontal screen size.
  46512. */
  46513. hScreenSize: number;
  46514. /**
  46515. * Define the vertical screen size.
  46516. */
  46517. vScreenSize: number;
  46518. /**
  46519. * Define the vertical screen center position.
  46520. */
  46521. vScreenCenter: number;
  46522. /**
  46523. * Define the distance of the eyes to the screen.
  46524. */
  46525. eyeToScreenDistance: number;
  46526. /**
  46527. * Define the distance between both lenses
  46528. */
  46529. lensSeparationDistance: number;
  46530. /**
  46531. * Define the distance between both viewer's eyes.
  46532. */
  46533. interpupillaryDistance: number;
  46534. /**
  46535. * Define the distortion factor of the VR postprocess.
  46536. * Please, touch with care.
  46537. */
  46538. distortionK: number[];
  46539. /**
  46540. * Define the chromatic aberration correction factors for the VR post process.
  46541. */
  46542. chromaAbCorrection: number[];
  46543. /**
  46544. * Define the scale factor of the post process.
  46545. * The smaller the better but the slower.
  46546. */
  46547. postProcessScaleFactor: number;
  46548. /**
  46549. * Define an offset for the lens center.
  46550. */
  46551. lensCenterOffset: number;
  46552. /**
  46553. * Define if the current vr camera should compensate the distortion of the lense or not.
  46554. */
  46555. compensateDistortion: boolean;
  46556. /**
  46557. * Defines if multiview should be enabled when rendering (Default: false)
  46558. */
  46559. multiviewEnabled: boolean;
  46560. /**
  46561. * Gets the rendering aspect ratio based on the provided resolutions.
  46562. */
  46563. get aspectRatio(): number;
  46564. /**
  46565. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46566. */
  46567. get aspectRatioFov(): number;
  46568. /**
  46569. * @hidden
  46570. */
  46571. get leftHMatrix(): Matrix;
  46572. /**
  46573. * @hidden
  46574. */
  46575. get rightHMatrix(): Matrix;
  46576. /**
  46577. * @hidden
  46578. */
  46579. get leftPreViewMatrix(): Matrix;
  46580. /**
  46581. * @hidden
  46582. */
  46583. get rightPreViewMatrix(): Matrix;
  46584. /**
  46585. * Get the default VRMetrics based on the most generic setup.
  46586. * @returns the default vr metrics
  46587. */
  46588. static GetDefault(): VRCameraMetrics;
  46589. }
  46590. }
  46591. declare module BABYLON {
  46592. /** @hidden */
  46593. export var vrDistortionCorrectionPixelShader: {
  46594. name: string;
  46595. shader: string;
  46596. };
  46597. }
  46598. declare module BABYLON {
  46599. /**
  46600. * VRDistortionCorrectionPostProcess used for mobile VR
  46601. */
  46602. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46603. private _isRightEye;
  46604. private _distortionFactors;
  46605. private _postProcessScaleFactor;
  46606. private _lensCenterOffset;
  46607. private _scaleIn;
  46608. private _scaleFactor;
  46609. private _lensCenter;
  46610. /**
  46611. * Gets a string identifying the name of the class
  46612. * @returns "VRDistortionCorrectionPostProcess" string
  46613. */
  46614. getClassName(): string;
  46615. /**
  46616. * Initializes the VRDistortionCorrectionPostProcess
  46617. * @param name The name of the effect.
  46618. * @param camera The camera to apply the render pass to.
  46619. * @param isRightEye If this is for the right eye distortion
  46620. * @param vrMetrics All the required metrics for the VR camera
  46621. */
  46622. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46623. }
  46624. }
  46625. declare module BABYLON {
  46626. /**
  46627. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46628. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46629. */
  46630. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46631. /**
  46632. * Creates a new VRDeviceOrientationArcRotateCamera
  46633. * @param name defines camera name
  46634. * @param alpha defines the camera rotation along the logitudinal axis
  46635. * @param beta defines the camera rotation along the latitudinal axis
  46636. * @param radius defines the camera distance from its target
  46637. * @param target defines the camera target
  46638. * @param scene defines the scene the camera belongs to
  46639. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46640. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46641. */
  46642. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46643. /**
  46644. * Gets camera class name
  46645. * @returns VRDeviceOrientationArcRotateCamera
  46646. */
  46647. getClassName(): string;
  46648. }
  46649. }
  46650. declare module BABYLON {
  46651. /**
  46652. * Camera used to simulate VR rendering (based on FreeCamera)
  46653. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46654. */
  46655. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46656. /**
  46657. * Creates a new VRDeviceOrientationFreeCamera
  46658. * @param name defines camera name
  46659. * @param position defines the start position of the camera
  46660. * @param scene defines the scene the camera belongs to
  46661. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46662. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46663. */
  46664. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46665. /**
  46666. * Gets camera class name
  46667. * @returns VRDeviceOrientationFreeCamera
  46668. */
  46669. getClassName(): string;
  46670. }
  46671. }
  46672. declare module BABYLON {
  46673. /**
  46674. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46675. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46676. */
  46677. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46678. /**
  46679. * Creates a new VRDeviceOrientationGamepadCamera
  46680. * @param name defines camera name
  46681. * @param position defines the start position of the camera
  46682. * @param scene defines the scene the camera belongs to
  46683. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46684. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46685. */
  46686. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46687. /**
  46688. * Gets camera class name
  46689. * @returns VRDeviceOrientationGamepadCamera
  46690. */
  46691. getClassName(): string;
  46692. }
  46693. }
  46694. declare module BABYLON {
  46695. /**
  46696. * A class extending Texture allowing drawing on a texture
  46697. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46698. */
  46699. export class DynamicTexture extends Texture {
  46700. private _generateMipMaps;
  46701. private _canvas;
  46702. private _context;
  46703. /**
  46704. * Creates a DynamicTexture
  46705. * @param name defines the name of the texture
  46706. * @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
  46707. * @param scene defines the scene where you want the texture
  46708. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46709. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46710. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46711. */
  46712. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46713. /**
  46714. * Get the current class name of the texture useful for serialization or dynamic coding.
  46715. * @returns "DynamicTexture"
  46716. */
  46717. getClassName(): string;
  46718. /**
  46719. * Gets the current state of canRescale
  46720. */
  46721. get canRescale(): boolean;
  46722. private _recreate;
  46723. /**
  46724. * Scales the texture
  46725. * @param ratio the scale factor to apply to both width and height
  46726. */
  46727. scale(ratio: number): void;
  46728. /**
  46729. * Resizes the texture
  46730. * @param width the new width
  46731. * @param height the new height
  46732. */
  46733. scaleTo(width: number, height: number): void;
  46734. /**
  46735. * Gets the context of the canvas used by the texture
  46736. * @returns the canvas context of the dynamic texture
  46737. */
  46738. getContext(): CanvasRenderingContext2D;
  46739. /**
  46740. * Clears the texture
  46741. */
  46742. clear(): void;
  46743. /**
  46744. * Updates the texture
  46745. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46746. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46747. */
  46748. update(invertY?: boolean, premulAlpha?: boolean): void;
  46749. /**
  46750. * Draws text onto the texture
  46751. * @param text defines the text to be drawn
  46752. * @param x defines the placement of the text from the left
  46753. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46754. * @param font defines the font to be used with font-style, font-size, font-name
  46755. * @param color defines the color used for the text
  46756. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46757. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46758. * @param update defines whether texture is immediately update (default is true)
  46759. */
  46760. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46761. /**
  46762. * Clones the texture
  46763. * @returns the clone of the texture.
  46764. */
  46765. clone(): DynamicTexture;
  46766. /**
  46767. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46768. * @returns a serialized dynamic texture object
  46769. */
  46770. serialize(): any;
  46771. private _IsCanvasElement;
  46772. /** @hidden */
  46773. _rebuild(): void;
  46774. }
  46775. }
  46776. declare module BABYLON {
  46777. /**
  46778. * Class containing static functions to help procedurally build meshes
  46779. */
  46780. export class GroundBuilder {
  46781. /**
  46782. * Creates a ground mesh
  46783. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46784. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46786. * @param name defines the name of the mesh
  46787. * @param options defines the options used to create the mesh
  46788. * @param scene defines the hosting scene
  46789. * @returns the ground mesh
  46790. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46791. */
  46792. static CreateGround(name: string, options: {
  46793. width?: number;
  46794. height?: number;
  46795. subdivisions?: number;
  46796. subdivisionsX?: number;
  46797. subdivisionsY?: number;
  46798. updatable?: boolean;
  46799. }, scene: any): Mesh;
  46800. /**
  46801. * Creates a tiled ground mesh
  46802. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46803. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46804. * * 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
  46805. * * 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
  46806. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46807. * @param name defines the name of the mesh
  46808. * @param options defines the options used to create the mesh
  46809. * @param scene defines the hosting scene
  46810. * @returns the tiled ground mesh
  46811. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46812. */
  46813. static CreateTiledGround(name: string, options: {
  46814. xmin: number;
  46815. zmin: number;
  46816. xmax: number;
  46817. zmax: number;
  46818. subdivisions?: {
  46819. w: number;
  46820. h: number;
  46821. };
  46822. precision?: {
  46823. w: number;
  46824. h: number;
  46825. };
  46826. updatable?: boolean;
  46827. }, scene?: Nullable<Scene>): Mesh;
  46828. /**
  46829. * Creates a ground mesh from a height map
  46830. * * The parameter `url` sets the URL of the height map image resource.
  46831. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46832. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46833. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46834. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46835. * * 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.
  46836. * * 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).
  46837. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46839. * @param name defines the name of the mesh
  46840. * @param url defines the url to the height map
  46841. * @param options defines the options used to create the mesh
  46842. * @param scene defines the hosting scene
  46843. * @returns the ground mesh
  46844. * @see https://doc.babylonjs.com/babylon101/height_map
  46845. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46846. */
  46847. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46848. width?: number;
  46849. height?: number;
  46850. subdivisions?: number;
  46851. minHeight?: number;
  46852. maxHeight?: number;
  46853. colorFilter?: Color3;
  46854. alphaFilter?: number;
  46855. updatable?: boolean;
  46856. onReady?: (mesh: GroundMesh) => void;
  46857. }, scene?: Nullable<Scene>): GroundMesh;
  46858. }
  46859. }
  46860. declare module BABYLON {
  46861. /**
  46862. * Class containing static functions to help procedurally build meshes
  46863. */
  46864. export class TorusBuilder {
  46865. /**
  46866. * Creates a torus mesh
  46867. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46868. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46869. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46870. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46871. * * 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
  46872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46873. * @param name defines the name of the mesh
  46874. * @param options defines the options used to create the mesh
  46875. * @param scene defines the hosting scene
  46876. * @returns the torus mesh
  46877. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46878. */
  46879. static CreateTorus(name: string, options: {
  46880. diameter?: number;
  46881. thickness?: number;
  46882. tessellation?: number;
  46883. updatable?: boolean;
  46884. sideOrientation?: number;
  46885. frontUVs?: Vector4;
  46886. backUVs?: Vector4;
  46887. }, scene: any): Mesh;
  46888. }
  46889. }
  46890. declare module BABYLON {
  46891. /**
  46892. * Class containing static functions to help procedurally build meshes
  46893. */
  46894. export class CylinderBuilder {
  46895. /**
  46896. * Creates a cylinder or a cone mesh
  46897. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46898. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46899. * * 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.
  46900. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46901. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46902. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46903. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46904. * * 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).
  46905. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46906. * * 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).
  46907. * * 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
  46908. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46909. * * 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
  46910. * * 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.
  46911. * * If `enclose` is false, a ring surface is one element.
  46912. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46913. * * 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
  46914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46915. * * 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
  46916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46917. * @param name defines the name of the mesh
  46918. * @param options defines the options used to create the mesh
  46919. * @param scene defines the hosting scene
  46920. * @returns the cylinder mesh
  46921. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46922. */
  46923. static CreateCylinder(name: string, options: {
  46924. height?: number;
  46925. diameterTop?: number;
  46926. diameterBottom?: number;
  46927. diameter?: number;
  46928. tessellation?: number;
  46929. subdivisions?: number;
  46930. arc?: number;
  46931. faceColors?: Color4[];
  46932. faceUV?: Vector4[];
  46933. updatable?: boolean;
  46934. hasRings?: boolean;
  46935. enclose?: boolean;
  46936. cap?: number;
  46937. sideOrientation?: number;
  46938. frontUVs?: Vector4;
  46939. backUVs?: Vector4;
  46940. }, scene: any): Mesh;
  46941. }
  46942. }
  46943. declare module BABYLON {
  46944. /**
  46945. * States of the webXR experience
  46946. */
  46947. export enum WebXRState {
  46948. /**
  46949. * Transitioning to being in XR mode
  46950. */
  46951. ENTERING_XR = 0,
  46952. /**
  46953. * Transitioning to non XR mode
  46954. */
  46955. EXITING_XR = 1,
  46956. /**
  46957. * In XR mode and presenting
  46958. */
  46959. IN_XR = 2,
  46960. /**
  46961. * Not entered XR mode
  46962. */
  46963. NOT_IN_XR = 3
  46964. }
  46965. /**
  46966. * Abstraction of the XR render target
  46967. */
  46968. export interface WebXRRenderTarget extends IDisposable {
  46969. /**
  46970. * xrpresent context of the canvas which can be used to display/mirror xr content
  46971. */
  46972. canvasContext: WebGLRenderingContext;
  46973. /**
  46974. * xr layer for the canvas
  46975. */
  46976. xrLayer: Nullable<XRWebGLLayer>;
  46977. /**
  46978. * Initializes the xr layer for the session
  46979. * @param xrSession xr session
  46980. * @returns a promise that will resolve once the XR Layer has been created
  46981. */
  46982. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46983. }
  46984. }
  46985. declare module BABYLON {
  46986. /**
  46987. * COnfiguration object for WebXR output canvas
  46988. */
  46989. export class WebXRManagedOutputCanvasOptions {
  46990. /**
  46991. * An optional canvas in case you wish to create it yourself and provide it here.
  46992. * If not provided, a new canvas will be created
  46993. */
  46994. canvasElement?: HTMLCanvasElement;
  46995. /**
  46996. * Options for this XR Layer output
  46997. */
  46998. canvasOptions?: XRWebGLLayerOptions;
  46999. /**
  47000. * CSS styling for a newly created canvas (if not provided)
  47001. */
  47002. newCanvasCssStyle?: string;
  47003. /**
  47004. * Get the default values of the configuration object
  47005. * @param engine defines the engine to use (can be null)
  47006. * @returns default values of this configuration object
  47007. */
  47008. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  47009. }
  47010. /**
  47011. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47012. */
  47013. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47014. private _options;
  47015. private _canvas;
  47016. private _engine;
  47017. private _originalCanvasSize;
  47018. /**
  47019. * Rendering context of the canvas which can be used to display/mirror xr content
  47020. */
  47021. canvasContext: WebGLRenderingContext;
  47022. /**
  47023. * xr layer for the canvas
  47024. */
  47025. xrLayer: Nullable<XRWebGLLayer>;
  47026. /**
  47027. * Obseervers registered here will be triggered when the xr layer was initialized
  47028. */
  47029. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  47030. /**
  47031. * Initializes the canvas to be added/removed upon entering/exiting xr
  47032. * @param _xrSessionManager The XR Session manager
  47033. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47034. */
  47035. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47036. /**
  47037. * Disposes of the object
  47038. */
  47039. dispose(): void;
  47040. /**
  47041. * Initializes the xr layer for the session
  47042. * @param xrSession xr session
  47043. * @returns a promise that will resolve once the XR Layer has been created
  47044. */
  47045. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47046. private _addCanvas;
  47047. private _removeCanvas;
  47048. private _setCanvasSize;
  47049. private _setManagedOutputCanvas;
  47050. }
  47051. }
  47052. declare module BABYLON {
  47053. /**
  47054. * Manages an XRSession to work with Babylon's engine
  47055. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  47056. */
  47057. export class WebXRSessionManager implements IDisposable {
  47058. /** The scene which the session should be created for */
  47059. scene: Scene;
  47060. private _referenceSpace;
  47061. private _rttProvider;
  47062. private _sessionEnded;
  47063. private _xrNavigator;
  47064. private baseLayer;
  47065. /**
  47066. * The base reference space from which the session started. good if you want to reset your
  47067. * reference space
  47068. */
  47069. baseReferenceSpace: XRReferenceSpace;
  47070. /**
  47071. * Current XR frame
  47072. */
  47073. currentFrame: Nullable<XRFrame>;
  47074. /** WebXR timestamp updated every frame */
  47075. currentTimestamp: number;
  47076. /**
  47077. * Used just in case of a failure to initialize an immersive session.
  47078. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47079. */
  47080. defaultHeightCompensation: number;
  47081. /**
  47082. * Fires every time a new xrFrame arrives which can be used to update the camera
  47083. */
  47084. onXRFrameObservable: Observable<XRFrame>;
  47085. /**
  47086. * Fires when the reference space changed
  47087. */
  47088. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47089. /**
  47090. * Fires when the xr session is ended either by the device or manually done
  47091. */
  47092. onXRSessionEnded: Observable<any>;
  47093. /**
  47094. * Fires when the xr session is ended either by the device or manually done
  47095. */
  47096. onXRSessionInit: Observable<XRSession>;
  47097. /**
  47098. * Underlying xr session
  47099. */
  47100. session: XRSession;
  47101. /**
  47102. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47103. * or get the offset the player is currently at.
  47104. */
  47105. viewerReferenceSpace: XRReferenceSpace;
  47106. /**
  47107. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47108. * @param scene The scene which the session should be created for
  47109. */
  47110. constructor(
  47111. /** The scene which the session should be created for */
  47112. scene: Scene);
  47113. /**
  47114. * The current reference space used in this session. This reference space can constantly change!
  47115. * It is mainly used to offset the camera's position.
  47116. */
  47117. get referenceSpace(): XRReferenceSpace;
  47118. /**
  47119. * Set a new reference space and triggers the observable
  47120. */
  47121. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47122. /**
  47123. * Disposes of the session manager
  47124. */
  47125. dispose(): void;
  47126. /**
  47127. * Stops the xrSession and restores the render loop
  47128. * @returns Promise which resolves after it exits XR
  47129. */
  47130. exitXRAsync(): Promise<void>;
  47131. /**
  47132. * Gets the correct render target texture to be rendered this frame for this eye
  47133. * @param eye the eye for which to get the render target
  47134. * @returns the render target for the specified eye
  47135. */
  47136. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47137. /**
  47138. * Creates a WebXRRenderTarget object for the XR session
  47139. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47140. * @param options optional options to provide when creating a new render target
  47141. * @returns a WebXR render target to which the session can render
  47142. */
  47143. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47144. /**
  47145. * Initializes the manager
  47146. * After initialization enterXR can be called to start an XR session
  47147. * @returns Promise which resolves after it is initialized
  47148. */
  47149. initializeAsync(): Promise<void>;
  47150. /**
  47151. * Initializes an xr session
  47152. * @param xrSessionMode mode to initialize
  47153. * @param xrSessionInit defines optional and required values to pass to the session builder
  47154. * @returns a promise which will resolve once the session has been initialized
  47155. */
  47156. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47157. /**
  47158. * Checks if a session would be supported for the creation options specified
  47159. * @param sessionMode session mode to check if supported eg. immersive-vr
  47160. * @returns A Promise that resolves to true if supported and false if not
  47161. */
  47162. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47163. /**
  47164. * Resets the reference space to the one started the session
  47165. */
  47166. resetReferenceSpace(): void;
  47167. /**
  47168. * Starts rendering to the xr layer
  47169. */
  47170. runXRRenderLoop(): void;
  47171. /**
  47172. * Sets the reference space on the xr session
  47173. * @param referenceSpaceType space to set
  47174. * @returns a promise that will resolve once the reference space has been set
  47175. */
  47176. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47177. /**
  47178. * Updates the render state of the session
  47179. * @param state state to set
  47180. * @returns a promise that resolves once the render state has been updated
  47181. */
  47182. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47183. /**
  47184. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47185. * @param sessionMode defines the session to test
  47186. * @returns a promise with boolean as final value
  47187. */
  47188. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47189. private _createRenderTargetTexture;
  47190. }
  47191. }
  47192. declare module BABYLON {
  47193. /**
  47194. * WebXR Camera which holds the views for the xrSession
  47195. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47196. */
  47197. export class WebXRCamera extends FreeCamera {
  47198. private _xrSessionManager;
  47199. private _firstFrame;
  47200. private _referenceQuaternion;
  47201. private _referencedPosition;
  47202. private _xrInvPositionCache;
  47203. private _xrInvQuaternionCache;
  47204. /**
  47205. * Observable raised before camera teleportation
  47206. */
  47207. onBeforeCameraTeleport: Observable<Vector3>;
  47208. /**
  47209. * Observable raised after camera teleportation
  47210. */
  47211. onAfterCameraTeleport: Observable<Vector3>;
  47212. /**
  47213. * Should position compensation execute on first frame.
  47214. * This is used when copying the position from a native (non XR) camera
  47215. */
  47216. compensateOnFirstFrame: boolean;
  47217. /**
  47218. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47219. * @param name the name of the camera
  47220. * @param scene the scene to add the camera to
  47221. * @param _xrSessionManager a constructed xr session manager
  47222. */
  47223. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47224. /**
  47225. * Return the user's height, unrelated to the current ground.
  47226. * This will be the y position of this camera, when ground level is 0.
  47227. */
  47228. get realWorldHeight(): number;
  47229. /** @hidden */
  47230. _updateForDualEyeDebugging(): void;
  47231. /**
  47232. * Sets this camera's transformation based on a non-vr camera
  47233. * @param otherCamera the non-vr camera to copy the transformation from
  47234. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47235. */
  47236. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47237. /**
  47238. * Gets the current instance class name ("WebXRCamera").
  47239. * @returns the class name
  47240. */
  47241. getClassName(): string;
  47242. private _rotate180;
  47243. private _updateFromXRSession;
  47244. private _updateNumberOfRigCameras;
  47245. private _updateReferenceSpace;
  47246. private _updateReferenceSpaceOffset;
  47247. }
  47248. }
  47249. declare module BABYLON {
  47250. /**
  47251. * Defining the interface required for a (webxr) feature
  47252. */
  47253. export interface IWebXRFeature extends IDisposable {
  47254. /**
  47255. * Is this feature attached
  47256. */
  47257. attached: boolean;
  47258. /**
  47259. * Should auto-attach be disabled?
  47260. */
  47261. disableAutoAttach: boolean;
  47262. /**
  47263. * Attach the feature to the session
  47264. * Will usually be called by the features manager
  47265. *
  47266. * @param force should attachment be forced (even when already attached)
  47267. * @returns true if successful.
  47268. */
  47269. attach(force?: boolean): boolean;
  47270. /**
  47271. * Detach the feature from the session
  47272. * Will usually be called by the features manager
  47273. *
  47274. * @returns true if successful.
  47275. */
  47276. detach(): boolean;
  47277. /**
  47278. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47279. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47280. *
  47281. * @returns whether or not the feature is compatible in this environment
  47282. */
  47283. isCompatible(): boolean;
  47284. /**
  47285. * Was this feature disposed;
  47286. */
  47287. isDisposed: boolean;
  47288. /**
  47289. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47290. */
  47291. xrNativeFeatureName?: string;
  47292. /**
  47293. * A list of (Babylon WebXR) features this feature depends on
  47294. */
  47295. dependsOn?: string[];
  47296. }
  47297. /**
  47298. * A list of the currently available features without referencing them
  47299. */
  47300. export class WebXRFeatureName {
  47301. /**
  47302. * The name of the anchor system feature
  47303. */
  47304. static readonly ANCHOR_SYSTEM: string;
  47305. /**
  47306. * The name of the background remover feature
  47307. */
  47308. static readonly BACKGROUND_REMOVER: string;
  47309. /**
  47310. * The name of the hit test feature
  47311. */
  47312. static readonly HIT_TEST: string;
  47313. /**
  47314. * physics impostors for xr controllers feature
  47315. */
  47316. static readonly PHYSICS_CONTROLLERS: string;
  47317. /**
  47318. * The name of the plane detection feature
  47319. */
  47320. static readonly PLANE_DETECTION: string;
  47321. /**
  47322. * The name of the pointer selection feature
  47323. */
  47324. static readonly POINTER_SELECTION: string;
  47325. /**
  47326. * The name of the teleportation feature
  47327. */
  47328. static readonly TELEPORTATION: string;
  47329. /**
  47330. * The name of the feature points feature.
  47331. */
  47332. static readonly FEATURE_POINTS: string;
  47333. /**
  47334. * The name of the hand tracking feature.
  47335. */
  47336. static readonly HAND_TRACKING: string;
  47337. }
  47338. /**
  47339. * Defining the constructor of a feature. Used to register the modules.
  47340. */
  47341. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47342. /**
  47343. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47344. * It is mainly used in AR sessions.
  47345. *
  47346. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47347. */
  47348. export class WebXRFeaturesManager implements IDisposable {
  47349. private _xrSessionManager;
  47350. private static readonly _AvailableFeatures;
  47351. private _features;
  47352. /**
  47353. * constructs a new features manages.
  47354. *
  47355. * @param _xrSessionManager an instance of WebXRSessionManager
  47356. */
  47357. constructor(_xrSessionManager: WebXRSessionManager);
  47358. /**
  47359. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47360. * Mainly used internally.
  47361. *
  47362. * @param featureName the name of the feature to register
  47363. * @param constructorFunction the function used to construct the module
  47364. * @param version the (babylon) version of the module
  47365. * @param stable is that a stable version of this module
  47366. */
  47367. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47368. /**
  47369. * Returns a constructor of a specific feature.
  47370. *
  47371. * @param featureName the name of the feature to construct
  47372. * @param version the version of the feature to load
  47373. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47374. * @param options optional options provided to the module.
  47375. * @returns a function that, when called, will return a new instance of this feature
  47376. */
  47377. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47378. /**
  47379. * Can be used to return the list of features currently registered
  47380. *
  47381. * @returns an Array of available features
  47382. */
  47383. static GetAvailableFeatures(): string[];
  47384. /**
  47385. * Gets the versions available for a specific feature
  47386. * @param featureName the name of the feature
  47387. * @returns an array with the available versions
  47388. */
  47389. static GetAvailableVersions(featureName: string): string[];
  47390. /**
  47391. * Return the latest unstable version of this feature
  47392. * @param featureName the name of the feature to search
  47393. * @returns the version number. if not found will return -1
  47394. */
  47395. static GetLatestVersionOfFeature(featureName: string): number;
  47396. /**
  47397. * Return the latest stable version of this feature
  47398. * @param featureName the name of the feature to search
  47399. * @returns the version number. if not found will return -1
  47400. */
  47401. static GetStableVersionOfFeature(featureName: string): number;
  47402. /**
  47403. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47404. * Can be used during a session to start a feature
  47405. * @param featureName the name of feature to attach
  47406. */
  47407. attachFeature(featureName: string): void;
  47408. /**
  47409. * Can be used inside a session or when the session ends to detach a specific feature
  47410. * @param featureName the name of the feature to detach
  47411. */
  47412. detachFeature(featureName: string): void;
  47413. /**
  47414. * Used to disable an already-enabled feature
  47415. * The feature will be disposed and will be recreated once enabled.
  47416. * @param featureName the feature to disable
  47417. * @returns true if disable was successful
  47418. */
  47419. disableFeature(featureName: string | {
  47420. Name: string;
  47421. }): boolean;
  47422. /**
  47423. * dispose this features manager
  47424. */
  47425. dispose(): void;
  47426. /**
  47427. * 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.
  47428. * 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.
  47429. *
  47430. * @param featureName the name of the feature to load or the class of the feature
  47431. * @param version optional version to load. if not provided the latest version will be enabled
  47432. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47433. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47434. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47435. * @returns a new constructed feature or throws an error if feature not found.
  47436. */
  47437. enableFeature(featureName: string | {
  47438. Name: string;
  47439. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47440. /**
  47441. * get the implementation of an enabled feature.
  47442. * @param featureName the name of the feature to load
  47443. * @returns the feature class, if found
  47444. */
  47445. getEnabledFeature(featureName: string): IWebXRFeature;
  47446. /**
  47447. * Get the list of enabled features
  47448. * @returns an array of enabled features
  47449. */
  47450. getEnabledFeatures(): string[];
  47451. /**
  47452. * This function will exten the session creation configuration object with enabled features.
  47453. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47454. * according to the defined "required" variable, provided during enableFeature call
  47455. * @param xrSessionInit the xr Session init object to extend
  47456. *
  47457. * @returns an extended XRSessionInit object
  47458. */
  47459. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47460. }
  47461. }
  47462. declare module BABYLON {
  47463. /**
  47464. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47465. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47466. */
  47467. export class WebXRExperienceHelper implements IDisposable {
  47468. private scene;
  47469. private _nonVRCamera;
  47470. private _originalSceneAutoClear;
  47471. private _supported;
  47472. /**
  47473. * Camera used to render xr content
  47474. */
  47475. camera: WebXRCamera;
  47476. /** A features manager for this xr session */
  47477. featuresManager: WebXRFeaturesManager;
  47478. /**
  47479. * Observers registered here will be triggered after the camera's initial transformation is set
  47480. * This can be used to set a different ground level or an extra rotation.
  47481. *
  47482. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47483. * to the position set after this observable is done executing.
  47484. */
  47485. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47486. /**
  47487. * Fires when the state of the experience helper has changed
  47488. */
  47489. onStateChangedObservable: Observable<WebXRState>;
  47490. /** Session manager used to keep track of xr session */
  47491. sessionManager: WebXRSessionManager;
  47492. /**
  47493. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47494. */
  47495. state: WebXRState;
  47496. /**
  47497. * Creates a WebXRExperienceHelper
  47498. * @param scene The scene the helper should be created in
  47499. */
  47500. private constructor();
  47501. /**
  47502. * Creates the experience helper
  47503. * @param scene the scene to attach the experience helper to
  47504. * @returns a promise for the experience helper
  47505. */
  47506. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47507. /**
  47508. * Disposes of the experience helper
  47509. */
  47510. dispose(): void;
  47511. /**
  47512. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47513. * @param sessionMode options for the XR session
  47514. * @param referenceSpaceType frame of reference of the XR session
  47515. * @param renderTarget the output canvas that will be used to enter XR mode
  47516. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47517. * @returns promise that resolves after xr mode has entered
  47518. */
  47519. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47520. /**
  47521. * Exits XR mode and returns the scene to its original state
  47522. * @returns promise that resolves after xr mode has exited
  47523. */
  47524. exitXRAsync(): Promise<void>;
  47525. private _nonXRToXRCamera;
  47526. private _setState;
  47527. }
  47528. }
  47529. declare module BABYLON {
  47530. /**
  47531. * X-Y values for axes in WebXR
  47532. */
  47533. export interface IWebXRMotionControllerAxesValue {
  47534. /**
  47535. * The value of the x axis
  47536. */
  47537. x: number;
  47538. /**
  47539. * The value of the y-axis
  47540. */
  47541. y: number;
  47542. }
  47543. /**
  47544. * changed / previous values for the values of this component
  47545. */
  47546. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47547. /**
  47548. * current (this frame) value
  47549. */
  47550. current: T;
  47551. /**
  47552. * previous (last change) value
  47553. */
  47554. previous: T;
  47555. }
  47556. /**
  47557. * Represents changes in the component between current frame and last values recorded
  47558. */
  47559. export interface IWebXRMotionControllerComponentChanges {
  47560. /**
  47561. * will be populated with previous and current values if axes changed
  47562. */
  47563. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47564. /**
  47565. * will be populated with previous and current values if pressed changed
  47566. */
  47567. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47568. /**
  47569. * will be populated with previous and current values if touched changed
  47570. */
  47571. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47572. /**
  47573. * will be populated with previous and current values if value changed
  47574. */
  47575. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47576. }
  47577. /**
  47578. * This class represents a single component (for example button or thumbstick) of a motion controller
  47579. */
  47580. export class WebXRControllerComponent implements IDisposable {
  47581. /**
  47582. * the id of this component
  47583. */
  47584. id: string;
  47585. /**
  47586. * the type of the component
  47587. */
  47588. type: MotionControllerComponentType;
  47589. private _buttonIndex;
  47590. private _axesIndices;
  47591. private _axes;
  47592. private _changes;
  47593. private _currentValue;
  47594. private _hasChanges;
  47595. private _pressed;
  47596. private _touched;
  47597. /**
  47598. * button component type
  47599. */
  47600. static BUTTON_TYPE: MotionControllerComponentType;
  47601. /**
  47602. * squeeze component type
  47603. */
  47604. static SQUEEZE_TYPE: MotionControllerComponentType;
  47605. /**
  47606. * Thumbstick component type
  47607. */
  47608. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47609. /**
  47610. * Touchpad component type
  47611. */
  47612. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47613. /**
  47614. * trigger component type
  47615. */
  47616. static TRIGGER_TYPE: MotionControllerComponentType;
  47617. /**
  47618. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47619. * the axes data changes
  47620. */
  47621. onAxisValueChangedObservable: Observable<{
  47622. x: number;
  47623. y: number;
  47624. }>;
  47625. /**
  47626. * Observers registered here will be triggered when the state of a button changes
  47627. * State change is either pressed / touched / value
  47628. */
  47629. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47630. /**
  47631. * Creates a new component for a motion controller.
  47632. * It is created by the motion controller itself
  47633. *
  47634. * @param id the id of this component
  47635. * @param type the type of the component
  47636. * @param _buttonIndex index in the buttons array of the gamepad
  47637. * @param _axesIndices indices of the values in the axes array of the gamepad
  47638. */
  47639. constructor(
  47640. /**
  47641. * the id of this component
  47642. */
  47643. id: string,
  47644. /**
  47645. * the type of the component
  47646. */
  47647. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47648. /**
  47649. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47650. */
  47651. get axes(): IWebXRMotionControllerAxesValue;
  47652. /**
  47653. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47654. */
  47655. get changes(): IWebXRMotionControllerComponentChanges;
  47656. /**
  47657. * Return whether or not the component changed the last frame
  47658. */
  47659. get hasChanges(): boolean;
  47660. /**
  47661. * is the button currently pressed
  47662. */
  47663. get pressed(): boolean;
  47664. /**
  47665. * is the button currently touched
  47666. */
  47667. get touched(): boolean;
  47668. /**
  47669. * Get the current value of this component
  47670. */
  47671. get value(): number;
  47672. /**
  47673. * Dispose this component
  47674. */
  47675. dispose(): void;
  47676. /**
  47677. * Are there axes correlating to this component
  47678. * @return true is axes data is available
  47679. */
  47680. isAxes(): boolean;
  47681. /**
  47682. * Is this component a button (hence - pressable)
  47683. * @returns true if can be pressed
  47684. */
  47685. isButton(): boolean;
  47686. /**
  47687. * update this component using the gamepad object it is in. Called on every frame
  47688. * @param nativeController the native gamepad controller object
  47689. */
  47690. update(nativeController: IMinimalMotionControllerObject): void;
  47691. }
  47692. }
  47693. declare module BABYLON {
  47694. /**
  47695. * Interface used to represent data loading progression
  47696. */
  47697. export interface ISceneLoaderProgressEvent {
  47698. /**
  47699. * Defines if data length to load can be evaluated
  47700. */
  47701. readonly lengthComputable: boolean;
  47702. /**
  47703. * Defines the loaded data length
  47704. */
  47705. readonly loaded: number;
  47706. /**
  47707. * Defines the data length to load
  47708. */
  47709. readonly total: number;
  47710. }
  47711. /**
  47712. * Interface used by SceneLoader plugins to define supported file extensions
  47713. */
  47714. export interface ISceneLoaderPluginExtensions {
  47715. /**
  47716. * Defines the list of supported extensions
  47717. */
  47718. [extension: string]: {
  47719. isBinary: boolean;
  47720. };
  47721. }
  47722. /**
  47723. * Interface used by SceneLoader plugin factory
  47724. */
  47725. export interface ISceneLoaderPluginFactory {
  47726. /**
  47727. * Defines the name of the factory
  47728. */
  47729. name: string;
  47730. /**
  47731. * Function called to create a new plugin
  47732. * @return the new plugin
  47733. */
  47734. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47735. /**
  47736. * The callback that returns true if the data can be directly loaded.
  47737. * @param data string containing the file data
  47738. * @returns if the data can be loaded directly
  47739. */
  47740. canDirectLoad?(data: string): boolean;
  47741. }
  47742. /**
  47743. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47744. */
  47745. export interface ISceneLoaderPluginBase {
  47746. /**
  47747. * The friendly name of this plugin.
  47748. */
  47749. name: string;
  47750. /**
  47751. * The file extensions supported by this plugin.
  47752. */
  47753. extensions: string | ISceneLoaderPluginExtensions;
  47754. /**
  47755. * The callback called when loading from a url.
  47756. * @param scene scene loading this url
  47757. * @param url url to load
  47758. * @param onSuccess callback called when the file successfully loads
  47759. * @param onProgress callback called while file is loading (if the server supports this mode)
  47760. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47761. * @param onError callback called when the file fails to load
  47762. * @returns a file request object
  47763. */
  47764. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47765. /**
  47766. * The callback called when loading from a file object.
  47767. * @param scene scene loading this file
  47768. * @param file defines the file to load
  47769. * @param onSuccess defines the callback to call when data is loaded
  47770. * @param onProgress defines the callback to call during loading process
  47771. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47772. * @param onError defines the callback to call when an error occurs
  47773. * @returns a file request object
  47774. */
  47775. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47776. /**
  47777. * The callback that returns true if the data can be directly loaded.
  47778. * @param data string containing the file data
  47779. * @returns if the data can be loaded directly
  47780. */
  47781. canDirectLoad?(data: string): boolean;
  47782. /**
  47783. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47784. * @param scene scene loading this data
  47785. * @param data string containing the data
  47786. * @returns data to pass to the plugin
  47787. */
  47788. directLoad?(scene: Scene, data: string): any;
  47789. /**
  47790. * The callback that allows custom handling of the root url based on the response url.
  47791. * @param rootUrl the original root url
  47792. * @param responseURL the response url if available
  47793. * @returns the new root url
  47794. */
  47795. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47796. }
  47797. /**
  47798. * Interface used to define a SceneLoader plugin
  47799. */
  47800. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47801. /**
  47802. * Import meshes into a scene.
  47803. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47804. * @param scene The scene to import into
  47805. * @param data The data to import
  47806. * @param rootUrl The root url for scene and resources
  47807. * @param meshes The meshes array to import into
  47808. * @param particleSystems The particle systems array to import into
  47809. * @param skeletons The skeletons array to import into
  47810. * @param onError The callback when import fails
  47811. * @returns True if successful or false otherwise
  47812. */
  47813. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47814. /**
  47815. * Load into a scene.
  47816. * @param scene The scene to load into
  47817. * @param data The data to import
  47818. * @param rootUrl The root url for scene and resources
  47819. * @param onError The callback when import fails
  47820. * @returns True if successful or false otherwise
  47821. */
  47822. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47823. /**
  47824. * Load into an asset container.
  47825. * @param scene The scene to load into
  47826. * @param data The data to import
  47827. * @param rootUrl The root url for scene and resources
  47828. * @param onError The callback when import fails
  47829. * @returns The loaded asset container
  47830. */
  47831. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47832. }
  47833. /**
  47834. * Interface used to define an async SceneLoader plugin
  47835. */
  47836. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47837. /**
  47838. * Import meshes into a scene.
  47839. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47840. * @param scene The scene to import into
  47841. * @param data The data to import
  47842. * @param rootUrl The root url for scene and resources
  47843. * @param onProgress The callback when the load progresses
  47844. * @param fileName Defines the name of the file to load
  47845. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47846. */
  47847. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47848. meshes: AbstractMesh[];
  47849. particleSystems: IParticleSystem[];
  47850. skeletons: Skeleton[];
  47851. animationGroups: AnimationGroup[];
  47852. }>;
  47853. /**
  47854. * Load into a scene.
  47855. * @param scene The scene to load into
  47856. * @param data The data to import
  47857. * @param rootUrl The root url for scene and resources
  47858. * @param onProgress The callback when the load progresses
  47859. * @param fileName Defines the name of the file to load
  47860. * @returns Nothing
  47861. */
  47862. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47863. /**
  47864. * Load into an asset container.
  47865. * @param scene The scene to load into
  47866. * @param data The data to import
  47867. * @param rootUrl The root url for scene and resources
  47868. * @param onProgress The callback when the load progresses
  47869. * @param fileName Defines the name of the file to load
  47870. * @returns The loaded asset container
  47871. */
  47872. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47873. }
  47874. /**
  47875. * Mode that determines how to handle old animation groups before loading new ones.
  47876. */
  47877. export enum SceneLoaderAnimationGroupLoadingMode {
  47878. /**
  47879. * Reset all old animations to initial state then dispose them.
  47880. */
  47881. Clean = 0,
  47882. /**
  47883. * Stop all old animations.
  47884. */
  47885. Stop = 1,
  47886. /**
  47887. * Restart old animations from first frame.
  47888. */
  47889. Sync = 2,
  47890. /**
  47891. * Old animations remains untouched.
  47892. */
  47893. NoSync = 3
  47894. }
  47895. /**
  47896. * Defines a plugin registered by the SceneLoader
  47897. */
  47898. interface IRegisteredPlugin {
  47899. /**
  47900. * Defines the plugin to use
  47901. */
  47902. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47903. /**
  47904. * Defines if the plugin supports binary data
  47905. */
  47906. isBinary: boolean;
  47907. }
  47908. /**
  47909. * Class used to load scene from various file formats using registered plugins
  47910. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47911. */
  47912. export class SceneLoader {
  47913. /**
  47914. * No logging while loading
  47915. */
  47916. static readonly NO_LOGGING: number;
  47917. /**
  47918. * Minimal logging while loading
  47919. */
  47920. static readonly MINIMAL_LOGGING: number;
  47921. /**
  47922. * Summary logging while loading
  47923. */
  47924. static readonly SUMMARY_LOGGING: number;
  47925. /**
  47926. * Detailled logging while loading
  47927. */
  47928. static readonly DETAILED_LOGGING: number;
  47929. /**
  47930. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47931. */
  47932. static get ForceFullSceneLoadingForIncremental(): boolean;
  47933. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47934. /**
  47935. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47936. */
  47937. static get ShowLoadingScreen(): boolean;
  47938. static set ShowLoadingScreen(value: boolean);
  47939. /**
  47940. * Defines the current logging level (while loading the scene)
  47941. * @ignorenaming
  47942. */
  47943. static get loggingLevel(): number;
  47944. static set loggingLevel(value: number);
  47945. /**
  47946. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47947. */
  47948. static get CleanBoneMatrixWeights(): boolean;
  47949. static set CleanBoneMatrixWeights(value: boolean);
  47950. /**
  47951. * Event raised when a plugin is used to load a scene
  47952. */
  47953. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47954. private static _registeredPlugins;
  47955. private static _showingLoadingScreen;
  47956. /**
  47957. * Gets the default plugin (used to load Babylon files)
  47958. * @returns the .babylon plugin
  47959. */
  47960. static GetDefaultPlugin(): IRegisteredPlugin;
  47961. private static _GetPluginForExtension;
  47962. private static _GetPluginForDirectLoad;
  47963. private static _GetPluginForFilename;
  47964. private static _GetDirectLoad;
  47965. private static _LoadData;
  47966. private static _GetFileInfo;
  47967. /**
  47968. * Gets a plugin that can load the given extension
  47969. * @param extension defines the extension to load
  47970. * @returns a plugin or null if none works
  47971. */
  47972. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47973. /**
  47974. * Gets a boolean indicating that the given extension can be loaded
  47975. * @param extension defines the extension to load
  47976. * @returns true if the extension is supported
  47977. */
  47978. static IsPluginForExtensionAvailable(extension: string): boolean;
  47979. /**
  47980. * Adds a new plugin to the list of registered plugins
  47981. * @param plugin defines the plugin to add
  47982. */
  47983. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47984. /**
  47985. * Import meshes into a scene
  47986. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47987. * @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)
  47988. * @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)
  47989. * @param scene the instance of BABYLON.Scene to append to
  47990. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47991. * @param onProgress a callback with a progress event for each file being loaded
  47992. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47993. * @param pluginExtension the extension used to determine the plugin
  47994. * @returns The loaded plugin
  47995. */
  47996. 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>;
  47997. /**
  47998. * Import meshes into a scene
  47999. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48000. * @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)
  48001. * @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)
  48002. * @param scene the instance of BABYLON.Scene to append to
  48003. * @param onProgress a callback with a progress event for each file being loaded
  48004. * @param pluginExtension the extension used to determine the plugin
  48005. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48006. */
  48007. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48008. meshes: AbstractMesh[];
  48009. particleSystems: IParticleSystem[];
  48010. skeletons: Skeleton[];
  48011. animationGroups: AnimationGroup[];
  48012. }>;
  48013. /**
  48014. * Load a scene
  48015. * @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)
  48016. * @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)
  48017. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48018. * @param onSuccess a callback with the scene when import succeeds
  48019. * @param onProgress a callback with a progress event for each file being loaded
  48020. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48021. * @param pluginExtension the extension used to determine the plugin
  48022. * @returns The loaded plugin
  48023. */
  48024. 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>;
  48025. /**
  48026. * Load a scene
  48027. * @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)
  48028. * @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)
  48029. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48030. * @param onProgress a callback with a progress event for each file being loaded
  48031. * @param pluginExtension the extension used to determine the plugin
  48032. * @returns The loaded scene
  48033. */
  48034. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48035. /**
  48036. * Append a scene
  48037. * @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)
  48038. * @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)
  48039. * @param scene is the instance of BABYLON.Scene to append to
  48040. * @param onSuccess a callback with the scene when import succeeds
  48041. * @param onProgress a callback with a progress event for each file being loaded
  48042. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48043. * @param pluginExtension the extension used to determine the plugin
  48044. * @returns The loaded plugin
  48045. */
  48046. 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>;
  48047. /**
  48048. * Append a scene
  48049. * @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)
  48050. * @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)
  48051. * @param scene is the instance of BABYLON.Scene to append to
  48052. * @param onProgress a callback with a progress event for each file being loaded
  48053. * @param pluginExtension the extension used to determine the plugin
  48054. * @returns The given scene
  48055. */
  48056. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48057. /**
  48058. * Load a scene into an asset container
  48059. * @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)
  48060. * @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)
  48061. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48062. * @param onSuccess a callback with the scene when import succeeds
  48063. * @param onProgress a callback with a progress event for each file being loaded
  48064. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48065. * @param pluginExtension the extension used to determine the plugin
  48066. * @returns The loaded plugin
  48067. */
  48068. 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>;
  48069. /**
  48070. * Load a scene into an asset container
  48071. * @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)
  48072. * @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)
  48073. * @param scene is the instance of Scene to append to
  48074. * @param onProgress a callback with a progress event for each file being loaded
  48075. * @param pluginExtension the extension used to determine the plugin
  48076. * @returns The loaded asset container
  48077. */
  48078. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48079. /**
  48080. * Import animations from a file into a scene
  48081. * @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)
  48082. * @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)
  48083. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48084. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48085. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48086. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48087. * @param onSuccess a callback with the scene when import succeeds
  48088. * @param onProgress a callback with a progress event for each file being loaded
  48089. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48090. * @param pluginExtension the extension used to determine the plugin
  48091. */
  48092. 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;
  48093. /**
  48094. * Import animations from a file into a scene
  48095. * @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)
  48096. * @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)
  48097. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48098. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48099. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48100. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48101. * @param onSuccess a callback with the scene when import succeeds
  48102. * @param onProgress a callback with a progress event for each file being loaded
  48103. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48104. * @param pluginExtension the extension used to determine the plugin
  48105. * @returns the updated scene with imported animations
  48106. */
  48107. 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>;
  48108. }
  48109. }
  48110. declare module BABYLON {
  48111. /**
  48112. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48113. */
  48114. export type MotionControllerHandedness = "none" | "left" | "right";
  48115. /**
  48116. * The type of components available in motion controllers.
  48117. * This is not the name of the component.
  48118. */
  48119. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48120. /**
  48121. * The state of a controller component
  48122. */
  48123. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48124. /**
  48125. * The schema of motion controller layout.
  48126. * No object will be initialized using this interface
  48127. * This is used just to define the profile.
  48128. */
  48129. export interface IMotionControllerLayout {
  48130. /**
  48131. * Path to load the assets. Usually relative to the base path
  48132. */
  48133. assetPath: string;
  48134. /**
  48135. * Available components (unsorted)
  48136. */
  48137. components: {
  48138. /**
  48139. * A map of component Ids
  48140. */
  48141. [componentId: string]: {
  48142. /**
  48143. * The type of input the component outputs
  48144. */
  48145. type: MotionControllerComponentType;
  48146. /**
  48147. * The indices of this component in the gamepad object
  48148. */
  48149. gamepadIndices: {
  48150. /**
  48151. * Index of button
  48152. */
  48153. button?: number;
  48154. /**
  48155. * If available, index of x-axis
  48156. */
  48157. xAxis?: number;
  48158. /**
  48159. * If available, index of y-axis
  48160. */
  48161. yAxis?: number;
  48162. };
  48163. /**
  48164. * The mesh's root node name
  48165. */
  48166. rootNodeName: string;
  48167. /**
  48168. * Animation definitions for this model
  48169. */
  48170. visualResponses: {
  48171. [stateKey: string]: {
  48172. /**
  48173. * What property will be animated
  48174. */
  48175. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48176. /**
  48177. * What states influence this visual response
  48178. */
  48179. states: MotionControllerComponentStateType[];
  48180. /**
  48181. * Type of animation - movement or visibility
  48182. */
  48183. valueNodeProperty: "transform" | "visibility";
  48184. /**
  48185. * Base node name to move. Its position will be calculated according to the min and max nodes
  48186. */
  48187. valueNodeName?: string;
  48188. /**
  48189. * Minimum movement node
  48190. */
  48191. minNodeName?: string;
  48192. /**
  48193. * Max movement node
  48194. */
  48195. maxNodeName?: string;
  48196. };
  48197. };
  48198. /**
  48199. * If touch enabled, what is the name of node to display user feedback
  48200. */
  48201. touchPointNodeName?: string;
  48202. };
  48203. };
  48204. /**
  48205. * Is it xr standard mapping or not
  48206. */
  48207. gamepadMapping: "" | "xr-standard";
  48208. /**
  48209. * Base root node of this entire model
  48210. */
  48211. rootNodeName: string;
  48212. /**
  48213. * Defines the main button component id
  48214. */
  48215. selectComponentId: string;
  48216. }
  48217. /**
  48218. * A definition for the layout map in the input profile
  48219. */
  48220. export interface IMotionControllerLayoutMap {
  48221. /**
  48222. * Layouts with handedness type as a key
  48223. */
  48224. [handedness: string]: IMotionControllerLayout;
  48225. }
  48226. /**
  48227. * The XR Input profile schema
  48228. * Profiles can be found here:
  48229. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48230. */
  48231. export interface IMotionControllerProfile {
  48232. /**
  48233. * fallback profiles for this profileId
  48234. */
  48235. fallbackProfileIds: string[];
  48236. /**
  48237. * The layout map, with handedness as key
  48238. */
  48239. layouts: IMotionControllerLayoutMap;
  48240. /**
  48241. * The id of this profile
  48242. * correlates to the profile(s) in the xrInput.profiles array
  48243. */
  48244. profileId: string;
  48245. }
  48246. /**
  48247. * A helper-interface for the 3 meshes needed for controller button animation
  48248. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48249. */
  48250. export interface IMotionControllerButtonMeshMap {
  48251. /**
  48252. * the mesh that defines the pressed value mesh position.
  48253. * This is used to find the max-position of this button
  48254. */
  48255. pressedMesh: AbstractMesh;
  48256. /**
  48257. * the mesh that defines the unpressed value mesh position.
  48258. * This is used to find the min (or initial) position of this button
  48259. */
  48260. unpressedMesh: AbstractMesh;
  48261. /**
  48262. * The mesh that will be changed when value changes
  48263. */
  48264. valueMesh: AbstractMesh;
  48265. }
  48266. /**
  48267. * A helper-interface for the 3 meshes needed for controller axis animation.
  48268. * This will be expanded when touchpad animations are fully supported
  48269. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48270. */
  48271. export interface IMotionControllerMeshMap {
  48272. /**
  48273. * the mesh that defines the maximum value mesh position.
  48274. */
  48275. maxMesh?: AbstractMesh;
  48276. /**
  48277. * the mesh that defines the minimum value mesh position.
  48278. */
  48279. minMesh?: AbstractMesh;
  48280. /**
  48281. * The mesh that will be changed when axis value changes
  48282. */
  48283. valueMesh?: AbstractMesh;
  48284. }
  48285. /**
  48286. * The elements needed for change-detection of the gamepad objects in motion controllers
  48287. */
  48288. export interface IMinimalMotionControllerObject {
  48289. /**
  48290. * Available axes of this controller
  48291. */
  48292. axes: number[];
  48293. /**
  48294. * An array of available buttons
  48295. */
  48296. buttons: Array<{
  48297. /**
  48298. * Value of the button/trigger
  48299. */
  48300. value: number;
  48301. /**
  48302. * If the button/trigger is currently touched
  48303. */
  48304. touched: boolean;
  48305. /**
  48306. * If the button/trigger is currently pressed
  48307. */
  48308. pressed: boolean;
  48309. }>;
  48310. /**
  48311. * EXPERIMENTAL haptic support.
  48312. */
  48313. hapticActuators?: Array<{
  48314. pulse: (value: number, duration: number) => Promise<boolean>;
  48315. }>;
  48316. }
  48317. /**
  48318. * An Abstract Motion controller
  48319. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48320. * Each component has an observable to check for changes in value and state
  48321. */
  48322. export abstract class WebXRAbstractMotionController implements IDisposable {
  48323. protected scene: Scene;
  48324. protected layout: IMotionControllerLayout;
  48325. /**
  48326. * The gamepad object correlating to this controller
  48327. */
  48328. gamepadObject: IMinimalMotionControllerObject;
  48329. /**
  48330. * handedness (left/right/none) of this controller
  48331. */
  48332. handedness: MotionControllerHandedness;
  48333. private _initComponent;
  48334. private _modelReady;
  48335. /**
  48336. * A map of components (WebXRControllerComponent) in this motion controller
  48337. * Components have a ComponentType and can also have both button and axis definitions
  48338. */
  48339. readonly components: {
  48340. [id: string]: WebXRControllerComponent;
  48341. };
  48342. /**
  48343. * Disable the model's animation. Can be set at any time.
  48344. */
  48345. disableAnimation: boolean;
  48346. /**
  48347. * Observers registered here will be triggered when the model of this controller is done loading
  48348. */
  48349. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48350. /**
  48351. * The profile id of this motion controller
  48352. */
  48353. abstract profileId: string;
  48354. /**
  48355. * The root mesh of the model. It is null if the model was not yet initialized
  48356. */
  48357. rootMesh: Nullable<AbstractMesh>;
  48358. /**
  48359. * constructs a new abstract motion controller
  48360. * @param scene the scene to which the model of the controller will be added
  48361. * @param layout The profile layout to load
  48362. * @param gamepadObject The gamepad object correlating to this controller
  48363. * @param handedness handedness (left/right/none) of this controller
  48364. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48365. */
  48366. constructor(scene: Scene, layout: IMotionControllerLayout,
  48367. /**
  48368. * The gamepad object correlating to this controller
  48369. */
  48370. gamepadObject: IMinimalMotionControllerObject,
  48371. /**
  48372. * handedness (left/right/none) of this controller
  48373. */
  48374. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48375. /**
  48376. * Dispose this controller, the model mesh and all its components
  48377. */
  48378. dispose(): void;
  48379. /**
  48380. * Returns all components of specific type
  48381. * @param type the type to search for
  48382. * @return an array of components with this type
  48383. */
  48384. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48385. /**
  48386. * get a component based an its component id as defined in layout.components
  48387. * @param id the id of the component
  48388. * @returns the component correlates to the id or undefined if not found
  48389. */
  48390. getComponent(id: string): WebXRControllerComponent;
  48391. /**
  48392. * Get the list of components available in this motion controller
  48393. * @returns an array of strings correlating to available components
  48394. */
  48395. getComponentIds(): string[];
  48396. /**
  48397. * Get the first component of specific type
  48398. * @param type type of component to find
  48399. * @return a controller component or null if not found
  48400. */
  48401. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48402. /**
  48403. * Get the main (Select) component of this controller as defined in the layout
  48404. * @returns the main component of this controller
  48405. */
  48406. getMainComponent(): WebXRControllerComponent;
  48407. /**
  48408. * Loads the model correlating to this controller
  48409. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48410. * @returns A promise fulfilled with the result of the model loading
  48411. */
  48412. loadModel(): Promise<boolean>;
  48413. /**
  48414. * Update this model using the current XRFrame
  48415. * @param xrFrame the current xr frame to use and update the model
  48416. */
  48417. updateFromXRFrame(xrFrame: XRFrame): void;
  48418. /**
  48419. * Backwards compatibility due to a deeply-integrated typo
  48420. */
  48421. get handness(): XREye;
  48422. /**
  48423. * Pulse (vibrate) this controller
  48424. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48425. * Consecutive calls to this function will cancel the last pulse call
  48426. *
  48427. * @param value the strength of the pulse in 0.0...1.0 range
  48428. * @param duration Duration of the pulse in milliseconds
  48429. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48430. * @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
  48431. */
  48432. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48433. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48434. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48435. /**
  48436. * Moves the axis on the controller mesh based on its current state
  48437. * @param axis the index of the axis
  48438. * @param axisValue the value of the axis which determines the meshes new position
  48439. * @hidden
  48440. */
  48441. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48442. /**
  48443. * Update the model itself with the current frame data
  48444. * @param xrFrame the frame to use for updating the model mesh
  48445. */
  48446. protected updateModel(xrFrame: XRFrame): void;
  48447. /**
  48448. * Get the filename and path for this controller's model
  48449. * @returns a map of filename and path
  48450. */
  48451. protected abstract _getFilenameAndPath(): {
  48452. filename: string;
  48453. path: string;
  48454. };
  48455. /**
  48456. * This function is called before the mesh is loaded. It checks for loading constraints.
  48457. * For example, this function can check if the GLB loader is available
  48458. * If this function returns false, the generic controller will be loaded instead
  48459. * @returns Is the client ready to load the mesh
  48460. */
  48461. protected abstract _getModelLoadingConstraints(): boolean;
  48462. /**
  48463. * This function will be called after the model was successfully loaded and can be used
  48464. * for mesh transformations before it is available for the user
  48465. * @param meshes the loaded meshes
  48466. */
  48467. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48468. /**
  48469. * Set the root mesh for this controller. Important for the WebXR controller class
  48470. * @param meshes the loaded meshes
  48471. */
  48472. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48473. /**
  48474. * A function executed each frame that updates the mesh (if needed)
  48475. * @param xrFrame the current xrFrame
  48476. */
  48477. protected abstract _updateModel(xrFrame: XRFrame): void;
  48478. private _getGenericFilenameAndPath;
  48479. private _getGenericParentMesh;
  48480. }
  48481. }
  48482. declare module BABYLON {
  48483. /**
  48484. * A generic trigger-only motion controller for WebXR
  48485. */
  48486. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48487. /**
  48488. * Static version of the profile id of this controller
  48489. */
  48490. static ProfileId: string;
  48491. profileId: string;
  48492. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48493. protected _getFilenameAndPath(): {
  48494. filename: string;
  48495. path: string;
  48496. };
  48497. protected _getModelLoadingConstraints(): boolean;
  48498. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48499. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48500. protected _updateModel(): void;
  48501. }
  48502. }
  48503. declare module BABYLON {
  48504. /**
  48505. * Class containing static functions to help procedurally build meshes
  48506. */
  48507. export class SphereBuilder {
  48508. /**
  48509. * Creates a sphere mesh
  48510. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48511. * * 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`)
  48512. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48513. * * 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
  48514. * * 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)
  48515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48516. * * 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
  48517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48518. * @param name defines the name of the mesh
  48519. * @param options defines the options used to create the mesh
  48520. * @param scene defines the hosting scene
  48521. * @returns the sphere mesh
  48522. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48523. */
  48524. static CreateSphere(name: string, options: {
  48525. segments?: number;
  48526. diameter?: number;
  48527. diameterX?: number;
  48528. diameterY?: number;
  48529. diameterZ?: number;
  48530. arc?: number;
  48531. slice?: number;
  48532. sideOrientation?: number;
  48533. frontUVs?: Vector4;
  48534. backUVs?: Vector4;
  48535. updatable?: boolean;
  48536. }, scene?: Nullable<Scene>): Mesh;
  48537. }
  48538. }
  48539. declare module BABYLON {
  48540. /**
  48541. * A profiled motion controller has its profile loaded from an online repository.
  48542. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48543. */
  48544. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48545. private _repositoryUrl;
  48546. private _buttonMeshMapping;
  48547. private _touchDots;
  48548. /**
  48549. * The profile ID of this controller. Will be populated when the controller initializes.
  48550. */
  48551. profileId: string;
  48552. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48553. dispose(): void;
  48554. protected _getFilenameAndPath(): {
  48555. filename: string;
  48556. path: string;
  48557. };
  48558. protected _getModelLoadingConstraints(): boolean;
  48559. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48560. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48561. protected _updateModel(_xrFrame: XRFrame): void;
  48562. }
  48563. }
  48564. declare module BABYLON {
  48565. /**
  48566. * A construction function type to create a new controller based on an xrInput object
  48567. */
  48568. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48569. /**
  48570. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48571. *
  48572. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48573. * it should be replaced with auto-loaded controllers.
  48574. *
  48575. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48576. */
  48577. export class WebXRMotionControllerManager {
  48578. private static _AvailableControllers;
  48579. private static _Fallbacks;
  48580. private static _ProfileLoadingPromises;
  48581. private static _ProfilesList;
  48582. /**
  48583. * The base URL of the online controller repository. Can be changed at any time.
  48584. */
  48585. static BaseRepositoryUrl: string;
  48586. /**
  48587. * Which repository gets priority - local or online
  48588. */
  48589. static PrioritizeOnlineRepository: boolean;
  48590. /**
  48591. * Use the online repository, or use only locally-defined controllers
  48592. */
  48593. static UseOnlineRepository: boolean;
  48594. /**
  48595. * Clear the cache used for profile loading and reload when requested again
  48596. */
  48597. static ClearProfilesCache(): void;
  48598. /**
  48599. * Register the default fallbacks.
  48600. * This function is called automatically when this file is imported.
  48601. */
  48602. static DefaultFallbacks(): void;
  48603. /**
  48604. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48605. * @param profileId the profile to which a fallback needs to be found
  48606. * @return an array with corresponding fallback profiles
  48607. */
  48608. static FindFallbackWithProfileId(profileId: string): string[];
  48609. /**
  48610. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48611. * The order of search:
  48612. *
  48613. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48614. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48615. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48616. * 4) return the generic trigger controller if none were found
  48617. *
  48618. * @param xrInput the xrInput to which a new controller is initialized
  48619. * @param scene the scene to which the model will be added
  48620. * @param forceProfile force a certain profile for this controller
  48621. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48622. */
  48623. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48624. /**
  48625. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48626. *
  48627. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48628. *
  48629. * @param type the profile type to register
  48630. * @param constructFunction the function to be called when loading this profile
  48631. */
  48632. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48633. /**
  48634. * Register a fallback to a specific profile.
  48635. * @param profileId the profileId that will receive the fallbacks
  48636. * @param fallbacks A list of fallback profiles
  48637. */
  48638. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48639. /**
  48640. * Will update the list of profiles available in the repository
  48641. * @return a promise that resolves to a map of profiles available online
  48642. */
  48643. static UpdateProfilesList(): Promise<{
  48644. [profile: string]: string;
  48645. }>;
  48646. private static _LoadProfileFromRepository;
  48647. private static _LoadProfilesFromAvailableControllers;
  48648. }
  48649. }
  48650. declare module BABYLON {
  48651. /**
  48652. * Configuration options for the WebXR controller creation
  48653. */
  48654. export interface IWebXRControllerOptions {
  48655. /**
  48656. * Should the controller mesh be animated when a user interacts with it
  48657. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48658. */
  48659. disableMotionControllerAnimation?: boolean;
  48660. /**
  48661. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48662. */
  48663. doNotLoadControllerMesh?: boolean;
  48664. /**
  48665. * Force a specific controller type for this controller.
  48666. * This can be used when creating your own profile or when testing different controllers
  48667. */
  48668. forceControllerProfile?: string;
  48669. /**
  48670. * Defines a rendering group ID for meshes that will be loaded.
  48671. * This is for the default controllers only.
  48672. */
  48673. renderingGroupId?: number;
  48674. }
  48675. /**
  48676. * Represents an XR controller
  48677. */
  48678. export class WebXRInputSource {
  48679. private _scene;
  48680. /** The underlying input source for the controller */
  48681. inputSource: XRInputSource;
  48682. private _options;
  48683. private _tmpVector;
  48684. private _uniqueId;
  48685. private _disposed;
  48686. /**
  48687. * 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
  48688. */
  48689. grip?: AbstractMesh;
  48690. /**
  48691. * If available, this is the gamepad object related to this controller.
  48692. * Using this object it is possible to get click events and trackpad changes of the
  48693. * webxr controller that is currently being used.
  48694. */
  48695. motionController?: WebXRAbstractMotionController;
  48696. /**
  48697. * Event that fires when the controller is removed/disposed.
  48698. * The object provided as event data is this controller, after associated assets were disposed.
  48699. * uniqueId is still available.
  48700. */
  48701. onDisposeObservable: Observable<WebXRInputSource>;
  48702. /**
  48703. * Will be triggered when the mesh associated with the motion controller is done loading.
  48704. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48705. * A shortened version of controller -> motion controller -> on mesh loaded.
  48706. */
  48707. onMeshLoadedObservable: Observable<AbstractMesh>;
  48708. /**
  48709. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48710. */
  48711. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48712. /**
  48713. * Pointer which can be used to select objects or attach a visible laser to
  48714. */
  48715. pointer: AbstractMesh;
  48716. /**
  48717. * Creates the input source object
  48718. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48719. * @param _scene the scene which the controller should be associated to
  48720. * @param inputSource the underlying input source for the controller
  48721. * @param _options options for this controller creation
  48722. */
  48723. constructor(_scene: Scene,
  48724. /** The underlying input source for the controller */
  48725. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48726. /**
  48727. * Get this controllers unique id
  48728. */
  48729. get uniqueId(): string;
  48730. /**
  48731. * Disposes of the object
  48732. */
  48733. dispose(): void;
  48734. /**
  48735. * Gets a world space ray coming from the pointer or grip
  48736. * @param result the resulting ray
  48737. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48738. */
  48739. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48740. /**
  48741. * Updates the controller pose based on the given XRFrame
  48742. * @param xrFrame xr frame to update the pose with
  48743. * @param referenceSpace reference space to use
  48744. */
  48745. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48746. }
  48747. }
  48748. declare module BABYLON {
  48749. /**
  48750. * The schema for initialization options of the XR Input class
  48751. */
  48752. export interface IWebXRInputOptions {
  48753. /**
  48754. * If set to true no model will be automatically loaded
  48755. */
  48756. doNotLoadControllerMeshes?: boolean;
  48757. /**
  48758. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48759. * If not found, the xr input profile data will be used.
  48760. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48761. */
  48762. forceInputProfile?: string;
  48763. /**
  48764. * Do not send a request to the controller repository to load the profile.
  48765. *
  48766. * Instead, use the controllers available in babylon itself.
  48767. */
  48768. disableOnlineControllerRepository?: boolean;
  48769. /**
  48770. * A custom URL for the controllers repository
  48771. */
  48772. customControllersRepositoryURL?: string;
  48773. /**
  48774. * Should the controller model's components not move according to the user input
  48775. */
  48776. disableControllerAnimation?: boolean;
  48777. /**
  48778. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48779. */
  48780. controllerOptions?: IWebXRControllerOptions;
  48781. }
  48782. /**
  48783. * XR input used to track XR inputs such as controllers/rays
  48784. */
  48785. export class WebXRInput implements IDisposable {
  48786. /**
  48787. * the xr session manager for this session
  48788. */
  48789. xrSessionManager: WebXRSessionManager;
  48790. /**
  48791. * the WebXR camera for this session. Mainly used for teleportation
  48792. */
  48793. xrCamera: WebXRCamera;
  48794. private readonly options;
  48795. /**
  48796. * XR controllers being tracked
  48797. */
  48798. controllers: Array<WebXRInputSource>;
  48799. private _frameObserver;
  48800. private _sessionEndedObserver;
  48801. private _sessionInitObserver;
  48802. /**
  48803. * Event when a controller has been connected/added
  48804. */
  48805. onControllerAddedObservable: Observable<WebXRInputSource>;
  48806. /**
  48807. * Event when a controller has been removed/disconnected
  48808. */
  48809. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48810. /**
  48811. * Initializes the WebXRInput
  48812. * @param xrSessionManager the xr session manager for this session
  48813. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48814. * @param options = initialization options for this xr input
  48815. */
  48816. constructor(
  48817. /**
  48818. * the xr session manager for this session
  48819. */
  48820. xrSessionManager: WebXRSessionManager,
  48821. /**
  48822. * the WebXR camera for this session. Mainly used for teleportation
  48823. */
  48824. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48825. private _onInputSourcesChange;
  48826. private _addAndRemoveControllers;
  48827. /**
  48828. * Disposes of the object
  48829. */
  48830. dispose(): void;
  48831. }
  48832. }
  48833. declare module BABYLON {
  48834. /**
  48835. * This is the base class for all WebXR features.
  48836. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48837. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48838. */
  48839. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48840. protected _xrSessionManager: WebXRSessionManager;
  48841. private _attached;
  48842. private _removeOnDetach;
  48843. /**
  48844. * Is this feature disposed?
  48845. */
  48846. isDisposed: boolean;
  48847. /**
  48848. * Should auto-attach be disabled?
  48849. */
  48850. disableAutoAttach: boolean;
  48851. /**
  48852. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48853. */
  48854. xrNativeFeatureName: string;
  48855. /**
  48856. * Construct a new (abstract) WebXR feature
  48857. * @param _xrSessionManager the xr session manager for this feature
  48858. */
  48859. constructor(_xrSessionManager: WebXRSessionManager);
  48860. /**
  48861. * Is this feature attached
  48862. */
  48863. get attached(): boolean;
  48864. /**
  48865. * attach this feature
  48866. *
  48867. * @param force should attachment be forced (even when already attached)
  48868. * @returns true if successful, false is failed or already attached
  48869. */
  48870. attach(force?: boolean): boolean;
  48871. /**
  48872. * detach this feature.
  48873. *
  48874. * @returns true if successful, false if failed or already detached
  48875. */
  48876. detach(): boolean;
  48877. /**
  48878. * Dispose this feature and all of the resources attached
  48879. */
  48880. dispose(): void;
  48881. /**
  48882. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48883. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48884. *
  48885. * @returns whether or not the feature is compatible in this environment
  48886. */
  48887. isCompatible(): boolean;
  48888. /**
  48889. * This is used to register callbacks that will automatically be removed when detach is called.
  48890. * @param observable the observable to which the observer will be attached
  48891. * @param callback the callback to register
  48892. */
  48893. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48894. /**
  48895. * Code in this function will be executed on each xrFrame received from the browser.
  48896. * This function will not execute after the feature is detached.
  48897. * @param _xrFrame the current frame
  48898. */
  48899. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48900. }
  48901. }
  48902. declare module BABYLON {
  48903. /**
  48904. * Renders a layer on top of an existing scene
  48905. */
  48906. export class UtilityLayerRenderer implements IDisposable {
  48907. /** the original scene that will be rendered on top of */
  48908. originalScene: Scene;
  48909. private _pointerCaptures;
  48910. private _lastPointerEvents;
  48911. private static _DefaultUtilityLayer;
  48912. private static _DefaultKeepDepthUtilityLayer;
  48913. private _sharedGizmoLight;
  48914. private _renderCamera;
  48915. /**
  48916. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48917. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48918. * @returns the camera that is used when rendering the utility layer
  48919. */
  48920. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48921. /**
  48922. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48923. * @param cam the camera that should be used when rendering the utility layer
  48924. */
  48925. setRenderCamera(cam: Nullable<Camera>): void;
  48926. /**
  48927. * @hidden
  48928. * Light which used by gizmos to get light shading
  48929. */
  48930. _getSharedGizmoLight(): HemisphericLight;
  48931. /**
  48932. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48933. */
  48934. pickUtilitySceneFirst: boolean;
  48935. /**
  48936. * 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)
  48937. */
  48938. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48939. /**
  48940. * 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)
  48941. */
  48942. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48943. /**
  48944. * The scene that is rendered on top of the original scene
  48945. */
  48946. utilityLayerScene: Scene;
  48947. /**
  48948. * If the utility layer should automatically be rendered on top of existing scene
  48949. */
  48950. shouldRender: boolean;
  48951. /**
  48952. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48953. */
  48954. onlyCheckPointerDownEvents: boolean;
  48955. /**
  48956. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48957. */
  48958. processAllEvents: boolean;
  48959. /**
  48960. * Observable raised when the pointer move from the utility layer scene to the main scene
  48961. */
  48962. onPointerOutObservable: Observable<number>;
  48963. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48964. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48965. private _afterRenderObserver;
  48966. private _sceneDisposeObserver;
  48967. private _originalPointerObserver;
  48968. /**
  48969. * Instantiates a UtilityLayerRenderer
  48970. * @param originalScene the original scene that will be rendered on top of
  48971. * @param handleEvents boolean indicating if the utility layer should handle events
  48972. */
  48973. constructor(
  48974. /** the original scene that will be rendered on top of */
  48975. originalScene: Scene, handleEvents?: boolean);
  48976. private _notifyObservers;
  48977. /**
  48978. * Renders the utility layers scene on top of the original scene
  48979. */
  48980. render(): void;
  48981. /**
  48982. * Disposes of the renderer
  48983. */
  48984. dispose(): void;
  48985. private _updateCamera;
  48986. }
  48987. }
  48988. declare module BABYLON {
  48989. /**
  48990. * Options interface for the pointer selection module
  48991. */
  48992. export interface IWebXRControllerPointerSelectionOptions {
  48993. /**
  48994. * if provided, this scene will be used to render meshes.
  48995. */
  48996. customUtilityLayerScene?: Scene;
  48997. /**
  48998. * 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)
  48999. * If not disabled, the last picked point will be used to execute a pointer up event
  49000. * If disabled, pointer up event will be triggered right after the pointer down event.
  49001. * Used in screen and gaze target ray mode only
  49002. */
  49003. disablePointerUpOnTouchOut: boolean;
  49004. /**
  49005. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  49006. */
  49007. forceGazeMode: boolean;
  49008. /**
  49009. * 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
  49010. * to start a new countdown to the pointer down event.
  49011. * Defaults to 1.
  49012. */
  49013. gazeModePointerMovedFactor?: number;
  49014. /**
  49015. * Different button type to use instead of the main component
  49016. */
  49017. overrideButtonId?: string;
  49018. /**
  49019. * use this rendering group id for the meshes (optional)
  49020. */
  49021. renderingGroupId?: number;
  49022. /**
  49023. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49024. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49025. * 3000 means 3 seconds between pointing at something and selecting it
  49026. */
  49027. timeToSelect?: number;
  49028. /**
  49029. * Should meshes created here be added to a utility layer or the main scene
  49030. */
  49031. useUtilityLayer?: boolean;
  49032. /**
  49033. * Optional WebXR camera to be used for gaze selection
  49034. */
  49035. gazeCamera?: WebXRCamera;
  49036. /**
  49037. * the xr input to use with this pointer selection
  49038. */
  49039. xrInput: WebXRInput;
  49040. }
  49041. /**
  49042. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49043. */
  49044. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49045. private readonly _options;
  49046. private static _idCounter;
  49047. private _attachController;
  49048. private _controllers;
  49049. private _scene;
  49050. private _tmpVectorForPickCompare;
  49051. /**
  49052. * The module's name
  49053. */
  49054. static readonly Name: string;
  49055. /**
  49056. * The (Babylon) version of this module.
  49057. * This is an integer representing the implementation version.
  49058. * This number does not correspond to the WebXR specs version
  49059. */
  49060. static readonly Version: number;
  49061. /**
  49062. * Disable lighting on the laser pointer (so it will always be visible)
  49063. */
  49064. disablePointerLighting: boolean;
  49065. /**
  49066. * Disable lighting on the selection mesh (so it will always be visible)
  49067. */
  49068. disableSelectionMeshLighting: boolean;
  49069. /**
  49070. * Should the laser pointer be displayed
  49071. */
  49072. displayLaserPointer: boolean;
  49073. /**
  49074. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49075. */
  49076. displaySelectionMesh: boolean;
  49077. /**
  49078. * This color will be set to the laser pointer when selection is triggered
  49079. */
  49080. laserPointerPickedColor: Color3;
  49081. /**
  49082. * Default color of the laser pointer
  49083. */
  49084. laserPointerDefaultColor: Color3;
  49085. /**
  49086. * default color of the selection ring
  49087. */
  49088. selectionMeshDefaultColor: Color3;
  49089. /**
  49090. * This color will be applied to the selection ring when selection is triggered
  49091. */
  49092. selectionMeshPickedColor: Color3;
  49093. /**
  49094. * Optional filter to be used for ray selection. This predicate shares behavior with
  49095. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49096. */
  49097. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49098. /**
  49099. * constructs a new background remover module
  49100. * @param _xrSessionManager the session manager for this module
  49101. * @param _options read-only options to be used in this module
  49102. */
  49103. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49104. /**
  49105. * attach this feature
  49106. * Will usually be called by the features manager
  49107. *
  49108. * @returns true if successful.
  49109. */
  49110. attach(): boolean;
  49111. /**
  49112. * detach this feature.
  49113. * Will usually be called by the features manager
  49114. *
  49115. * @returns true if successful.
  49116. */
  49117. detach(): boolean;
  49118. /**
  49119. * Will get the mesh under a specific pointer.
  49120. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49121. * @param controllerId the controllerId to check
  49122. * @returns The mesh under pointer or null if no mesh is under the pointer
  49123. */
  49124. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49125. /**
  49126. * Get the xr controller that correlates to the pointer id in the pointer event
  49127. *
  49128. * @param id the pointer id to search for
  49129. * @returns the controller that correlates to this id or null if not found
  49130. */
  49131. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49132. protected _onXRFrame(_xrFrame: XRFrame): void;
  49133. private _attachGazeMode;
  49134. private _attachScreenRayMode;
  49135. private _attachTrackedPointerRayMode;
  49136. private _convertNormalToDirectionOfRay;
  49137. private _detachController;
  49138. private _generateNewMeshPair;
  49139. private _pickingMoved;
  49140. private _updatePointerDistance;
  49141. /** @hidden */
  49142. get lasterPointerDefaultColor(): Color3;
  49143. }
  49144. }
  49145. declare module BABYLON {
  49146. /**
  49147. * Button which can be used to enter a different mode of XR
  49148. */
  49149. export class WebXREnterExitUIButton {
  49150. /** button element */
  49151. element: HTMLElement;
  49152. /** XR initialization options for the button */
  49153. sessionMode: XRSessionMode;
  49154. /** Reference space type */
  49155. referenceSpaceType: XRReferenceSpaceType;
  49156. /**
  49157. * Creates a WebXREnterExitUIButton
  49158. * @param element button element
  49159. * @param sessionMode XR initialization session mode
  49160. * @param referenceSpaceType the type of reference space to be used
  49161. */
  49162. constructor(
  49163. /** button element */
  49164. element: HTMLElement,
  49165. /** XR initialization options for the button */
  49166. sessionMode: XRSessionMode,
  49167. /** Reference space type */
  49168. referenceSpaceType: XRReferenceSpaceType);
  49169. /**
  49170. * Extendable function which can be used to update the button's visuals when the state changes
  49171. * @param activeButton the current active button in the UI
  49172. */
  49173. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49174. }
  49175. /**
  49176. * Options to create the webXR UI
  49177. */
  49178. export class WebXREnterExitUIOptions {
  49179. /**
  49180. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49181. */
  49182. customButtons?: Array<WebXREnterExitUIButton>;
  49183. /**
  49184. * A reference space type to use when creating the default button.
  49185. * Default is local-floor
  49186. */
  49187. referenceSpaceType?: XRReferenceSpaceType;
  49188. /**
  49189. * Context to enter xr with
  49190. */
  49191. renderTarget?: Nullable<WebXRRenderTarget>;
  49192. /**
  49193. * A session mode to use when creating the default button.
  49194. * Default is immersive-vr
  49195. */
  49196. sessionMode?: XRSessionMode;
  49197. /**
  49198. * A list of optional features to init the session with
  49199. */
  49200. optionalFeatures?: string[];
  49201. /**
  49202. * A list of optional features to init the session with
  49203. */
  49204. requiredFeatures?: string[];
  49205. }
  49206. /**
  49207. * UI to allow the user to enter/exit XR mode
  49208. */
  49209. export class WebXREnterExitUI implements IDisposable {
  49210. private scene;
  49211. /** version of the options passed to this UI */
  49212. options: WebXREnterExitUIOptions;
  49213. private _activeButton;
  49214. private _buttons;
  49215. /**
  49216. * The HTML Div Element to which buttons are added.
  49217. */
  49218. readonly overlay: HTMLDivElement;
  49219. /**
  49220. * Fired every time the active button is changed.
  49221. *
  49222. * When xr is entered via a button that launches xr that button will be the callback parameter
  49223. *
  49224. * When exiting xr the callback parameter will be null)
  49225. */
  49226. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49227. /**
  49228. *
  49229. * @param scene babylon scene object to use
  49230. * @param options (read-only) version of the options passed to this UI
  49231. */
  49232. private constructor();
  49233. /**
  49234. * Creates UI to allow the user to enter/exit XR mode
  49235. * @param scene the scene to add the ui to
  49236. * @param helper the xr experience helper to enter/exit xr with
  49237. * @param options options to configure the UI
  49238. * @returns the created ui
  49239. */
  49240. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49241. /**
  49242. * Disposes of the XR UI component
  49243. */
  49244. dispose(): void;
  49245. private _updateButtons;
  49246. }
  49247. }
  49248. declare module BABYLON {
  49249. /**
  49250. * Class containing static functions to help procedurally build meshes
  49251. */
  49252. export class LinesBuilder {
  49253. /**
  49254. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49255. * * 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
  49256. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49257. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49258. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49259. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49260. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49261. * * 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
  49262. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49265. * @param name defines the name of the new line system
  49266. * @param options defines the options used to create the line system
  49267. * @param scene defines the hosting scene
  49268. * @returns a new line system mesh
  49269. */
  49270. static CreateLineSystem(name: string, options: {
  49271. lines: Vector3[][];
  49272. updatable?: boolean;
  49273. instance?: Nullable<LinesMesh>;
  49274. colors?: Nullable<Color4[][]>;
  49275. useVertexAlpha?: boolean;
  49276. }, scene: Nullable<Scene>): LinesMesh;
  49277. /**
  49278. * Creates a line mesh
  49279. * 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
  49280. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49281. * * The parameter `points` is an array successive Vector3
  49282. * * 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
  49283. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49284. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49285. * * When updating an instance, remember that only point positions can change, not the number of points
  49286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49288. * @param name defines the name of the new line system
  49289. * @param options defines the options used to create the line system
  49290. * @param scene defines the hosting scene
  49291. * @returns a new line mesh
  49292. */
  49293. static CreateLines(name: string, options: {
  49294. points: Vector3[];
  49295. updatable?: boolean;
  49296. instance?: Nullable<LinesMesh>;
  49297. colors?: Color4[];
  49298. useVertexAlpha?: boolean;
  49299. }, scene?: Nullable<Scene>): LinesMesh;
  49300. /**
  49301. * Creates a dashed line mesh
  49302. * * 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
  49303. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49304. * * The parameter `points` is an array successive Vector3
  49305. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49306. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49307. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49308. * * 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
  49309. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49310. * * When updating an instance, remember that only point positions can change, not the number of points
  49311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49312. * @param name defines the name of the mesh
  49313. * @param options defines the options used to create the mesh
  49314. * @param scene defines the hosting scene
  49315. * @returns the dashed line mesh
  49316. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49317. */
  49318. static CreateDashedLines(name: string, options: {
  49319. points: Vector3[];
  49320. dashSize?: number;
  49321. gapSize?: number;
  49322. dashNb?: number;
  49323. updatable?: boolean;
  49324. instance?: LinesMesh;
  49325. useVertexAlpha?: boolean;
  49326. }, scene?: Nullable<Scene>): LinesMesh;
  49327. }
  49328. }
  49329. declare module BABYLON {
  49330. /**
  49331. * Construction options for a timer
  49332. */
  49333. export interface ITimerOptions<T> {
  49334. /**
  49335. * Time-to-end
  49336. */
  49337. timeout: number;
  49338. /**
  49339. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49340. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49341. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49342. */
  49343. contextObservable: Observable<T>;
  49344. /**
  49345. * Optional parameters when adding an observer to the observable
  49346. */
  49347. observableParameters?: {
  49348. mask?: number;
  49349. insertFirst?: boolean;
  49350. scope?: any;
  49351. };
  49352. /**
  49353. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49354. */
  49355. breakCondition?: (data?: ITimerData<T>) => boolean;
  49356. /**
  49357. * Will be triggered when the time condition has met
  49358. */
  49359. onEnded?: (data: ITimerData<any>) => void;
  49360. /**
  49361. * Will be triggered when the break condition has met (prematurely ended)
  49362. */
  49363. onAborted?: (data: ITimerData<any>) => void;
  49364. /**
  49365. * Optional function to execute on each tick (or count)
  49366. */
  49367. onTick?: (data: ITimerData<any>) => void;
  49368. }
  49369. /**
  49370. * An interface defining the data sent by the timer
  49371. */
  49372. export interface ITimerData<T> {
  49373. /**
  49374. * When did it start
  49375. */
  49376. startTime: number;
  49377. /**
  49378. * Time now
  49379. */
  49380. currentTime: number;
  49381. /**
  49382. * Time passed since started
  49383. */
  49384. deltaTime: number;
  49385. /**
  49386. * How much is completed, in [0.0...1.0].
  49387. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49388. */
  49389. completeRate: number;
  49390. /**
  49391. * What the registered observable sent in the last count
  49392. */
  49393. payload: T;
  49394. }
  49395. /**
  49396. * The current state of the timer
  49397. */
  49398. export enum TimerState {
  49399. /**
  49400. * Timer initialized, not yet started
  49401. */
  49402. INIT = 0,
  49403. /**
  49404. * Timer started and counting
  49405. */
  49406. STARTED = 1,
  49407. /**
  49408. * Timer ended (whether aborted or time reached)
  49409. */
  49410. ENDED = 2
  49411. }
  49412. /**
  49413. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49414. *
  49415. * @param options options with which to initialize this timer
  49416. */
  49417. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49418. /**
  49419. * An advanced implementation of a timer class
  49420. */
  49421. export class AdvancedTimer<T = any> implements IDisposable {
  49422. /**
  49423. * Will notify each time the timer calculates the remaining time
  49424. */
  49425. onEachCountObservable: Observable<ITimerData<T>>;
  49426. /**
  49427. * Will trigger when the timer was aborted due to the break condition
  49428. */
  49429. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49430. /**
  49431. * Will trigger when the timer ended successfully
  49432. */
  49433. onTimerEndedObservable: Observable<ITimerData<T>>;
  49434. /**
  49435. * Will trigger when the timer state has changed
  49436. */
  49437. onStateChangedObservable: Observable<TimerState>;
  49438. private _observer;
  49439. private _contextObservable;
  49440. private _observableParameters;
  49441. private _startTime;
  49442. private _timer;
  49443. private _state;
  49444. private _breakCondition;
  49445. private _timeToEnd;
  49446. private _breakOnNextTick;
  49447. /**
  49448. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49449. * @param options construction options for this advanced timer
  49450. */
  49451. constructor(options: ITimerOptions<T>);
  49452. /**
  49453. * set a breaking condition for this timer. Default is to never break during count
  49454. * @param predicate the new break condition. Returns true to break, false otherwise
  49455. */
  49456. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49457. /**
  49458. * Reset ALL associated observables in this advanced timer
  49459. */
  49460. clearObservables(): void;
  49461. /**
  49462. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49463. *
  49464. * @param timeToEnd how much time to measure until timer ended
  49465. */
  49466. start(timeToEnd?: number): void;
  49467. /**
  49468. * Will force a stop on the next tick.
  49469. */
  49470. stop(): void;
  49471. /**
  49472. * Dispose this timer, clearing all resources
  49473. */
  49474. dispose(): void;
  49475. private _setState;
  49476. private _tick;
  49477. private _stop;
  49478. }
  49479. }
  49480. declare module BABYLON {
  49481. /**
  49482. * The options container for the teleportation module
  49483. */
  49484. export interface IWebXRTeleportationOptions {
  49485. /**
  49486. * if provided, this scene will be used to render meshes.
  49487. */
  49488. customUtilityLayerScene?: Scene;
  49489. /**
  49490. * Values to configure the default target mesh
  49491. */
  49492. defaultTargetMeshOptions?: {
  49493. /**
  49494. * Fill color of the teleportation area
  49495. */
  49496. teleportationFillColor?: string;
  49497. /**
  49498. * Border color for the teleportation area
  49499. */
  49500. teleportationBorderColor?: string;
  49501. /**
  49502. * Disable the mesh's animation sequence
  49503. */
  49504. disableAnimation?: boolean;
  49505. /**
  49506. * Disable lighting on the material or the ring and arrow
  49507. */
  49508. disableLighting?: boolean;
  49509. /**
  49510. * Override the default material of the torus and arrow
  49511. */
  49512. torusArrowMaterial?: Material;
  49513. };
  49514. /**
  49515. * A list of meshes to use as floor meshes.
  49516. * Meshes can be added and removed after initializing the feature using the
  49517. * addFloorMesh and removeFloorMesh functions
  49518. * If empty, rotation will still work
  49519. */
  49520. floorMeshes?: AbstractMesh[];
  49521. /**
  49522. * use this rendering group id for the meshes (optional)
  49523. */
  49524. renderingGroupId?: number;
  49525. /**
  49526. * Should teleportation move only to snap points
  49527. */
  49528. snapPointsOnly?: boolean;
  49529. /**
  49530. * An array of points to which the teleportation will snap to.
  49531. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49532. */
  49533. snapPositions?: Vector3[];
  49534. /**
  49535. * How close should the teleportation ray be in order to snap to position.
  49536. * Default to 0.8 units (meters)
  49537. */
  49538. snapToPositionRadius?: number;
  49539. /**
  49540. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49541. * If you want to support rotation, make sure your mesh has a direction indicator.
  49542. *
  49543. * When left untouched, the default mesh will be initialized.
  49544. */
  49545. teleportationTargetMesh?: AbstractMesh;
  49546. /**
  49547. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49548. */
  49549. timeToTeleport?: number;
  49550. /**
  49551. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49552. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49553. */
  49554. useMainComponentOnly?: boolean;
  49555. /**
  49556. * Should meshes created here be added to a utility layer or the main scene
  49557. */
  49558. useUtilityLayer?: boolean;
  49559. /**
  49560. * Babylon XR Input class for controller
  49561. */
  49562. xrInput: WebXRInput;
  49563. /**
  49564. * Meshes that the teleportation ray cannot go through
  49565. */
  49566. pickBlockerMeshes?: AbstractMesh[];
  49567. }
  49568. /**
  49569. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49570. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49571. * the input of the attached controllers.
  49572. */
  49573. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49574. private _options;
  49575. private _controllers;
  49576. private _currentTeleportationControllerId;
  49577. private _floorMeshes;
  49578. private _quadraticBezierCurve;
  49579. private _selectionFeature;
  49580. private _snapToPositions;
  49581. private _snappedToPoint;
  49582. private _teleportationRingMaterial?;
  49583. private _tmpRay;
  49584. private _tmpVector;
  49585. private _tmpQuaternion;
  49586. /**
  49587. * The module's name
  49588. */
  49589. static readonly Name: string;
  49590. /**
  49591. * The (Babylon) version of this module.
  49592. * This is an integer representing the implementation version.
  49593. * This number does not correspond to the webxr specs version
  49594. */
  49595. static readonly Version: number;
  49596. /**
  49597. * Is movement backwards enabled
  49598. */
  49599. backwardsMovementEnabled: boolean;
  49600. /**
  49601. * Distance to travel when moving backwards
  49602. */
  49603. backwardsTeleportationDistance: number;
  49604. /**
  49605. * The distance from the user to the inspection point in the direction of the controller
  49606. * A higher number will allow the user to move further
  49607. * defaults to 5 (meters, in xr units)
  49608. */
  49609. parabolicCheckRadius: number;
  49610. /**
  49611. * Should the module support parabolic ray on top of direct ray
  49612. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49613. * Very helpful when moving between floors / different heights
  49614. */
  49615. parabolicRayEnabled: boolean;
  49616. /**
  49617. * How much rotation should be applied when rotating right and left
  49618. */
  49619. rotationAngle: number;
  49620. /**
  49621. * Is rotation enabled when moving forward?
  49622. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49623. */
  49624. rotationEnabled: boolean;
  49625. /**
  49626. * constructs a new anchor system
  49627. * @param _xrSessionManager an instance of WebXRSessionManager
  49628. * @param _options configuration object for this feature
  49629. */
  49630. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49631. /**
  49632. * Get the snapPointsOnly flag
  49633. */
  49634. get snapPointsOnly(): boolean;
  49635. /**
  49636. * Sets the snapPointsOnly flag
  49637. * @param snapToPoints should teleportation be exclusively to snap points
  49638. */
  49639. set snapPointsOnly(snapToPoints: boolean);
  49640. /**
  49641. * Add a new mesh to the floor meshes array
  49642. * @param mesh the mesh to use as floor mesh
  49643. */
  49644. addFloorMesh(mesh: AbstractMesh): void;
  49645. /**
  49646. * Add a new snap-to point to fix teleportation to this position
  49647. * @param newSnapPoint The new Snap-To point
  49648. */
  49649. addSnapPoint(newSnapPoint: Vector3): void;
  49650. attach(): boolean;
  49651. detach(): boolean;
  49652. dispose(): void;
  49653. /**
  49654. * Remove a mesh from the floor meshes array
  49655. * @param mesh the mesh to remove
  49656. */
  49657. removeFloorMesh(mesh: AbstractMesh): void;
  49658. /**
  49659. * Remove a mesh from the floor meshes array using its name
  49660. * @param name the mesh name to remove
  49661. */
  49662. removeFloorMeshByName(name: string): void;
  49663. /**
  49664. * 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
  49665. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49666. * @returns was the point found and removed or not
  49667. */
  49668. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49669. /**
  49670. * This function sets a selection feature that will be disabled when
  49671. * the forward ray is shown and will be reattached when hidden.
  49672. * This is used to remove the selection rays when moving.
  49673. * @param selectionFeature the feature to disable when forward movement is enabled
  49674. */
  49675. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  49676. protected _onXRFrame(_xrFrame: XRFrame): void;
  49677. private _attachController;
  49678. private _createDefaultTargetMesh;
  49679. private _detachController;
  49680. private _findClosestSnapPointWithRadius;
  49681. private _setTargetMeshPosition;
  49682. private _setTargetMeshVisibility;
  49683. private _showParabolicPath;
  49684. private _teleportForward;
  49685. }
  49686. }
  49687. declare module BABYLON {
  49688. /**
  49689. * Options for the default xr helper
  49690. */
  49691. export class WebXRDefaultExperienceOptions {
  49692. /**
  49693. * Enable or disable default UI to enter XR
  49694. */
  49695. disableDefaultUI?: boolean;
  49696. /**
  49697. * Should teleportation not initialize. defaults to false.
  49698. */
  49699. disableTeleportation?: boolean;
  49700. /**
  49701. * Floor meshes that will be used for teleport
  49702. */
  49703. floorMeshes?: Array<AbstractMesh>;
  49704. /**
  49705. * If set to true, the first frame will not be used to reset position
  49706. * The first frame is mainly used when copying transformation from the old camera
  49707. * Mainly used in AR
  49708. */
  49709. ignoreNativeCameraTransformation?: boolean;
  49710. /**
  49711. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49712. */
  49713. inputOptions?: IWebXRInputOptions;
  49714. /**
  49715. * optional configuration for the output canvas
  49716. */
  49717. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49718. /**
  49719. * optional UI options. This can be used among other to change session mode and reference space type
  49720. */
  49721. uiOptions?: WebXREnterExitUIOptions;
  49722. /**
  49723. * When loading teleportation and pointer select, use stable versions instead of latest.
  49724. */
  49725. useStablePlugins?: boolean;
  49726. /**
  49727. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49728. */
  49729. renderingGroupId?: number;
  49730. /**
  49731. * A list of optional features to init the session with
  49732. * If set to true, all features we support will be added
  49733. */
  49734. optionalFeatures?: boolean | string[];
  49735. }
  49736. /**
  49737. * Default experience which provides a similar setup to the previous webVRExperience
  49738. */
  49739. export class WebXRDefaultExperience {
  49740. /**
  49741. * Base experience
  49742. */
  49743. baseExperience: WebXRExperienceHelper;
  49744. /**
  49745. * Enables ui for entering/exiting xr
  49746. */
  49747. enterExitUI: WebXREnterExitUI;
  49748. /**
  49749. * Input experience extension
  49750. */
  49751. input: WebXRInput;
  49752. /**
  49753. * Enables laser pointer and selection
  49754. */
  49755. pointerSelection: WebXRControllerPointerSelection;
  49756. /**
  49757. * Default target xr should render to
  49758. */
  49759. renderTarget: WebXRRenderTarget;
  49760. /**
  49761. * Enables teleportation
  49762. */
  49763. teleportation: WebXRMotionControllerTeleportation;
  49764. private constructor();
  49765. /**
  49766. * Creates the default xr experience
  49767. * @param scene scene
  49768. * @param options options for basic configuration
  49769. * @returns resulting WebXRDefaultExperience
  49770. */
  49771. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49772. /**
  49773. * DIsposes of the experience helper
  49774. */
  49775. dispose(): void;
  49776. }
  49777. }
  49778. declare module BABYLON {
  49779. /**
  49780. * Options to modify the vr teleportation behavior.
  49781. */
  49782. export interface VRTeleportationOptions {
  49783. /**
  49784. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49785. */
  49786. floorMeshName?: string;
  49787. /**
  49788. * A list of meshes to be used as the teleportation floor. (default: empty)
  49789. */
  49790. floorMeshes?: Mesh[];
  49791. /**
  49792. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49793. */
  49794. teleportationMode?: number;
  49795. /**
  49796. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49797. */
  49798. teleportationTime?: number;
  49799. /**
  49800. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49801. */
  49802. teleportationSpeed?: number;
  49803. /**
  49804. * The easing function used in the animation or null for Linear. (default CircleEase)
  49805. */
  49806. easingFunction?: EasingFunction;
  49807. }
  49808. /**
  49809. * Options to modify the vr experience helper's behavior.
  49810. */
  49811. export interface VRExperienceHelperOptions extends WebVROptions {
  49812. /**
  49813. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49814. */
  49815. createDeviceOrientationCamera?: boolean;
  49816. /**
  49817. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49818. */
  49819. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49820. /**
  49821. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49822. */
  49823. laserToggle?: boolean;
  49824. /**
  49825. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49826. */
  49827. floorMeshes?: Mesh[];
  49828. /**
  49829. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49830. */
  49831. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49832. /**
  49833. * Defines if WebXR should be used instead of WebVR (if available)
  49834. */
  49835. useXR?: boolean;
  49836. }
  49837. /**
  49838. * Event containing information after VR has been entered
  49839. */
  49840. export class OnAfterEnteringVRObservableEvent {
  49841. /**
  49842. * If entering vr was successful
  49843. */
  49844. success: boolean;
  49845. }
  49846. /**
  49847. * Helps to quickly add VR support to an existing scene.
  49848. * See https://doc.babylonjs.com/how_to/webvr_helper
  49849. */
  49850. export class VRExperienceHelper {
  49851. /** Options to modify the vr experience helper's behavior. */
  49852. webVROptions: VRExperienceHelperOptions;
  49853. private _scene;
  49854. private _position;
  49855. private _btnVR;
  49856. private _btnVRDisplayed;
  49857. private _webVRsupported;
  49858. private _webVRready;
  49859. private _webVRrequesting;
  49860. private _webVRpresenting;
  49861. private _hasEnteredVR;
  49862. private _fullscreenVRpresenting;
  49863. private _inputElement;
  49864. private _webVRCamera;
  49865. private _vrDeviceOrientationCamera;
  49866. private _deviceOrientationCamera;
  49867. private _existingCamera;
  49868. private _onKeyDown;
  49869. private _onVrDisplayPresentChange;
  49870. private _onVRDisplayChanged;
  49871. private _onVRRequestPresentStart;
  49872. private _onVRRequestPresentComplete;
  49873. /**
  49874. * 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)
  49875. */
  49876. enableGazeEvenWhenNoPointerLock: boolean;
  49877. /**
  49878. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49879. */
  49880. exitVROnDoubleTap: boolean;
  49881. /**
  49882. * Observable raised right before entering VR.
  49883. */
  49884. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49885. /**
  49886. * Observable raised when entering VR has completed.
  49887. */
  49888. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49889. /**
  49890. * Observable raised when exiting VR.
  49891. */
  49892. onExitingVRObservable: Observable<VRExperienceHelper>;
  49893. /**
  49894. * Observable raised when controller mesh is loaded.
  49895. */
  49896. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49897. /** Return this.onEnteringVRObservable
  49898. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49899. */
  49900. get onEnteringVR(): Observable<VRExperienceHelper>;
  49901. /** Return this.onExitingVRObservable
  49902. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49903. */
  49904. get onExitingVR(): Observable<VRExperienceHelper>;
  49905. /** Return this.onControllerMeshLoadedObservable
  49906. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49907. */
  49908. get onControllerMeshLoaded(): Observable<WebVRController>;
  49909. private _rayLength;
  49910. private _useCustomVRButton;
  49911. private _teleportationRequested;
  49912. private _teleportActive;
  49913. private _floorMeshName;
  49914. private _floorMeshesCollection;
  49915. private _teleportationMode;
  49916. private _teleportationTime;
  49917. private _teleportationSpeed;
  49918. private _teleportationEasing;
  49919. private _rotationAllowed;
  49920. private _teleportBackwardsVector;
  49921. private _teleportationTarget;
  49922. private _isDefaultTeleportationTarget;
  49923. private _postProcessMove;
  49924. private _teleportationFillColor;
  49925. private _teleportationBorderColor;
  49926. private _rotationAngle;
  49927. private _haloCenter;
  49928. private _cameraGazer;
  49929. private _padSensibilityUp;
  49930. private _padSensibilityDown;
  49931. private _leftController;
  49932. private _rightController;
  49933. private _gazeColor;
  49934. private _laserColor;
  49935. private _pickedLaserColor;
  49936. private _pickedGazeColor;
  49937. /**
  49938. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49939. */
  49940. onNewMeshSelected: Observable<AbstractMesh>;
  49941. /**
  49942. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49943. * This observable will provide the mesh and the controller used to select the mesh
  49944. */
  49945. onMeshSelectedWithController: Observable<{
  49946. mesh: AbstractMesh;
  49947. controller: WebVRController;
  49948. }>;
  49949. /**
  49950. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49951. */
  49952. onNewMeshPicked: Observable<PickingInfo>;
  49953. private _circleEase;
  49954. /**
  49955. * Observable raised before camera teleportation
  49956. */
  49957. onBeforeCameraTeleport: Observable<Vector3>;
  49958. /**
  49959. * Observable raised after camera teleportation
  49960. */
  49961. onAfterCameraTeleport: Observable<Vector3>;
  49962. /**
  49963. * Observable raised when current selected mesh gets unselected
  49964. */
  49965. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49966. private _raySelectionPredicate;
  49967. /**
  49968. * To be optionaly changed by user to define custom ray selection
  49969. */
  49970. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49971. /**
  49972. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49973. */
  49974. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49975. /**
  49976. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49977. */
  49978. teleportationEnabled: boolean;
  49979. private _defaultHeight;
  49980. private _teleportationInitialized;
  49981. private _interactionsEnabled;
  49982. private _interactionsRequested;
  49983. private _displayGaze;
  49984. private _displayLaserPointer;
  49985. /**
  49986. * The mesh used to display where the user is going to teleport.
  49987. */
  49988. get teleportationTarget(): Mesh;
  49989. /**
  49990. * Sets the mesh to be used to display where the user is going to teleport.
  49991. */
  49992. set teleportationTarget(value: Mesh);
  49993. /**
  49994. * 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
  49995. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49996. * See https://doc.babylonjs.com/resources/baking_transformations
  49997. */
  49998. get gazeTrackerMesh(): Mesh;
  49999. set gazeTrackerMesh(value: Mesh);
  50000. /**
  50001. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50002. */
  50003. updateGazeTrackerScale: boolean;
  50004. /**
  50005. * If the gaze trackers color should be updated when selecting meshes
  50006. */
  50007. updateGazeTrackerColor: boolean;
  50008. /**
  50009. * If the controller laser color should be updated when selecting meshes
  50010. */
  50011. updateControllerLaserColor: boolean;
  50012. /**
  50013. * The gaze tracking mesh corresponding to the left controller
  50014. */
  50015. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50016. /**
  50017. * The gaze tracking mesh corresponding to the right controller
  50018. */
  50019. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50020. /**
  50021. * If the ray of the gaze should be displayed.
  50022. */
  50023. get displayGaze(): boolean;
  50024. /**
  50025. * Sets if the ray of the gaze should be displayed.
  50026. */
  50027. set displayGaze(value: boolean);
  50028. /**
  50029. * If the ray of the LaserPointer should be displayed.
  50030. */
  50031. get displayLaserPointer(): boolean;
  50032. /**
  50033. * Sets if the ray of the LaserPointer should be displayed.
  50034. */
  50035. set displayLaserPointer(value: boolean);
  50036. /**
  50037. * The deviceOrientationCamera used as the camera when not in VR.
  50038. */
  50039. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50040. /**
  50041. * Based on the current WebVR support, returns the current VR camera used.
  50042. */
  50043. get currentVRCamera(): Nullable<Camera>;
  50044. /**
  50045. * The webVRCamera which is used when in VR.
  50046. */
  50047. get webVRCamera(): WebVRFreeCamera;
  50048. /**
  50049. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50050. */
  50051. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50052. /**
  50053. * The html button that is used to trigger entering into VR.
  50054. */
  50055. get vrButton(): Nullable<HTMLButtonElement>;
  50056. private get _teleportationRequestInitiated();
  50057. /**
  50058. * Defines whether or not Pointer lock should be requested when switching to
  50059. * full screen.
  50060. */
  50061. requestPointerLockOnFullScreen: boolean;
  50062. /**
  50063. * If asking to force XR, this will be populated with the default xr experience
  50064. */
  50065. xr: WebXRDefaultExperience;
  50066. /**
  50067. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50068. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50069. */
  50070. xrTestDone: boolean;
  50071. /**
  50072. * Instantiates a VRExperienceHelper.
  50073. * Helps to quickly add VR support to an existing scene.
  50074. * @param scene The scene the VRExperienceHelper belongs to.
  50075. * @param webVROptions Options to modify the vr experience helper's behavior.
  50076. */
  50077. constructor(scene: Scene,
  50078. /** Options to modify the vr experience helper's behavior. */
  50079. webVROptions?: VRExperienceHelperOptions);
  50080. private completeVRInit;
  50081. private _onDefaultMeshLoaded;
  50082. private _onResize;
  50083. private _onFullscreenChange;
  50084. /**
  50085. * Gets a value indicating if we are currently in VR mode.
  50086. */
  50087. get isInVRMode(): boolean;
  50088. private onVrDisplayPresentChange;
  50089. private onVRDisplayChanged;
  50090. private moveButtonToBottomRight;
  50091. private displayVRButton;
  50092. private updateButtonVisibility;
  50093. private _cachedAngularSensibility;
  50094. /**
  50095. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50096. * Otherwise, will use the fullscreen API.
  50097. */
  50098. enterVR(): void;
  50099. /**
  50100. * Attempt to exit VR, or fullscreen.
  50101. */
  50102. exitVR(): void;
  50103. /**
  50104. * The position of the vr experience helper.
  50105. */
  50106. get position(): Vector3;
  50107. /**
  50108. * Sets the position of the vr experience helper.
  50109. */
  50110. set position(value: Vector3);
  50111. /**
  50112. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50113. */
  50114. enableInteractions(): void;
  50115. private get _noControllerIsActive();
  50116. private beforeRender;
  50117. private _isTeleportationFloor;
  50118. /**
  50119. * Adds a floor mesh to be used for teleportation.
  50120. * @param floorMesh the mesh to be used for teleportation.
  50121. */
  50122. addFloorMesh(floorMesh: Mesh): void;
  50123. /**
  50124. * Removes a floor mesh from being used for teleportation.
  50125. * @param floorMesh the mesh to be removed.
  50126. */
  50127. removeFloorMesh(floorMesh: Mesh): void;
  50128. /**
  50129. * Enables interactions and teleportation using the VR controllers and gaze.
  50130. * @param vrTeleportationOptions options to modify teleportation behavior.
  50131. */
  50132. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50133. private _onNewGamepadConnected;
  50134. private _tryEnableInteractionOnController;
  50135. private _onNewGamepadDisconnected;
  50136. private _enableInteractionOnController;
  50137. private _checkTeleportWithRay;
  50138. private _checkRotate;
  50139. private _checkTeleportBackwards;
  50140. private _enableTeleportationOnController;
  50141. private _createTeleportationCircles;
  50142. private _displayTeleportationTarget;
  50143. private _hideTeleportationTarget;
  50144. private _rotateCamera;
  50145. private _moveTeleportationSelectorTo;
  50146. private _workingVector;
  50147. private _workingQuaternion;
  50148. private _workingMatrix;
  50149. /**
  50150. * Time Constant Teleportation Mode
  50151. */
  50152. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50153. /**
  50154. * Speed Constant Teleportation Mode
  50155. */
  50156. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50157. /**
  50158. * Teleports the users feet to the desired location
  50159. * @param location The location where the user's feet should be placed
  50160. */
  50161. teleportCamera(location: Vector3): void;
  50162. private _convertNormalToDirectionOfRay;
  50163. private _castRayAndSelectObject;
  50164. private _notifySelectedMeshUnselected;
  50165. /**
  50166. * Permanently set new colors for the laser pointer
  50167. * @param color the new laser color
  50168. * @param pickedColor the new laser color when picked mesh detected
  50169. */
  50170. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50171. /**
  50172. * Set lighting enabled / disabled on the laser pointer of both controllers
  50173. * @param enabled should the lighting be enabled on the laser pointer
  50174. */
  50175. setLaserLightingState(enabled?: boolean): void;
  50176. /**
  50177. * Permanently set new colors for the gaze pointer
  50178. * @param color the new gaze color
  50179. * @param pickedColor the new gaze color when picked mesh detected
  50180. */
  50181. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50182. /**
  50183. * Sets the color of the laser ray from the vr controllers.
  50184. * @param color new color for the ray.
  50185. */
  50186. changeLaserColor(color: Color3): void;
  50187. /**
  50188. * Sets the color of the ray from the vr headsets gaze.
  50189. * @param color new color for the ray.
  50190. */
  50191. changeGazeColor(color: Color3): void;
  50192. /**
  50193. * Exits VR and disposes of the vr experience helper
  50194. */
  50195. dispose(): void;
  50196. /**
  50197. * Gets the name of the VRExperienceHelper class
  50198. * @returns "VRExperienceHelper"
  50199. */
  50200. getClassName(): string;
  50201. }
  50202. }
  50203. declare module BABYLON {
  50204. /**
  50205. * Contains an array of blocks representing the octree
  50206. */
  50207. export interface IOctreeContainer<T> {
  50208. /**
  50209. * Blocks within the octree
  50210. */
  50211. blocks: Array<OctreeBlock<T>>;
  50212. }
  50213. /**
  50214. * Class used to store a cell in an octree
  50215. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50216. */
  50217. export class OctreeBlock<T> {
  50218. /**
  50219. * Gets the content of the current block
  50220. */
  50221. entries: T[];
  50222. /**
  50223. * Gets the list of block children
  50224. */
  50225. blocks: Array<OctreeBlock<T>>;
  50226. private _depth;
  50227. private _maxDepth;
  50228. private _capacity;
  50229. private _minPoint;
  50230. private _maxPoint;
  50231. private _boundingVectors;
  50232. private _creationFunc;
  50233. /**
  50234. * Creates a new block
  50235. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50236. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50237. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50238. * @param depth defines the current depth of this block in the octree
  50239. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50240. * @param creationFunc defines a callback to call when an element is added to the block
  50241. */
  50242. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50243. /**
  50244. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50245. */
  50246. get capacity(): number;
  50247. /**
  50248. * Gets the minimum vector (in world space) of the block's bounding box
  50249. */
  50250. get minPoint(): Vector3;
  50251. /**
  50252. * Gets the maximum vector (in world space) of the block's bounding box
  50253. */
  50254. get maxPoint(): Vector3;
  50255. /**
  50256. * Add a new element to this block
  50257. * @param entry defines the element to add
  50258. */
  50259. addEntry(entry: T): void;
  50260. /**
  50261. * Remove an element from this block
  50262. * @param entry defines the element to remove
  50263. */
  50264. removeEntry(entry: T): void;
  50265. /**
  50266. * Add an array of elements to this block
  50267. * @param entries defines the array of elements to add
  50268. */
  50269. addEntries(entries: T[]): void;
  50270. /**
  50271. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50272. * @param frustumPlanes defines the frustum planes to test
  50273. * @param selection defines the array to store current content if selection is positive
  50274. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50275. */
  50276. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50277. /**
  50278. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50279. * @param sphereCenter defines the bounding sphere center
  50280. * @param sphereRadius defines the bounding sphere radius
  50281. * @param selection defines the array to store current content if selection is positive
  50282. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50283. */
  50284. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50285. /**
  50286. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50287. * @param ray defines the ray to test with
  50288. * @param selection defines the array to store current content if selection is positive
  50289. */
  50290. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50291. /**
  50292. * Subdivide the content into child blocks (this block will then be empty)
  50293. */
  50294. createInnerBlocks(): void;
  50295. /**
  50296. * @hidden
  50297. */
  50298. 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;
  50299. }
  50300. }
  50301. declare module BABYLON {
  50302. /**
  50303. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50304. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50305. */
  50306. export class Octree<T> {
  50307. /** 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.) */
  50308. maxDepth: number;
  50309. /**
  50310. * Blocks within the octree containing objects
  50311. */
  50312. blocks: Array<OctreeBlock<T>>;
  50313. /**
  50314. * Content stored in the octree
  50315. */
  50316. dynamicContent: T[];
  50317. private _maxBlockCapacity;
  50318. private _selectionContent;
  50319. private _creationFunc;
  50320. /**
  50321. * Creates a octree
  50322. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50323. * @param creationFunc function to be used to instatiate the octree
  50324. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50325. * @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.)
  50326. */
  50327. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50328. /** 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.) */
  50329. maxDepth?: number);
  50330. /**
  50331. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50332. * @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);
  50333. * @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);
  50334. * @param entries meshes to be added to the octree blocks
  50335. */
  50336. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50337. /**
  50338. * Adds a mesh to the octree
  50339. * @param entry Mesh to add to the octree
  50340. */
  50341. addMesh(entry: T): void;
  50342. /**
  50343. * Remove an element from the octree
  50344. * @param entry defines the element to remove
  50345. */
  50346. removeMesh(entry: T): void;
  50347. /**
  50348. * Selects an array of meshes within the frustum
  50349. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50350. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50351. * @returns array of meshes within the frustum
  50352. */
  50353. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50354. /**
  50355. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50356. * @param sphereCenter defines the bounding sphere center
  50357. * @param sphereRadius defines the bounding sphere radius
  50358. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50359. * @returns an array of objects that intersect the sphere
  50360. */
  50361. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50362. /**
  50363. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50364. * @param ray defines the ray to test with
  50365. * @returns array of intersected objects
  50366. */
  50367. intersectsRay(ray: Ray): SmartArray<T>;
  50368. /**
  50369. * Adds a mesh into the octree block if it intersects the block
  50370. */
  50371. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50372. /**
  50373. * Adds a submesh into the octree block if it intersects the block
  50374. */
  50375. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50376. }
  50377. }
  50378. declare module BABYLON {
  50379. interface Scene {
  50380. /**
  50381. * @hidden
  50382. * Backing Filed
  50383. */
  50384. _selectionOctree: Octree<AbstractMesh>;
  50385. /**
  50386. * Gets the octree used to boost mesh selection (picking)
  50387. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50388. */
  50389. selectionOctree: Octree<AbstractMesh>;
  50390. /**
  50391. * Creates or updates the octree used to boost selection (picking)
  50392. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50393. * @param maxCapacity defines the maximum capacity per leaf
  50394. * @param maxDepth defines the maximum depth of the octree
  50395. * @returns an octree of AbstractMesh
  50396. */
  50397. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50398. }
  50399. interface AbstractMesh {
  50400. /**
  50401. * @hidden
  50402. * Backing Field
  50403. */
  50404. _submeshesOctree: Octree<SubMesh>;
  50405. /**
  50406. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50407. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50408. * @param maxCapacity defines the maximum size of each block (64 by default)
  50409. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50410. * @returns the new octree
  50411. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50412. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50413. */
  50414. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50415. }
  50416. /**
  50417. * Defines the octree scene component responsible to manage any octrees
  50418. * in a given scene.
  50419. */
  50420. export class OctreeSceneComponent {
  50421. /**
  50422. * The component name help to identify the component in the list of scene components.
  50423. */
  50424. readonly name: string;
  50425. /**
  50426. * The scene the component belongs to.
  50427. */
  50428. scene: Scene;
  50429. /**
  50430. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50431. */
  50432. readonly checksIsEnabled: boolean;
  50433. /**
  50434. * Creates a new instance of the component for the given scene
  50435. * @param scene Defines the scene to register the component in
  50436. */
  50437. constructor(scene: Scene);
  50438. /**
  50439. * Registers the component in a given scene
  50440. */
  50441. register(): void;
  50442. /**
  50443. * Return the list of active meshes
  50444. * @returns the list of active meshes
  50445. */
  50446. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50447. /**
  50448. * Return the list of active sub meshes
  50449. * @param mesh The mesh to get the candidates sub meshes from
  50450. * @returns the list of active sub meshes
  50451. */
  50452. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50453. private _tempRay;
  50454. /**
  50455. * Return the list of sub meshes intersecting with a given local ray
  50456. * @param mesh defines the mesh to find the submesh for
  50457. * @param localRay defines the ray in local space
  50458. * @returns the list of intersecting sub meshes
  50459. */
  50460. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50461. /**
  50462. * Return the list of sub meshes colliding with a collider
  50463. * @param mesh defines the mesh to find the submesh for
  50464. * @param collider defines the collider to evaluate the collision against
  50465. * @returns the list of colliding sub meshes
  50466. */
  50467. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50468. /**
  50469. * Rebuilds the elements related to this component in case of
  50470. * context lost for instance.
  50471. */
  50472. rebuild(): void;
  50473. /**
  50474. * Disposes the component and the associated ressources.
  50475. */
  50476. dispose(): void;
  50477. }
  50478. }
  50479. declare module BABYLON {
  50480. /**
  50481. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50482. */
  50483. export class Gizmo implements IDisposable {
  50484. /** The utility layer the gizmo will be added to */
  50485. gizmoLayer: UtilityLayerRenderer;
  50486. /**
  50487. * The root mesh of the gizmo
  50488. */
  50489. _rootMesh: Mesh;
  50490. private _attachedMesh;
  50491. private _attachedNode;
  50492. /**
  50493. * Ratio for the scale of the gizmo (Default: 1)
  50494. */
  50495. protected _scaleRatio: number;
  50496. /**
  50497. * Ratio for the scale of the gizmo (Default: 1)
  50498. */
  50499. set scaleRatio(value: number);
  50500. get scaleRatio(): number;
  50501. /**
  50502. * If a custom mesh has been set (Default: false)
  50503. */
  50504. protected _customMeshSet: boolean;
  50505. /**
  50506. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50507. * * When set, interactions will be enabled
  50508. */
  50509. get attachedMesh(): Nullable<AbstractMesh>;
  50510. set attachedMesh(value: Nullable<AbstractMesh>);
  50511. /**
  50512. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50513. * * When set, interactions will be enabled
  50514. */
  50515. get attachedNode(): Nullable<Node>;
  50516. set attachedNode(value: Nullable<Node>);
  50517. /**
  50518. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50519. * @param mesh The mesh to replace the default mesh of the gizmo
  50520. */
  50521. setCustomMesh(mesh: Mesh): void;
  50522. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  50523. /**
  50524. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50525. */
  50526. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50527. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50528. /**
  50529. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50530. */
  50531. updateGizmoPositionToMatchAttachedMesh: boolean;
  50532. /**
  50533. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50534. */
  50535. updateScale: boolean;
  50536. protected _interactionsEnabled: boolean;
  50537. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50538. private _beforeRenderObserver;
  50539. private _tempQuaternion;
  50540. private _tempVector;
  50541. private _tempVector2;
  50542. private _tempMatrix1;
  50543. private _tempMatrix2;
  50544. private _rightHandtoLeftHandMatrix;
  50545. /**
  50546. * Creates a gizmo
  50547. * @param gizmoLayer The utility layer the gizmo will be added to
  50548. */
  50549. constructor(
  50550. /** The utility layer the gizmo will be added to */
  50551. gizmoLayer?: UtilityLayerRenderer);
  50552. /**
  50553. * Updates the gizmo to match the attached mesh's position/rotation
  50554. */
  50555. protected _update(): void;
  50556. /**
  50557. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50558. * @param value Node, TransformNode or mesh
  50559. */
  50560. protected _matrixChanged(): void;
  50561. /**
  50562. * Disposes of the gizmo
  50563. */
  50564. dispose(): void;
  50565. }
  50566. }
  50567. declare module BABYLON {
  50568. /**
  50569. * Single plane drag gizmo
  50570. */
  50571. export class PlaneDragGizmo extends Gizmo {
  50572. /**
  50573. * Drag behavior responsible for the gizmos dragging interactions
  50574. */
  50575. dragBehavior: PointerDragBehavior;
  50576. private _pointerObserver;
  50577. /**
  50578. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50579. */
  50580. snapDistance: number;
  50581. /**
  50582. * Event that fires each time the gizmo snaps to a new location.
  50583. * * snapDistance is the the change in distance
  50584. */
  50585. onSnapObservable: Observable<{
  50586. snapDistance: number;
  50587. }>;
  50588. private _plane;
  50589. private _coloredMaterial;
  50590. private _hoverMaterial;
  50591. private _isEnabled;
  50592. private _parent;
  50593. /** @hidden */
  50594. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50595. /** @hidden */
  50596. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50597. /**
  50598. * Creates a PlaneDragGizmo
  50599. * @param gizmoLayer The utility layer the gizmo will be added to
  50600. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50601. * @param color The color of the gizmo
  50602. */
  50603. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50604. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50605. /**
  50606. * If the gizmo is enabled
  50607. */
  50608. set isEnabled(value: boolean);
  50609. get isEnabled(): boolean;
  50610. /**
  50611. * Disposes of the gizmo
  50612. */
  50613. dispose(): void;
  50614. }
  50615. }
  50616. declare module BABYLON {
  50617. /**
  50618. * Gizmo that enables dragging a mesh along 3 axis
  50619. */
  50620. export class PositionGizmo extends Gizmo {
  50621. /**
  50622. * Internal gizmo used for interactions on the x axis
  50623. */
  50624. xGizmo: AxisDragGizmo;
  50625. /**
  50626. * Internal gizmo used for interactions on the y axis
  50627. */
  50628. yGizmo: AxisDragGizmo;
  50629. /**
  50630. * Internal gizmo used for interactions on the z axis
  50631. */
  50632. zGizmo: AxisDragGizmo;
  50633. /**
  50634. * Internal gizmo used for interactions on the yz plane
  50635. */
  50636. xPlaneGizmo: PlaneDragGizmo;
  50637. /**
  50638. * Internal gizmo used for interactions on the xz plane
  50639. */
  50640. yPlaneGizmo: PlaneDragGizmo;
  50641. /**
  50642. * Internal gizmo used for interactions on the xy plane
  50643. */
  50644. zPlaneGizmo: PlaneDragGizmo;
  50645. /**
  50646. * private variables
  50647. */
  50648. private _meshAttached;
  50649. private _nodeAttached;
  50650. private _snapDistance;
  50651. /** Fires an event when any of it's sub gizmos are dragged */
  50652. onDragStartObservable: Observable<unknown>;
  50653. /** Fires an event when any of it's sub gizmos are released from dragging */
  50654. onDragEndObservable: Observable<unknown>;
  50655. /**
  50656. * If set to true, planar drag is enabled
  50657. */
  50658. private _planarGizmoEnabled;
  50659. get attachedMesh(): Nullable<AbstractMesh>;
  50660. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50661. get attachedNode(): Nullable<Node>;
  50662. set attachedNode(node: Nullable<Node>);
  50663. /**
  50664. * Creates a PositionGizmo
  50665. * @param gizmoLayer The utility layer the gizmo will be added to
  50666. @param thickness display gizmo axis thickness
  50667. */
  50668. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50669. /**
  50670. * If the planar drag gizmo is enabled
  50671. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50672. */
  50673. set planarGizmoEnabled(value: boolean);
  50674. get planarGizmoEnabled(): boolean;
  50675. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50676. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50677. /**
  50678. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50679. */
  50680. set snapDistance(value: number);
  50681. get snapDistance(): number;
  50682. /**
  50683. * Ratio for the scale of the gizmo (Default: 1)
  50684. */
  50685. set scaleRatio(value: number);
  50686. get scaleRatio(): number;
  50687. /**
  50688. * Disposes of the gizmo
  50689. */
  50690. dispose(): void;
  50691. /**
  50692. * CustomMeshes are not supported by this gizmo
  50693. * @param mesh The mesh to replace the default mesh of the gizmo
  50694. */
  50695. setCustomMesh(mesh: Mesh): void;
  50696. }
  50697. }
  50698. declare module BABYLON {
  50699. /**
  50700. * Single axis drag gizmo
  50701. */
  50702. export class AxisDragGizmo extends Gizmo {
  50703. /**
  50704. * Drag behavior responsible for the gizmos dragging interactions
  50705. */
  50706. dragBehavior: PointerDragBehavior;
  50707. private _pointerObserver;
  50708. /**
  50709. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50710. */
  50711. snapDistance: number;
  50712. /**
  50713. * Event that fires each time the gizmo snaps to a new location.
  50714. * * snapDistance is the the change in distance
  50715. */
  50716. onSnapObservable: Observable<{
  50717. snapDistance: number;
  50718. }>;
  50719. private _isEnabled;
  50720. private _parent;
  50721. private _arrow;
  50722. private _coloredMaterial;
  50723. private _hoverMaterial;
  50724. /** @hidden */
  50725. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50726. /** @hidden */
  50727. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50728. /**
  50729. * Creates an AxisDragGizmo
  50730. * @param gizmoLayer The utility layer the gizmo will be added to
  50731. * @param dragAxis The axis which the gizmo will be able to drag on
  50732. * @param color The color of the gizmo
  50733. * @param thickness display gizmo axis thickness
  50734. */
  50735. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50736. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50737. /**
  50738. * If the gizmo is enabled
  50739. */
  50740. set isEnabled(value: boolean);
  50741. get isEnabled(): boolean;
  50742. /**
  50743. * Disposes of the gizmo
  50744. */
  50745. dispose(): void;
  50746. }
  50747. }
  50748. declare module BABYLON.Debug {
  50749. /**
  50750. * The Axes viewer will show 3 axes in a specific point in space
  50751. */
  50752. export class AxesViewer {
  50753. private _xAxis;
  50754. private _yAxis;
  50755. private _zAxis;
  50756. private _scaleLinesFactor;
  50757. private _instanced;
  50758. /**
  50759. * Gets the hosting scene
  50760. */
  50761. scene: Nullable<Scene>;
  50762. /**
  50763. * Gets or sets a number used to scale line length
  50764. */
  50765. scaleLines: number;
  50766. /** Gets the node hierarchy used to render x-axis */
  50767. get xAxis(): TransformNode;
  50768. /** Gets the node hierarchy used to render y-axis */
  50769. get yAxis(): TransformNode;
  50770. /** Gets the node hierarchy used to render z-axis */
  50771. get zAxis(): TransformNode;
  50772. /**
  50773. * Creates a new AxesViewer
  50774. * @param scene defines the hosting scene
  50775. * @param scaleLines defines a number used to scale line length (1 by default)
  50776. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50777. * @param xAxis defines the node hierarchy used to render the x-axis
  50778. * @param yAxis defines the node hierarchy used to render the y-axis
  50779. * @param zAxis defines the node hierarchy used to render the z-axis
  50780. */
  50781. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50782. /**
  50783. * Force the viewer to update
  50784. * @param position defines the position of the viewer
  50785. * @param xaxis defines the x axis of the viewer
  50786. * @param yaxis defines the y axis of the viewer
  50787. * @param zaxis defines the z axis of the viewer
  50788. */
  50789. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50790. /**
  50791. * Creates an instance of this axes viewer.
  50792. * @returns a new axes viewer with instanced meshes
  50793. */
  50794. createInstance(): AxesViewer;
  50795. /** Releases resources */
  50796. dispose(): void;
  50797. private static _SetRenderingGroupId;
  50798. }
  50799. }
  50800. declare module BABYLON.Debug {
  50801. /**
  50802. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50803. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50804. */
  50805. export class BoneAxesViewer extends AxesViewer {
  50806. /**
  50807. * Gets or sets the target mesh where to display the axes viewer
  50808. */
  50809. mesh: Nullable<Mesh>;
  50810. /**
  50811. * Gets or sets the target bone where to display the axes viewer
  50812. */
  50813. bone: Nullable<Bone>;
  50814. /** Gets current position */
  50815. pos: Vector3;
  50816. /** Gets direction of X axis */
  50817. xaxis: Vector3;
  50818. /** Gets direction of Y axis */
  50819. yaxis: Vector3;
  50820. /** Gets direction of Z axis */
  50821. zaxis: Vector3;
  50822. /**
  50823. * Creates a new BoneAxesViewer
  50824. * @param scene defines the hosting scene
  50825. * @param bone defines the target bone
  50826. * @param mesh defines the target mesh
  50827. * @param scaleLines defines a scaling factor for line length (1 by default)
  50828. */
  50829. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50830. /**
  50831. * Force the viewer to update
  50832. */
  50833. update(): void;
  50834. /** Releases resources */
  50835. dispose(): void;
  50836. }
  50837. }
  50838. declare module BABYLON {
  50839. /**
  50840. * Interface used to define scene explorer extensibility option
  50841. */
  50842. export interface IExplorerExtensibilityOption {
  50843. /**
  50844. * Define the option label
  50845. */
  50846. label: string;
  50847. /**
  50848. * Defines the action to execute on click
  50849. */
  50850. action: (entity: any) => void;
  50851. }
  50852. /**
  50853. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50854. */
  50855. export interface IExplorerExtensibilityGroup {
  50856. /**
  50857. * Defines a predicate to test if a given type mut be extended
  50858. */
  50859. predicate: (entity: any) => boolean;
  50860. /**
  50861. * Gets the list of options added to a type
  50862. */
  50863. entries: IExplorerExtensibilityOption[];
  50864. }
  50865. /**
  50866. * Interface used to define the options to use to create the Inspector
  50867. */
  50868. export interface IInspectorOptions {
  50869. /**
  50870. * Display in overlay mode (default: false)
  50871. */
  50872. overlay?: boolean;
  50873. /**
  50874. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50875. */
  50876. globalRoot?: HTMLElement;
  50877. /**
  50878. * Display the Scene explorer
  50879. */
  50880. showExplorer?: boolean;
  50881. /**
  50882. * Display the property inspector
  50883. */
  50884. showInspector?: boolean;
  50885. /**
  50886. * Display in embed mode (both panes on the right)
  50887. */
  50888. embedMode?: boolean;
  50889. /**
  50890. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50891. */
  50892. handleResize?: boolean;
  50893. /**
  50894. * Allow the panes to popup (default: true)
  50895. */
  50896. enablePopup?: boolean;
  50897. /**
  50898. * Allow the panes to be closed by users (default: true)
  50899. */
  50900. enableClose?: boolean;
  50901. /**
  50902. * Optional list of extensibility entries
  50903. */
  50904. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50905. /**
  50906. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50907. */
  50908. inspectorURL?: string;
  50909. /**
  50910. * Optional initial tab (default to DebugLayerTab.Properties)
  50911. */
  50912. initialTab?: DebugLayerTab;
  50913. }
  50914. interface Scene {
  50915. /**
  50916. * @hidden
  50917. * Backing field
  50918. */
  50919. _debugLayer: DebugLayer;
  50920. /**
  50921. * Gets the debug layer (aka Inspector) associated with the scene
  50922. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50923. */
  50924. debugLayer: DebugLayer;
  50925. }
  50926. /**
  50927. * Enum of inspector action tab
  50928. */
  50929. export enum DebugLayerTab {
  50930. /**
  50931. * Properties tag (default)
  50932. */
  50933. Properties = 0,
  50934. /**
  50935. * Debug tab
  50936. */
  50937. Debug = 1,
  50938. /**
  50939. * Statistics tab
  50940. */
  50941. Statistics = 2,
  50942. /**
  50943. * Tools tab
  50944. */
  50945. Tools = 3,
  50946. /**
  50947. * Settings tab
  50948. */
  50949. Settings = 4
  50950. }
  50951. /**
  50952. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50953. * what is happening in your scene
  50954. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50955. */
  50956. export class DebugLayer {
  50957. /**
  50958. * Define the url to get the inspector script from.
  50959. * By default it uses the babylonjs CDN.
  50960. * @ignoreNaming
  50961. */
  50962. static InspectorURL: string;
  50963. private _scene;
  50964. private BJSINSPECTOR;
  50965. private _onPropertyChangedObservable?;
  50966. /**
  50967. * Observable triggered when a property is changed through the inspector.
  50968. */
  50969. get onPropertyChangedObservable(): any;
  50970. /**
  50971. * Instantiates a new debug layer.
  50972. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50973. * what is happening in your scene
  50974. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50975. * @param scene Defines the scene to inspect
  50976. */
  50977. constructor(scene: Scene);
  50978. /** Creates the inspector window. */
  50979. private _createInspector;
  50980. /**
  50981. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50982. * @param entity defines the entity to select
  50983. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50984. */
  50985. select(entity: any, lineContainerTitles?: string | string[]): void;
  50986. /** Get the inspector from bundle or global */
  50987. private _getGlobalInspector;
  50988. /**
  50989. * Get if the inspector is visible or not.
  50990. * @returns true if visible otherwise, false
  50991. */
  50992. isVisible(): boolean;
  50993. /**
  50994. * Hide the inspector and close its window.
  50995. */
  50996. hide(): void;
  50997. /**
  50998. * Update the scene in the inspector
  50999. */
  51000. setAsActiveScene(): void;
  51001. /**
  51002. * Launch the debugLayer.
  51003. * @param config Define the configuration of the inspector
  51004. * @return a promise fulfilled when the debug layer is visible
  51005. */
  51006. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51007. }
  51008. }
  51009. declare module BABYLON {
  51010. /**
  51011. * Class containing static functions to help procedurally build meshes
  51012. */
  51013. export class BoxBuilder {
  51014. /**
  51015. * Creates a box mesh
  51016. * * The parameter `size` sets the size (float) of each box side (default 1)
  51017. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51018. * * 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)
  51019. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51021. * * 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
  51022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51023. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51024. * @param name defines the name of the mesh
  51025. * @param options defines the options used to create the mesh
  51026. * @param scene defines the hosting scene
  51027. * @returns the box mesh
  51028. */
  51029. static CreateBox(name: string, options: {
  51030. size?: number;
  51031. width?: number;
  51032. height?: number;
  51033. depth?: number;
  51034. faceUV?: Vector4[];
  51035. faceColors?: Color4[];
  51036. sideOrientation?: number;
  51037. frontUVs?: Vector4;
  51038. backUVs?: Vector4;
  51039. wrap?: boolean;
  51040. topBaseAt?: number;
  51041. bottomBaseAt?: number;
  51042. updatable?: boolean;
  51043. }, scene?: Nullable<Scene>): Mesh;
  51044. }
  51045. }
  51046. declare module BABYLON.Debug {
  51047. /**
  51048. * Used to show the physics impostor around the specific mesh
  51049. */
  51050. export class PhysicsViewer {
  51051. /** @hidden */
  51052. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51053. /** @hidden */
  51054. protected _meshes: Array<Nullable<AbstractMesh>>;
  51055. /** @hidden */
  51056. protected _scene: Nullable<Scene>;
  51057. /** @hidden */
  51058. protected _numMeshes: number;
  51059. /** @hidden */
  51060. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51061. private _renderFunction;
  51062. private _utilityLayer;
  51063. private _debugBoxMesh;
  51064. private _debugSphereMesh;
  51065. private _debugCylinderMesh;
  51066. private _debugMaterial;
  51067. private _debugMeshMeshes;
  51068. /**
  51069. * Creates a new PhysicsViewer
  51070. * @param scene defines the hosting scene
  51071. */
  51072. constructor(scene: Scene);
  51073. /** @hidden */
  51074. protected _updateDebugMeshes(): void;
  51075. /**
  51076. * Renders a specified physic impostor
  51077. * @param impostor defines the impostor to render
  51078. * @param targetMesh defines the mesh represented by the impostor
  51079. * @returns the new debug mesh used to render the impostor
  51080. */
  51081. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51082. /**
  51083. * Hides a specified physic impostor
  51084. * @param impostor defines the impostor to hide
  51085. */
  51086. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51087. private _getDebugMaterial;
  51088. private _getDebugBoxMesh;
  51089. private _getDebugSphereMesh;
  51090. private _getDebugCylinderMesh;
  51091. private _getDebugMeshMesh;
  51092. private _getDebugMesh;
  51093. /** Releases all resources */
  51094. dispose(): void;
  51095. }
  51096. }
  51097. declare module BABYLON {
  51098. /**
  51099. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51100. * in order to better appreciate the issue one might have.
  51101. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51102. */
  51103. export class RayHelper {
  51104. /**
  51105. * Defines the ray we are currently tryin to visualize.
  51106. */
  51107. ray: Nullable<Ray>;
  51108. private _renderPoints;
  51109. private _renderLine;
  51110. private _renderFunction;
  51111. private _scene;
  51112. private _onAfterRenderObserver;
  51113. private _onAfterStepObserver;
  51114. private _attachedToMesh;
  51115. private _meshSpaceDirection;
  51116. private _meshSpaceOrigin;
  51117. /**
  51118. * Helper function to create a colored helper in a scene in one line.
  51119. * @param ray Defines the ray we are currently tryin to visualize
  51120. * @param scene Defines the scene the ray is used in
  51121. * @param color Defines the color we want to see the ray in
  51122. * @returns The newly created ray helper.
  51123. */
  51124. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51125. /**
  51126. * Instantiate a new ray helper.
  51127. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51128. * in order to better appreciate the issue one might have.
  51129. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51130. * @param ray Defines the ray we are currently tryin to visualize
  51131. */
  51132. constructor(ray: Ray);
  51133. /**
  51134. * Shows the ray we are willing to debug.
  51135. * @param scene Defines the scene the ray needs to be rendered in
  51136. * @param color Defines the color the ray needs to be rendered in
  51137. */
  51138. show(scene: Scene, color?: Color3): void;
  51139. /**
  51140. * Hides the ray we are debugging.
  51141. */
  51142. hide(): void;
  51143. private _render;
  51144. /**
  51145. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51146. * @param mesh Defines the mesh we want the helper attached to
  51147. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51148. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51149. * @param length Defines the length of the ray
  51150. */
  51151. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51152. /**
  51153. * Detach the ray helper from the mesh it has previously been attached to.
  51154. */
  51155. detachFromMesh(): void;
  51156. private _updateToMesh;
  51157. /**
  51158. * Dispose the helper and release its associated resources.
  51159. */
  51160. dispose(): void;
  51161. }
  51162. }
  51163. declare module BABYLON {
  51164. /**
  51165. * Defines the options associated with the creation of a SkeletonViewer.
  51166. */
  51167. export interface ISkeletonViewerOptions {
  51168. /** Should the system pause animations before building the Viewer? */
  51169. pauseAnimations: boolean;
  51170. /** Should the system return the skeleton to rest before building? */
  51171. returnToRest: boolean;
  51172. /** public Display Mode of the Viewer */
  51173. displayMode: number;
  51174. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51175. displayOptions: ISkeletonViewerDisplayOptions;
  51176. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51177. computeBonesUsingShaders: boolean;
  51178. /** Flag ignore non weighted bones */
  51179. useAllBones: boolean;
  51180. }
  51181. /**
  51182. * Defines how to display the various bone meshes for the viewer.
  51183. */
  51184. export interface ISkeletonViewerDisplayOptions {
  51185. /** How far down to start tapering the bone spurs */
  51186. midStep?: number;
  51187. /** How big is the midStep? */
  51188. midStepFactor?: number;
  51189. /** Base for the Sphere Size */
  51190. sphereBaseSize?: number;
  51191. /** The ratio of the sphere to the longest bone in units */
  51192. sphereScaleUnit?: number;
  51193. /** Ratio for the Sphere Size */
  51194. sphereFactor?: number;
  51195. }
  51196. /**
  51197. * Defines the constructor options for the BoneWeight Shader.
  51198. */
  51199. export interface IBoneWeightShaderOptions {
  51200. /** Skeleton to Map */
  51201. skeleton: Skeleton;
  51202. /** Colors for Uninfluenced bones */
  51203. colorBase?: Color3;
  51204. /** Colors for 0.0-0.25 Weight bones */
  51205. colorZero?: Color3;
  51206. /** Color for 0.25-0.5 Weight Influence */
  51207. colorQuarter?: Color3;
  51208. /** Color for 0.5-0.75 Weight Influence */
  51209. colorHalf?: Color3;
  51210. /** Color for 0.75-1 Weight Influence */
  51211. colorFull?: Color3;
  51212. /** Color for Zero Weight Influence */
  51213. targetBoneIndex?: number;
  51214. }
  51215. /**
  51216. * Simple structure of the gradient steps for the Color Map.
  51217. */
  51218. export interface ISkeletonMapShaderColorMapKnot {
  51219. /** Color of the Knot */
  51220. color: Color3;
  51221. /** Location of the Knot */
  51222. location: number;
  51223. }
  51224. /**
  51225. * Defines the constructor options for the SkeletonMap Shader.
  51226. */
  51227. export interface ISkeletonMapShaderOptions {
  51228. /** Skeleton to Map */
  51229. skeleton: Skeleton;
  51230. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  51231. colorMap?: ISkeletonMapShaderColorMapKnot[];
  51232. }
  51233. }
  51234. declare module BABYLON {
  51235. /**
  51236. * Class containing static functions to help procedurally build meshes
  51237. */
  51238. export class RibbonBuilder {
  51239. /**
  51240. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51241. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51242. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51243. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51244. * * 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
  51245. * * 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
  51246. * * 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
  51247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51248. * * 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
  51249. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51250. * * 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
  51251. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51252. * * 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
  51253. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51255. * @param name defines the name of the mesh
  51256. * @param options defines the options used to create the mesh
  51257. * @param scene defines the hosting scene
  51258. * @returns the ribbon mesh
  51259. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51260. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51261. */
  51262. static CreateRibbon(name: string, options: {
  51263. pathArray: Vector3[][];
  51264. closeArray?: boolean;
  51265. closePath?: boolean;
  51266. offset?: number;
  51267. updatable?: boolean;
  51268. sideOrientation?: number;
  51269. frontUVs?: Vector4;
  51270. backUVs?: Vector4;
  51271. instance?: Mesh;
  51272. invertUV?: boolean;
  51273. uvs?: Vector2[];
  51274. colors?: Color4[];
  51275. }, scene?: Nullable<Scene>): Mesh;
  51276. }
  51277. }
  51278. declare module BABYLON {
  51279. /**
  51280. * Class containing static functions to help procedurally build meshes
  51281. */
  51282. export class ShapeBuilder {
  51283. /**
  51284. * 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.
  51285. * * 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.
  51286. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51287. * * 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.
  51288. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51289. * * 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
  51290. * * 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
  51291. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51293. * * 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
  51294. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51296. * @param name defines the name of the mesh
  51297. * @param options defines the options used to create the mesh
  51298. * @param scene defines the hosting scene
  51299. * @returns the extruded shape mesh
  51300. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51301. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51302. */
  51303. static ExtrudeShape(name: string, options: {
  51304. shape: Vector3[];
  51305. path: Vector3[];
  51306. scale?: number;
  51307. rotation?: number;
  51308. cap?: number;
  51309. updatable?: boolean;
  51310. sideOrientation?: number;
  51311. frontUVs?: Vector4;
  51312. backUVs?: Vector4;
  51313. instance?: Mesh;
  51314. invertUV?: boolean;
  51315. }, scene?: Nullable<Scene>): Mesh;
  51316. /**
  51317. * Creates an custom extruded shape mesh.
  51318. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51319. * * 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.
  51320. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51321. * * 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
  51322. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51323. * * 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
  51324. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51325. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51326. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51327. * * 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
  51328. * * 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
  51329. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51330. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51331. * * 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
  51332. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51334. * @param name defines the name of the mesh
  51335. * @param options defines the options used to create the mesh
  51336. * @param scene defines the hosting scene
  51337. * @returns the custom extruded shape mesh
  51338. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51339. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51340. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51341. */
  51342. static ExtrudeShapeCustom(name: string, options: {
  51343. shape: Vector3[];
  51344. path: Vector3[];
  51345. scaleFunction?: any;
  51346. rotationFunction?: any;
  51347. ribbonCloseArray?: boolean;
  51348. ribbonClosePath?: boolean;
  51349. cap?: number;
  51350. updatable?: boolean;
  51351. sideOrientation?: number;
  51352. frontUVs?: Vector4;
  51353. backUVs?: Vector4;
  51354. instance?: Mesh;
  51355. invertUV?: boolean;
  51356. }, scene?: Nullable<Scene>): Mesh;
  51357. private static _ExtrudeShapeGeneric;
  51358. }
  51359. }
  51360. declare module BABYLON.Debug {
  51361. /**
  51362. * Class used to render a debug view of a given skeleton
  51363. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51364. */
  51365. export class SkeletonViewer {
  51366. /** defines the skeleton to render */
  51367. skeleton: Skeleton;
  51368. /** defines the mesh attached to the skeleton */
  51369. mesh: AbstractMesh;
  51370. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51371. autoUpdateBonesMatrices: boolean;
  51372. /** defines the rendering group id to use with the viewer */
  51373. renderingGroupId: number;
  51374. /** is the options for the viewer */
  51375. options: Partial<ISkeletonViewerOptions>;
  51376. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51377. static readonly DISPLAY_LINES: number;
  51378. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51379. static readonly DISPLAY_SPHERES: number;
  51380. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51381. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51382. /** public static method to create a BoneWeight Shader
  51383. * @param options The constructor options
  51384. * @param scene The scene that the shader is scoped to
  51385. * @returns The created ShaderMaterial
  51386. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  51387. */
  51388. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  51389. /** public static method to create a BoneWeight Shader
  51390. * @param options The constructor options
  51391. * @param scene The scene that the shader is scoped to
  51392. * @returns The created ShaderMaterial
  51393. */
  51394. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  51395. /** private static method to create a BoneWeight Shader
  51396. * @param size The size of the buffer to create (usually the bone count)
  51397. * @param colorMap The gradient data to generate
  51398. * @param scene The scene that the shader is scoped to
  51399. * @returns an Array of floats from the color gradient values
  51400. */
  51401. private static _CreateBoneMapColorBuffer;
  51402. /** If SkeletonViewer scene scope. */
  51403. private _scene;
  51404. /** Gets or sets the color used to render the skeleton */
  51405. color: Color3;
  51406. /** Array of the points of the skeleton fo the line view. */
  51407. private _debugLines;
  51408. /** The SkeletonViewers Mesh. */
  51409. private _debugMesh;
  51410. /** If SkeletonViewer is enabled. */
  51411. private _isEnabled;
  51412. /** If SkeletonViewer is ready. */
  51413. private _ready;
  51414. /** SkeletonViewer render observable. */
  51415. private _obs;
  51416. /** The Utility Layer to render the gizmos in. */
  51417. private _utilityLayer;
  51418. private _boneIndices;
  51419. /** Gets the Scene. */
  51420. get scene(): Scene;
  51421. /** Gets the utilityLayer. */
  51422. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51423. /** Checks Ready Status. */
  51424. get isReady(): Boolean;
  51425. /** Sets Ready Status. */
  51426. set ready(value: boolean);
  51427. /** Gets the debugMesh */
  51428. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51429. /** Sets the debugMesh */
  51430. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51431. /** Gets the displayMode */
  51432. get displayMode(): number;
  51433. /** Sets the displayMode */
  51434. set displayMode(value: number);
  51435. /**
  51436. * Creates a new SkeletonViewer
  51437. * @param skeleton defines the skeleton to render
  51438. * @param mesh defines the mesh attached to the skeleton
  51439. * @param scene defines the hosting scene
  51440. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51441. * @param renderingGroupId defines the rendering group id to use with the viewer
  51442. * @param options All of the extra constructor options for the SkeletonViewer
  51443. */
  51444. constructor(
  51445. /** defines the skeleton to render */
  51446. skeleton: Skeleton,
  51447. /** defines the mesh attached to the skeleton */
  51448. mesh: AbstractMesh,
  51449. /** The Scene scope*/
  51450. scene: Scene,
  51451. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51452. autoUpdateBonesMatrices?: boolean,
  51453. /** defines the rendering group id to use with the viewer */
  51454. renderingGroupId?: number,
  51455. /** is the options for the viewer */
  51456. options?: Partial<ISkeletonViewerOptions>);
  51457. /** The Dynamic bindings for the update functions */
  51458. private _bindObs;
  51459. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51460. update(): void;
  51461. /** Gets or sets a boolean indicating if the viewer is enabled */
  51462. set isEnabled(value: boolean);
  51463. get isEnabled(): boolean;
  51464. private _getBonePosition;
  51465. private _getLinesForBonesWithLength;
  51466. private _getLinesForBonesNoLength;
  51467. /** function to revert the mesh and scene back to the initial state. */
  51468. private _revert;
  51469. /** function to build and bind sphere joint points and spur bone representations. */
  51470. private _buildSpheresAndSpurs;
  51471. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51472. private _displayLinesUpdate;
  51473. /** Changes the displayMode of the skeleton viewer
  51474. * @param mode The displayMode numerical value
  51475. */
  51476. changeDisplayMode(mode: number): void;
  51477. /** Changes the displayMode of the skeleton viewer
  51478. * @param option String of the option name
  51479. * @param value The numerical option value
  51480. */
  51481. changeDisplayOptions(option: string, value: number): void;
  51482. /** Release associated resources */
  51483. dispose(): void;
  51484. }
  51485. }
  51486. declare module BABYLON {
  51487. /**
  51488. * Enum for Device Types
  51489. */
  51490. export enum DeviceType {
  51491. /** Generic */
  51492. Generic = 0,
  51493. /** Keyboard */
  51494. Keyboard = 1,
  51495. /** Mouse */
  51496. Mouse = 2,
  51497. /** Touch Pointers */
  51498. Touch = 3,
  51499. /** PS4 Dual Shock */
  51500. DualShock = 4,
  51501. /** Xbox */
  51502. Xbox = 5,
  51503. /** Switch Controller */
  51504. Switch = 6
  51505. }
  51506. /**
  51507. * Enum for All Pointers (Touch/Mouse)
  51508. */
  51509. export enum PointerInput {
  51510. /** Horizontal Axis */
  51511. Horizontal = 0,
  51512. /** Vertical Axis */
  51513. Vertical = 1,
  51514. /** Left Click or Touch */
  51515. LeftClick = 2,
  51516. /** Middle Click */
  51517. MiddleClick = 3,
  51518. /** Right Click */
  51519. RightClick = 4,
  51520. /** Browser Back */
  51521. BrowserBack = 5,
  51522. /** Browser Forward */
  51523. BrowserForward = 6
  51524. }
  51525. /**
  51526. * Enum for Dual Shock Gamepad
  51527. */
  51528. export enum DualShockInput {
  51529. /** Cross */
  51530. Cross = 0,
  51531. /** Circle */
  51532. Circle = 1,
  51533. /** Square */
  51534. Square = 2,
  51535. /** Triangle */
  51536. Triangle = 3,
  51537. /** L1 */
  51538. L1 = 4,
  51539. /** R1 */
  51540. R1 = 5,
  51541. /** L2 */
  51542. L2 = 6,
  51543. /** R2 */
  51544. R2 = 7,
  51545. /** Share */
  51546. Share = 8,
  51547. /** Options */
  51548. Options = 9,
  51549. /** L3 */
  51550. L3 = 10,
  51551. /** R3 */
  51552. R3 = 11,
  51553. /** DPadUp */
  51554. DPadUp = 12,
  51555. /** DPadDown */
  51556. DPadDown = 13,
  51557. /** DPadLeft */
  51558. DPadLeft = 14,
  51559. /** DRight */
  51560. DPadRight = 15,
  51561. /** Home */
  51562. Home = 16,
  51563. /** TouchPad */
  51564. TouchPad = 17,
  51565. /** LStickXAxis */
  51566. LStickXAxis = 18,
  51567. /** LStickYAxis */
  51568. LStickYAxis = 19,
  51569. /** RStickXAxis */
  51570. RStickXAxis = 20,
  51571. /** RStickYAxis */
  51572. RStickYAxis = 21
  51573. }
  51574. /**
  51575. * Enum for Xbox Gamepad
  51576. */
  51577. export enum XboxInput {
  51578. /** A */
  51579. A = 0,
  51580. /** B */
  51581. B = 1,
  51582. /** X */
  51583. X = 2,
  51584. /** Y */
  51585. Y = 3,
  51586. /** LB */
  51587. LB = 4,
  51588. /** RB */
  51589. RB = 5,
  51590. /** LT */
  51591. LT = 6,
  51592. /** RT */
  51593. RT = 7,
  51594. /** Back */
  51595. Back = 8,
  51596. /** Start */
  51597. Start = 9,
  51598. /** LS */
  51599. LS = 10,
  51600. /** RS */
  51601. RS = 11,
  51602. /** DPadUp */
  51603. DPadUp = 12,
  51604. /** DPadDown */
  51605. DPadDown = 13,
  51606. /** DPadLeft */
  51607. DPadLeft = 14,
  51608. /** DRight */
  51609. DPadRight = 15,
  51610. /** Home */
  51611. Home = 16,
  51612. /** LStickXAxis */
  51613. LStickXAxis = 17,
  51614. /** LStickYAxis */
  51615. LStickYAxis = 18,
  51616. /** RStickXAxis */
  51617. RStickXAxis = 19,
  51618. /** RStickYAxis */
  51619. RStickYAxis = 20
  51620. }
  51621. /**
  51622. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51623. */
  51624. export enum SwitchInput {
  51625. /** B */
  51626. B = 0,
  51627. /** A */
  51628. A = 1,
  51629. /** Y */
  51630. Y = 2,
  51631. /** X */
  51632. X = 3,
  51633. /** L */
  51634. L = 4,
  51635. /** R */
  51636. R = 5,
  51637. /** ZL */
  51638. ZL = 6,
  51639. /** ZR */
  51640. ZR = 7,
  51641. /** Minus */
  51642. Minus = 8,
  51643. /** Plus */
  51644. Plus = 9,
  51645. /** LS */
  51646. LS = 10,
  51647. /** RS */
  51648. RS = 11,
  51649. /** DPadUp */
  51650. DPadUp = 12,
  51651. /** DPadDown */
  51652. DPadDown = 13,
  51653. /** DPadLeft */
  51654. DPadLeft = 14,
  51655. /** DRight */
  51656. DPadRight = 15,
  51657. /** Home */
  51658. Home = 16,
  51659. /** Capture */
  51660. Capture = 17,
  51661. /** LStickXAxis */
  51662. LStickXAxis = 18,
  51663. /** LStickYAxis */
  51664. LStickYAxis = 19,
  51665. /** RStickXAxis */
  51666. RStickXAxis = 20,
  51667. /** RStickYAxis */
  51668. RStickYAxis = 21
  51669. }
  51670. }
  51671. declare module BABYLON {
  51672. /**
  51673. * This class will take all inputs from Keyboard, Pointer, and
  51674. * any Gamepads and provide a polling system that all devices
  51675. * will use. This class assumes that there will only be one
  51676. * pointer device and one keyboard.
  51677. */
  51678. export class DeviceInputSystem implements IDisposable {
  51679. /**
  51680. * Callback to be triggered when a device is connected
  51681. */
  51682. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51683. /**
  51684. * Callback to be triggered when a device is disconnected
  51685. */
  51686. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51687. /**
  51688. * Callback to be triggered when event driven input is updated
  51689. */
  51690. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51691. private _inputs;
  51692. private _gamepads;
  51693. private _keyboardActive;
  51694. private _pointerActive;
  51695. private _elementToAttachTo;
  51696. private _keyboardDownEvent;
  51697. private _keyboardUpEvent;
  51698. private _pointerMoveEvent;
  51699. private _pointerDownEvent;
  51700. private _pointerUpEvent;
  51701. private _gamepadConnectedEvent;
  51702. private _gamepadDisconnectedEvent;
  51703. private static _MAX_KEYCODES;
  51704. private static _MAX_POINTER_INPUTS;
  51705. private constructor();
  51706. /**
  51707. * Creates a new DeviceInputSystem instance
  51708. * @param engine Engine to pull input element from
  51709. * @returns The new instance
  51710. */
  51711. static Create(engine: Engine): DeviceInputSystem;
  51712. /**
  51713. * Checks for current device input value, given an id and input index
  51714. * @param deviceName Id of connected device
  51715. * @param inputIndex Index of device input
  51716. * @returns Current value of input
  51717. */
  51718. /**
  51719. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51720. * @param deviceType Enum specifiying device type
  51721. * @param deviceSlot "Slot" or index that device is referenced in
  51722. * @param inputIndex Id of input to be checked
  51723. * @returns Current value of input
  51724. */
  51725. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51726. /**
  51727. * Dispose of all the eventlisteners
  51728. */
  51729. dispose(): void;
  51730. /**
  51731. * Add device and inputs to device array
  51732. * @param deviceType Enum specifiying device type
  51733. * @param deviceSlot "Slot" or index that device is referenced in
  51734. * @param numberOfInputs Number of input entries to create for given device
  51735. */
  51736. private _registerDevice;
  51737. /**
  51738. * Given a specific device name, remove that device from the device map
  51739. * @param deviceType Enum specifiying device type
  51740. * @param deviceSlot "Slot" or index that device is referenced in
  51741. */
  51742. private _unregisterDevice;
  51743. /**
  51744. * Handle all actions that come from keyboard interaction
  51745. */
  51746. private _handleKeyActions;
  51747. /**
  51748. * Handle all actions that come from pointer interaction
  51749. */
  51750. private _handlePointerActions;
  51751. /**
  51752. * Handle all actions that come from gamepad interaction
  51753. */
  51754. private _handleGamepadActions;
  51755. /**
  51756. * Update all non-event based devices with each frame
  51757. * @param deviceType Enum specifiying device type
  51758. * @param deviceSlot "Slot" or index that device is referenced in
  51759. * @param inputIndex Id of input to be checked
  51760. */
  51761. private _updateDevice;
  51762. /**
  51763. * Gets DeviceType from the device name
  51764. * @param deviceName Name of Device from DeviceInputSystem
  51765. * @returns DeviceType enum value
  51766. */
  51767. private _getGamepadDeviceType;
  51768. }
  51769. }
  51770. declare module BABYLON {
  51771. /**
  51772. * Type to handle enforcement of inputs
  51773. */
  51774. 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;
  51775. }
  51776. declare module BABYLON {
  51777. /**
  51778. * Class that handles all input for a specific device
  51779. */
  51780. export class DeviceSource<T extends DeviceType> {
  51781. /** Type of device */
  51782. readonly deviceType: DeviceType;
  51783. /** "Slot" or index that device is referenced in */
  51784. readonly deviceSlot: number;
  51785. /**
  51786. * Observable to handle device input changes per device
  51787. */
  51788. readonly onInputChangedObservable: Observable<{
  51789. inputIndex: DeviceInput<T>;
  51790. previousState: Nullable<number>;
  51791. currentState: Nullable<number>;
  51792. }>;
  51793. private readonly _deviceInputSystem;
  51794. /**
  51795. * Default Constructor
  51796. * @param deviceInputSystem Reference to DeviceInputSystem
  51797. * @param deviceType Type of device
  51798. * @param deviceSlot "Slot" or index that device is referenced in
  51799. */
  51800. constructor(deviceInputSystem: DeviceInputSystem,
  51801. /** Type of device */
  51802. deviceType: DeviceType,
  51803. /** "Slot" or index that device is referenced in */
  51804. deviceSlot?: number);
  51805. /**
  51806. * Get input for specific input
  51807. * @param inputIndex index of specific input on device
  51808. * @returns Input value from DeviceInputSystem
  51809. */
  51810. getInput(inputIndex: DeviceInput<T>): number;
  51811. }
  51812. /**
  51813. * Class to keep track of devices
  51814. */
  51815. export class DeviceSourceManager implements IDisposable {
  51816. /**
  51817. * Observable to be triggered when before a device is connected
  51818. */
  51819. readonly onBeforeDeviceConnectedObservable: Observable<{
  51820. deviceType: DeviceType;
  51821. deviceSlot: number;
  51822. }>;
  51823. /**
  51824. * Observable to be triggered when before a device is disconnected
  51825. */
  51826. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51827. deviceType: DeviceType;
  51828. deviceSlot: number;
  51829. }>;
  51830. /**
  51831. * Observable to be triggered when after a device is connected
  51832. */
  51833. readonly onAfterDeviceConnectedObservable: Observable<{
  51834. deviceType: DeviceType;
  51835. deviceSlot: number;
  51836. }>;
  51837. /**
  51838. * Observable to be triggered when after a device is disconnected
  51839. */
  51840. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51841. deviceType: DeviceType;
  51842. deviceSlot: number;
  51843. }>;
  51844. private readonly _devices;
  51845. private readonly _firstDevice;
  51846. private readonly _deviceInputSystem;
  51847. /**
  51848. * Default Constructor
  51849. * @param engine engine to pull input element from
  51850. */
  51851. constructor(engine: Engine);
  51852. /**
  51853. * Gets a DeviceSource, given a type and slot
  51854. * @param deviceType Enum specifying device type
  51855. * @param deviceSlot "Slot" or index that device is referenced in
  51856. * @returns DeviceSource object
  51857. */
  51858. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51859. /**
  51860. * Gets an array of DeviceSource objects for a given device type
  51861. * @param deviceType Enum specifying device type
  51862. * @returns Array of DeviceSource objects
  51863. */
  51864. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51865. /**
  51866. * Dispose of DeviceInputSystem and other parts
  51867. */
  51868. dispose(): void;
  51869. /**
  51870. * Function to add device name to device list
  51871. * @param deviceType Enum specifying device type
  51872. * @param deviceSlot "Slot" or index that device is referenced in
  51873. */
  51874. private _addDevice;
  51875. /**
  51876. * Function to remove device name to device list
  51877. * @param deviceType Enum specifying device type
  51878. * @param deviceSlot "Slot" or index that device is referenced in
  51879. */
  51880. private _removeDevice;
  51881. /**
  51882. * Updates array storing first connected device of each type
  51883. * @param type Type of Device
  51884. */
  51885. private _updateFirstDevices;
  51886. }
  51887. }
  51888. declare module BABYLON {
  51889. /**
  51890. * Options to create the null engine
  51891. */
  51892. export class NullEngineOptions {
  51893. /**
  51894. * Render width (Default: 512)
  51895. */
  51896. renderWidth: number;
  51897. /**
  51898. * Render height (Default: 256)
  51899. */
  51900. renderHeight: number;
  51901. /**
  51902. * Texture size (Default: 512)
  51903. */
  51904. textureSize: number;
  51905. /**
  51906. * If delta time between frames should be constant
  51907. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51908. */
  51909. deterministicLockstep: boolean;
  51910. /**
  51911. * Maximum about of steps between frames (Default: 4)
  51912. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51913. */
  51914. lockstepMaxSteps: number;
  51915. /**
  51916. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51917. */
  51918. useHighPrecisionMatrix?: boolean;
  51919. }
  51920. /**
  51921. * The null engine class provides support for headless version of babylon.js.
  51922. * This can be used in server side scenario or for testing purposes
  51923. */
  51924. export class NullEngine extends Engine {
  51925. private _options;
  51926. /**
  51927. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51928. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51929. * @returns true if engine is in deterministic lock step mode
  51930. */
  51931. isDeterministicLockStep(): boolean;
  51932. /**
  51933. * Gets the max steps when engine is running in deterministic lock step
  51934. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51935. * @returns the max steps
  51936. */
  51937. getLockstepMaxSteps(): number;
  51938. /**
  51939. * Gets the current hardware scaling level.
  51940. * By default the hardware scaling level is computed from the window device ratio.
  51941. * 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.
  51942. * @returns a number indicating the current hardware scaling level
  51943. */
  51944. getHardwareScalingLevel(): number;
  51945. constructor(options?: NullEngineOptions);
  51946. /**
  51947. * Creates a vertex buffer
  51948. * @param vertices the data for the vertex buffer
  51949. * @returns the new WebGL static buffer
  51950. */
  51951. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51952. /**
  51953. * Creates a new index buffer
  51954. * @param indices defines the content of the index buffer
  51955. * @param updatable defines if the index buffer must be updatable
  51956. * @returns a new webGL buffer
  51957. */
  51958. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51959. /**
  51960. * Clear the current render buffer or the current render target (if any is set up)
  51961. * @param color defines the color to use
  51962. * @param backBuffer defines if the back buffer must be cleared
  51963. * @param depth defines if the depth buffer must be cleared
  51964. * @param stencil defines if the stencil buffer must be cleared
  51965. */
  51966. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51967. /**
  51968. * Gets the current render width
  51969. * @param useScreen defines if screen size must be used (or the current render target if any)
  51970. * @returns a number defining the current render width
  51971. */
  51972. getRenderWidth(useScreen?: boolean): number;
  51973. /**
  51974. * Gets the current render height
  51975. * @param useScreen defines if screen size must be used (or the current render target if any)
  51976. * @returns a number defining the current render height
  51977. */
  51978. getRenderHeight(useScreen?: boolean): number;
  51979. /**
  51980. * Set the WebGL's viewport
  51981. * @param viewport defines the viewport element to be used
  51982. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51983. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51984. */
  51985. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51986. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51987. /**
  51988. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51989. * @param pipelineContext defines the pipeline context to use
  51990. * @param uniformsNames defines the list of uniform names
  51991. * @returns an array of webGL uniform locations
  51992. */
  51993. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51994. /**
  51995. * Gets the lsit of active attributes for a given webGL program
  51996. * @param pipelineContext defines the pipeline context to use
  51997. * @param attributesNames defines the list of attribute names to get
  51998. * @returns an array of indices indicating the offset of each attribute
  51999. */
  52000. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52001. /**
  52002. * Binds an effect to the webGL context
  52003. * @param effect defines the effect to bind
  52004. */
  52005. bindSamplers(effect: Effect): void;
  52006. /**
  52007. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52008. * @param effect defines the effect to activate
  52009. */
  52010. enableEffect(effect: Effect): void;
  52011. /**
  52012. * Set various states to the webGL context
  52013. * @param culling defines backface culling state
  52014. * @param zOffset defines the value to apply to zOffset (0 by default)
  52015. * @param force defines if states must be applied even if cache is up to date
  52016. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52017. */
  52018. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52019. /**
  52020. * Set the value of an uniform to an array of int32
  52021. * @param uniform defines the webGL uniform location where to store the value
  52022. * @param array defines the array of int32 to store
  52023. */
  52024. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52025. /**
  52026. * Set the value of an uniform to an array of int32 (stored as vec2)
  52027. * @param uniform defines the webGL uniform location where to store the value
  52028. * @param array defines the array of int32 to store
  52029. */
  52030. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52031. /**
  52032. * Set the value of an uniform to an array of int32 (stored as vec3)
  52033. * @param uniform defines the webGL uniform location where to store the value
  52034. * @param array defines the array of int32 to store
  52035. */
  52036. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52037. /**
  52038. * Set the value of an uniform to an array of int32 (stored as vec4)
  52039. * @param uniform defines the webGL uniform location where to store the value
  52040. * @param array defines the array of int32 to store
  52041. */
  52042. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52043. /**
  52044. * Set the value of an uniform to an array of float32
  52045. * @param uniform defines the webGL uniform location where to store the value
  52046. * @param array defines the array of float32 to store
  52047. */
  52048. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52049. /**
  52050. * Set the value of an uniform to an array of float32 (stored as vec2)
  52051. * @param uniform defines the webGL uniform location where to store the value
  52052. * @param array defines the array of float32 to store
  52053. */
  52054. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52055. /**
  52056. * Set the value of an uniform to an array of float32 (stored as vec3)
  52057. * @param uniform defines the webGL uniform location where to store the value
  52058. * @param array defines the array of float32 to store
  52059. */
  52060. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52061. /**
  52062. * Set the value of an uniform to an array of float32 (stored as vec4)
  52063. * @param uniform defines the webGL uniform location where to store the value
  52064. * @param array defines the array of float32 to store
  52065. */
  52066. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52067. /**
  52068. * Set the value of an uniform to an array of number
  52069. * @param uniform defines the webGL uniform location where to store the value
  52070. * @param array defines the array of number to store
  52071. */
  52072. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52073. /**
  52074. * Set the value of an uniform to an array of number (stored as vec2)
  52075. * @param uniform defines the webGL uniform location where to store the value
  52076. * @param array defines the array of number to store
  52077. */
  52078. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52079. /**
  52080. * Set the value of an uniform to an array of number (stored as vec3)
  52081. * @param uniform defines the webGL uniform location where to store the value
  52082. * @param array defines the array of number to store
  52083. */
  52084. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52085. /**
  52086. * Set the value of an uniform to an array of number (stored as vec4)
  52087. * @param uniform defines the webGL uniform location where to store the value
  52088. * @param array defines the array of number to store
  52089. */
  52090. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52091. /**
  52092. * Set the value of an uniform to an array of float32 (stored as matrices)
  52093. * @param uniform defines the webGL uniform location where to store the value
  52094. * @param matrices defines the array of float32 to store
  52095. */
  52096. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52097. /**
  52098. * Set the value of an uniform to a matrix (3x3)
  52099. * @param uniform defines the webGL uniform location where to store the value
  52100. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52101. */
  52102. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52103. /**
  52104. * Set the value of an uniform to a matrix (2x2)
  52105. * @param uniform defines the webGL uniform location where to store the value
  52106. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52107. */
  52108. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52109. /**
  52110. * Set the value of an uniform to a number (float)
  52111. * @param uniform defines the webGL uniform location where to store the value
  52112. * @param value defines the float number to store
  52113. */
  52114. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52115. /**
  52116. * Set the value of an uniform to a vec2
  52117. * @param uniform defines the webGL uniform location where to store the value
  52118. * @param x defines the 1st component of the value
  52119. * @param y defines the 2nd component of the value
  52120. */
  52121. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52122. /**
  52123. * Set the value of an uniform to a vec3
  52124. * @param uniform defines the webGL uniform location where to store the value
  52125. * @param x defines the 1st component of the value
  52126. * @param y defines the 2nd component of the value
  52127. * @param z defines the 3rd component of the value
  52128. */
  52129. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52130. /**
  52131. * Set the value of an uniform to a boolean
  52132. * @param uniform defines the webGL uniform location where to store the value
  52133. * @param bool defines the boolean to store
  52134. */
  52135. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52136. /**
  52137. * Set the value of an uniform to a vec4
  52138. * @param uniform defines the webGL uniform location where to store the value
  52139. * @param x defines the 1st component of the value
  52140. * @param y defines the 2nd component of the value
  52141. * @param z defines the 3rd component of the value
  52142. * @param w defines the 4th component of the value
  52143. */
  52144. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52145. /**
  52146. * Sets the current alpha mode
  52147. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52148. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52149. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52150. */
  52151. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52152. /**
  52153. * Bind webGl buffers directly to the webGL context
  52154. * @param vertexBuffers defines the vertex buffer to bind
  52155. * @param indexBuffer defines the index buffer to bind
  52156. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52157. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52158. * @param effect defines the effect associated with the vertex buffer
  52159. */
  52160. bindBuffers(vertexBuffers: {
  52161. [key: string]: VertexBuffer;
  52162. }, indexBuffer: DataBuffer, effect: Effect): void;
  52163. /**
  52164. * Force the entire cache to be cleared
  52165. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52166. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52167. */
  52168. wipeCaches(bruteForce?: boolean): void;
  52169. /**
  52170. * Send a draw order
  52171. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52172. * @param indexStart defines the starting index
  52173. * @param indexCount defines the number of index to draw
  52174. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52175. */
  52176. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52177. /**
  52178. * Draw a list of indexed primitives
  52179. * @param fillMode defines the primitive to use
  52180. * @param indexStart defines the starting index
  52181. * @param indexCount defines the number of index to draw
  52182. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52183. */
  52184. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52185. /**
  52186. * Draw a list of unindexed primitives
  52187. * @param fillMode defines the primitive to use
  52188. * @param verticesStart defines the index of first vertex to draw
  52189. * @param verticesCount defines the count of vertices to draw
  52190. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52191. */
  52192. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52193. /** @hidden */
  52194. _createTexture(): WebGLTexture;
  52195. /** @hidden */
  52196. _releaseTexture(texture: InternalTexture): void;
  52197. /**
  52198. * Usually called from Texture.ts.
  52199. * Passed information to create a WebGLTexture
  52200. * @param urlArg defines a value which contains one of the following:
  52201. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52202. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52203. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52204. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52205. * @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)
  52206. * @param scene needed for loading to the correct scene
  52207. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52208. * @param onLoad optional callback to be called upon successful completion
  52209. * @param onError optional callback to be called upon failure
  52210. * @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
  52211. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52212. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52213. * @param forcedExtension defines the extension to use to pick the right loader
  52214. * @param mimeType defines an optional mime type
  52215. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52216. */
  52217. 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;
  52218. /**
  52219. * Creates a new render target texture
  52220. * @param size defines the size of the texture
  52221. * @param options defines the options used to create the texture
  52222. * @returns a new render target texture stored in an InternalTexture
  52223. */
  52224. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52225. /**
  52226. * Update the sampling mode of a given texture
  52227. * @param samplingMode defines the required sampling mode
  52228. * @param texture defines the texture to update
  52229. */
  52230. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52231. /**
  52232. * Binds the frame buffer to the specified texture.
  52233. * @param texture The texture to render to or null for the default canvas
  52234. * @param faceIndex The face of the texture to render to in case of cube texture
  52235. * @param requiredWidth The width of the target to render to
  52236. * @param requiredHeight The height of the target to render to
  52237. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52238. * @param lodLevel defines le lod level to bind to the frame buffer
  52239. */
  52240. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52241. /**
  52242. * Unbind the current render target texture from the webGL context
  52243. * @param texture defines the render target texture to unbind
  52244. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52245. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52246. */
  52247. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52248. /**
  52249. * Creates a dynamic vertex buffer
  52250. * @param vertices the data for the dynamic vertex buffer
  52251. * @returns the new WebGL dynamic buffer
  52252. */
  52253. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52254. /**
  52255. * Update the content of a dynamic texture
  52256. * @param texture defines the texture to update
  52257. * @param canvas defines the canvas containing the source
  52258. * @param invertY defines if data must be stored with Y axis inverted
  52259. * @param premulAlpha defines if alpha is stored as premultiplied
  52260. * @param format defines the format of the data
  52261. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52262. */
  52263. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52264. /**
  52265. * Gets a boolean indicating if all created effects are ready
  52266. * @returns true if all effects are ready
  52267. */
  52268. areAllEffectsReady(): boolean;
  52269. /**
  52270. * @hidden
  52271. * Get the current error code of the webGL context
  52272. * @returns the error code
  52273. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52274. */
  52275. getError(): number;
  52276. /** @hidden */
  52277. _getUnpackAlignement(): number;
  52278. /** @hidden */
  52279. _unpackFlipY(value: boolean): void;
  52280. /**
  52281. * Update a dynamic index buffer
  52282. * @param indexBuffer defines the target index buffer
  52283. * @param indices defines the data to update
  52284. * @param offset defines the offset in the target index buffer where update should start
  52285. */
  52286. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52287. /**
  52288. * Updates a dynamic vertex buffer.
  52289. * @param vertexBuffer the vertex buffer to update
  52290. * @param vertices the data used to update the vertex buffer
  52291. * @param byteOffset the byte offset of the data (optional)
  52292. * @param byteLength the byte length of the data (optional)
  52293. */
  52294. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52295. /** @hidden */
  52296. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52297. /** @hidden */
  52298. _bindTexture(channel: number, texture: InternalTexture): void;
  52299. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52300. /**
  52301. * 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
  52302. */
  52303. releaseEffects(): void;
  52304. displayLoadingUI(): void;
  52305. hideLoadingUI(): void;
  52306. /** @hidden */
  52307. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52308. /** @hidden */
  52309. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52310. /** @hidden */
  52311. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52312. /** @hidden */
  52313. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52314. }
  52315. }
  52316. declare module BABYLON {
  52317. /**
  52318. * @hidden
  52319. **/
  52320. export class _TimeToken {
  52321. _startTimeQuery: Nullable<WebGLQuery>;
  52322. _endTimeQuery: Nullable<WebGLQuery>;
  52323. _timeElapsedQuery: Nullable<WebGLQuery>;
  52324. _timeElapsedQueryEnded: boolean;
  52325. }
  52326. }
  52327. declare module BABYLON {
  52328. /** @hidden */
  52329. export class _OcclusionDataStorage {
  52330. /** @hidden */
  52331. occlusionInternalRetryCounter: number;
  52332. /** @hidden */
  52333. isOcclusionQueryInProgress: boolean;
  52334. /** @hidden */
  52335. isOccluded: boolean;
  52336. /** @hidden */
  52337. occlusionRetryCount: number;
  52338. /** @hidden */
  52339. occlusionType: number;
  52340. /** @hidden */
  52341. occlusionQueryAlgorithmType: number;
  52342. }
  52343. interface Engine {
  52344. /**
  52345. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52346. * @return the new query
  52347. */
  52348. createQuery(): WebGLQuery;
  52349. /**
  52350. * Delete and release a webGL query
  52351. * @param query defines the query to delete
  52352. * @return the current engine
  52353. */
  52354. deleteQuery(query: WebGLQuery): Engine;
  52355. /**
  52356. * Check if a given query has resolved and got its value
  52357. * @param query defines the query to check
  52358. * @returns true if the query got its value
  52359. */
  52360. isQueryResultAvailable(query: WebGLQuery): boolean;
  52361. /**
  52362. * Gets the value of a given query
  52363. * @param query defines the query to check
  52364. * @returns the value of the query
  52365. */
  52366. getQueryResult(query: WebGLQuery): number;
  52367. /**
  52368. * Initiates an occlusion query
  52369. * @param algorithmType defines the algorithm to use
  52370. * @param query defines the query to use
  52371. * @returns the current engine
  52372. * @see https://doc.babylonjs.com/features/occlusionquery
  52373. */
  52374. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52375. /**
  52376. * Ends an occlusion query
  52377. * @see https://doc.babylonjs.com/features/occlusionquery
  52378. * @param algorithmType defines the algorithm to use
  52379. * @returns the current engine
  52380. */
  52381. endOcclusionQuery(algorithmType: number): Engine;
  52382. /**
  52383. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52384. * Please note that only one query can be issued at a time
  52385. * @returns a time token used to track the time span
  52386. */
  52387. startTimeQuery(): Nullable<_TimeToken>;
  52388. /**
  52389. * Ends a time query
  52390. * @param token defines the token used to measure the time span
  52391. * @returns the time spent (in ns)
  52392. */
  52393. endTimeQuery(token: _TimeToken): int;
  52394. /** @hidden */
  52395. _currentNonTimestampToken: Nullable<_TimeToken>;
  52396. /** @hidden */
  52397. _createTimeQuery(): WebGLQuery;
  52398. /** @hidden */
  52399. _deleteTimeQuery(query: WebGLQuery): void;
  52400. /** @hidden */
  52401. _getGlAlgorithmType(algorithmType: number): number;
  52402. /** @hidden */
  52403. _getTimeQueryResult(query: WebGLQuery): any;
  52404. /** @hidden */
  52405. _getTimeQueryAvailability(query: WebGLQuery): any;
  52406. }
  52407. interface AbstractMesh {
  52408. /**
  52409. * Backing filed
  52410. * @hidden
  52411. */
  52412. __occlusionDataStorage: _OcclusionDataStorage;
  52413. /**
  52414. * Access property
  52415. * @hidden
  52416. */
  52417. _occlusionDataStorage: _OcclusionDataStorage;
  52418. /**
  52419. * 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.
  52420. * The default value is -1 which means don't break the query and wait till the result
  52421. * @see https://doc.babylonjs.com/features/occlusionquery
  52422. */
  52423. occlusionRetryCount: number;
  52424. /**
  52425. * 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:
  52426. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52427. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52428. * * 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.
  52429. * @see https://doc.babylonjs.com/features/occlusionquery
  52430. */
  52431. occlusionType: number;
  52432. /**
  52433. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52434. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52435. * * 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.
  52436. * @see https://doc.babylonjs.com/features/occlusionquery
  52437. */
  52438. occlusionQueryAlgorithmType: number;
  52439. /**
  52440. * 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
  52441. * @see https://doc.babylonjs.com/features/occlusionquery
  52442. */
  52443. isOccluded: boolean;
  52444. /**
  52445. * Flag to check the progress status of the query
  52446. * @see https://doc.babylonjs.com/features/occlusionquery
  52447. */
  52448. isOcclusionQueryInProgress: boolean;
  52449. }
  52450. }
  52451. declare module BABYLON {
  52452. /** @hidden */
  52453. export var _forceTransformFeedbackToBundle: boolean;
  52454. interface Engine {
  52455. /**
  52456. * Creates a webGL transform feedback object
  52457. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52458. * @returns the webGL transform feedback object
  52459. */
  52460. createTransformFeedback(): WebGLTransformFeedback;
  52461. /**
  52462. * Delete a webGL transform feedback object
  52463. * @param value defines the webGL transform feedback object to delete
  52464. */
  52465. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52466. /**
  52467. * Bind a webGL transform feedback object to the webgl context
  52468. * @param value defines the webGL transform feedback object to bind
  52469. */
  52470. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52471. /**
  52472. * Begins a transform feedback operation
  52473. * @param usePoints defines if points or triangles must be used
  52474. */
  52475. beginTransformFeedback(usePoints: boolean): void;
  52476. /**
  52477. * Ends a transform feedback operation
  52478. */
  52479. endTransformFeedback(): void;
  52480. /**
  52481. * Specify the varyings to use with transform feedback
  52482. * @param program defines the associated webGL program
  52483. * @param value defines the list of strings representing the varying names
  52484. */
  52485. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52486. /**
  52487. * Bind a webGL buffer for a transform feedback operation
  52488. * @param value defines the webGL buffer to bind
  52489. */
  52490. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52491. }
  52492. }
  52493. declare module BABYLON {
  52494. /**
  52495. * Class used to define an additional view for the engine
  52496. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52497. */
  52498. export class EngineView {
  52499. /** Defines the canvas where to render the view */
  52500. target: HTMLCanvasElement;
  52501. /** Defines an optional camera used to render the view (will use active camera else) */
  52502. camera?: Camera;
  52503. }
  52504. interface Engine {
  52505. /**
  52506. * Gets or sets the HTML element to use for attaching events
  52507. */
  52508. inputElement: Nullable<HTMLElement>;
  52509. /**
  52510. * Gets the current engine view
  52511. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52512. */
  52513. activeView: Nullable<EngineView>;
  52514. /** Gets or sets the list of views */
  52515. views: EngineView[];
  52516. /**
  52517. * Register a new child canvas
  52518. * @param canvas defines the canvas to register
  52519. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52520. * @returns the associated view
  52521. */
  52522. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52523. /**
  52524. * Remove a registered child canvas
  52525. * @param canvas defines the canvas to remove
  52526. * @returns the current engine
  52527. */
  52528. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52529. }
  52530. }
  52531. declare module BABYLON {
  52532. interface Engine {
  52533. /** @hidden */
  52534. _excludedCompressedTextures: string[];
  52535. /** @hidden */
  52536. _textureFormatInUse: string;
  52537. /**
  52538. * Gets the list of texture formats supported
  52539. */
  52540. readonly texturesSupported: Array<string>;
  52541. /**
  52542. * Gets the texture format in use
  52543. */
  52544. readonly textureFormatInUse: Nullable<string>;
  52545. /**
  52546. * Set the compressed texture extensions or file names to skip.
  52547. *
  52548. * @param skippedFiles defines the list of those texture files you want to skip
  52549. * Example: [".dds", ".env", "myfile.png"]
  52550. */
  52551. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52552. /**
  52553. * Set the compressed texture format to use, based on the formats you have, and the formats
  52554. * supported by the hardware / browser.
  52555. *
  52556. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52557. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52558. * to API arguments needed to compressed textures. This puts the burden on the container
  52559. * generator to house the arcane code for determining these for current & future formats.
  52560. *
  52561. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52562. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52563. *
  52564. * Note: The result of this call is not taken into account when a texture is base64.
  52565. *
  52566. * @param formatsAvailable defines the list of those format families you have created
  52567. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52568. *
  52569. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52570. * @returns The extension selected.
  52571. */
  52572. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52573. }
  52574. }
  52575. declare module BABYLON {
  52576. /**
  52577. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52578. */
  52579. export interface CubeMapInfo {
  52580. /**
  52581. * The pixel array for the front face.
  52582. * This is stored in format, left to right, up to down format.
  52583. */
  52584. front: Nullable<ArrayBufferView>;
  52585. /**
  52586. * The pixel array for the back face.
  52587. * This is stored in format, left to right, up to down format.
  52588. */
  52589. back: Nullable<ArrayBufferView>;
  52590. /**
  52591. * The pixel array for the left face.
  52592. * This is stored in format, left to right, up to down format.
  52593. */
  52594. left: Nullable<ArrayBufferView>;
  52595. /**
  52596. * The pixel array for the right face.
  52597. * This is stored in format, left to right, up to down format.
  52598. */
  52599. right: Nullable<ArrayBufferView>;
  52600. /**
  52601. * The pixel array for the up face.
  52602. * This is stored in format, left to right, up to down format.
  52603. */
  52604. up: Nullable<ArrayBufferView>;
  52605. /**
  52606. * The pixel array for the down face.
  52607. * This is stored in format, left to right, up to down format.
  52608. */
  52609. down: Nullable<ArrayBufferView>;
  52610. /**
  52611. * The size of the cubemap stored.
  52612. *
  52613. * Each faces will be size * size pixels.
  52614. */
  52615. size: number;
  52616. /**
  52617. * The format of the texture.
  52618. *
  52619. * RGBA, RGB.
  52620. */
  52621. format: number;
  52622. /**
  52623. * The type of the texture data.
  52624. *
  52625. * UNSIGNED_INT, FLOAT.
  52626. */
  52627. type: number;
  52628. /**
  52629. * Specifies whether the texture is in gamma space.
  52630. */
  52631. gammaSpace: boolean;
  52632. }
  52633. /**
  52634. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52635. */
  52636. export class PanoramaToCubeMapTools {
  52637. private static FACE_LEFT;
  52638. private static FACE_RIGHT;
  52639. private static FACE_FRONT;
  52640. private static FACE_BACK;
  52641. private static FACE_DOWN;
  52642. private static FACE_UP;
  52643. /**
  52644. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52645. *
  52646. * @param float32Array The source data.
  52647. * @param inputWidth The width of the input panorama.
  52648. * @param inputHeight The height of the input panorama.
  52649. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52650. * @return The cubemap data
  52651. */
  52652. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52653. private static CreateCubemapTexture;
  52654. private static CalcProjectionSpherical;
  52655. }
  52656. }
  52657. declare module BABYLON {
  52658. /**
  52659. * Helper class dealing with the extraction of spherical polynomial dataArray
  52660. * from a cube map.
  52661. */
  52662. export class CubeMapToSphericalPolynomialTools {
  52663. private static FileFaces;
  52664. /**
  52665. * Converts a texture to the according Spherical Polynomial data.
  52666. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52667. *
  52668. * @param texture The texture to extract the information from.
  52669. * @return The Spherical Polynomial data.
  52670. */
  52671. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52672. /**
  52673. * Converts a cubemap to the according Spherical Polynomial data.
  52674. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52675. *
  52676. * @param cubeInfo The Cube map to extract the information from.
  52677. * @return The Spherical Polynomial data.
  52678. */
  52679. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52680. }
  52681. }
  52682. declare module BABYLON {
  52683. interface BaseTexture {
  52684. /**
  52685. * Get the polynomial representation of the texture data.
  52686. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52687. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52688. */
  52689. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52690. }
  52691. }
  52692. declare module BABYLON {
  52693. /** @hidden */
  52694. export var rgbdEncodePixelShader: {
  52695. name: string;
  52696. shader: string;
  52697. };
  52698. }
  52699. declare module BABYLON {
  52700. /** @hidden */
  52701. export var rgbdDecodePixelShader: {
  52702. name: string;
  52703. shader: string;
  52704. };
  52705. }
  52706. declare module BABYLON {
  52707. /**
  52708. * Raw texture data and descriptor sufficient for WebGL texture upload
  52709. */
  52710. export interface EnvironmentTextureInfo {
  52711. /**
  52712. * Version of the environment map
  52713. */
  52714. version: number;
  52715. /**
  52716. * Width of image
  52717. */
  52718. width: number;
  52719. /**
  52720. * Irradiance information stored in the file.
  52721. */
  52722. irradiance: any;
  52723. /**
  52724. * Specular information stored in the file.
  52725. */
  52726. specular: any;
  52727. }
  52728. /**
  52729. * Defines One Image in the file. It requires only the position in the file
  52730. * as well as the length.
  52731. */
  52732. interface BufferImageData {
  52733. /**
  52734. * Length of the image data.
  52735. */
  52736. length: number;
  52737. /**
  52738. * Position of the data from the null terminator delimiting the end of the JSON.
  52739. */
  52740. position: number;
  52741. }
  52742. /**
  52743. * Defines the specular data enclosed in the file.
  52744. * This corresponds to the version 1 of the data.
  52745. */
  52746. export interface EnvironmentTextureSpecularInfoV1 {
  52747. /**
  52748. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52749. */
  52750. specularDataPosition?: number;
  52751. /**
  52752. * This contains all the images data needed to reconstruct the cubemap.
  52753. */
  52754. mipmaps: Array<BufferImageData>;
  52755. /**
  52756. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52757. */
  52758. lodGenerationScale: number;
  52759. }
  52760. /**
  52761. * Sets of helpers addressing the serialization and deserialization of environment texture
  52762. * stored in a BabylonJS env file.
  52763. * Those files are usually stored as .env files.
  52764. */
  52765. export class EnvironmentTextureTools {
  52766. /**
  52767. * Magic number identifying the env file.
  52768. */
  52769. private static _MagicBytes;
  52770. /**
  52771. * Gets the environment info from an env file.
  52772. * @param data The array buffer containing the .env bytes.
  52773. * @returns the environment file info (the json header) if successfully parsed.
  52774. */
  52775. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52776. /**
  52777. * Creates an environment texture from a loaded cube texture.
  52778. * @param texture defines the cube texture to convert in env file
  52779. * @return a promise containing the environment data if succesfull.
  52780. */
  52781. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52782. /**
  52783. * Creates a JSON representation of the spherical data.
  52784. * @param texture defines the texture containing the polynomials
  52785. * @return the JSON representation of the spherical info
  52786. */
  52787. private static _CreateEnvTextureIrradiance;
  52788. /**
  52789. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52790. * @param data the image data
  52791. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52792. * @return the views described by info providing access to the underlying buffer
  52793. */
  52794. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52795. /**
  52796. * Uploads the texture info contained in the env file to the GPU.
  52797. * @param texture defines the internal texture to upload to
  52798. * @param data defines the data to load
  52799. * @param info defines the texture info retrieved through the GetEnvInfo method
  52800. * @returns a promise
  52801. */
  52802. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52803. private static _OnImageReadyAsync;
  52804. /**
  52805. * Uploads the levels of image data to the GPU.
  52806. * @param texture defines the internal texture to upload to
  52807. * @param imageData defines the array buffer views of image data [mipmap][face]
  52808. * @returns a promise
  52809. */
  52810. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52811. /**
  52812. * Uploads spherical polynomials information to the texture.
  52813. * @param texture defines the texture we are trying to upload the information to
  52814. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52815. */
  52816. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52817. /** @hidden */
  52818. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52819. }
  52820. }
  52821. declare module BABYLON {
  52822. /**
  52823. * Class used to inline functions in shader code
  52824. */
  52825. export class ShaderCodeInliner {
  52826. private static readonly _RegexpFindFunctionNameAndType;
  52827. private _sourceCode;
  52828. private _functionDescr;
  52829. private _numMaxIterations;
  52830. /** Gets or sets the token used to mark the functions to inline */
  52831. inlineToken: string;
  52832. /** Gets or sets the debug mode */
  52833. debug: boolean;
  52834. /** Gets the code after the inlining process */
  52835. get code(): string;
  52836. /**
  52837. * Initializes the inliner
  52838. * @param sourceCode shader code source to inline
  52839. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52840. */
  52841. constructor(sourceCode: string, numMaxIterations?: number);
  52842. /**
  52843. * Start the processing of the shader code
  52844. */
  52845. processCode(): void;
  52846. private _collectFunctions;
  52847. private _processInlining;
  52848. private _extractBetweenMarkers;
  52849. private _skipWhitespaces;
  52850. private _removeComments;
  52851. private _replaceFunctionCallsByCode;
  52852. private _findBackward;
  52853. private _escapeRegExp;
  52854. private _replaceNames;
  52855. }
  52856. }
  52857. declare module BABYLON {
  52858. /**
  52859. * Container for accessors for natively-stored mesh data buffers.
  52860. */
  52861. class NativeDataBuffer extends DataBuffer {
  52862. /**
  52863. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52864. */
  52865. nativeIndexBuffer?: any;
  52866. /**
  52867. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52868. */
  52869. nativeVertexBuffer?: any;
  52870. }
  52871. /** @hidden */
  52872. class NativeTexture extends InternalTexture {
  52873. getInternalTexture(): InternalTexture;
  52874. getViewCount(): number;
  52875. }
  52876. /** @hidden */
  52877. export class NativeEngine extends Engine {
  52878. private readonly _native;
  52879. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52880. private readonly INVALID_HANDLE;
  52881. private _boundBuffersVertexArray;
  52882. getHardwareScalingLevel(): number;
  52883. constructor();
  52884. dispose(): void;
  52885. /**
  52886. * Can be used to override the current requestAnimationFrame requester.
  52887. * @hidden
  52888. */
  52889. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52890. /**
  52891. * Override default engine behavior.
  52892. * @param color
  52893. * @param backBuffer
  52894. * @param depth
  52895. * @param stencil
  52896. */
  52897. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52898. /**
  52899. * Gets host document
  52900. * @returns the host document object
  52901. */
  52902. getHostDocument(): Nullable<Document>;
  52903. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52904. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52905. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52906. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52907. [key: string]: VertexBuffer;
  52908. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52909. bindBuffers(vertexBuffers: {
  52910. [key: string]: VertexBuffer;
  52911. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52912. recordVertexArrayObject(vertexBuffers: {
  52913. [key: string]: VertexBuffer;
  52914. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52915. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52916. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52917. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52918. /**
  52919. * Draw a list of indexed primitives
  52920. * @param fillMode defines the primitive to use
  52921. * @param indexStart defines the starting index
  52922. * @param indexCount defines the number of index to draw
  52923. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52924. */
  52925. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52926. /**
  52927. * Draw a list of unindexed primitives
  52928. * @param fillMode defines the primitive to use
  52929. * @param verticesStart defines the index of first vertex to draw
  52930. * @param verticesCount defines the count of vertices to draw
  52931. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52932. */
  52933. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52934. createPipelineContext(): IPipelineContext;
  52935. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52936. /** @hidden */
  52937. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52938. /** @hidden */
  52939. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52940. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52941. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52942. protected _setProgram(program: WebGLProgram): void;
  52943. _releaseEffect(effect: Effect): void;
  52944. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52945. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52946. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52947. bindSamplers(effect: Effect): void;
  52948. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52949. getRenderWidth(useScreen?: boolean): number;
  52950. getRenderHeight(useScreen?: boolean): number;
  52951. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52952. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52953. /**
  52954. * Set the z offset to apply to current rendering
  52955. * @param value defines the offset to apply
  52956. */
  52957. setZOffset(value: number): void;
  52958. /**
  52959. * Gets the current value of the zOffset
  52960. * @returns the current zOffset state
  52961. */
  52962. getZOffset(): number;
  52963. /**
  52964. * Enable or disable depth buffering
  52965. * @param enable defines the state to set
  52966. */
  52967. setDepthBuffer(enable: boolean): void;
  52968. /**
  52969. * Gets a boolean indicating if depth writing is enabled
  52970. * @returns the current depth writing state
  52971. */
  52972. getDepthWrite(): boolean;
  52973. /**
  52974. * Enable or disable depth writing
  52975. * @param enable defines the state to set
  52976. */
  52977. setDepthWrite(enable: boolean): void;
  52978. /**
  52979. * Enable or disable color writing
  52980. * @param enable defines the state to set
  52981. */
  52982. setColorWrite(enable: boolean): void;
  52983. /**
  52984. * Gets a boolean indicating if color writing is enabled
  52985. * @returns the current color writing state
  52986. */
  52987. getColorWrite(): boolean;
  52988. /**
  52989. * Sets alpha constants used by some alpha blending modes
  52990. * @param r defines the red component
  52991. * @param g defines the green component
  52992. * @param b defines the blue component
  52993. * @param a defines the alpha component
  52994. */
  52995. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52996. /**
  52997. * Sets the current alpha mode
  52998. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52999. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53000. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53001. */
  53002. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53003. /**
  53004. * Gets the current alpha mode
  53005. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53006. * @returns the current alpha mode
  53007. */
  53008. getAlphaMode(): number;
  53009. setInt(uniform: WebGLUniformLocation, int: number): void;
  53010. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53011. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53012. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53013. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53014. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53015. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53016. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53017. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53018. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53019. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53020. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53021. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53022. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53023. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53024. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53025. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53026. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53027. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53028. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53029. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53030. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  53031. wipeCaches(bruteForce?: boolean): void;
  53032. _createTexture(): WebGLTexture;
  53033. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53034. /**
  53035. * Usually called from Texture.ts.
  53036. * Passed information to create a WebGLTexture
  53037. * @param url defines a value which contains one of the following:
  53038. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53039. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53040. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53041. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53042. * @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)
  53043. * @param scene needed for loading to the correct scene
  53044. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53045. * @param onLoad optional callback to be called upon successful completion
  53046. * @param onError optional callback to be called upon failure
  53047. * @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
  53048. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53049. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53050. * @param forcedExtension defines the extension to use to pick the right loader
  53051. * @param mimeType defines an optional mime type
  53052. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53053. */
  53054. 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;
  53055. /**
  53056. * Creates a cube texture
  53057. * @param rootUrl defines the url where the files to load is located
  53058. * @param scene defines the current scene
  53059. * @param files defines the list of files to load (1 per face)
  53060. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53061. * @param onLoad defines an optional callback raised when the texture is loaded
  53062. * @param onError defines an optional callback raised if there is an issue to load the texture
  53063. * @param format defines the format of the data
  53064. * @param forcedExtension defines the extension to use to pick the right loader
  53065. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53066. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53067. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53068. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53069. * @returns the cube texture as an InternalTexture
  53070. */
  53071. 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;
  53072. private _getSamplingFilter;
  53073. private static _GetNativeTextureFormat;
  53074. createRenderTargetTexture(size: number | {
  53075. width: number;
  53076. height: number;
  53077. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53078. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53079. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53080. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53081. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53082. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53083. /**
  53084. * Updates a dynamic vertex buffer.
  53085. * @param vertexBuffer the vertex buffer to update
  53086. * @param data the data used to update the vertex buffer
  53087. * @param byteOffset the byte offset of the data (optional)
  53088. * @param byteLength the byte length of the data (optional)
  53089. */
  53090. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53091. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53092. private _updateAnisotropicLevel;
  53093. private _getAddressMode;
  53094. /** @hidden */
  53095. _bindTexture(channel: number, texture: InternalTexture): void;
  53096. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53097. releaseEffects(): void;
  53098. /** @hidden */
  53099. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53100. /** @hidden */
  53101. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53102. /** @hidden */
  53103. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53104. /** @hidden */
  53105. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53106. }
  53107. }
  53108. declare module BABYLON {
  53109. /**
  53110. * Gather the list of clipboard event types as constants.
  53111. */
  53112. export class ClipboardEventTypes {
  53113. /**
  53114. * The clipboard event is fired when a copy command is active (pressed).
  53115. */
  53116. static readonly COPY: number;
  53117. /**
  53118. * The clipboard event is fired when a cut command is active (pressed).
  53119. */
  53120. static readonly CUT: number;
  53121. /**
  53122. * The clipboard event is fired when a paste command is active (pressed).
  53123. */
  53124. static readonly PASTE: number;
  53125. }
  53126. /**
  53127. * This class is used to store clipboard related info for the onClipboardObservable event.
  53128. */
  53129. export class ClipboardInfo {
  53130. /**
  53131. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53132. */
  53133. type: number;
  53134. /**
  53135. * Defines the related dom event
  53136. */
  53137. event: ClipboardEvent;
  53138. /**
  53139. *Creates an instance of ClipboardInfo.
  53140. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53141. * @param event Defines the related dom event
  53142. */
  53143. constructor(
  53144. /**
  53145. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53146. */
  53147. type: number,
  53148. /**
  53149. * Defines the related dom event
  53150. */
  53151. event: ClipboardEvent);
  53152. /**
  53153. * Get the clipboard event's type from the keycode.
  53154. * @param keyCode Defines the keyCode for the current keyboard event.
  53155. * @return {number}
  53156. */
  53157. static GetTypeFromCharacter(keyCode: number): number;
  53158. }
  53159. }
  53160. declare module BABYLON {
  53161. /**
  53162. * Google Daydream controller
  53163. */
  53164. export class DaydreamController extends WebVRController {
  53165. /**
  53166. * Base Url for the controller model.
  53167. */
  53168. static MODEL_BASE_URL: string;
  53169. /**
  53170. * File name for the controller model.
  53171. */
  53172. static MODEL_FILENAME: string;
  53173. /**
  53174. * Gamepad Id prefix used to identify Daydream Controller.
  53175. */
  53176. static readonly GAMEPAD_ID_PREFIX: string;
  53177. /**
  53178. * Creates a new DaydreamController from a gamepad
  53179. * @param vrGamepad the gamepad that the controller should be created from
  53180. */
  53181. constructor(vrGamepad: any);
  53182. /**
  53183. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53184. * @param scene scene in which to add meshes
  53185. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53186. */
  53187. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53188. /**
  53189. * Called once for each button that changed state since the last frame
  53190. * @param buttonIdx Which button index changed
  53191. * @param state New state of the button
  53192. * @param changes Which properties on the state changed since last frame
  53193. */
  53194. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53195. }
  53196. }
  53197. declare module BABYLON {
  53198. /**
  53199. * Gear VR Controller
  53200. */
  53201. export class GearVRController extends WebVRController {
  53202. /**
  53203. * Base Url for the controller model.
  53204. */
  53205. static MODEL_BASE_URL: string;
  53206. /**
  53207. * File name for the controller model.
  53208. */
  53209. static MODEL_FILENAME: string;
  53210. /**
  53211. * Gamepad Id prefix used to identify this controller.
  53212. */
  53213. static readonly GAMEPAD_ID_PREFIX: string;
  53214. private readonly _buttonIndexToObservableNameMap;
  53215. /**
  53216. * Creates a new GearVRController from a gamepad
  53217. * @param vrGamepad the gamepad that the controller should be created from
  53218. */
  53219. constructor(vrGamepad: any);
  53220. /**
  53221. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53222. * @param scene scene in which to add meshes
  53223. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53224. */
  53225. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53226. /**
  53227. * Called once for each button that changed state since the last frame
  53228. * @param buttonIdx Which button index changed
  53229. * @param state New state of the button
  53230. * @param changes Which properties on the state changed since last frame
  53231. */
  53232. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53233. }
  53234. }
  53235. declare module BABYLON {
  53236. /**
  53237. * Generic Controller
  53238. */
  53239. export class GenericController extends WebVRController {
  53240. /**
  53241. * Base Url for the controller model.
  53242. */
  53243. static readonly MODEL_BASE_URL: string;
  53244. /**
  53245. * File name for the controller model.
  53246. */
  53247. static readonly MODEL_FILENAME: string;
  53248. /**
  53249. * Creates a new GenericController from a gamepad
  53250. * @param vrGamepad the gamepad that the controller should be created from
  53251. */
  53252. constructor(vrGamepad: any);
  53253. /**
  53254. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53255. * @param scene scene in which to add meshes
  53256. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53257. */
  53258. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53259. /**
  53260. * Called once for each button that changed state since the last frame
  53261. * @param buttonIdx Which button index changed
  53262. * @param state New state of the button
  53263. * @param changes Which properties on the state changed since last frame
  53264. */
  53265. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53266. }
  53267. }
  53268. declare module BABYLON {
  53269. /**
  53270. * Oculus Touch Controller
  53271. */
  53272. export class OculusTouchController extends WebVRController {
  53273. /**
  53274. * Base Url for the controller model.
  53275. */
  53276. static MODEL_BASE_URL: string;
  53277. /**
  53278. * File name for the left controller model.
  53279. */
  53280. static MODEL_LEFT_FILENAME: string;
  53281. /**
  53282. * File name for the right controller model.
  53283. */
  53284. static MODEL_RIGHT_FILENAME: string;
  53285. /**
  53286. * Base Url for the Quest controller model.
  53287. */
  53288. static QUEST_MODEL_BASE_URL: string;
  53289. /**
  53290. * @hidden
  53291. * If the controllers are running on a device that needs the updated Quest controller models
  53292. */
  53293. static _IsQuest: boolean;
  53294. /**
  53295. * Fired when the secondary trigger on this controller is modified
  53296. */
  53297. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53298. /**
  53299. * Fired when the thumb rest on this controller is modified
  53300. */
  53301. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53302. /**
  53303. * Creates a new OculusTouchController from a gamepad
  53304. * @param vrGamepad the gamepad that the controller should be created from
  53305. */
  53306. constructor(vrGamepad: any);
  53307. /**
  53308. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53309. * @param scene scene in which to add meshes
  53310. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53311. */
  53312. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53313. /**
  53314. * Fired when the A button on this controller is modified
  53315. */
  53316. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53317. /**
  53318. * Fired when the B button on this controller is modified
  53319. */
  53320. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53321. /**
  53322. * Fired when the X button on this controller is modified
  53323. */
  53324. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53325. /**
  53326. * Fired when the Y button on this controller is modified
  53327. */
  53328. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53329. /**
  53330. * Called once for each button that changed state since the last frame
  53331. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53332. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53333. * 2) secondary trigger (same)
  53334. * 3) A (right) X (left), touch, pressed = value
  53335. * 4) B / Y
  53336. * 5) thumb rest
  53337. * @param buttonIdx Which button index changed
  53338. * @param state New state of the button
  53339. * @param changes Which properties on the state changed since last frame
  53340. */
  53341. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53342. }
  53343. }
  53344. declare module BABYLON {
  53345. /**
  53346. * Vive Controller
  53347. */
  53348. export class ViveController extends WebVRController {
  53349. /**
  53350. * Base Url for the controller model.
  53351. */
  53352. static MODEL_BASE_URL: string;
  53353. /**
  53354. * File name for the controller model.
  53355. */
  53356. static MODEL_FILENAME: string;
  53357. /**
  53358. * Creates a new ViveController from a gamepad
  53359. * @param vrGamepad the gamepad that the controller should be created from
  53360. */
  53361. constructor(vrGamepad: any);
  53362. /**
  53363. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53364. * @param scene scene in which to add meshes
  53365. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53366. */
  53367. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53368. /**
  53369. * Fired when the left button on this controller is modified
  53370. */
  53371. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53372. /**
  53373. * Fired when the right button on this controller is modified
  53374. */
  53375. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53376. /**
  53377. * Fired when the menu button on this controller is modified
  53378. */
  53379. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53380. /**
  53381. * Called once for each button that changed state since the last frame
  53382. * Vive mapping:
  53383. * 0: touchpad
  53384. * 1: trigger
  53385. * 2: left AND right buttons
  53386. * 3: menu button
  53387. * @param buttonIdx Which button index changed
  53388. * @param state New state of the button
  53389. * @param changes Which properties on the state changed since last frame
  53390. */
  53391. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53392. }
  53393. }
  53394. declare module BABYLON {
  53395. /**
  53396. * Defines the WindowsMotionController object that the state of the windows motion controller
  53397. */
  53398. export class WindowsMotionController extends WebVRController {
  53399. /**
  53400. * The base url used to load the left and right controller models
  53401. */
  53402. static MODEL_BASE_URL: string;
  53403. /**
  53404. * The name of the left controller model file
  53405. */
  53406. static MODEL_LEFT_FILENAME: string;
  53407. /**
  53408. * The name of the right controller model file
  53409. */
  53410. static MODEL_RIGHT_FILENAME: string;
  53411. /**
  53412. * The controller name prefix for this controller type
  53413. */
  53414. static readonly GAMEPAD_ID_PREFIX: string;
  53415. /**
  53416. * The controller id pattern for this controller type
  53417. */
  53418. private static readonly GAMEPAD_ID_PATTERN;
  53419. private _loadedMeshInfo;
  53420. protected readonly _mapping: {
  53421. buttons: string[];
  53422. buttonMeshNames: {
  53423. trigger: string;
  53424. menu: string;
  53425. grip: string;
  53426. thumbstick: string;
  53427. trackpad: string;
  53428. };
  53429. buttonObservableNames: {
  53430. trigger: string;
  53431. menu: string;
  53432. grip: string;
  53433. thumbstick: string;
  53434. trackpad: string;
  53435. };
  53436. axisMeshNames: string[];
  53437. pointingPoseMeshName: string;
  53438. };
  53439. /**
  53440. * Fired when the trackpad on this controller is clicked
  53441. */
  53442. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53443. /**
  53444. * Fired when the trackpad on this controller is modified
  53445. */
  53446. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53447. /**
  53448. * The current x and y values of this controller's trackpad
  53449. */
  53450. trackpad: StickValues;
  53451. /**
  53452. * Creates a new WindowsMotionController from a gamepad
  53453. * @param vrGamepad the gamepad that the controller should be created from
  53454. */
  53455. constructor(vrGamepad: any);
  53456. /**
  53457. * Fired when the trigger on this controller is modified
  53458. */
  53459. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53460. /**
  53461. * Fired when the menu button on this controller is modified
  53462. */
  53463. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53464. /**
  53465. * Fired when the grip button on this controller is modified
  53466. */
  53467. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53468. /**
  53469. * Fired when the thumbstick button on this controller is modified
  53470. */
  53471. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53472. /**
  53473. * Fired when the touchpad button on this controller is modified
  53474. */
  53475. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53476. /**
  53477. * Fired when the touchpad values on this controller are modified
  53478. */
  53479. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53480. protected _updateTrackpad(): void;
  53481. /**
  53482. * Called once per frame by the engine.
  53483. */
  53484. update(): void;
  53485. /**
  53486. * Called once for each button that changed state since the last frame
  53487. * @param buttonIdx Which button index changed
  53488. * @param state New state of the button
  53489. * @param changes Which properties on the state changed since last frame
  53490. */
  53491. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53492. /**
  53493. * Moves the buttons on the controller mesh based on their current state
  53494. * @param buttonName the name of the button to move
  53495. * @param buttonValue the value of the button which determines the buttons new position
  53496. */
  53497. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53498. /**
  53499. * Moves the axis on the controller mesh based on its current state
  53500. * @param axis the index of the axis
  53501. * @param axisValue the value of the axis which determines the meshes new position
  53502. * @hidden
  53503. */
  53504. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53505. /**
  53506. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53507. * @param scene scene in which to add meshes
  53508. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53509. */
  53510. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53511. /**
  53512. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53513. * can be transformed by button presses and axes values, based on this._mapping.
  53514. *
  53515. * @param scene scene in which the meshes exist
  53516. * @param meshes list of meshes that make up the controller model to process
  53517. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53518. */
  53519. private processModel;
  53520. private createMeshInfo;
  53521. /**
  53522. * Gets the ray of the controller in the direction the controller is pointing
  53523. * @param length the length the resulting ray should be
  53524. * @returns a ray in the direction the controller is pointing
  53525. */
  53526. getForwardRay(length?: number): Ray;
  53527. /**
  53528. * Disposes of the controller
  53529. */
  53530. dispose(): void;
  53531. }
  53532. /**
  53533. * This class represents a new windows motion controller in XR.
  53534. */
  53535. export class XRWindowsMotionController extends WindowsMotionController {
  53536. /**
  53537. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53538. */
  53539. protected readonly _mapping: {
  53540. buttons: string[];
  53541. buttonMeshNames: {
  53542. trigger: string;
  53543. menu: string;
  53544. grip: string;
  53545. thumbstick: string;
  53546. trackpad: string;
  53547. };
  53548. buttonObservableNames: {
  53549. trigger: string;
  53550. menu: string;
  53551. grip: string;
  53552. thumbstick: string;
  53553. trackpad: string;
  53554. };
  53555. axisMeshNames: string[];
  53556. pointingPoseMeshName: string;
  53557. };
  53558. /**
  53559. * Construct a new XR-Based windows motion controller
  53560. *
  53561. * @param gamepadInfo the gamepad object from the browser
  53562. */
  53563. constructor(gamepadInfo: any);
  53564. /**
  53565. * holds the thumbstick values (X,Y)
  53566. */
  53567. thumbstickValues: StickValues;
  53568. /**
  53569. * Fired when the thumbstick on this controller is clicked
  53570. */
  53571. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53572. /**
  53573. * Fired when the thumbstick on this controller is modified
  53574. */
  53575. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53576. /**
  53577. * Fired when the touchpad button on this controller is modified
  53578. */
  53579. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53580. /**
  53581. * Fired when the touchpad values on this controller are modified
  53582. */
  53583. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53584. /**
  53585. * Fired when the thumbstick button on this controller is modified
  53586. * here to prevent breaking changes
  53587. */
  53588. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53589. /**
  53590. * updating the thumbstick(!) and not the trackpad.
  53591. * This is named this way due to the difference between WebVR and XR and to avoid
  53592. * changing the parent class.
  53593. */
  53594. protected _updateTrackpad(): void;
  53595. /**
  53596. * Disposes the class with joy
  53597. */
  53598. dispose(): void;
  53599. }
  53600. }
  53601. declare module BABYLON {
  53602. /**
  53603. * Class containing static functions to help procedurally build meshes
  53604. */
  53605. export class PolyhedronBuilder {
  53606. /**
  53607. * Creates a polyhedron mesh
  53608. * * 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
  53609. * * The parameter `size` (positive float, default 1) sets the polygon size
  53610. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53611. * * 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`
  53612. * * 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
  53613. * * 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)`)
  53614. * * 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
  53615. * * 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
  53616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53617. * * 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
  53618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53619. * @param name defines the name of the mesh
  53620. * @param options defines the options used to create the mesh
  53621. * @param scene defines the hosting scene
  53622. * @returns the polyhedron mesh
  53623. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53624. */
  53625. static CreatePolyhedron(name: string, options: {
  53626. type?: number;
  53627. size?: number;
  53628. sizeX?: number;
  53629. sizeY?: number;
  53630. sizeZ?: number;
  53631. custom?: any;
  53632. faceUV?: Vector4[];
  53633. faceColors?: Color4[];
  53634. flat?: boolean;
  53635. updatable?: boolean;
  53636. sideOrientation?: number;
  53637. frontUVs?: Vector4;
  53638. backUVs?: Vector4;
  53639. }, scene?: Nullable<Scene>): Mesh;
  53640. }
  53641. }
  53642. declare module BABYLON {
  53643. /**
  53644. * Gizmo that enables scaling a mesh along 3 axis
  53645. */
  53646. export class ScaleGizmo extends Gizmo {
  53647. /**
  53648. * Internal gizmo used for interactions on the x axis
  53649. */
  53650. xGizmo: AxisScaleGizmo;
  53651. /**
  53652. * Internal gizmo used for interactions on the y axis
  53653. */
  53654. yGizmo: AxisScaleGizmo;
  53655. /**
  53656. * Internal gizmo used for interactions on the z axis
  53657. */
  53658. zGizmo: AxisScaleGizmo;
  53659. /**
  53660. * Internal gizmo used to scale all axis equally
  53661. */
  53662. uniformScaleGizmo: AxisScaleGizmo;
  53663. private _meshAttached;
  53664. private _nodeAttached;
  53665. private _snapDistance;
  53666. private _uniformScalingMesh;
  53667. private _octahedron;
  53668. private _sensitivity;
  53669. /** Fires an event when any of it's sub gizmos are dragged */
  53670. onDragStartObservable: Observable<unknown>;
  53671. /** Fires an event when any of it's sub gizmos are released from dragging */
  53672. onDragEndObservable: Observable<unknown>;
  53673. get attachedMesh(): Nullable<AbstractMesh>;
  53674. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53675. get attachedNode(): Nullable<Node>;
  53676. set attachedNode(node: Nullable<Node>);
  53677. /**
  53678. * Creates a ScaleGizmo
  53679. * @param gizmoLayer The utility layer the gizmo will be added to
  53680. * @param thickness display gizmo axis thickness
  53681. */
  53682. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53683. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53684. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53685. /**
  53686. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53687. */
  53688. set snapDistance(value: number);
  53689. get snapDistance(): number;
  53690. /**
  53691. * Ratio for the scale of the gizmo (Default: 1)
  53692. */
  53693. set scaleRatio(value: number);
  53694. get scaleRatio(): number;
  53695. /**
  53696. * Sensitivity factor for dragging (Default: 1)
  53697. */
  53698. set sensitivity(value: number);
  53699. get sensitivity(): number;
  53700. /**
  53701. * Disposes of the gizmo
  53702. */
  53703. dispose(): void;
  53704. }
  53705. }
  53706. declare module BABYLON {
  53707. /**
  53708. * Single axis scale gizmo
  53709. */
  53710. export class AxisScaleGizmo extends Gizmo {
  53711. /**
  53712. * Drag behavior responsible for the gizmos dragging interactions
  53713. */
  53714. dragBehavior: PointerDragBehavior;
  53715. private _pointerObserver;
  53716. /**
  53717. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53718. */
  53719. snapDistance: number;
  53720. /**
  53721. * Event that fires each time the gizmo snaps to a new location.
  53722. * * snapDistance is the the change in distance
  53723. */
  53724. onSnapObservable: Observable<{
  53725. snapDistance: number;
  53726. }>;
  53727. /**
  53728. * If the scaling operation should be done on all axis (default: false)
  53729. */
  53730. uniformScaling: boolean;
  53731. /**
  53732. * Custom sensitivity value for the drag strength
  53733. */
  53734. sensitivity: number;
  53735. private _isEnabled;
  53736. private _parent;
  53737. private _arrow;
  53738. private _coloredMaterial;
  53739. private _hoverMaterial;
  53740. /**
  53741. * Creates an AxisScaleGizmo
  53742. * @param gizmoLayer The utility layer the gizmo will be added to
  53743. * @param dragAxis The axis which the gizmo will be able to scale on
  53744. * @param color The color of the gizmo
  53745. * @param thickness display gizmo axis thickness
  53746. */
  53747. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53748. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53749. /**
  53750. * If the gizmo is enabled
  53751. */
  53752. set isEnabled(value: boolean);
  53753. get isEnabled(): boolean;
  53754. /**
  53755. * Disposes of the gizmo
  53756. */
  53757. dispose(): void;
  53758. /**
  53759. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53760. * @param mesh The mesh to replace the default mesh of the gizmo
  53761. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53762. */
  53763. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53764. }
  53765. }
  53766. declare module BABYLON {
  53767. /**
  53768. * Bounding box gizmo
  53769. */
  53770. export class BoundingBoxGizmo extends Gizmo {
  53771. private _lineBoundingBox;
  53772. private _rotateSpheresParent;
  53773. private _scaleBoxesParent;
  53774. private _boundingDimensions;
  53775. private _renderObserver;
  53776. private _pointerObserver;
  53777. private _scaleDragSpeed;
  53778. private _tmpQuaternion;
  53779. private _tmpVector;
  53780. private _tmpRotationMatrix;
  53781. /**
  53782. * 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)
  53783. */
  53784. ignoreChildren: boolean;
  53785. /**
  53786. * 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)
  53787. */
  53788. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53789. /**
  53790. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53791. */
  53792. rotationSphereSize: number;
  53793. /**
  53794. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53795. */
  53796. scaleBoxSize: number;
  53797. /**
  53798. * 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)
  53799. */
  53800. fixedDragMeshScreenSize: boolean;
  53801. /**
  53802. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53803. */
  53804. fixedDragMeshScreenSizeDistanceFactor: number;
  53805. /**
  53806. * Fired when a rotation sphere or scale box is dragged
  53807. */
  53808. onDragStartObservable: Observable<{}>;
  53809. /**
  53810. * Fired when a scale box is dragged
  53811. */
  53812. onScaleBoxDragObservable: Observable<{}>;
  53813. /**
  53814. * Fired when a scale box drag is ended
  53815. */
  53816. onScaleBoxDragEndObservable: Observable<{}>;
  53817. /**
  53818. * Fired when a rotation sphere is dragged
  53819. */
  53820. onRotationSphereDragObservable: Observable<{}>;
  53821. /**
  53822. * Fired when a rotation sphere drag is ended
  53823. */
  53824. onRotationSphereDragEndObservable: Observable<{}>;
  53825. /**
  53826. * 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)
  53827. */
  53828. scalePivot: Nullable<Vector3>;
  53829. /**
  53830. * Mesh used as a pivot to rotate the attached node
  53831. */
  53832. private _anchorMesh;
  53833. private _existingMeshScale;
  53834. private _dragMesh;
  53835. private pointerDragBehavior;
  53836. private coloredMaterial;
  53837. private hoverColoredMaterial;
  53838. /**
  53839. * Sets the color of the bounding box gizmo
  53840. * @param color the color to set
  53841. */
  53842. setColor(color: Color3): void;
  53843. /**
  53844. * Creates an BoundingBoxGizmo
  53845. * @param gizmoLayer The utility layer the gizmo will be added to
  53846. * @param color The color of the gizmo
  53847. */
  53848. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53849. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53850. private _selectNode;
  53851. /**
  53852. * Updates the bounding box information for the Gizmo
  53853. */
  53854. updateBoundingBox(): void;
  53855. private _updateRotationSpheres;
  53856. private _updateScaleBoxes;
  53857. /**
  53858. * Enables rotation on the specified axis and disables rotation on the others
  53859. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53860. */
  53861. setEnabledRotationAxis(axis: string): void;
  53862. /**
  53863. * Enables/disables scaling
  53864. * @param enable if scaling should be enabled
  53865. * @param homogeneousScaling defines if scaling should only be homogeneous
  53866. */
  53867. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53868. private _updateDummy;
  53869. /**
  53870. * Enables a pointer drag behavior on the bounding box of the gizmo
  53871. */
  53872. enableDragBehavior(): void;
  53873. /**
  53874. * Disposes of the gizmo
  53875. */
  53876. dispose(): void;
  53877. /**
  53878. * 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)
  53879. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53880. * @returns the bounding box mesh with the passed in mesh as a child
  53881. */
  53882. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53883. /**
  53884. * CustomMeshes are not supported by this gizmo
  53885. * @param mesh The mesh to replace the default mesh of the gizmo
  53886. */
  53887. setCustomMesh(mesh: Mesh): void;
  53888. }
  53889. }
  53890. declare module BABYLON {
  53891. /**
  53892. * Single plane rotation gizmo
  53893. */
  53894. export class PlaneRotationGizmo extends Gizmo {
  53895. /**
  53896. * Drag behavior responsible for the gizmos dragging interactions
  53897. */
  53898. dragBehavior: PointerDragBehavior;
  53899. private _pointerObserver;
  53900. /**
  53901. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53902. */
  53903. snapDistance: number;
  53904. /**
  53905. * Event that fires each time the gizmo snaps to a new location.
  53906. * * snapDistance is the the change in distance
  53907. */
  53908. onSnapObservable: Observable<{
  53909. snapDistance: number;
  53910. }>;
  53911. private _isEnabled;
  53912. private _parent;
  53913. /**
  53914. * Creates a PlaneRotationGizmo
  53915. * @param gizmoLayer The utility layer the gizmo will be added to
  53916. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53917. * @param color The color of the gizmo
  53918. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53919. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53920. * @param thickness display gizmo axis thickness
  53921. */
  53922. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53923. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53924. /**
  53925. * If the gizmo is enabled
  53926. */
  53927. set isEnabled(value: boolean);
  53928. get isEnabled(): boolean;
  53929. /**
  53930. * Disposes of the gizmo
  53931. */
  53932. dispose(): void;
  53933. }
  53934. }
  53935. declare module BABYLON {
  53936. /**
  53937. * Gizmo that enables rotating a mesh along 3 axis
  53938. */
  53939. export class RotationGizmo extends Gizmo {
  53940. /**
  53941. * Internal gizmo used for interactions on the x axis
  53942. */
  53943. xGizmo: PlaneRotationGizmo;
  53944. /**
  53945. * Internal gizmo used for interactions on the y axis
  53946. */
  53947. yGizmo: PlaneRotationGizmo;
  53948. /**
  53949. * Internal gizmo used for interactions on the z axis
  53950. */
  53951. zGizmo: PlaneRotationGizmo;
  53952. /** Fires an event when any of it's sub gizmos are dragged */
  53953. onDragStartObservable: Observable<unknown>;
  53954. /** Fires an event when any of it's sub gizmos are released from dragging */
  53955. onDragEndObservable: Observable<unknown>;
  53956. private _meshAttached;
  53957. private _nodeAttached;
  53958. get attachedMesh(): Nullable<AbstractMesh>;
  53959. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53960. get attachedNode(): Nullable<Node>;
  53961. set attachedNode(node: Nullable<Node>);
  53962. /**
  53963. * Creates a RotationGizmo
  53964. * @param gizmoLayer The utility layer the gizmo will be added to
  53965. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53966. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53967. * @param thickness display gizmo axis thickness
  53968. */
  53969. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53970. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53971. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53972. /**
  53973. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53974. */
  53975. set snapDistance(value: number);
  53976. get snapDistance(): number;
  53977. /**
  53978. * Ratio for the scale of the gizmo (Default: 1)
  53979. */
  53980. set scaleRatio(value: number);
  53981. get scaleRatio(): number;
  53982. /**
  53983. * Disposes of the gizmo
  53984. */
  53985. dispose(): void;
  53986. /**
  53987. * CustomMeshes are not supported by this gizmo
  53988. * @param mesh The mesh to replace the default mesh of the gizmo
  53989. */
  53990. setCustomMesh(mesh: Mesh): void;
  53991. }
  53992. }
  53993. declare module BABYLON {
  53994. /**
  53995. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  53996. */
  53997. export class GizmoManager implements IDisposable {
  53998. private scene;
  53999. /**
  54000. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54001. */
  54002. gizmos: {
  54003. positionGizmo: Nullable<PositionGizmo>;
  54004. rotationGizmo: Nullable<RotationGizmo>;
  54005. scaleGizmo: Nullable<ScaleGizmo>;
  54006. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54007. };
  54008. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54009. clearGizmoOnEmptyPointerEvent: boolean;
  54010. /** Fires an event when the manager is attached to a mesh */
  54011. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54012. /** Fires an event when the manager is attached to a node */
  54013. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54014. private _gizmosEnabled;
  54015. private _pointerObserver;
  54016. private _attachedMesh;
  54017. private _attachedNode;
  54018. private _boundingBoxColor;
  54019. private _defaultUtilityLayer;
  54020. private _defaultKeepDepthUtilityLayer;
  54021. private _thickness;
  54022. /**
  54023. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54024. */
  54025. boundingBoxDragBehavior: SixDofDragBehavior;
  54026. /**
  54027. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54028. */
  54029. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54030. /**
  54031. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54032. */
  54033. attachableNodes: Nullable<Array<Node>>;
  54034. /**
  54035. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54036. */
  54037. usePointerToAttachGizmos: boolean;
  54038. /**
  54039. * Utility layer that the bounding box gizmo belongs to
  54040. */
  54041. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54042. /**
  54043. * Utility layer that all gizmos besides bounding box belong to
  54044. */
  54045. get utilityLayer(): UtilityLayerRenderer;
  54046. /**
  54047. * Instatiates a gizmo manager
  54048. * @param scene the scene to overlay the gizmos on top of
  54049. * @param thickness display gizmo axis thickness
  54050. */
  54051. constructor(scene: Scene, thickness?: number);
  54052. /**
  54053. * Attaches a set of gizmos to the specified mesh
  54054. * @param mesh The mesh the gizmo's should be attached to
  54055. */
  54056. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54057. /**
  54058. * Attaches a set of gizmos to the specified node
  54059. * @param node The node the gizmo's should be attached to
  54060. */
  54061. attachToNode(node: Nullable<Node>): void;
  54062. /**
  54063. * If the position gizmo is enabled
  54064. */
  54065. set positionGizmoEnabled(value: boolean);
  54066. get positionGizmoEnabled(): boolean;
  54067. /**
  54068. * If the rotation gizmo is enabled
  54069. */
  54070. set rotationGizmoEnabled(value: boolean);
  54071. get rotationGizmoEnabled(): boolean;
  54072. /**
  54073. * If the scale gizmo is enabled
  54074. */
  54075. set scaleGizmoEnabled(value: boolean);
  54076. get scaleGizmoEnabled(): boolean;
  54077. /**
  54078. * If the boundingBox gizmo is enabled
  54079. */
  54080. set boundingBoxGizmoEnabled(value: boolean);
  54081. get boundingBoxGizmoEnabled(): boolean;
  54082. /**
  54083. * Disposes of the gizmo manager
  54084. */
  54085. dispose(): void;
  54086. }
  54087. }
  54088. declare module BABYLON {
  54089. /**
  54090. * A directional light is defined by a direction (what a surprise!).
  54091. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54092. * 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.
  54093. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54094. */
  54095. export class DirectionalLight extends ShadowLight {
  54096. private _shadowFrustumSize;
  54097. /**
  54098. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54099. */
  54100. get shadowFrustumSize(): number;
  54101. /**
  54102. * Specifies a fix frustum size for the shadow generation.
  54103. */
  54104. set shadowFrustumSize(value: number);
  54105. private _shadowOrthoScale;
  54106. /**
  54107. * Gets the shadow projection scale against the optimal computed one.
  54108. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54109. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54110. */
  54111. get shadowOrthoScale(): number;
  54112. /**
  54113. * Sets the shadow projection scale against the optimal computed one.
  54114. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54115. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54116. */
  54117. set shadowOrthoScale(value: number);
  54118. /**
  54119. * Automatically compute the projection matrix to best fit (including all the casters)
  54120. * on each frame.
  54121. */
  54122. autoUpdateExtends: boolean;
  54123. /**
  54124. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54125. * on each frame. autoUpdateExtends must be set to true for this to work
  54126. */
  54127. autoCalcShadowZBounds: boolean;
  54128. private _orthoLeft;
  54129. private _orthoRight;
  54130. private _orthoTop;
  54131. private _orthoBottom;
  54132. /**
  54133. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54134. * The directional light is emitted from everywhere in the given direction.
  54135. * It can cast shadows.
  54136. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54137. * @param name The friendly name of the light
  54138. * @param direction The direction of the light
  54139. * @param scene The scene the light belongs to
  54140. */
  54141. constructor(name: string, direction: Vector3, scene: Scene);
  54142. /**
  54143. * Returns the string "DirectionalLight".
  54144. * @return The class name
  54145. */
  54146. getClassName(): string;
  54147. /**
  54148. * Returns the integer 1.
  54149. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54150. */
  54151. getTypeID(): number;
  54152. /**
  54153. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54154. * Returns the DirectionalLight Shadow projection matrix.
  54155. */
  54156. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54157. /**
  54158. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54159. * Returns the DirectionalLight Shadow projection matrix.
  54160. */
  54161. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54162. /**
  54163. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54164. * Returns the DirectionalLight Shadow projection matrix.
  54165. */
  54166. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54167. protected _buildUniformLayout(): void;
  54168. /**
  54169. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54170. * @param effect The effect to update
  54171. * @param lightIndex The index of the light in the effect to update
  54172. * @returns The directional light
  54173. */
  54174. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54175. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54176. /**
  54177. * Gets the minZ used for shadow according to both the scene and the light.
  54178. *
  54179. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54180. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54181. * @param activeCamera The camera we are returning the min for
  54182. * @returns the depth min z
  54183. */
  54184. getDepthMinZ(activeCamera: Camera): number;
  54185. /**
  54186. * Gets the maxZ used for shadow according to both the scene and the light.
  54187. *
  54188. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54189. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54190. * @param activeCamera The camera we are returning the max for
  54191. * @returns the depth max z
  54192. */
  54193. getDepthMaxZ(activeCamera: Camera): number;
  54194. /**
  54195. * Prepares the list of defines specific to the light type.
  54196. * @param defines the list of defines
  54197. * @param lightIndex defines the index of the light for the effect
  54198. */
  54199. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54200. }
  54201. }
  54202. declare module BABYLON {
  54203. /**
  54204. * Class containing static functions to help procedurally build meshes
  54205. */
  54206. export class HemisphereBuilder {
  54207. /**
  54208. * Creates a hemisphere mesh
  54209. * @param name defines the name of the mesh
  54210. * @param options defines the options used to create the mesh
  54211. * @param scene defines the hosting scene
  54212. * @returns the hemisphere mesh
  54213. */
  54214. static CreateHemisphere(name: string, options: {
  54215. segments?: number;
  54216. diameter?: number;
  54217. sideOrientation?: number;
  54218. }, scene: any): Mesh;
  54219. }
  54220. }
  54221. declare module BABYLON {
  54222. /**
  54223. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54224. * These values define a cone of light starting from the position, emitting toward the direction.
  54225. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54226. * and the exponent defines the speed of the decay of the light with distance (reach).
  54227. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54228. */
  54229. export class SpotLight extends ShadowLight {
  54230. private _angle;
  54231. private _innerAngle;
  54232. private _cosHalfAngle;
  54233. private _lightAngleScale;
  54234. private _lightAngleOffset;
  54235. /**
  54236. * Gets the cone angle of the spot light in Radians.
  54237. */
  54238. get angle(): number;
  54239. /**
  54240. * Sets the cone angle of the spot light in Radians.
  54241. */
  54242. set angle(value: number);
  54243. /**
  54244. * Only used in gltf falloff mode, this defines the angle where
  54245. * the directional falloff will start before cutting at angle which could be seen
  54246. * as outer angle.
  54247. */
  54248. get innerAngle(): number;
  54249. /**
  54250. * Only used in gltf falloff mode, this defines the angle where
  54251. * the directional falloff will start before cutting at angle which could be seen
  54252. * as outer angle.
  54253. */
  54254. set innerAngle(value: number);
  54255. private _shadowAngleScale;
  54256. /**
  54257. * Allows scaling the angle of the light for shadow generation only.
  54258. */
  54259. get shadowAngleScale(): number;
  54260. /**
  54261. * Allows scaling the angle of the light for shadow generation only.
  54262. */
  54263. set shadowAngleScale(value: number);
  54264. /**
  54265. * The light decay speed with the distance from the emission spot.
  54266. */
  54267. exponent: number;
  54268. private _projectionTextureMatrix;
  54269. /**
  54270. * Allows reading the projecton texture
  54271. */
  54272. get projectionTextureMatrix(): Matrix;
  54273. protected _projectionTextureLightNear: number;
  54274. /**
  54275. * Gets the near clip of the Spotlight for texture projection.
  54276. */
  54277. get projectionTextureLightNear(): number;
  54278. /**
  54279. * Sets the near clip of the Spotlight for texture projection.
  54280. */
  54281. set projectionTextureLightNear(value: number);
  54282. protected _projectionTextureLightFar: number;
  54283. /**
  54284. * Gets the far clip of the Spotlight for texture projection.
  54285. */
  54286. get projectionTextureLightFar(): number;
  54287. /**
  54288. * Sets the far clip of the Spotlight for texture projection.
  54289. */
  54290. set projectionTextureLightFar(value: number);
  54291. protected _projectionTextureUpDirection: Vector3;
  54292. /**
  54293. * Gets the Up vector of the Spotlight for texture projection.
  54294. */
  54295. get projectionTextureUpDirection(): Vector3;
  54296. /**
  54297. * Sets the Up vector of the Spotlight for texture projection.
  54298. */
  54299. set projectionTextureUpDirection(value: Vector3);
  54300. private _projectionTexture;
  54301. /**
  54302. * Gets the projection texture of the light.
  54303. */
  54304. get projectionTexture(): Nullable<BaseTexture>;
  54305. /**
  54306. * Sets the projection texture of the light.
  54307. */
  54308. set projectionTexture(value: Nullable<BaseTexture>);
  54309. private _projectionTextureViewLightDirty;
  54310. private _projectionTextureProjectionLightDirty;
  54311. private _projectionTextureDirty;
  54312. private _projectionTextureViewTargetVector;
  54313. private _projectionTextureViewLightMatrix;
  54314. private _projectionTextureProjectionLightMatrix;
  54315. private _projectionTextureScalingMatrix;
  54316. /**
  54317. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54318. * It can cast shadows.
  54319. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54320. * @param name The light friendly name
  54321. * @param position The position of the spot light in the scene
  54322. * @param direction The direction of the light in the scene
  54323. * @param angle The cone angle of the light in Radians
  54324. * @param exponent The light decay speed with the distance from the emission spot
  54325. * @param scene The scene the lights belongs to
  54326. */
  54327. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54328. /**
  54329. * Returns the string "SpotLight".
  54330. * @returns the class name
  54331. */
  54332. getClassName(): string;
  54333. /**
  54334. * Returns the integer 2.
  54335. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54336. */
  54337. getTypeID(): number;
  54338. /**
  54339. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54340. */
  54341. protected _setDirection(value: Vector3): void;
  54342. /**
  54343. * Overrides the position setter to recompute the projection texture view light Matrix.
  54344. */
  54345. protected _setPosition(value: Vector3): void;
  54346. /**
  54347. * 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.
  54348. * Returns the SpotLight.
  54349. */
  54350. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54351. protected _computeProjectionTextureViewLightMatrix(): void;
  54352. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54353. /**
  54354. * Main function for light texture projection matrix computing.
  54355. */
  54356. protected _computeProjectionTextureMatrix(): void;
  54357. protected _buildUniformLayout(): void;
  54358. private _computeAngleValues;
  54359. /**
  54360. * Sets the passed Effect "effect" with the Light textures.
  54361. * @param effect The effect to update
  54362. * @param lightIndex The index of the light in the effect to update
  54363. * @returns The light
  54364. */
  54365. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54366. /**
  54367. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54368. * @param effect The effect to update
  54369. * @param lightIndex The index of the light in the effect to update
  54370. * @returns The spot light
  54371. */
  54372. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54373. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54374. /**
  54375. * Disposes the light and the associated resources.
  54376. */
  54377. dispose(): void;
  54378. /**
  54379. * Prepares the list of defines specific to the light type.
  54380. * @param defines the list of defines
  54381. * @param lightIndex defines the index of the light for the effect
  54382. */
  54383. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54384. }
  54385. }
  54386. declare module BABYLON {
  54387. /**
  54388. * Gizmo that enables viewing a light
  54389. */
  54390. export class LightGizmo extends Gizmo {
  54391. private _lightMesh;
  54392. private _material;
  54393. private _cachedPosition;
  54394. private _cachedForward;
  54395. private _attachedMeshParent;
  54396. private _pointerObserver;
  54397. /**
  54398. * Event that fires each time the gizmo is clicked
  54399. */
  54400. onClickedObservable: Observable<Light>;
  54401. /**
  54402. * Creates a LightGizmo
  54403. * @param gizmoLayer The utility layer the gizmo will be added to
  54404. */
  54405. constructor(gizmoLayer?: UtilityLayerRenderer);
  54406. private _light;
  54407. /**
  54408. * The light that the gizmo is attached to
  54409. */
  54410. set light(light: Nullable<Light>);
  54411. get light(): Nullable<Light>;
  54412. /**
  54413. * Gets the material used to render the light gizmo
  54414. */
  54415. get material(): StandardMaterial;
  54416. /**
  54417. * @hidden
  54418. * Updates the gizmo to match the attached mesh's position/rotation
  54419. */
  54420. protected _update(): void;
  54421. private static _Scale;
  54422. /**
  54423. * Creates the lines for a light mesh
  54424. */
  54425. private static _CreateLightLines;
  54426. /**
  54427. * Disposes of the light gizmo
  54428. */
  54429. dispose(): void;
  54430. private static _CreateHemisphericLightMesh;
  54431. private static _CreatePointLightMesh;
  54432. private static _CreateSpotLightMesh;
  54433. private static _CreateDirectionalLightMesh;
  54434. }
  54435. }
  54436. declare module BABYLON {
  54437. /**
  54438. * Gizmo that enables viewing a camera
  54439. */
  54440. export class CameraGizmo extends Gizmo {
  54441. private _cameraMesh;
  54442. private _cameraLinesMesh;
  54443. private _material;
  54444. private _pointerObserver;
  54445. /**
  54446. * Event that fires each time the gizmo is clicked
  54447. */
  54448. onClickedObservable: Observable<Camera>;
  54449. /**
  54450. * Creates a CameraGizmo
  54451. * @param gizmoLayer The utility layer the gizmo will be added to
  54452. */
  54453. constructor(gizmoLayer?: UtilityLayerRenderer);
  54454. private _camera;
  54455. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54456. get displayFrustum(): boolean;
  54457. set displayFrustum(value: boolean);
  54458. /**
  54459. * The camera that the gizmo is attached to
  54460. */
  54461. set camera(camera: Nullable<Camera>);
  54462. get camera(): Nullable<Camera>;
  54463. /**
  54464. * Gets the material used to render the camera gizmo
  54465. */
  54466. get material(): StandardMaterial;
  54467. /**
  54468. * @hidden
  54469. * Updates the gizmo to match the attached mesh's position/rotation
  54470. */
  54471. protected _update(): void;
  54472. private static _Scale;
  54473. private _invProjection;
  54474. /**
  54475. * Disposes of the camera gizmo
  54476. */
  54477. dispose(): void;
  54478. private static _CreateCameraMesh;
  54479. private static _CreateCameraFrustum;
  54480. }
  54481. }
  54482. declare module BABYLON {
  54483. /** @hidden */
  54484. export var backgroundFragmentDeclaration: {
  54485. name: string;
  54486. shader: string;
  54487. };
  54488. }
  54489. declare module BABYLON {
  54490. /** @hidden */
  54491. export var backgroundUboDeclaration: {
  54492. name: string;
  54493. shader: string;
  54494. };
  54495. }
  54496. declare module BABYLON {
  54497. /** @hidden */
  54498. export var backgroundPixelShader: {
  54499. name: string;
  54500. shader: string;
  54501. };
  54502. }
  54503. declare module BABYLON {
  54504. /** @hidden */
  54505. export var backgroundVertexDeclaration: {
  54506. name: string;
  54507. shader: string;
  54508. };
  54509. }
  54510. declare module BABYLON {
  54511. /** @hidden */
  54512. export var backgroundVertexShader: {
  54513. name: string;
  54514. shader: string;
  54515. };
  54516. }
  54517. declare module BABYLON {
  54518. /**
  54519. * Background material used to create an efficient environement around your scene.
  54520. */
  54521. export class BackgroundMaterial extends PushMaterial {
  54522. /**
  54523. * Standard reflectance value at parallel view angle.
  54524. */
  54525. static StandardReflectance0: number;
  54526. /**
  54527. * Standard reflectance value at grazing angle.
  54528. */
  54529. static StandardReflectance90: number;
  54530. protected _primaryColor: Color3;
  54531. /**
  54532. * Key light Color (multiply against the environement texture)
  54533. */
  54534. primaryColor: Color3;
  54535. protected __perceptualColor: Nullable<Color3>;
  54536. /**
  54537. * Experimental Internal Use Only.
  54538. *
  54539. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54540. * This acts as a helper to set the primary color to a more "human friendly" value.
  54541. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54542. * output color as close as possible from the chosen value.
  54543. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54544. * part of lighting setup.)
  54545. */
  54546. get _perceptualColor(): Nullable<Color3>;
  54547. set _perceptualColor(value: Nullable<Color3>);
  54548. protected _primaryColorShadowLevel: float;
  54549. /**
  54550. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54551. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54552. */
  54553. get primaryColorShadowLevel(): float;
  54554. set primaryColorShadowLevel(value: float);
  54555. protected _primaryColorHighlightLevel: float;
  54556. /**
  54557. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54558. * The primary color is used at the level chosen to define what the white area would look.
  54559. */
  54560. get primaryColorHighlightLevel(): float;
  54561. set primaryColorHighlightLevel(value: float);
  54562. protected _reflectionTexture: Nullable<BaseTexture>;
  54563. /**
  54564. * Reflection Texture used in the material.
  54565. * Should be author in a specific way for the best result (refer to the documentation).
  54566. */
  54567. reflectionTexture: Nullable<BaseTexture>;
  54568. protected _reflectionBlur: float;
  54569. /**
  54570. * Reflection Texture level of blur.
  54571. *
  54572. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54573. * texture twice.
  54574. */
  54575. reflectionBlur: float;
  54576. protected _diffuseTexture: Nullable<BaseTexture>;
  54577. /**
  54578. * Diffuse Texture used in the material.
  54579. * Should be author in a specific way for the best result (refer to the documentation).
  54580. */
  54581. diffuseTexture: Nullable<BaseTexture>;
  54582. protected _shadowLights: Nullable<IShadowLight[]>;
  54583. /**
  54584. * Specify the list of lights casting shadow on the material.
  54585. * All scene shadow lights will be included if null.
  54586. */
  54587. shadowLights: Nullable<IShadowLight[]>;
  54588. protected _shadowLevel: float;
  54589. /**
  54590. * Helps adjusting the shadow to a softer level if required.
  54591. * 0 means black shadows and 1 means no shadows.
  54592. */
  54593. shadowLevel: float;
  54594. protected _sceneCenter: Vector3;
  54595. /**
  54596. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54597. * It is usually zero but might be interesting to modify according to your setup.
  54598. */
  54599. sceneCenter: Vector3;
  54600. protected _opacityFresnel: boolean;
  54601. /**
  54602. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54603. * This helps ensuring a nice transition when the camera goes under the ground.
  54604. */
  54605. opacityFresnel: boolean;
  54606. protected _reflectionFresnel: boolean;
  54607. /**
  54608. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54609. * This helps adding a mirror texture on the ground.
  54610. */
  54611. reflectionFresnel: boolean;
  54612. protected _reflectionFalloffDistance: number;
  54613. /**
  54614. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54615. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54616. */
  54617. reflectionFalloffDistance: number;
  54618. protected _reflectionAmount: number;
  54619. /**
  54620. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54621. */
  54622. reflectionAmount: number;
  54623. protected _reflectionReflectance0: number;
  54624. /**
  54625. * This specifies the weight of the reflection at grazing angle.
  54626. */
  54627. reflectionReflectance0: number;
  54628. protected _reflectionReflectance90: number;
  54629. /**
  54630. * This specifies the weight of the reflection at a perpendicular point of view.
  54631. */
  54632. reflectionReflectance90: number;
  54633. /**
  54634. * Sets the reflection reflectance fresnel values according to the default standard
  54635. * empirically know to work well :-)
  54636. */
  54637. set reflectionStandardFresnelWeight(value: number);
  54638. protected _useRGBColor: boolean;
  54639. /**
  54640. * Helps to directly use the maps channels instead of their level.
  54641. */
  54642. useRGBColor: boolean;
  54643. protected _enableNoise: boolean;
  54644. /**
  54645. * This helps reducing the banding effect that could occur on the background.
  54646. */
  54647. enableNoise: boolean;
  54648. /**
  54649. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54650. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54651. * Recommended to be keep at 1.0 except for special cases.
  54652. */
  54653. get fovMultiplier(): number;
  54654. set fovMultiplier(value: number);
  54655. private _fovMultiplier;
  54656. /**
  54657. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54658. */
  54659. useEquirectangularFOV: boolean;
  54660. private _maxSimultaneousLights;
  54661. /**
  54662. * Number of Simultaneous lights allowed on the material.
  54663. */
  54664. maxSimultaneousLights: int;
  54665. private _shadowOnly;
  54666. /**
  54667. * Make the material only render shadows
  54668. */
  54669. shadowOnly: boolean;
  54670. /**
  54671. * Default configuration related to image processing available in the Background Material.
  54672. */
  54673. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54674. /**
  54675. * Keep track of the image processing observer to allow dispose and replace.
  54676. */
  54677. private _imageProcessingObserver;
  54678. /**
  54679. * Attaches a new image processing configuration to the PBR Material.
  54680. * @param configuration (if null the scene configuration will be use)
  54681. */
  54682. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54683. /**
  54684. * Gets the image processing configuration used either in this material.
  54685. */
  54686. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54687. /**
  54688. * Sets the Default image processing configuration used either in the this material.
  54689. *
  54690. * If sets to null, the scene one is in use.
  54691. */
  54692. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54693. /**
  54694. * Gets wether the color curves effect is enabled.
  54695. */
  54696. get cameraColorCurvesEnabled(): boolean;
  54697. /**
  54698. * Sets wether the color curves effect is enabled.
  54699. */
  54700. set cameraColorCurvesEnabled(value: boolean);
  54701. /**
  54702. * Gets wether the color grading effect is enabled.
  54703. */
  54704. get cameraColorGradingEnabled(): boolean;
  54705. /**
  54706. * Gets wether the color grading effect is enabled.
  54707. */
  54708. set cameraColorGradingEnabled(value: boolean);
  54709. /**
  54710. * Gets wether tonemapping is enabled or not.
  54711. */
  54712. get cameraToneMappingEnabled(): boolean;
  54713. /**
  54714. * Sets wether tonemapping is enabled or not
  54715. */
  54716. set cameraToneMappingEnabled(value: boolean);
  54717. /**
  54718. * The camera exposure used on this material.
  54719. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54720. * This corresponds to a photographic exposure.
  54721. */
  54722. get cameraExposure(): float;
  54723. /**
  54724. * The camera exposure used on this material.
  54725. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54726. * This corresponds to a photographic exposure.
  54727. */
  54728. set cameraExposure(value: float);
  54729. /**
  54730. * Gets The camera contrast used on this material.
  54731. */
  54732. get cameraContrast(): float;
  54733. /**
  54734. * Sets The camera contrast used on this material.
  54735. */
  54736. set cameraContrast(value: float);
  54737. /**
  54738. * Gets the Color Grading 2D Lookup Texture.
  54739. */
  54740. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54741. /**
  54742. * Sets the Color Grading 2D Lookup Texture.
  54743. */
  54744. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54745. /**
  54746. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54747. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54748. * 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;
  54749. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54750. */
  54751. get cameraColorCurves(): Nullable<ColorCurves>;
  54752. /**
  54753. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54754. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54755. * 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;
  54756. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54757. */
  54758. set cameraColorCurves(value: Nullable<ColorCurves>);
  54759. /**
  54760. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54761. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54762. */
  54763. switchToBGR: boolean;
  54764. private _renderTargets;
  54765. private _reflectionControls;
  54766. private _white;
  54767. private _primaryShadowColor;
  54768. private _primaryHighlightColor;
  54769. /**
  54770. * Instantiates a Background Material in the given scene
  54771. * @param name The friendly name of the material
  54772. * @param scene The scene to add the material to
  54773. */
  54774. constructor(name: string, scene: Scene);
  54775. /**
  54776. * Gets a boolean indicating that current material needs to register RTT
  54777. */
  54778. get hasRenderTargetTextures(): boolean;
  54779. /**
  54780. * The entire material has been created in order to prevent overdraw.
  54781. * @returns false
  54782. */
  54783. needAlphaTesting(): boolean;
  54784. /**
  54785. * The entire material has been created in order to prevent overdraw.
  54786. * @returns true if blending is enable
  54787. */
  54788. needAlphaBlending(): boolean;
  54789. /**
  54790. * Checks wether the material is ready to be rendered for a given mesh.
  54791. * @param mesh The mesh to render
  54792. * @param subMesh The submesh to check against
  54793. * @param useInstances Specify wether or not the material is used with instances
  54794. * @returns true if all the dependencies are ready (Textures, Effects...)
  54795. */
  54796. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54797. /**
  54798. * Compute the primary color according to the chosen perceptual color.
  54799. */
  54800. private _computePrimaryColorFromPerceptualColor;
  54801. /**
  54802. * Compute the highlights and shadow colors according to their chosen levels.
  54803. */
  54804. private _computePrimaryColors;
  54805. /**
  54806. * Build the uniform buffer used in the material.
  54807. */
  54808. buildUniformLayout(): void;
  54809. /**
  54810. * Unbind the material.
  54811. */
  54812. unbind(): void;
  54813. /**
  54814. * Bind only the world matrix to the material.
  54815. * @param world The world matrix to bind.
  54816. */
  54817. bindOnlyWorldMatrix(world: Matrix): void;
  54818. /**
  54819. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54820. * @param world The world matrix to bind.
  54821. * @param subMesh The submesh to bind for.
  54822. */
  54823. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54824. /**
  54825. * Checks to see if a texture is used in the material.
  54826. * @param texture - Base texture to use.
  54827. * @returns - Boolean specifying if a texture is used in the material.
  54828. */
  54829. hasTexture(texture: BaseTexture): boolean;
  54830. /**
  54831. * Dispose the material.
  54832. * @param forceDisposeEffect Force disposal of the associated effect.
  54833. * @param forceDisposeTextures Force disposal of the associated textures.
  54834. */
  54835. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54836. /**
  54837. * Clones the material.
  54838. * @param name The cloned name.
  54839. * @returns The cloned material.
  54840. */
  54841. clone(name: string): BackgroundMaterial;
  54842. /**
  54843. * Serializes the current material to its JSON representation.
  54844. * @returns The JSON representation.
  54845. */
  54846. serialize(): any;
  54847. /**
  54848. * Gets the class name of the material
  54849. * @returns "BackgroundMaterial"
  54850. */
  54851. getClassName(): string;
  54852. /**
  54853. * Parse a JSON input to create back a background material.
  54854. * @param source The JSON data to parse
  54855. * @param scene The scene to create the parsed material in
  54856. * @param rootUrl The root url of the assets the material depends upon
  54857. * @returns the instantiated BackgroundMaterial.
  54858. */
  54859. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54860. }
  54861. }
  54862. declare module BABYLON {
  54863. /**
  54864. * Represents the different options available during the creation of
  54865. * a Environment helper.
  54866. *
  54867. * This can control the default ground, skybox and image processing setup of your scene.
  54868. */
  54869. export interface IEnvironmentHelperOptions {
  54870. /**
  54871. * Specifies whether or not to create a ground.
  54872. * True by default.
  54873. */
  54874. createGround: boolean;
  54875. /**
  54876. * Specifies the ground size.
  54877. * 15 by default.
  54878. */
  54879. groundSize: number;
  54880. /**
  54881. * The texture used on the ground for the main color.
  54882. * Comes from the BabylonJS CDN by default.
  54883. *
  54884. * Remarks: Can be either a texture or a url.
  54885. */
  54886. groundTexture: string | BaseTexture;
  54887. /**
  54888. * The color mixed in the ground texture by default.
  54889. * BabylonJS clearColor by default.
  54890. */
  54891. groundColor: Color3;
  54892. /**
  54893. * Specifies the ground opacity.
  54894. * 1 by default.
  54895. */
  54896. groundOpacity: number;
  54897. /**
  54898. * Enables the ground to receive shadows.
  54899. * True by default.
  54900. */
  54901. enableGroundShadow: boolean;
  54902. /**
  54903. * Helps preventing the shadow to be fully black on the ground.
  54904. * 0.5 by default.
  54905. */
  54906. groundShadowLevel: number;
  54907. /**
  54908. * Creates a mirror texture attach to the ground.
  54909. * false by default.
  54910. */
  54911. enableGroundMirror: boolean;
  54912. /**
  54913. * Specifies the ground mirror size ratio.
  54914. * 0.3 by default as the default kernel is 64.
  54915. */
  54916. groundMirrorSizeRatio: number;
  54917. /**
  54918. * Specifies the ground mirror blur kernel size.
  54919. * 64 by default.
  54920. */
  54921. groundMirrorBlurKernel: number;
  54922. /**
  54923. * Specifies the ground mirror visibility amount.
  54924. * 1 by default
  54925. */
  54926. groundMirrorAmount: number;
  54927. /**
  54928. * Specifies the ground mirror reflectance weight.
  54929. * This uses the standard weight of the background material to setup the fresnel effect
  54930. * of the mirror.
  54931. * 1 by default.
  54932. */
  54933. groundMirrorFresnelWeight: number;
  54934. /**
  54935. * Specifies the ground mirror Falloff distance.
  54936. * This can helps reducing the size of the reflection.
  54937. * 0 by Default.
  54938. */
  54939. groundMirrorFallOffDistance: number;
  54940. /**
  54941. * Specifies the ground mirror texture type.
  54942. * Unsigned Int by Default.
  54943. */
  54944. groundMirrorTextureType: number;
  54945. /**
  54946. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54947. * the shown objects.
  54948. */
  54949. groundYBias: number;
  54950. /**
  54951. * Specifies whether or not to create a skybox.
  54952. * True by default.
  54953. */
  54954. createSkybox: boolean;
  54955. /**
  54956. * Specifies the skybox size.
  54957. * 20 by default.
  54958. */
  54959. skyboxSize: number;
  54960. /**
  54961. * The texture used on the skybox for the main color.
  54962. * Comes from the BabylonJS CDN by default.
  54963. *
  54964. * Remarks: Can be either a texture or a url.
  54965. */
  54966. skyboxTexture: string | BaseTexture;
  54967. /**
  54968. * The color mixed in the skybox texture by default.
  54969. * BabylonJS clearColor by default.
  54970. */
  54971. skyboxColor: Color3;
  54972. /**
  54973. * The background rotation around the Y axis of the scene.
  54974. * This helps aligning the key lights of your scene with the background.
  54975. * 0 by default.
  54976. */
  54977. backgroundYRotation: number;
  54978. /**
  54979. * Compute automatically the size of the elements to best fit with the scene.
  54980. */
  54981. sizeAuto: boolean;
  54982. /**
  54983. * Default position of the rootMesh if autoSize is not true.
  54984. */
  54985. rootPosition: Vector3;
  54986. /**
  54987. * Sets up the image processing in the scene.
  54988. * true by default.
  54989. */
  54990. setupImageProcessing: boolean;
  54991. /**
  54992. * The texture used as your environment texture in the scene.
  54993. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54994. *
  54995. * Remarks: Can be either a texture or a url.
  54996. */
  54997. environmentTexture: string | BaseTexture;
  54998. /**
  54999. * The value of the exposure to apply to the scene.
  55000. * 0.6 by default if setupImageProcessing is true.
  55001. */
  55002. cameraExposure: number;
  55003. /**
  55004. * The value of the contrast to apply to the scene.
  55005. * 1.6 by default if setupImageProcessing is true.
  55006. */
  55007. cameraContrast: number;
  55008. /**
  55009. * Specifies whether or not tonemapping should be enabled in the scene.
  55010. * true by default if setupImageProcessing is true.
  55011. */
  55012. toneMappingEnabled: boolean;
  55013. }
  55014. /**
  55015. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55016. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55017. * It also helps with the default setup of your imageProcessing configuration.
  55018. */
  55019. export class EnvironmentHelper {
  55020. /**
  55021. * Default ground texture URL.
  55022. */
  55023. private static _groundTextureCDNUrl;
  55024. /**
  55025. * Default skybox texture URL.
  55026. */
  55027. private static _skyboxTextureCDNUrl;
  55028. /**
  55029. * Default environment texture URL.
  55030. */
  55031. private static _environmentTextureCDNUrl;
  55032. /**
  55033. * Creates the default options for the helper.
  55034. */
  55035. private static _getDefaultOptions;
  55036. private _rootMesh;
  55037. /**
  55038. * Gets the root mesh created by the helper.
  55039. */
  55040. get rootMesh(): Mesh;
  55041. private _skybox;
  55042. /**
  55043. * Gets the skybox created by the helper.
  55044. */
  55045. get skybox(): Nullable<Mesh>;
  55046. private _skyboxTexture;
  55047. /**
  55048. * Gets the skybox texture created by the helper.
  55049. */
  55050. get skyboxTexture(): Nullable<BaseTexture>;
  55051. private _skyboxMaterial;
  55052. /**
  55053. * Gets the skybox material created by the helper.
  55054. */
  55055. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55056. private _ground;
  55057. /**
  55058. * Gets the ground mesh created by the helper.
  55059. */
  55060. get ground(): Nullable<Mesh>;
  55061. private _groundTexture;
  55062. /**
  55063. * Gets the ground texture created by the helper.
  55064. */
  55065. get groundTexture(): Nullable<BaseTexture>;
  55066. private _groundMirror;
  55067. /**
  55068. * Gets the ground mirror created by the helper.
  55069. */
  55070. get groundMirror(): Nullable<MirrorTexture>;
  55071. /**
  55072. * Gets the ground mirror render list to helps pushing the meshes
  55073. * you wish in the ground reflection.
  55074. */
  55075. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55076. private _groundMaterial;
  55077. /**
  55078. * Gets the ground material created by the helper.
  55079. */
  55080. get groundMaterial(): Nullable<BackgroundMaterial>;
  55081. /**
  55082. * Stores the creation options.
  55083. */
  55084. private readonly _scene;
  55085. private _options;
  55086. /**
  55087. * This observable will be notified with any error during the creation of the environment,
  55088. * mainly texture creation errors.
  55089. */
  55090. onErrorObservable: Observable<{
  55091. message?: string;
  55092. exception?: any;
  55093. }>;
  55094. /**
  55095. * constructor
  55096. * @param options Defines the options we want to customize the helper
  55097. * @param scene The scene to add the material to
  55098. */
  55099. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55100. /**
  55101. * Updates the background according to the new options
  55102. * @param options
  55103. */
  55104. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55105. /**
  55106. * Sets the primary color of all the available elements.
  55107. * @param color the main color to affect to the ground and the background
  55108. */
  55109. setMainColor(color: Color3): void;
  55110. /**
  55111. * Setup the image processing according to the specified options.
  55112. */
  55113. private _setupImageProcessing;
  55114. /**
  55115. * Setup the environment texture according to the specified options.
  55116. */
  55117. private _setupEnvironmentTexture;
  55118. /**
  55119. * Setup the background according to the specified options.
  55120. */
  55121. private _setupBackground;
  55122. /**
  55123. * Get the scene sizes according to the setup.
  55124. */
  55125. private _getSceneSize;
  55126. /**
  55127. * Setup the ground according to the specified options.
  55128. */
  55129. private _setupGround;
  55130. /**
  55131. * Setup the ground material according to the specified options.
  55132. */
  55133. private _setupGroundMaterial;
  55134. /**
  55135. * Setup the ground diffuse texture according to the specified options.
  55136. */
  55137. private _setupGroundDiffuseTexture;
  55138. /**
  55139. * Setup the ground mirror texture according to the specified options.
  55140. */
  55141. private _setupGroundMirrorTexture;
  55142. /**
  55143. * Setup the ground to receive the mirror texture.
  55144. */
  55145. private _setupMirrorInGroundMaterial;
  55146. /**
  55147. * Setup the skybox according to the specified options.
  55148. */
  55149. private _setupSkybox;
  55150. /**
  55151. * Setup the skybox material according to the specified options.
  55152. */
  55153. private _setupSkyboxMaterial;
  55154. /**
  55155. * Setup the skybox reflection texture according to the specified options.
  55156. */
  55157. private _setupSkyboxReflectionTexture;
  55158. private _errorHandler;
  55159. /**
  55160. * Dispose all the elements created by the Helper.
  55161. */
  55162. dispose(): void;
  55163. }
  55164. }
  55165. declare module BABYLON {
  55166. /**
  55167. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  55168. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  55169. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55170. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55171. */
  55172. export abstract class TextureDome<T extends Texture> extends TransformNode {
  55173. protected onError: Nullable<(message?: string, exception?: any) => void>;
  55174. /**
  55175. * Define the source as a Monoscopic panoramic 360/180.
  55176. */
  55177. static readonly MODE_MONOSCOPIC: number;
  55178. /**
  55179. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  55180. */
  55181. static readonly MODE_TOPBOTTOM: number;
  55182. /**
  55183. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  55184. */
  55185. static readonly MODE_SIDEBYSIDE: number;
  55186. private _halfDome;
  55187. protected _useDirectMapping: boolean;
  55188. /**
  55189. * The texture being displayed on the sphere
  55190. */
  55191. protected _texture: T;
  55192. /**
  55193. * Gets the texture being displayed on the sphere
  55194. */
  55195. get texture(): T;
  55196. /**
  55197. * Sets the texture being displayed on the sphere
  55198. */
  55199. set texture(newTexture: T);
  55200. /**
  55201. * The skybox material
  55202. */
  55203. protected _material: BackgroundMaterial;
  55204. /**
  55205. * The surface used for the dome
  55206. */
  55207. protected _mesh: Mesh;
  55208. /**
  55209. * Gets the mesh used for the dome.
  55210. */
  55211. get mesh(): Mesh;
  55212. /**
  55213. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  55214. */
  55215. private _halfDomeMask;
  55216. /**
  55217. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55218. * Also see the options.resolution property.
  55219. */
  55220. get fovMultiplier(): number;
  55221. set fovMultiplier(value: number);
  55222. protected _textureMode: number;
  55223. /**
  55224. * Gets or set the current texture mode for the texture. It can be:
  55225. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55226. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55227. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55228. */
  55229. get textureMode(): number;
  55230. /**
  55231. * Sets the current texture mode for the texture. It can be:
  55232. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55233. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55234. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55235. */
  55236. set textureMode(value: number);
  55237. /**
  55238. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  55239. */
  55240. get halfDome(): boolean;
  55241. /**
  55242. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55243. */
  55244. set halfDome(enabled: boolean);
  55245. /**
  55246. * Oberserver used in Stereoscopic VR Mode.
  55247. */
  55248. private _onBeforeCameraRenderObserver;
  55249. /**
  55250. * Observable raised when an error occured while loading the 360 image
  55251. */
  55252. onLoadErrorObservable: Observable<string>;
  55253. /**
  55254. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  55255. * @param name Element's name, child elements will append suffixes for their own names.
  55256. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  55257. * @param options An object containing optional or exposed sub element properties
  55258. */
  55259. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  55260. resolution?: number;
  55261. clickToPlay?: boolean;
  55262. autoPlay?: boolean;
  55263. loop?: boolean;
  55264. size?: number;
  55265. poster?: string;
  55266. faceForward?: boolean;
  55267. useDirectMapping?: boolean;
  55268. halfDomeMode?: boolean;
  55269. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55270. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  55271. protected _changeTextureMode(value: number): void;
  55272. /**
  55273. * Releases resources associated with this node.
  55274. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55275. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55276. */
  55277. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55278. }
  55279. }
  55280. declare module BABYLON {
  55281. /**
  55282. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55283. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55284. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55285. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55286. */
  55287. export class PhotoDome extends TextureDome<Texture> {
  55288. /**
  55289. * Define the image as a Monoscopic panoramic 360 image.
  55290. */
  55291. static readonly MODE_MONOSCOPIC: number;
  55292. /**
  55293. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55294. */
  55295. static readonly MODE_TOPBOTTOM: number;
  55296. /**
  55297. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55298. */
  55299. static readonly MODE_SIDEBYSIDE: number;
  55300. /**
  55301. * Gets or sets the texture being displayed on the sphere
  55302. */
  55303. get photoTexture(): Texture;
  55304. /**
  55305. * sets the texture being displayed on the sphere
  55306. */
  55307. set photoTexture(value: Texture);
  55308. /**
  55309. * Gets the current video mode for the video. It can be:
  55310. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55311. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55312. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55313. */
  55314. get imageMode(): number;
  55315. /**
  55316. * Sets the current video mode for the video. It can be:
  55317. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55318. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55319. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55320. */
  55321. set imageMode(value: number);
  55322. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  55323. }
  55324. }
  55325. declare module BABYLON {
  55326. /**
  55327. * Class used to host RGBD texture specific utilities
  55328. */
  55329. export class RGBDTextureTools {
  55330. /**
  55331. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55332. * @param texture the texture to expand.
  55333. */
  55334. static ExpandRGBDTexture(texture: Texture): void;
  55335. }
  55336. }
  55337. declare module BABYLON {
  55338. /**
  55339. * Class used to host texture specific utilities
  55340. */
  55341. export class BRDFTextureTools {
  55342. /**
  55343. * Prevents texture cache collision
  55344. */
  55345. private static _instanceNumber;
  55346. /**
  55347. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55348. * @param scene defines the hosting scene
  55349. * @returns the environment BRDF texture
  55350. */
  55351. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55352. private static _environmentBRDFBase64Texture;
  55353. }
  55354. }
  55355. declare module BABYLON {
  55356. /**
  55357. * @hidden
  55358. */
  55359. export interface IMaterialClearCoatDefines {
  55360. CLEARCOAT: boolean;
  55361. CLEARCOAT_DEFAULTIOR: boolean;
  55362. CLEARCOAT_TEXTURE: boolean;
  55363. CLEARCOAT_TEXTUREDIRECTUV: number;
  55364. CLEARCOAT_BUMP: boolean;
  55365. CLEARCOAT_BUMPDIRECTUV: number;
  55366. CLEARCOAT_TINT: boolean;
  55367. CLEARCOAT_TINT_TEXTURE: boolean;
  55368. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55369. /** @hidden */
  55370. _areTexturesDirty: boolean;
  55371. }
  55372. /**
  55373. * Define the code related to the clear coat parameters of the pbr material.
  55374. */
  55375. export class PBRClearCoatConfiguration {
  55376. /**
  55377. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55378. * The default fits with a polyurethane material.
  55379. */
  55380. private static readonly _DefaultIndexOfRefraction;
  55381. private _isEnabled;
  55382. /**
  55383. * Defines if the clear coat is enabled in the material.
  55384. */
  55385. isEnabled: boolean;
  55386. /**
  55387. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55388. */
  55389. intensity: number;
  55390. /**
  55391. * Defines the clear coat layer roughness.
  55392. */
  55393. roughness: number;
  55394. private _indexOfRefraction;
  55395. /**
  55396. * Defines the index of refraction of the clear coat.
  55397. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55398. * The default fits with a polyurethane material.
  55399. * Changing the default value is more performance intensive.
  55400. */
  55401. indexOfRefraction: number;
  55402. private _texture;
  55403. /**
  55404. * Stores the clear coat values in a texture.
  55405. */
  55406. texture: Nullable<BaseTexture>;
  55407. private _bumpTexture;
  55408. /**
  55409. * Define the clear coat specific bump texture.
  55410. */
  55411. bumpTexture: Nullable<BaseTexture>;
  55412. private _isTintEnabled;
  55413. /**
  55414. * Defines if the clear coat tint is enabled in the material.
  55415. */
  55416. isTintEnabled: boolean;
  55417. /**
  55418. * Defines the clear coat tint of the material.
  55419. * This is only use if tint is enabled
  55420. */
  55421. tintColor: Color3;
  55422. /**
  55423. * Defines the distance at which the tint color should be found in the
  55424. * clear coat media.
  55425. * This is only use if tint is enabled
  55426. */
  55427. tintColorAtDistance: number;
  55428. /**
  55429. * Defines the clear coat layer thickness.
  55430. * This is only use if tint is enabled
  55431. */
  55432. tintThickness: number;
  55433. private _tintTexture;
  55434. /**
  55435. * Stores the clear tint values in a texture.
  55436. * rgb is tint
  55437. * a is a thickness factor
  55438. */
  55439. tintTexture: Nullable<BaseTexture>;
  55440. /** @hidden */
  55441. private _internalMarkAllSubMeshesAsTexturesDirty;
  55442. /** @hidden */
  55443. _markAllSubMeshesAsTexturesDirty(): void;
  55444. /**
  55445. * Instantiate a new istance of clear coat configuration.
  55446. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55447. */
  55448. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55449. /**
  55450. * Gets wehter the submesh is ready to be used or not.
  55451. * @param defines the list of "defines" to update.
  55452. * @param scene defines the scene the material belongs to.
  55453. * @param engine defines the engine the material belongs to.
  55454. * @param disableBumpMap defines wether the material disables bump or not.
  55455. * @returns - boolean indicating that the submesh is ready or not.
  55456. */
  55457. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55458. /**
  55459. * Checks to see if a texture is used in the material.
  55460. * @param defines the list of "defines" to update.
  55461. * @param scene defines the scene to the material belongs to.
  55462. */
  55463. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55464. /**
  55465. * Binds the material data.
  55466. * @param uniformBuffer defines the Uniform buffer to fill in.
  55467. * @param scene defines the scene the material belongs to.
  55468. * @param engine defines the engine the material belongs to.
  55469. * @param disableBumpMap defines wether the material disables bump or not.
  55470. * @param isFrozen defines wether the material is frozen or not.
  55471. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55472. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55473. */
  55474. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55475. /**
  55476. * Checks to see if a texture is used in the material.
  55477. * @param texture - Base texture to use.
  55478. * @returns - Boolean specifying if a texture is used in the material.
  55479. */
  55480. hasTexture(texture: BaseTexture): boolean;
  55481. /**
  55482. * Returns an array of the actively used textures.
  55483. * @param activeTextures Array of BaseTextures
  55484. */
  55485. getActiveTextures(activeTextures: BaseTexture[]): void;
  55486. /**
  55487. * Returns the animatable textures.
  55488. * @param animatables Array of animatable textures.
  55489. */
  55490. getAnimatables(animatables: IAnimatable[]): void;
  55491. /**
  55492. * Disposes the resources of the material.
  55493. * @param forceDisposeTextures - Forces the disposal of all textures.
  55494. */
  55495. dispose(forceDisposeTextures?: boolean): void;
  55496. /**
  55497. * Get the current class name of the texture useful for serialization or dynamic coding.
  55498. * @returns "PBRClearCoatConfiguration"
  55499. */
  55500. getClassName(): string;
  55501. /**
  55502. * Add fallbacks to the effect fallbacks list.
  55503. * @param defines defines the Base texture to use.
  55504. * @param fallbacks defines the current fallback list.
  55505. * @param currentRank defines the current fallback rank.
  55506. * @returns the new fallback rank.
  55507. */
  55508. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55509. /**
  55510. * Add the required uniforms to the current list.
  55511. * @param uniforms defines the current uniform list.
  55512. */
  55513. static AddUniforms(uniforms: string[]): void;
  55514. /**
  55515. * Add the required samplers to the current list.
  55516. * @param samplers defines the current sampler list.
  55517. */
  55518. static AddSamplers(samplers: string[]): void;
  55519. /**
  55520. * Add the required uniforms to the current buffer.
  55521. * @param uniformBuffer defines the current uniform buffer.
  55522. */
  55523. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55524. /**
  55525. * Makes a duplicate of the current configuration into another one.
  55526. * @param clearCoatConfiguration define the config where to copy the info
  55527. */
  55528. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55529. /**
  55530. * Serializes this clear coat configuration.
  55531. * @returns - An object with the serialized config.
  55532. */
  55533. serialize(): any;
  55534. /**
  55535. * Parses a anisotropy Configuration from a serialized object.
  55536. * @param source - Serialized object.
  55537. * @param scene Defines the scene we are parsing for
  55538. * @param rootUrl Defines the rootUrl to load from
  55539. */
  55540. parse(source: any, scene: Scene, rootUrl: string): void;
  55541. }
  55542. }
  55543. declare module BABYLON {
  55544. /**
  55545. * @hidden
  55546. */
  55547. export interface IMaterialAnisotropicDefines {
  55548. ANISOTROPIC: boolean;
  55549. ANISOTROPIC_TEXTURE: boolean;
  55550. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55551. MAINUV1: boolean;
  55552. _areTexturesDirty: boolean;
  55553. _needUVs: boolean;
  55554. }
  55555. /**
  55556. * Define the code related to the anisotropic parameters of the pbr material.
  55557. */
  55558. export class PBRAnisotropicConfiguration {
  55559. private _isEnabled;
  55560. /**
  55561. * Defines if the anisotropy is enabled in the material.
  55562. */
  55563. isEnabled: boolean;
  55564. /**
  55565. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55566. */
  55567. intensity: number;
  55568. /**
  55569. * Defines if the effect is along the tangents, bitangents or in between.
  55570. * By default, the effect is "strectching" the highlights along the tangents.
  55571. */
  55572. direction: Vector2;
  55573. private _texture;
  55574. /**
  55575. * Stores the anisotropy values in a texture.
  55576. * rg is direction (like normal from -1 to 1)
  55577. * b is a intensity
  55578. */
  55579. texture: Nullable<BaseTexture>;
  55580. /** @hidden */
  55581. private _internalMarkAllSubMeshesAsTexturesDirty;
  55582. /** @hidden */
  55583. _markAllSubMeshesAsTexturesDirty(): void;
  55584. /**
  55585. * Instantiate a new istance of anisotropy configuration.
  55586. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55587. */
  55588. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55589. /**
  55590. * Specifies that the submesh is ready to be used.
  55591. * @param defines the list of "defines" to update.
  55592. * @param scene defines the scene the material belongs to.
  55593. * @returns - boolean indicating that the submesh is ready or not.
  55594. */
  55595. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55596. /**
  55597. * Checks to see if a texture is used in the material.
  55598. * @param defines the list of "defines" to update.
  55599. * @param mesh the mesh we are preparing the defines for.
  55600. * @param scene defines the scene the material belongs to.
  55601. */
  55602. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55603. /**
  55604. * Binds the material data.
  55605. * @param uniformBuffer defines the Uniform buffer to fill in.
  55606. * @param scene defines the scene the material belongs to.
  55607. * @param isFrozen defines wether the material is frozen or not.
  55608. */
  55609. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55610. /**
  55611. * Checks to see if a texture is used in the material.
  55612. * @param texture - Base texture to use.
  55613. * @returns - Boolean specifying if a texture is used in the material.
  55614. */
  55615. hasTexture(texture: BaseTexture): boolean;
  55616. /**
  55617. * Returns an array of the actively used textures.
  55618. * @param activeTextures Array of BaseTextures
  55619. */
  55620. getActiveTextures(activeTextures: BaseTexture[]): void;
  55621. /**
  55622. * Returns the animatable textures.
  55623. * @param animatables Array of animatable textures.
  55624. */
  55625. getAnimatables(animatables: IAnimatable[]): void;
  55626. /**
  55627. * Disposes the resources of the material.
  55628. * @param forceDisposeTextures - Forces the disposal of all textures.
  55629. */
  55630. dispose(forceDisposeTextures?: boolean): void;
  55631. /**
  55632. * Get the current class name of the texture useful for serialization or dynamic coding.
  55633. * @returns "PBRAnisotropicConfiguration"
  55634. */
  55635. getClassName(): string;
  55636. /**
  55637. * Add fallbacks to the effect fallbacks list.
  55638. * @param defines defines the Base texture to use.
  55639. * @param fallbacks defines the current fallback list.
  55640. * @param currentRank defines the current fallback rank.
  55641. * @returns the new fallback rank.
  55642. */
  55643. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55644. /**
  55645. * Add the required uniforms to the current list.
  55646. * @param uniforms defines the current uniform list.
  55647. */
  55648. static AddUniforms(uniforms: string[]): void;
  55649. /**
  55650. * Add the required uniforms to the current buffer.
  55651. * @param uniformBuffer defines the current uniform buffer.
  55652. */
  55653. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55654. /**
  55655. * Add the required samplers to the current list.
  55656. * @param samplers defines the current sampler list.
  55657. */
  55658. static AddSamplers(samplers: string[]): void;
  55659. /**
  55660. * Makes a duplicate of the current configuration into another one.
  55661. * @param anisotropicConfiguration define the config where to copy the info
  55662. */
  55663. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55664. /**
  55665. * Serializes this anisotropy configuration.
  55666. * @returns - An object with the serialized config.
  55667. */
  55668. serialize(): any;
  55669. /**
  55670. * Parses a anisotropy Configuration from a serialized object.
  55671. * @param source - Serialized object.
  55672. * @param scene Defines the scene we are parsing for
  55673. * @param rootUrl Defines the rootUrl to load from
  55674. */
  55675. parse(source: any, scene: Scene, rootUrl: string): void;
  55676. }
  55677. }
  55678. declare module BABYLON {
  55679. /**
  55680. * @hidden
  55681. */
  55682. export interface IMaterialBRDFDefines {
  55683. BRDF_V_HEIGHT_CORRELATED: boolean;
  55684. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55685. SPHERICAL_HARMONICS: boolean;
  55686. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55687. /** @hidden */
  55688. _areMiscDirty: boolean;
  55689. }
  55690. /**
  55691. * Define the code related to the BRDF parameters of the pbr material.
  55692. */
  55693. export class PBRBRDFConfiguration {
  55694. /**
  55695. * Default value used for the energy conservation.
  55696. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55697. */
  55698. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55699. /**
  55700. * Default value used for the Smith Visibility Height Correlated mode.
  55701. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55702. */
  55703. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55704. /**
  55705. * Default value used for the IBL diffuse part.
  55706. * This can help switching back to the polynomials mode globally which is a tiny bit
  55707. * less GPU intensive at the drawback of a lower quality.
  55708. */
  55709. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55710. /**
  55711. * Default value used for activating energy conservation for the specular workflow.
  55712. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55713. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55714. */
  55715. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55716. private _useEnergyConservation;
  55717. /**
  55718. * Defines if the material uses energy conservation.
  55719. */
  55720. useEnergyConservation: boolean;
  55721. private _useSmithVisibilityHeightCorrelated;
  55722. /**
  55723. * LEGACY Mode set to false
  55724. * Defines if the material uses height smith correlated visibility term.
  55725. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55726. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55727. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55728. * Not relying on height correlated will also disable energy conservation.
  55729. */
  55730. useSmithVisibilityHeightCorrelated: boolean;
  55731. private _useSphericalHarmonics;
  55732. /**
  55733. * LEGACY Mode set to false
  55734. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55735. * diffuse part of the IBL.
  55736. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55737. * to the ground truth.
  55738. */
  55739. useSphericalHarmonics: boolean;
  55740. private _useSpecularGlossinessInputEnergyConservation;
  55741. /**
  55742. * Defines if the material uses energy conservation, when the specular workflow is active.
  55743. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55744. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55745. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55746. */
  55747. useSpecularGlossinessInputEnergyConservation: boolean;
  55748. /** @hidden */
  55749. private _internalMarkAllSubMeshesAsMiscDirty;
  55750. /** @hidden */
  55751. _markAllSubMeshesAsMiscDirty(): void;
  55752. /**
  55753. * Instantiate a new istance of clear coat configuration.
  55754. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55755. */
  55756. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55757. /**
  55758. * Checks to see if a texture is used in the material.
  55759. * @param defines the list of "defines" to update.
  55760. */
  55761. prepareDefines(defines: IMaterialBRDFDefines): void;
  55762. /**
  55763. * Get the current class name of the texture useful for serialization or dynamic coding.
  55764. * @returns "PBRClearCoatConfiguration"
  55765. */
  55766. getClassName(): string;
  55767. /**
  55768. * Makes a duplicate of the current configuration into another one.
  55769. * @param brdfConfiguration define the config where to copy the info
  55770. */
  55771. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55772. /**
  55773. * Serializes this BRDF configuration.
  55774. * @returns - An object with the serialized config.
  55775. */
  55776. serialize(): any;
  55777. /**
  55778. * Parses a anisotropy Configuration from a serialized object.
  55779. * @param source - Serialized object.
  55780. * @param scene Defines the scene we are parsing for
  55781. * @param rootUrl Defines the rootUrl to load from
  55782. */
  55783. parse(source: any, scene: Scene, rootUrl: string): void;
  55784. }
  55785. }
  55786. declare module BABYLON {
  55787. /**
  55788. * @hidden
  55789. */
  55790. export interface IMaterialSheenDefines {
  55791. SHEEN: boolean;
  55792. SHEEN_TEXTURE: boolean;
  55793. SHEEN_TEXTUREDIRECTUV: number;
  55794. SHEEN_LINKWITHALBEDO: boolean;
  55795. SHEEN_ROUGHNESS: boolean;
  55796. SHEEN_ALBEDOSCALING: boolean;
  55797. /** @hidden */
  55798. _areTexturesDirty: boolean;
  55799. }
  55800. /**
  55801. * Define the code related to the Sheen parameters of the pbr material.
  55802. */
  55803. export class PBRSheenConfiguration {
  55804. private _isEnabled;
  55805. /**
  55806. * Defines if the material uses sheen.
  55807. */
  55808. isEnabled: boolean;
  55809. private _linkSheenWithAlbedo;
  55810. /**
  55811. * Defines if the sheen is linked to the sheen color.
  55812. */
  55813. linkSheenWithAlbedo: boolean;
  55814. /**
  55815. * Defines the sheen intensity.
  55816. */
  55817. intensity: number;
  55818. /**
  55819. * Defines the sheen color.
  55820. */
  55821. color: Color3;
  55822. private _texture;
  55823. /**
  55824. * Stores the sheen tint values in a texture.
  55825. * rgb is tint
  55826. * a is a intensity or roughness if roughness has been defined
  55827. */
  55828. texture: Nullable<BaseTexture>;
  55829. private _roughness;
  55830. /**
  55831. * Defines the sheen roughness.
  55832. * It is not taken into account if linkSheenWithAlbedo is true.
  55833. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55834. */
  55835. roughness: Nullable<number>;
  55836. private _albedoScaling;
  55837. /**
  55838. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55839. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55840. * making it easier to setup and tweak the effect
  55841. */
  55842. albedoScaling: boolean;
  55843. /** @hidden */
  55844. private _internalMarkAllSubMeshesAsTexturesDirty;
  55845. /** @hidden */
  55846. _markAllSubMeshesAsTexturesDirty(): void;
  55847. /**
  55848. * Instantiate a new istance of clear coat configuration.
  55849. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55850. */
  55851. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55852. /**
  55853. * Specifies that the submesh is ready to be used.
  55854. * @param defines the list of "defines" to update.
  55855. * @param scene defines the scene the material belongs to.
  55856. * @returns - boolean indicating that the submesh is ready or not.
  55857. */
  55858. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55859. /**
  55860. * Checks to see if a texture is used in the material.
  55861. * @param defines the list of "defines" to update.
  55862. * @param scene defines the scene the material belongs to.
  55863. */
  55864. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55865. /**
  55866. * Binds the material data.
  55867. * @param uniformBuffer defines the Uniform buffer to fill in.
  55868. * @param scene defines the scene the material belongs to.
  55869. * @param isFrozen defines wether the material is frozen or not.
  55870. */
  55871. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55872. /**
  55873. * Checks to see if a texture is used in the material.
  55874. * @param texture - Base texture to use.
  55875. * @returns - Boolean specifying if a texture is used in the material.
  55876. */
  55877. hasTexture(texture: BaseTexture): boolean;
  55878. /**
  55879. * Returns an array of the actively used textures.
  55880. * @param activeTextures Array of BaseTextures
  55881. */
  55882. getActiveTextures(activeTextures: BaseTexture[]): void;
  55883. /**
  55884. * Returns the animatable textures.
  55885. * @param animatables Array of animatable textures.
  55886. */
  55887. getAnimatables(animatables: IAnimatable[]): void;
  55888. /**
  55889. * Disposes the resources of the material.
  55890. * @param forceDisposeTextures - Forces the disposal of all textures.
  55891. */
  55892. dispose(forceDisposeTextures?: boolean): void;
  55893. /**
  55894. * Get the current class name of the texture useful for serialization or dynamic coding.
  55895. * @returns "PBRSheenConfiguration"
  55896. */
  55897. getClassName(): string;
  55898. /**
  55899. * Add fallbacks to the effect fallbacks list.
  55900. * @param defines defines the Base texture to use.
  55901. * @param fallbacks defines the current fallback list.
  55902. * @param currentRank defines the current fallback rank.
  55903. * @returns the new fallback rank.
  55904. */
  55905. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55906. /**
  55907. * Add the required uniforms to the current list.
  55908. * @param uniforms defines the current uniform list.
  55909. */
  55910. static AddUniforms(uniforms: string[]): void;
  55911. /**
  55912. * Add the required uniforms to the current buffer.
  55913. * @param uniformBuffer defines the current uniform buffer.
  55914. */
  55915. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55916. /**
  55917. * Add the required samplers to the current list.
  55918. * @param samplers defines the current sampler list.
  55919. */
  55920. static AddSamplers(samplers: string[]): void;
  55921. /**
  55922. * Makes a duplicate of the current configuration into another one.
  55923. * @param sheenConfiguration define the config where to copy the info
  55924. */
  55925. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55926. /**
  55927. * Serializes this BRDF configuration.
  55928. * @returns - An object with the serialized config.
  55929. */
  55930. serialize(): any;
  55931. /**
  55932. * Parses a anisotropy Configuration from a serialized object.
  55933. * @param source - Serialized object.
  55934. * @param scene Defines the scene we are parsing for
  55935. * @param rootUrl Defines the rootUrl to load from
  55936. */
  55937. parse(source: any, scene: Scene, rootUrl: string): void;
  55938. }
  55939. }
  55940. declare module BABYLON {
  55941. /**
  55942. * @hidden
  55943. */
  55944. export interface IMaterialSubSurfaceDefines {
  55945. SUBSURFACE: boolean;
  55946. SS_REFRACTION: boolean;
  55947. SS_TRANSLUCENCY: boolean;
  55948. SS_SCATTERING: boolean;
  55949. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55950. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55951. SS_REFRACTIONMAP_3D: boolean;
  55952. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55953. SS_LODINREFRACTIONALPHA: boolean;
  55954. SS_GAMMAREFRACTION: boolean;
  55955. SS_RGBDREFRACTION: boolean;
  55956. SS_LINEARSPECULARREFRACTION: boolean;
  55957. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55958. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55959. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55960. /** @hidden */
  55961. _areTexturesDirty: boolean;
  55962. }
  55963. /**
  55964. * Define the code related to the sub surface parameters of the pbr material.
  55965. */
  55966. export class PBRSubSurfaceConfiguration {
  55967. private _isRefractionEnabled;
  55968. /**
  55969. * Defines if the refraction is enabled in the material.
  55970. */
  55971. isRefractionEnabled: boolean;
  55972. private _isTranslucencyEnabled;
  55973. /**
  55974. * Defines if the translucency is enabled in the material.
  55975. */
  55976. isTranslucencyEnabled: boolean;
  55977. private _isScatteringEnabled;
  55978. /**
  55979. * Defines if the sub surface scattering is enabled in the material.
  55980. */
  55981. isScatteringEnabled: boolean;
  55982. private _scatteringDiffusionProfileIndex;
  55983. /**
  55984. * Diffusion profile for subsurface scattering.
  55985. * Useful for better scattering in the skins or foliages.
  55986. */
  55987. get scatteringDiffusionProfile(): Nullable<Color3>;
  55988. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55989. /**
  55990. * Defines the refraction intensity of the material.
  55991. * The refraction when enabled replaces the Diffuse part of the material.
  55992. * The intensity helps transitionning between diffuse and refraction.
  55993. */
  55994. refractionIntensity: number;
  55995. /**
  55996. * Defines the translucency intensity of the material.
  55997. * When translucency has been enabled, this defines how much of the "translucency"
  55998. * is addded to the diffuse part of the material.
  55999. */
  56000. translucencyIntensity: number;
  56001. /**
  56002. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  56003. */
  56004. useAlbedoToTintRefraction: boolean;
  56005. private _thicknessTexture;
  56006. /**
  56007. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56008. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56009. * 0 would mean minimumThickness
  56010. * 1 would mean maximumThickness
  56011. * The other channels might be use as a mask to vary the different effects intensity.
  56012. */
  56013. thicknessTexture: Nullable<BaseTexture>;
  56014. private _refractionTexture;
  56015. /**
  56016. * Defines the texture to use for refraction.
  56017. */
  56018. refractionTexture: Nullable<BaseTexture>;
  56019. private _indexOfRefraction;
  56020. /**
  56021. * Index of refraction of the material base layer.
  56022. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56023. *
  56024. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56025. *
  56026. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56027. */
  56028. indexOfRefraction: number;
  56029. private _volumeIndexOfRefraction;
  56030. /**
  56031. * Index of refraction of the material's volume.
  56032. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56033. *
  56034. * This ONLY impacts refraction. If not provided or given a non-valid value,
  56035. * the volume will use the same IOR as the surface.
  56036. */
  56037. get volumeIndexOfRefraction(): number;
  56038. set volumeIndexOfRefraction(value: number);
  56039. private _invertRefractionY;
  56040. /**
  56041. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56042. */
  56043. invertRefractionY: boolean;
  56044. private _linkRefractionWithTransparency;
  56045. /**
  56046. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56047. * Materials half opaque for instance using refraction could benefit from this control.
  56048. */
  56049. linkRefractionWithTransparency: boolean;
  56050. /**
  56051. * Defines the minimum thickness stored in the thickness map.
  56052. * If no thickness map is defined, this value will be used to simulate thickness.
  56053. */
  56054. minimumThickness: number;
  56055. /**
  56056. * Defines the maximum thickness stored in the thickness map.
  56057. */
  56058. maximumThickness: number;
  56059. /**
  56060. * Defines the volume tint of the material.
  56061. * This is used for both translucency and scattering.
  56062. */
  56063. tintColor: Color3;
  56064. /**
  56065. * Defines the distance at which the tint color should be found in the media.
  56066. * This is used for refraction only.
  56067. */
  56068. tintColorAtDistance: number;
  56069. /**
  56070. * Defines how far each channel transmit through the media.
  56071. * It is defined as a color to simplify it selection.
  56072. */
  56073. diffusionDistance: Color3;
  56074. private _useMaskFromThicknessTexture;
  56075. /**
  56076. * Stores the intensity of the different subsurface effects in the thickness texture.
  56077. * * the green channel is the translucency intensity.
  56078. * * the blue channel is the scattering intensity.
  56079. * * the alpha channel is the refraction intensity.
  56080. */
  56081. useMaskFromThicknessTexture: boolean;
  56082. private _scene;
  56083. /** @hidden */
  56084. private _internalMarkAllSubMeshesAsTexturesDirty;
  56085. private _internalMarkScenePrePassDirty;
  56086. /** @hidden */
  56087. _markAllSubMeshesAsTexturesDirty(): void;
  56088. /** @hidden */
  56089. _markScenePrePassDirty(): void;
  56090. /**
  56091. * Instantiate a new istance of sub surface configuration.
  56092. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56093. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  56094. * @param scene The scene
  56095. */
  56096. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  56097. /**
  56098. * Gets wehter the submesh is ready to be used or not.
  56099. * @param defines the list of "defines" to update.
  56100. * @param scene defines the scene the material belongs to.
  56101. * @returns - boolean indicating that the submesh is ready or not.
  56102. */
  56103. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56104. /**
  56105. * Checks to see if a texture is used in the material.
  56106. * @param defines the list of "defines" to update.
  56107. * @param scene defines the scene to the material belongs to.
  56108. */
  56109. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56110. /**
  56111. * Binds the material data.
  56112. * @param uniformBuffer defines the Uniform buffer to fill in.
  56113. * @param scene defines the scene the material belongs to.
  56114. * @param engine defines the engine the material belongs to.
  56115. * @param isFrozen defines whether the material is frozen or not.
  56116. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56117. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56118. */
  56119. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56120. /**
  56121. * Unbinds the material from the mesh.
  56122. * @param activeEffect defines the effect that should be unbound from.
  56123. * @returns true if unbound, otherwise false
  56124. */
  56125. unbind(activeEffect: Effect): boolean;
  56126. /**
  56127. * Returns the texture used for refraction or null if none is used.
  56128. * @param scene defines the scene the material belongs to.
  56129. * @returns - Refraction texture if present. If no refraction texture and refraction
  56130. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56131. */
  56132. private _getRefractionTexture;
  56133. /**
  56134. * Returns true if alpha blending should be disabled.
  56135. */
  56136. get disableAlphaBlending(): boolean;
  56137. /**
  56138. * Fills the list of render target textures.
  56139. * @param renderTargets the list of render targets to update
  56140. */
  56141. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56142. /**
  56143. * Checks to see if a texture is used in the material.
  56144. * @param texture - Base texture to use.
  56145. * @returns - Boolean specifying if a texture is used in the material.
  56146. */
  56147. hasTexture(texture: BaseTexture): boolean;
  56148. /**
  56149. * Gets a boolean indicating that current material needs to register RTT
  56150. * @returns true if this uses a render target otherwise false.
  56151. */
  56152. hasRenderTargetTextures(): boolean;
  56153. /**
  56154. * Returns an array of the actively used textures.
  56155. * @param activeTextures Array of BaseTextures
  56156. */
  56157. getActiveTextures(activeTextures: BaseTexture[]): void;
  56158. /**
  56159. * Returns the animatable textures.
  56160. * @param animatables Array of animatable textures.
  56161. */
  56162. getAnimatables(animatables: IAnimatable[]): void;
  56163. /**
  56164. * Disposes the resources of the material.
  56165. * @param forceDisposeTextures - Forces the disposal of all textures.
  56166. */
  56167. dispose(forceDisposeTextures?: boolean): void;
  56168. /**
  56169. * Get the current class name of the texture useful for serialization or dynamic coding.
  56170. * @returns "PBRSubSurfaceConfiguration"
  56171. */
  56172. getClassName(): string;
  56173. /**
  56174. * Add fallbacks to the effect fallbacks list.
  56175. * @param defines defines the Base texture to use.
  56176. * @param fallbacks defines the current fallback list.
  56177. * @param currentRank defines the current fallback rank.
  56178. * @returns the new fallback rank.
  56179. */
  56180. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56181. /**
  56182. * Add the required uniforms to the current list.
  56183. * @param uniforms defines the current uniform list.
  56184. */
  56185. static AddUniforms(uniforms: string[]): void;
  56186. /**
  56187. * Add the required samplers to the current list.
  56188. * @param samplers defines the current sampler list.
  56189. */
  56190. static AddSamplers(samplers: string[]): void;
  56191. /**
  56192. * Add the required uniforms to the current buffer.
  56193. * @param uniformBuffer defines the current uniform buffer.
  56194. */
  56195. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56196. /**
  56197. * Makes a duplicate of the current configuration into another one.
  56198. * @param configuration define the config where to copy the info
  56199. */
  56200. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56201. /**
  56202. * Serializes this Sub Surface configuration.
  56203. * @returns - An object with the serialized config.
  56204. */
  56205. serialize(): any;
  56206. /**
  56207. * Parses a anisotropy Configuration from a serialized object.
  56208. * @param source - Serialized object.
  56209. * @param scene Defines the scene we are parsing for
  56210. * @param rootUrl Defines the rootUrl to load from
  56211. */
  56212. parse(source: any, scene: Scene, rootUrl: string): void;
  56213. }
  56214. }
  56215. declare module BABYLON {
  56216. /** @hidden */
  56217. export var pbrFragmentDeclaration: {
  56218. name: string;
  56219. shader: string;
  56220. };
  56221. }
  56222. declare module BABYLON {
  56223. /** @hidden */
  56224. export var pbrUboDeclaration: {
  56225. name: string;
  56226. shader: string;
  56227. };
  56228. }
  56229. declare module BABYLON {
  56230. /** @hidden */
  56231. export var pbrFragmentExtraDeclaration: {
  56232. name: string;
  56233. shader: string;
  56234. };
  56235. }
  56236. declare module BABYLON {
  56237. /** @hidden */
  56238. export var pbrFragmentSamplersDeclaration: {
  56239. name: string;
  56240. shader: string;
  56241. };
  56242. }
  56243. declare module BABYLON {
  56244. /** @hidden */
  56245. export var importanceSampling: {
  56246. name: string;
  56247. shader: string;
  56248. };
  56249. }
  56250. declare module BABYLON {
  56251. /** @hidden */
  56252. export var pbrHelperFunctions: {
  56253. name: string;
  56254. shader: string;
  56255. };
  56256. }
  56257. declare module BABYLON {
  56258. /** @hidden */
  56259. export var harmonicsFunctions: {
  56260. name: string;
  56261. shader: string;
  56262. };
  56263. }
  56264. declare module BABYLON {
  56265. /** @hidden */
  56266. export var pbrDirectLightingSetupFunctions: {
  56267. name: string;
  56268. shader: string;
  56269. };
  56270. }
  56271. declare module BABYLON {
  56272. /** @hidden */
  56273. export var pbrDirectLightingFalloffFunctions: {
  56274. name: string;
  56275. shader: string;
  56276. };
  56277. }
  56278. declare module BABYLON {
  56279. /** @hidden */
  56280. export var pbrBRDFFunctions: {
  56281. name: string;
  56282. shader: string;
  56283. };
  56284. }
  56285. declare module BABYLON {
  56286. /** @hidden */
  56287. export var hdrFilteringFunctions: {
  56288. name: string;
  56289. shader: string;
  56290. };
  56291. }
  56292. declare module BABYLON {
  56293. /** @hidden */
  56294. export var pbrDirectLightingFunctions: {
  56295. name: string;
  56296. shader: string;
  56297. };
  56298. }
  56299. declare module BABYLON {
  56300. /** @hidden */
  56301. export var pbrIBLFunctions: {
  56302. name: string;
  56303. shader: string;
  56304. };
  56305. }
  56306. declare module BABYLON {
  56307. /** @hidden */
  56308. export var pbrBlockAlbedoOpacity: {
  56309. name: string;
  56310. shader: string;
  56311. };
  56312. }
  56313. declare module BABYLON {
  56314. /** @hidden */
  56315. export var pbrBlockReflectivity: {
  56316. name: string;
  56317. shader: string;
  56318. };
  56319. }
  56320. declare module BABYLON {
  56321. /** @hidden */
  56322. export var pbrBlockAmbientOcclusion: {
  56323. name: string;
  56324. shader: string;
  56325. };
  56326. }
  56327. declare module BABYLON {
  56328. /** @hidden */
  56329. export var pbrBlockAlphaFresnel: {
  56330. name: string;
  56331. shader: string;
  56332. };
  56333. }
  56334. declare module BABYLON {
  56335. /** @hidden */
  56336. export var pbrBlockAnisotropic: {
  56337. name: string;
  56338. shader: string;
  56339. };
  56340. }
  56341. declare module BABYLON {
  56342. /** @hidden */
  56343. export var pbrBlockReflection: {
  56344. name: string;
  56345. shader: string;
  56346. };
  56347. }
  56348. declare module BABYLON {
  56349. /** @hidden */
  56350. export var pbrBlockSheen: {
  56351. name: string;
  56352. shader: string;
  56353. };
  56354. }
  56355. declare module BABYLON {
  56356. /** @hidden */
  56357. export var pbrBlockClearcoat: {
  56358. name: string;
  56359. shader: string;
  56360. };
  56361. }
  56362. declare module BABYLON {
  56363. /** @hidden */
  56364. export var pbrBlockSubSurface: {
  56365. name: string;
  56366. shader: string;
  56367. };
  56368. }
  56369. declare module BABYLON {
  56370. /** @hidden */
  56371. export var pbrBlockNormalGeometric: {
  56372. name: string;
  56373. shader: string;
  56374. };
  56375. }
  56376. declare module BABYLON {
  56377. /** @hidden */
  56378. export var pbrBlockNormalFinal: {
  56379. name: string;
  56380. shader: string;
  56381. };
  56382. }
  56383. declare module BABYLON {
  56384. /** @hidden */
  56385. export var pbrBlockLightmapInit: {
  56386. name: string;
  56387. shader: string;
  56388. };
  56389. }
  56390. declare module BABYLON {
  56391. /** @hidden */
  56392. export var pbrBlockGeometryInfo: {
  56393. name: string;
  56394. shader: string;
  56395. };
  56396. }
  56397. declare module BABYLON {
  56398. /** @hidden */
  56399. export var pbrBlockReflectance0: {
  56400. name: string;
  56401. shader: string;
  56402. };
  56403. }
  56404. declare module BABYLON {
  56405. /** @hidden */
  56406. export var pbrBlockReflectance: {
  56407. name: string;
  56408. shader: string;
  56409. };
  56410. }
  56411. declare module BABYLON {
  56412. /** @hidden */
  56413. export var pbrBlockDirectLighting: {
  56414. name: string;
  56415. shader: string;
  56416. };
  56417. }
  56418. declare module BABYLON {
  56419. /** @hidden */
  56420. export var pbrBlockFinalLitComponents: {
  56421. name: string;
  56422. shader: string;
  56423. };
  56424. }
  56425. declare module BABYLON {
  56426. /** @hidden */
  56427. export var pbrBlockFinalUnlitComponents: {
  56428. name: string;
  56429. shader: string;
  56430. };
  56431. }
  56432. declare module BABYLON {
  56433. /** @hidden */
  56434. export var pbrBlockFinalColorComposition: {
  56435. name: string;
  56436. shader: string;
  56437. };
  56438. }
  56439. declare module BABYLON {
  56440. /** @hidden */
  56441. export var pbrBlockImageProcessing: {
  56442. name: string;
  56443. shader: string;
  56444. };
  56445. }
  56446. declare module BABYLON {
  56447. /** @hidden */
  56448. export var pbrDebug: {
  56449. name: string;
  56450. shader: string;
  56451. };
  56452. }
  56453. declare module BABYLON {
  56454. /** @hidden */
  56455. export var pbrPixelShader: {
  56456. name: string;
  56457. shader: string;
  56458. };
  56459. }
  56460. declare module BABYLON {
  56461. /** @hidden */
  56462. export var pbrVertexDeclaration: {
  56463. name: string;
  56464. shader: string;
  56465. };
  56466. }
  56467. declare module BABYLON {
  56468. /** @hidden */
  56469. export var pbrVertexShader: {
  56470. name: string;
  56471. shader: string;
  56472. };
  56473. }
  56474. declare module BABYLON {
  56475. /**
  56476. * Manages the defines for the PBR Material.
  56477. * @hidden
  56478. */
  56479. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56480. PBR: boolean;
  56481. NUM_SAMPLES: string;
  56482. REALTIME_FILTERING: boolean;
  56483. MAINUV1: boolean;
  56484. MAINUV2: boolean;
  56485. UV1: boolean;
  56486. UV2: boolean;
  56487. ALBEDO: boolean;
  56488. GAMMAALBEDO: boolean;
  56489. ALBEDODIRECTUV: number;
  56490. VERTEXCOLOR: boolean;
  56491. DETAIL: boolean;
  56492. DETAILDIRECTUV: number;
  56493. DETAIL_NORMALBLENDMETHOD: number;
  56494. AMBIENT: boolean;
  56495. AMBIENTDIRECTUV: number;
  56496. AMBIENTINGRAYSCALE: boolean;
  56497. OPACITY: boolean;
  56498. VERTEXALPHA: boolean;
  56499. OPACITYDIRECTUV: number;
  56500. OPACITYRGB: boolean;
  56501. ALPHATEST: boolean;
  56502. DEPTHPREPASS: boolean;
  56503. ALPHABLEND: boolean;
  56504. ALPHAFROMALBEDO: boolean;
  56505. ALPHATESTVALUE: string;
  56506. SPECULAROVERALPHA: boolean;
  56507. RADIANCEOVERALPHA: boolean;
  56508. ALPHAFRESNEL: boolean;
  56509. LINEARALPHAFRESNEL: boolean;
  56510. PREMULTIPLYALPHA: boolean;
  56511. EMISSIVE: boolean;
  56512. EMISSIVEDIRECTUV: number;
  56513. REFLECTIVITY: boolean;
  56514. REFLECTIVITYDIRECTUV: number;
  56515. SPECULARTERM: boolean;
  56516. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56517. MICROSURFACEAUTOMATIC: boolean;
  56518. LODBASEDMICROSFURACE: boolean;
  56519. MICROSURFACEMAP: boolean;
  56520. MICROSURFACEMAPDIRECTUV: number;
  56521. METALLICWORKFLOW: boolean;
  56522. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56523. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56524. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56525. AOSTOREINMETALMAPRED: boolean;
  56526. METALLIC_REFLECTANCE: boolean;
  56527. METALLIC_REFLECTANCEDIRECTUV: number;
  56528. ENVIRONMENTBRDF: boolean;
  56529. ENVIRONMENTBRDF_RGBD: boolean;
  56530. NORMAL: boolean;
  56531. TANGENT: boolean;
  56532. BUMP: boolean;
  56533. BUMPDIRECTUV: number;
  56534. OBJECTSPACE_NORMALMAP: boolean;
  56535. PARALLAX: boolean;
  56536. PARALLAXOCCLUSION: boolean;
  56537. NORMALXYSCALE: boolean;
  56538. LIGHTMAP: boolean;
  56539. LIGHTMAPDIRECTUV: number;
  56540. USELIGHTMAPASSHADOWMAP: boolean;
  56541. GAMMALIGHTMAP: boolean;
  56542. RGBDLIGHTMAP: boolean;
  56543. REFLECTION: boolean;
  56544. REFLECTIONMAP_3D: boolean;
  56545. REFLECTIONMAP_SPHERICAL: boolean;
  56546. REFLECTIONMAP_PLANAR: boolean;
  56547. REFLECTIONMAP_CUBIC: boolean;
  56548. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56549. REFLECTIONMAP_PROJECTION: boolean;
  56550. REFLECTIONMAP_SKYBOX: boolean;
  56551. REFLECTIONMAP_EXPLICIT: boolean;
  56552. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56553. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56554. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56555. INVERTCUBICMAP: boolean;
  56556. USESPHERICALFROMREFLECTIONMAP: boolean;
  56557. USEIRRADIANCEMAP: boolean;
  56558. SPHERICAL_HARMONICS: boolean;
  56559. USESPHERICALINVERTEX: boolean;
  56560. REFLECTIONMAP_OPPOSITEZ: boolean;
  56561. LODINREFLECTIONALPHA: boolean;
  56562. GAMMAREFLECTION: boolean;
  56563. RGBDREFLECTION: boolean;
  56564. LINEARSPECULARREFLECTION: boolean;
  56565. RADIANCEOCCLUSION: boolean;
  56566. HORIZONOCCLUSION: boolean;
  56567. INSTANCES: boolean;
  56568. THIN_INSTANCES: boolean;
  56569. PREPASS: boolean;
  56570. SCENE_MRT_COUNT: number;
  56571. NUM_BONE_INFLUENCERS: number;
  56572. BonesPerMesh: number;
  56573. BONETEXTURE: boolean;
  56574. NONUNIFORMSCALING: boolean;
  56575. MORPHTARGETS: boolean;
  56576. MORPHTARGETS_NORMAL: boolean;
  56577. MORPHTARGETS_TANGENT: boolean;
  56578. MORPHTARGETS_UV: boolean;
  56579. NUM_MORPH_INFLUENCERS: number;
  56580. IMAGEPROCESSING: boolean;
  56581. VIGNETTE: boolean;
  56582. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56583. VIGNETTEBLENDMODEOPAQUE: boolean;
  56584. TONEMAPPING: boolean;
  56585. TONEMAPPING_ACES: boolean;
  56586. CONTRAST: boolean;
  56587. COLORCURVES: boolean;
  56588. COLORGRADING: boolean;
  56589. COLORGRADING3D: boolean;
  56590. SAMPLER3DGREENDEPTH: boolean;
  56591. SAMPLER3DBGRMAP: boolean;
  56592. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56593. EXPOSURE: boolean;
  56594. MULTIVIEW: boolean;
  56595. USEPHYSICALLIGHTFALLOFF: boolean;
  56596. USEGLTFLIGHTFALLOFF: boolean;
  56597. TWOSIDEDLIGHTING: boolean;
  56598. SHADOWFLOAT: boolean;
  56599. CLIPPLANE: boolean;
  56600. CLIPPLANE2: boolean;
  56601. CLIPPLANE3: boolean;
  56602. CLIPPLANE4: boolean;
  56603. CLIPPLANE5: boolean;
  56604. CLIPPLANE6: boolean;
  56605. POINTSIZE: boolean;
  56606. FOG: boolean;
  56607. LOGARITHMICDEPTH: boolean;
  56608. FORCENORMALFORWARD: boolean;
  56609. SPECULARAA: boolean;
  56610. CLEARCOAT: boolean;
  56611. CLEARCOAT_DEFAULTIOR: boolean;
  56612. CLEARCOAT_TEXTURE: boolean;
  56613. CLEARCOAT_TEXTUREDIRECTUV: number;
  56614. CLEARCOAT_BUMP: boolean;
  56615. CLEARCOAT_BUMPDIRECTUV: number;
  56616. CLEARCOAT_TINT: boolean;
  56617. CLEARCOAT_TINT_TEXTURE: boolean;
  56618. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56619. ANISOTROPIC: boolean;
  56620. ANISOTROPIC_TEXTURE: boolean;
  56621. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56622. BRDF_V_HEIGHT_CORRELATED: boolean;
  56623. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56624. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56625. SHEEN: boolean;
  56626. SHEEN_TEXTURE: boolean;
  56627. SHEEN_TEXTUREDIRECTUV: number;
  56628. SHEEN_LINKWITHALBEDO: boolean;
  56629. SHEEN_ROUGHNESS: boolean;
  56630. SHEEN_ALBEDOSCALING: boolean;
  56631. SUBSURFACE: boolean;
  56632. SS_REFRACTION: boolean;
  56633. SS_TRANSLUCENCY: boolean;
  56634. SS_SCATTERING: boolean;
  56635. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56636. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56637. SS_REFRACTIONMAP_3D: boolean;
  56638. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56639. SS_LODINREFRACTIONALPHA: boolean;
  56640. SS_GAMMAREFRACTION: boolean;
  56641. SS_RGBDREFRACTION: boolean;
  56642. SS_LINEARSPECULARREFRACTION: boolean;
  56643. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56644. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56645. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56646. UNLIT: boolean;
  56647. DEBUGMODE: number;
  56648. /**
  56649. * Initializes the PBR Material defines.
  56650. */
  56651. constructor();
  56652. /**
  56653. * Resets the PBR Material defines.
  56654. */
  56655. reset(): void;
  56656. }
  56657. /**
  56658. * The Physically based material base class of BJS.
  56659. *
  56660. * This offers the main features of a standard PBR material.
  56661. * For more information, please refer to the documentation :
  56662. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56663. */
  56664. export abstract class PBRBaseMaterial extends PushMaterial {
  56665. /**
  56666. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56667. */
  56668. static readonly PBRMATERIAL_OPAQUE: number;
  56669. /**
  56670. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56671. */
  56672. static readonly PBRMATERIAL_ALPHATEST: number;
  56673. /**
  56674. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56675. */
  56676. static readonly PBRMATERIAL_ALPHABLEND: number;
  56677. /**
  56678. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56679. * They are also discarded below the alpha cutoff threshold to improve performances.
  56680. */
  56681. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56682. /**
  56683. * Defines the default value of how much AO map is occluding the analytical lights
  56684. * (point spot...).
  56685. */
  56686. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56687. /**
  56688. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56689. */
  56690. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56691. /**
  56692. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56693. * to enhance interoperability with other engines.
  56694. */
  56695. static readonly LIGHTFALLOFF_GLTF: number;
  56696. /**
  56697. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56698. * to enhance interoperability with other materials.
  56699. */
  56700. static readonly LIGHTFALLOFF_STANDARD: number;
  56701. /**
  56702. * Intensity of the direct lights e.g. the four lights available in your scene.
  56703. * This impacts both the direct diffuse and specular highlights.
  56704. */
  56705. protected _directIntensity: number;
  56706. /**
  56707. * Intensity of the emissive part of the material.
  56708. * This helps controlling the emissive effect without modifying the emissive color.
  56709. */
  56710. protected _emissiveIntensity: number;
  56711. /**
  56712. * Intensity of the environment e.g. how much the environment will light the object
  56713. * either through harmonics for rough material or through the refelction for shiny ones.
  56714. */
  56715. protected _environmentIntensity: number;
  56716. /**
  56717. * This is a special control allowing the reduction of the specular highlights coming from the
  56718. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56719. */
  56720. protected _specularIntensity: number;
  56721. /**
  56722. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56723. */
  56724. private _lightingInfos;
  56725. /**
  56726. * Debug Control allowing disabling the bump map on this material.
  56727. */
  56728. protected _disableBumpMap: boolean;
  56729. /**
  56730. * AKA Diffuse Texture in standard nomenclature.
  56731. */
  56732. protected _albedoTexture: Nullable<BaseTexture>;
  56733. /**
  56734. * AKA Occlusion Texture in other nomenclature.
  56735. */
  56736. protected _ambientTexture: Nullable<BaseTexture>;
  56737. /**
  56738. * AKA Occlusion Texture Intensity in other nomenclature.
  56739. */
  56740. protected _ambientTextureStrength: number;
  56741. /**
  56742. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56743. * 1 means it completely occludes it
  56744. * 0 mean it has no impact
  56745. */
  56746. protected _ambientTextureImpactOnAnalyticalLights: number;
  56747. /**
  56748. * Stores the alpha values in a texture.
  56749. */
  56750. protected _opacityTexture: Nullable<BaseTexture>;
  56751. /**
  56752. * Stores the reflection values in a texture.
  56753. */
  56754. protected _reflectionTexture: Nullable<BaseTexture>;
  56755. /**
  56756. * Stores the emissive values in a texture.
  56757. */
  56758. protected _emissiveTexture: Nullable<BaseTexture>;
  56759. /**
  56760. * AKA Specular texture in other nomenclature.
  56761. */
  56762. protected _reflectivityTexture: Nullable<BaseTexture>;
  56763. /**
  56764. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56765. */
  56766. protected _metallicTexture: Nullable<BaseTexture>;
  56767. /**
  56768. * Specifies the metallic scalar of the metallic/roughness workflow.
  56769. * Can also be used to scale the metalness values of the metallic texture.
  56770. */
  56771. protected _metallic: Nullable<number>;
  56772. /**
  56773. * Specifies the roughness scalar of the metallic/roughness workflow.
  56774. * Can also be used to scale the roughness values of the metallic texture.
  56775. */
  56776. protected _roughness: Nullable<number>;
  56777. /**
  56778. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56779. * By default the indexOfrefraction is used to compute F0;
  56780. *
  56781. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56782. *
  56783. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56784. * F90 = metallicReflectanceColor;
  56785. */
  56786. protected _metallicF0Factor: number;
  56787. /**
  56788. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56789. * By default the F90 is always 1;
  56790. *
  56791. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56792. *
  56793. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56794. * F90 = metallicReflectanceColor;
  56795. */
  56796. protected _metallicReflectanceColor: Color3;
  56797. /**
  56798. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56799. * This is multiply against the scalar values defined in the material.
  56800. */
  56801. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56802. /**
  56803. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56804. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56805. */
  56806. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56807. /**
  56808. * Stores surface normal data used to displace a mesh in a texture.
  56809. */
  56810. protected _bumpTexture: Nullable<BaseTexture>;
  56811. /**
  56812. * Stores the pre-calculated light information of a mesh in a texture.
  56813. */
  56814. protected _lightmapTexture: Nullable<BaseTexture>;
  56815. /**
  56816. * The color of a material in ambient lighting.
  56817. */
  56818. protected _ambientColor: Color3;
  56819. /**
  56820. * AKA Diffuse Color in other nomenclature.
  56821. */
  56822. protected _albedoColor: Color3;
  56823. /**
  56824. * AKA Specular Color in other nomenclature.
  56825. */
  56826. protected _reflectivityColor: Color3;
  56827. /**
  56828. * The color applied when light is reflected from a material.
  56829. */
  56830. protected _reflectionColor: Color3;
  56831. /**
  56832. * The color applied when light is emitted from a material.
  56833. */
  56834. protected _emissiveColor: Color3;
  56835. /**
  56836. * AKA Glossiness in other nomenclature.
  56837. */
  56838. protected _microSurface: number;
  56839. /**
  56840. * Specifies that the material will use the light map as a show map.
  56841. */
  56842. protected _useLightmapAsShadowmap: boolean;
  56843. /**
  56844. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56845. * makes the reflect vector face the model (under horizon).
  56846. */
  56847. protected _useHorizonOcclusion: boolean;
  56848. /**
  56849. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56850. * too much the area relying on ambient texture to define their ambient occlusion.
  56851. */
  56852. protected _useRadianceOcclusion: boolean;
  56853. /**
  56854. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56855. */
  56856. protected _useAlphaFromAlbedoTexture: boolean;
  56857. /**
  56858. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56859. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56860. */
  56861. protected _useSpecularOverAlpha: boolean;
  56862. /**
  56863. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56864. */
  56865. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56866. /**
  56867. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56868. */
  56869. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56870. /**
  56871. * Specifies if the metallic texture contains the roughness information in its green channel.
  56872. */
  56873. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56874. /**
  56875. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56876. */
  56877. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56878. /**
  56879. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56880. */
  56881. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56882. /**
  56883. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56884. */
  56885. protected _useAmbientInGrayScale: boolean;
  56886. /**
  56887. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56888. * The material will try to infer what glossiness each pixel should be.
  56889. */
  56890. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56891. /**
  56892. * Defines the falloff type used in this material.
  56893. * It by default is Physical.
  56894. */
  56895. protected _lightFalloff: number;
  56896. /**
  56897. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56898. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56899. */
  56900. protected _useRadianceOverAlpha: boolean;
  56901. /**
  56902. * Allows using an object space normal map (instead of tangent space).
  56903. */
  56904. protected _useObjectSpaceNormalMap: boolean;
  56905. /**
  56906. * Allows using the bump map in parallax mode.
  56907. */
  56908. protected _useParallax: boolean;
  56909. /**
  56910. * Allows using the bump map in parallax occlusion mode.
  56911. */
  56912. protected _useParallaxOcclusion: boolean;
  56913. /**
  56914. * Controls the scale bias of the parallax mode.
  56915. */
  56916. protected _parallaxScaleBias: number;
  56917. /**
  56918. * If sets to true, disables all the lights affecting the material.
  56919. */
  56920. protected _disableLighting: boolean;
  56921. /**
  56922. * Number of Simultaneous lights allowed on the material.
  56923. */
  56924. protected _maxSimultaneousLights: number;
  56925. /**
  56926. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56927. */
  56928. protected _invertNormalMapX: boolean;
  56929. /**
  56930. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56931. */
  56932. protected _invertNormalMapY: boolean;
  56933. /**
  56934. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56935. */
  56936. protected _twoSidedLighting: boolean;
  56937. /**
  56938. * Defines the alpha limits in alpha test mode.
  56939. */
  56940. protected _alphaCutOff: number;
  56941. /**
  56942. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56943. */
  56944. protected _forceAlphaTest: boolean;
  56945. /**
  56946. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56947. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56948. */
  56949. protected _useAlphaFresnel: boolean;
  56950. /**
  56951. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56952. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56953. */
  56954. protected _useLinearAlphaFresnel: boolean;
  56955. /**
  56956. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56957. * from cos thetav and roughness:
  56958. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56959. */
  56960. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56961. /**
  56962. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56963. */
  56964. protected _forceIrradianceInFragment: boolean;
  56965. private _realTimeFiltering;
  56966. /**
  56967. * Enables realtime filtering on the texture.
  56968. */
  56969. get realTimeFiltering(): boolean;
  56970. set realTimeFiltering(b: boolean);
  56971. private _realTimeFilteringQuality;
  56972. /**
  56973. * Quality switch for realtime filtering
  56974. */
  56975. get realTimeFilteringQuality(): number;
  56976. set realTimeFilteringQuality(n: number);
  56977. /**
  56978. * Can this material render to several textures at once
  56979. */
  56980. get canRenderToMRT(): boolean;
  56981. /**
  56982. * Force normal to face away from face.
  56983. */
  56984. protected _forceNormalForward: boolean;
  56985. /**
  56986. * Enables specular anti aliasing in the PBR shader.
  56987. * It will both interacts on the Geometry for analytical and IBL lighting.
  56988. * It also prefilter the roughness map based on the bump values.
  56989. */
  56990. protected _enableSpecularAntiAliasing: boolean;
  56991. /**
  56992. * Default configuration related to image processing available in the PBR Material.
  56993. */
  56994. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56995. /**
  56996. * Keep track of the image processing observer to allow dispose and replace.
  56997. */
  56998. private _imageProcessingObserver;
  56999. /**
  57000. * Attaches a new image processing configuration to the PBR Material.
  57001. * @param configuration
  57002. */
  57003. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57004. /**
  57005. * Stores the available render targets.
  57006. */
  57007. private _renderTargets;
  57008. /**
  57009. * Sets the global ambient color for the material used in lighting calculations.
  57010. */
  57011. private _globalAmbientColor;
  57012. /**
  57013. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57014. */
  57015. private _useLogarithmicDepth;
  57016. /**
  57017. * If set to true, no lighting calculations will be applied.
  57018. */
  57019. private _unlit;
  57020. private _debugMode;
  57021. /**
  57022. * @hidden
  57023. * This is reserved for the inspector.
  57024. * Defines the material debug mode.
  57025. * It helps seeing only some components of the material while troubleshooting.
  57026. */
  57027. debugMode: number;
  57028. /**
  57029. * @hidden
  57030. * This is reserved for the inspector.
  57031. * Specify from where on screen the debug mode should start.
  57032. * The value goes from -1 (full screen) to 1 (not visible)
  57033. * It helps with side by side comparison against the final render
  57034. * This defaults to -1
  57035. */
  57036. private debugLimit;
  57037. /**
  57038. * @hidden
  57039. * This is reserved for the inspector.
  57040. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57041. * You can use the factor to better multiply the final value.
  57042. */
  57043. private debugFactor;
  57044. /**
  57045. * Defines the clear coat layer parameters for the material.
  57046. */
  57047. readonly clearCoat: PBRClearCoatConfiguration;
  57048. /**
  57049. * Defines the anisotropic parameters for the material.
  57050. */
  57051. readonly anisotropy: PBRAnisotropicConfiguration;
  57052. /**
  57053. * Defines the BRDF parameters for the material.
  57054. */
  57055. readonly brdf: PBRBRDFConfiguration;
  57056. /**
  57057. * Defines the Sheen parameters for the material.
  57058. */
  57059. readonly sheen: PBRSheenConfiguration;
  57060. /**
  57061. * Defines the SubSurface parameters for the material.
  57062. */
  57063. readonly subSurface: PBRSubSurfaceConfiguration;
  57064. /**
  57065. * Defines the detail map parameters for the material.
  57066. */
  57067. readonly detailMap: DetailMapConfiguration;
  57068. protected _rebuildInParallel: boolean;
  57069. /**
  57070. * Instantiates a new PBRMaterial instance.
  57071. *
  57072. * @param name The material name
  57073. * @param scene The scene the material will be use in.
  57074. */
  57075. constructor(name: string, scene: Scene);
  57076. /**
  57077. * Gets a boolean indicating that current material needs to register RTT
  57078. */
  57079. get hasRenderTargetTextures(): boolean;
  57080. /**
  57081. * Gets the name of the material class.
  57082. */
  57083. getClassName(): string;
  57084. /**
  57085. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57086. */
  57087. get useLogarithmicDepth(): boolean;
  57088. /**
  57089. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57090. */
  57091. set useLogarithmicDepth(value: boolean);
  57092. /**
  57093. * Returns true if alpha blending should be disabled.
  57094. */
  57095. protected get _disableAlphaBlending(): boolean;
  57096. /**
  57097. * Specifies whether or not this material should be rendered in alpha blend mode.
  57098. */
  57099. needAlphaBlending(): boolean;
  57100. /**
  57101. * Specifies whether or not this material should be rendered in alpha test mode.
  57102. */
  57103. needAlphaTesting(): boolean;
  57104. /**
  57105. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57106. */
  57107. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57108. /**
  57109. * Gets the texture used for the alpha test.
  57110. */
  57111. getAlphaTestTexture(): Nullable<BaseTexture>;
  57112. /**
  57113. * Specifies that the submesh is ready to be used.
  57114. * @param mesh - BJS mesh.
  57115. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57116. * @param useInstances - Specifies that instances should be used.
  57117. * @returns - boolean indicating that the submesh is ready or not.
  57118. */
  57119. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57120. /**
  57121. * Specifies if the material uses metallic roughness workflow.
  57122. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57123. */
  57124. isMetallicWorkflow(): boolean;
  57125. private _prepareEffect;
  57126. private _prepareDefines;
  57127. /**
  57128. * Force shader compilation
  57129. */
  57130. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57131. /**
  57132. * Initializes the uniform buffer layout for the shader.
  57133. */
  57134. buildUniformLayout(): void;
  57135. /**
  57136. * Unbinds the material from the mesh
  57137. */
  57138. unbind(): void;
  57139. /**
  57140. * Binds the submesh data.
  57141. * @param world - The world matrix.
  57142. * @param mesh - The BJS mesh.
  57143. * @param subMesh - A submesh of the BJS mesh.
  57144. */
  57145. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57146. /**
  57147. * Returns the animatable textures.
  57148. * @returns - Array of animatable textures.
  57149. */
  57150. getAnimatables(): IAnimatable[];
  57151. /**
  57152. * Returns the texture used for reflections.
  57153. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57154. */
  57155. private _getReflectionTexture;
  57156. /**
  57157. * Returns an array of the actively used textures.
  57158. * @returns - Array of BaseTextures
  57159. */
  57160. getActiveTextures(): BaseTexture[];
  57161. /**
  57162. * Checks to see if a texture is used in the material.
  57163. * @param texture - Base texture to use.
  57164. * @returns - Boolean specifying if a texture is used in the material.
  57165. */
  57166. hasTexture(texture: BaseTexture): boolean;
  57167. /**
  57168. * Sets the required values to the prepass renderer.
  57169. * @param prePassRenderer defines the prepass renderer to setup
  57170. */
  57171. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  57172. /**
  57173. * Disposes the resources of the material.
  57174. * @param forceDisposeEffect - Forces the disposal of effects.
  57175. * @param forceDisposeTextures - Forces the disposal of all textures.
  57176. */
  57177. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57178. }
  57179. }
  57180. declare module BABYLON {
  57181. /**
  57182. * The Physically based material of BJS.
  57183. *
  57184. * This offers the main features of a standard PBR material.
  57185. * For more information, please refer to the documentation :
  57186. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57187. */
  57188. export class PBRMaterial extends PBRBaseMaterial {
  57189. /**
  57190. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57191. */
  57192. static readonly PBRMATERIAL_OPAQUE: number;
  57193. /**
  57194. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57195. */
  57196. static readonly PBRMATERIAL_ALPHATEST: number;
  57197. /**
  57198. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57199. */
  57200. static readonly PBRMATERIAL_ALPHABLEND: number;
  57201. /**
  57202. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57203. * They are also discarded below the alpha cutoff threshold to improve performances.
  57204. */
  57205. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57206. /**
  57207. * Defines the default value of how much AO map is occluding the analytical lights
  57208. * (point spot...).
  57209. */
  57210. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57211. /**
  57212. * Intensity of the direct lights e.g. the four lights available in your scene.
  57213. * This impacts both the direct diffuse and specular highlights.
  57214. */
  57215. directIntensity: number;
  57216. /**
  57217. * Intensity of the emissive part of the material.
  57218. * This helps controlling the emissive effect without modifying the emissive color.
  57219. */
  57220. emissiveIntensity: number;
  57221. /**
  57222. * Intensity of the environment e.g. how much the environment will light the object
  57223. * either through harmonics for rough material or through the refelction for shiny ones.
  57224. */
  57225. environmentIntensity: number;
  57226. /**
  57227. * This is a special control allowing the reduction of the specular highlights coming from the
  57228. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57229. */
  57230. specularIntensity: number;
  57231. /**
  57232. * Debug Control allowing disabling the bump map on this material.
  57233. */
  57234. disableBumpMap: boolean;
  57235. /**
  57236. * AKA Diffuse Texture in standard nomenclature.
  57237. */
  57238. albedoTexture: BaseTexture;
  57239. /**
  57240. * AKA Occlusion Texture in other nomenclature.
  57241. */
  57242. ambientTexture: BaseTexture;
  57243. /**
  57244. * AKA Occlusion Texture Intensity in other nomenclature.
  57245. */
  57246. ambientTextureStrength: number;
  57247. /**
  57248. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57249. * 1 means it completely occludes it
  57250. * 0 mean it has no impact
  57251. */
  57252. ambientTextureImpactOnAnalyticalLights: number;
  57253. /**
  57254. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57255. */
  57256. opacityTexture: BaseTexture;
  57257. /**
  57258. * Stores the reflection values in a texture.
  57259. */
  57260. reflectionTexture: Nullable<BaseTexture>;
  57261. /**
  57262. * Stores the emissive values in a texture.
  57263. */
  57264. emissiveTexture: BaseTexture;
  57265. /**
  57266. * AKA Specular texture in other nomenclature.
  57267. */
  57268. reflectivityTexture: BaseTexture;
  57269. /**
  57270. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57271. */
  57272. metallicTexture: BaseTexture;
  57273. /**
  57274. * Specifies the metallic scalar of the metallic/roughness workflow.
  57275. * Can also be used to scale the metalness values of the metallic texture.
  57276. */
  57277. metallic: Nullable<number>;
  57278. /**
  57279. * Specifies the roughness scalar of the metallic/roughness workflow.
  57280. * Can also be used to scale the roughness values of the metallic texture.
  57281. */
  57282. roughness: Nullable<number>;
  57283. /**
  57284. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57285. * By default the indexOfrefraction is used to compute F0;
  57286. *
  57287. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57288. *
  57289. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57290. * F90 = metallicReflectanceColor;
  57291. */
  57292. metallicF0Factor: number;
  57293. /**
  57294. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57295. * By default the F90 is always 1;
  57296. *
  57297. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57298. *
  57299. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57300. * F90 = metallicReflectanceColor;
  57301. */
  57302. metallicReflectanceColor: Color3;
  57303. /**
  57304. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57305. * This is multiply against the scalar values defined in the material.
  57306. */
  57307. metallicReflectanceTexture: Nullable<BaseTexture>;
  57308. /**
  57309. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57310. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57311. */
  57312. microSurfaceTexture: BaseTexture;
  57313. /**
  57314. * Stores surface normal data used to displace a mesh in a texture.
  57315. */
  57316. bumpTexture: BaseTexture;
  57317. /**
  57318. * Stores the pre-calculated light information of a mesh in a texture.
  57319. */
  57320. lightmapTexture: BaseTexture;
  57321. /**
  57322. * Stores the refracted light information in a texture.
  57323. */
  57324. get refractionTexture(): Nullable<BaseTexture>;
  57325. set refractionTexture(value: Nullable<BaseTexture>);
  57326. /**
  57327. * The color of a material in ambient lighting.
  57328. */
  57329. ambientColor: Color3;
  57330. /**
  57331. * AKA Diffuse Color in other nomenclature.
  57332. */
  57333. albedoColor: Color3;
  57334. /**
  57335. * AKA Specular Color in other nomenclature.
  57336. */
  57337. reflectivityColor: Color3;
  57338. /**
  57339. * The color reflected from the material.
  57340. */
  57341. reflectionColor: Color3;
  57342. /**
  57343. * The color emitted from the material.
  57344. */
  57345. emissiveColor: Color3;
  57346. /**
  57347. * AKA Glossiness in other nomenclature.
  57348. */
  57349. microSurface: number;
  57350. /**
  57351. * Index of refraction of the material base layer.
  57352. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57353. *
  57354. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57355. *
  57356. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57357. */
  57358. get indexOfRefraction(): number;
  57359. set indexOfRefraction(value: number);
  57360. /**
  57361. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57362. */
  57363. get invertRefractionY(): boolean;
  57364. set invertRefractionY(value: boolean);
  57365. /**
  57366. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57367. * Materials half opaque for instance using refraction could benefit from this control.
  57368. */
  57369. get linkRefractionWithTransparency(): boolean;
  57370. set linkRefractionWithTransparency(value: boolean);
  57371. /**
  57372. * If true, the light map contains occlusion information instead of lighting info.
  57373. */
  57374. useLightmapAsShadowmap: boolean;
  57375. /**
  57376. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57377. */
  57378. useAlphaFromAlbedoTexture: boolean;
  57379. /**
  57380. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57381. */
  57382. forceAlphaTest: boolean;
  57383. /**
  57384. * Defines the alpha limits in alpha test mode.
  57385. */
  57386. alphaCutOff: number;
  57387. /**
  57388. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57389. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57390. */
  57391. useSpecularOverAlpha: boolean;
  57392. /**
  57393. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57394. */
  57395. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57396. /**
  57397. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57398. */
  57399. useRoughnessFromMetallicTextureAlpha: boolean;
  57400. /**
  57401. * Specifies if the metallic texture contains the roughness information in its green channel.
  57402. */
  57403. useRoughnessFromMetallicTextureGreen: boolean;
  57404. /**
  57405. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57406. */
  57407. useMetallnessFromMetallicTextureBlue: boolean;
  57408. /**
  57409. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57410. */
  57411. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57412. /**
  57413. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57414. */
  57415. useAmbientInGrayScale: boolean;
  57416. /**
  57417. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57418. * The material will try to infer what glossiness each pixel should be.
  57419. */
  57420. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57421. /**
  57422. * BJS is using an harcoded light falloff based on a manually sets up range.
  57423. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57424. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57425. */
  57426. get usePhysicalLightFalloff(): boolean;
  57427. /**
  57428. * BJS is using an harcoded light falloff based on a manually sets up range.
  57429. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57430. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57431. */
  57432. set usePhysicalLightFalloff(value: boolean);
  57433. /**
  57434. * In order to support the falloff compatibility with gltf, a special mode has been added
  57435. * to reproduce the gltf light falloff.
  57436. */
  57437. get useGLTFLightFalloff(): boolean;
  57438. /**
  57439. * In order to support the falloff compatibility with gltf, a special mode has been added
  57440. * to reproduce the gltf light falloff.
  57441. */
  57442. set useGLTFLightFalloff(value: boolean);
  57443. /**
  57444. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57445. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57446. */
  57447. useRadianceOverAlpha: boolean;
  57448. /**
  57449. * Allows using an object space normal map (instead of tangent space).
  57450. */
  57451. useObjectSpaceNormalMap: boolean;
  57452. /**
  57453. * Allows using the bump map in parallax mode.
  57454. */
  57455. useParallax: boolean;
  57456. /**
  57457. * Allows using the bump map in parallax occlusion mode.
  57458. */
  57459. useParallaxOcclusion: boolean;
  57460. /**
  57461. * Controls the scale bias of the parallax mode.
  57462. */
  57463. parallaxScaleBias: number;
  57464. /**
  57465. * If sets to true, disables all the lights affecting the material.
  57466. */
  57467. disableLighting: boolean;
  57468. /**
  57469. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57470. */
  57471. forceIrradianceInFragment: boolean;
  57472. /**
  57473. * Number of Simultaneous lights allowed on the material.
  57474. */
  57475. maxSimultaneousLights: number;
  57476. /**
  57477. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57478. */
  57479. invertNormalMapX: boolean;
  57480. /**
  57481. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57482. */
  57483. invertNormalMapY: boolean;
  57484. /**
  57485. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57486. */
  57487. twoSidedLighting: boolean;
  57488. /**
  57489. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57490. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57491. */
  57492. useAlphaFresnel: boolean;
  57493. /**
  57494. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57495. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57496. */
  57497. useLinearAlphaFresnel: boolean;
  57498. /**
  57499. * Let user defines the brdf lookup texture used for IBL.
  57500. * A default 8bit version is embedded but you could point at :
  57501. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57502. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57503. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57504. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57505. */
  57506. environmentBRDFTexture: Nullable<BaseTexture>;
  57507. /**
  57508. * Force normal to face away from face.
  57509. */
  57510. forceNormalForward: boolean;
  57511. /**
  57512. * Enables specular anti aliasing in the PBR shader.
  57513. * It will both interacts on the Geometry for analytical and IBL lighting.
  57514. * It also prefilter the roughness map based on the bump values.
  57515. */
  57516. enableSpecularAntiAliasing: boolean;
  57517. /**
  57518. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57519. * makes the reflect vector face the model (under horizon).
  57520. */
  57521. useHorizonOcclusion: boolean;
  57522. /**
  57523. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57524. * too much the area relying on ambient texture to define their ambient occlusion.
  57525. */
  57526. useRadianceOcclusion: boolean;
  57527. /**
  57528. * If set to true, no lighting calculations will be applied.
  57529. */
  57530. unlit: boolean;
  57531. /**
  57532. * Gets the image processing configuration used either in this material.
  57533. */
  57534. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57535. /**
  57536. * Sets the Default image processing configuration used either in the this material.
  57537. *
  57538. * If sets to null, the scene one is in use.
  57539. */
  57540. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57541. /**
  57542. * Gets wether the color curves effect is enabled.
  57543. */
  57544. get cameraColorCurvesEnabled(): boolean;
  57545. /**
  57546. * Sets wether the color curves effect is enabled.
  57547. */
  57548. set cameraColorCurvesEnabled(value: boolean);
  57549. /**
  57550. * Gets wether the color grading effect is enabled.
  57551. */
  57552. get cameraColorGradingEnabled(): boolean;
  57553. /**
  57554. * Gets wether the color grading effect is enabled.
  57555. */
  57556. set cameraColorGradingEnabled(value: boolean);
  57557. /**
  57558. * Gets wether tonemapping is enabled or not.
  57559. */
  57560. get cameraToneMappingEnabled(): boolean;
  57561. /**
  57562. * Sets wether tonemapping is enabled or not
  57563. */
  57564. set cameraToneMappingEnabled(value: boolean);
  57565. /**
  57566. * The camera exposure used on this material.
  57567. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57568. * This corresponds to a photographic exposure.
  57569. */
  57570. get cameraExposure(): number;
  57571. /**
  57572. * The camera exposure used on this material.
  57573. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57574. * This corresponds to a photographic exposure.
  57575. */
  57576. set cameraExposure(value: number);
  57577. /**
  57578. * Gets The camera contrast used on this material.
  57579. */
  57580. get cameraContrast(): number;
  57581. /**
  57582. * Sets The camera contrast used on this material.
  57583. */
  57584. set cameraContrast(value: number);
  57585. /**
  57586. * Gets the Color Grading 2D Lookup Texture.
  57587. */
  57588. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57589. /**
  57590. * Sets the Color Grading 2D Lookup Texture.
  57591. */
  57592. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57593. /**
  57594. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57595. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57596. * 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;
  57597. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57598. */
  57599. get cameraColorCurves(): Nullable<ColorCurves>;
  57600. /**
  57601. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57602. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57603. * 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;
  57604. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57605. */
  57606. set cameraColorCurves(value: Nullable<ColorCurves>);
  57607. /**
  57608. * Instantiates a new PBRMaterial instance.
  57609. *
  57610. * @param name The material name
  57611. * @param scene The scene the material will be use in.
  57612. */
  57613. constructor(name: string, scene: Scene);
  57614. /**
  57615. * Returns the name of this material class.
  57616. */
  57617. getClassName(): string;
  57618. /**
  57619. * Makes a duplicate of the current material.
  57620. * @param name - name to use for the new material.
  57621. */
  57622. clone(name: string): PBRMaterial;
  57623. /**
  57624. * Serializes this PBR Material.
  57625. * @returns - An object with the serialized material.
  57626. */
  57627. serialize(): any;
  57628. /**
  57629. * Parses a PBR Material from a serialized object.
  57630. * @param source - Serialized object.
  57631. * @param scene - BJS scene instance.
  57632. * @param rootUrl - url for the scene object
  57633. * @returns - PBRMaterial
  57634. */
  57635. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57636. }
  57637. }
  57638. declare module BABYLON {
  57639. /**
  57640. * Direct draw surface info
  57641. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57642. */
  57643. export interface DDSInfo {
  57644. /**
  57645. * Width of the texture
  57646. */
  57647. width: number;
  57648. /**
  57649. * Width of the texture
  57650. */
  57651. height: number;
  57652. /**
  57653. * Number of Mipmaps for the texture
  57654. * @see https://en.wikipedia.org/wiki/Mipmap
  57655. */
  57656. mipmapCount: number;
  57657. /**
  57658. * If the textures format is a known fourCC format
  57659. * @see https://www.fourcc.org/
  57660. */
  57661. isFourCC: boolean;
  57662. /**
  57663. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57664. */
  57665. isRGB: boolean;
  57666. /**
  57667. * If the texture is a lumincance format
  57668. */
  57669. isLuminance: boolean;
  57670. /**
  57671. * If this is a cube texture
  57672. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57673. */
  57674. isCube: boolean;
  57675. /**
  57676. * If the texture is a compressed format eg. FOURCC_DXT1
  57677. */
  57678. isCompressed: boolean;
  57679. /**
  57680. * The dxgiFormat of the texture
  57681. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57682. */
  57683. dxgiFormat: number;
  57684. /**
  57685. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57686. */
  57687. textureType: number;
  57688. /**
  57689. * Sphericle polynomial created for the dds texture
  57690. */
  57691. sphericalPolynomial?: SphericalPolynomial;
  57692. }
  57693. /**
  57694. * Class used to provide DDS decompression tools
  57695. */
  57696. export class DDSTools {
  57697. /**
  57698. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57699. */
  57700. static StoreLODInAlphaChannel: boolean;
  57701. /**
  57702. * Gets DDS information from an array buffer
  57703. * @param data defines the array buffer view to read data from
  57704. * @returns the DDS information
  57705. */
  57706. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57707. private static _FloatView;
  57708. private static _Int32View;
  57709. private static _ToHalfFloat;
  57710. private static _FromHalfFloat;
  57711. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57712. private static _GetHalfFloatRGBAArrayBuffer;
  57713. private static _GetFloatRGBAArrayBuffer;
  57714. private static _GetFloatAsUIntRGBAArrayBuffer;
  57715. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57716. private static _GetRGBAArrayBuffer;
  57717. private static _ExtractLongWordOrder;
  57718. private static _GetRGBArrayBuffer;
  57719. private static _GetLuminanceArrayBuffer;
  57720. /**
  57721. * Uploads DDS Levels to a Babylon Texture
  57722. * @hidden
  57723. */
  57724. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57725. }
  57726. interface ThinEngine {
  57727. /**
  57728. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57729. * @param rootUrl defines the url where the file to load is located
  57730. * @param scene defines the current scene
  57731. * @param lodScale defines scale to apply to the mip map selection
  57732. * @param lodOffset defines offset to apply to the mip map selection
  57733. * @param onLoad defines an optional callback raised when the texture is loaded
  57734. * @param onError defines an optional callback raised if there is an issue to load the texture
  57735. * @param format defines the format of the data
  57736. * @param forcedExtension defines the extension to use to pick the right loader
  57737. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57738. * @returns the cube texture as an InternalTexture
  57739. */
  57740. 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;
  57741. }
  57742. }
  57743. declare module BABYLON {
  57744. /**
  57745. * Implementation of the DDS Texture Loader.
  57746. * @hidden
  57747. */
  57748. export class _DDSTextureLoader implements IInternalTextureLoader {
  57749. /**
  57750. * Defines wether the loader supports cascade loading the different faces.
  57751. */
  57752. readonly supportCascades: boolean;
  57753. /**
  57754. * This returns if the loader support the current file information.
  57755. * @param extension defines the file extension of the file being loaded
  57756. * @returns true if the loader can load the specified file
  57757. */
  57758. canLoad(extension: string): boolean;
  57759. /**
  57760. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57761. * @param data contains the texture data
  57762. * @param texture defines the BabylonJS internal texture
  57763. * @param createPolynomials will be true if polynomials have been requested
  57764. * @param onLoad defines the callback to trigger once the texture is ready
  57765. * @param onError defines the callback to trigger in case of error
  57766. */
  57767. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57768. /**
  57769. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57770. * @param data contains the texture data
  57771. * @param texture defines the BabylonJS internal texture
  57772. * @param callback defines the method to call once ready to upload
  57773. */
  57774. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57775. }
  57776. }
  57777. declare module BABYLON {
  57778. /**
  57779. * Implementation of the ENV Texture Loader.
  57780. * @hidden
  57781. */
  57782. export class _ENVTextureLoader implements IInternalTextureLoader {
  57783. /**
  57784. * Defines wether the loader supports cascade loading the different faces.
  57785. */
  57786. readonly supportCascades: boolean;
  57787. /**
  57788. * This returns if the loader support the current file information.
  57789. * @param extension defines the file extension of the file being loaded
  57790. * @returns true if the loader can load the specified file
  57791. */
  57792. canLoad(extension: string): boolean;
  57793. /**
  57794. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57795. * @param data contains the texture data
  57796. * @param texture defines the BabylonJS internal texture
  57797. * @param createPolynomials will be true if polynomials have been requested
  57798. * @param onLoad defines the callback to trigger once the texture is ready
  57799. * @param onError defines the callback to trigger in case of error
  57800. */
  57801. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57802. /**
  57803. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57804. * @param data contains the texture data
  57805. * @param texture defines the BabylonJS internal texture
  57806. * @param callback defines the method to call once ready to upload
  57807. */
  57808. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57809. }
  57810. }
  57811. declare module BABYLON {
  57812. /**
  57813. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57814. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57815. */
  57816. export class KhronosTextureContainer {
  57817. /** contents of the KTX container file */
  57818. data: ArrayBufferView;
  57819. private static HEADER_LEN;
  57820. private static COMPRESSED_2D;
  57821. private static COMPRESSED_3D;
  57822. private static TEX_2D;
  57823. private static TEX_3D;
  57824. /**
  57825. * Gets the openGL type
  57826. */
  57827. glType: number;
  57828. /**
  57829. * Gets the openGL type size
  57830. */
  57831. glTypeSize: number;
  57832. /**
  57833. * Gets the openGL format
  57834. */
  57835. glFormat: number;
  57836. /**
  57837. * Gets the openGL internal format
  57838. */
  57839. glInternalFormat: number;
  57840. /**
  57841. * Gets the base internal format
  57842. */
  57843. glBaseInternalFormat: number;
  57844. /**
  57845. * Gets image width in pixel
  57846. */
  57847. pixelWidth: number;
  57848. /**
  57849. * Gets image height in pixel
  57850. */
  57851. pixelHeight: number;
  57852. /**
  57853. * Gets image depth in pixels
  57854. */
  57855. pixelDepth: number;
  57856. /**
  57857. * Gets the number of array elements
  57858. */
  57859. numberOfArrayElements: number;
  57860. /**
  57861. * Gets the number of faces
  57862. */
  57863. numberOfFaces: number;
  57864. /**
  57865. * Gets the number of mipmap levels
  57866. */
  57867. numberOfMipmapLevels: number;
  57868. /**
  57869. * Gets the bytes of key value data
  57870. */
  57871. bytesOfKeyValueData: number;
  57872. /**
  57873. * Gets the load type
  57874. */
  57875. loadType: number;
  57876. /**
  57877. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57878. */
  57879. isInvalid: boolean;
  57880. /**
  57881. * Creates a new KhronosTextureContainer
  57882. * @param data contents of the KTX container file
  57883. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57884. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57885. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57886. */
  57887. constructor(
  57888. /** contents of the KTX container file */
  57889. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57890. /**
  57891. * Uploads KTX content to a Babylon Texture.
  57892. * It is assumed that the texture has already been created & is currently bound
  57893. * @hidden
  57894. */
  57895. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57896. private _upload2DCompressedLevels;
  57897. /**
  57898. * Checks if the given data starts with a KTX file identifier.
  57899. * @param data the data to check
  57900. * @returns true if the data is a KTX file or false otherwise
  57901. */
  57902. static IsValid(data: ArrayBufferView): boolean;
  57903. }
  57904. }
  57905. declare module BABYLON {
  57906. /**
  57907. * Helper class to push actions to a pool of workers.
  57908. */
  57909. export class WorkerPool implements IDisposable {
  57910. private _workerInfos;
  57911. private _pendingActions;
  57912. /**
  57913. * Constructor
  57914. * @param workers Array of workers to use for actions
  57915. */
  57916. constructor(workers: Array<Worker>);
  57917. /**
  57918. * Terminates all workers and clears any pending actions.
  57919. */
  57920. dispose(): void;
  57921. /**
  57922. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57923. * pended until a worker has completed its action.
  57924. * @param action The action to perform. Call onComplete when the action is complete.
  57925. */
  57926. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57927. private _execute;
  57928. }
  57929. }
  57930. declare module BABYLON {
  57931. /**
  57932. * Class for loading KTX2 files
  57933. * @hidden
  57934. */
  57935. export class KhronosTextureContainer2 {
  57936. private static _WorkerPoolPromise?;
  57937. private static _Initialized;
  57938. private static _Ktx2Decoder;
  57939. /**
  57940. * URL to use when loading the KTX2 decoder module
  57941. */
  57942. static JSModuleURL: string;
  57943. /**
  57944. * Default number of workers used to handle data decoding
  57945. */
  57946. static DefaultNumWorkers: number;
  57947. private static GetDefaultNumWorkers;
  57948. private _engine;
  57949. private static _CreateWorkerPool;
  57950. /**
  57951. * Constructor
  57952. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57953. */
  57954. constructor(engine: ThinEngine, numWorkers?: number);
  57955. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57956. /**
  57957. * Stop all async operations and release resources.
  57958. */
  57959. dispose(): void;
  57960. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  57961. /**
  57962. * Checks if the given data starts with a KTX2 file identifier.
  57963. * @param data the data to check
  57964. * @returns true if the data is a KTX2 file or false otherwise
  57965. */
  57966. static IsValid(data: ArrayBufferView): boolean;
  57967. }
  57968. export function workerFunc(): void;
  57969. }
  57970. declare module BABYLON {
  57971. /**
  57972. * Implementation of the KTX Texture Loader.
  57973. * @hidden
  57974. */
  57975. export class _KTXTextureLoader implements IInternalTextureLoader {
  57976. /**
  57977. * Defines wether the loader supports cascade loading the different faces.
  57978. */
  57979. readonly supportCascades: boolean;
  57980. /**
  57981. * This returns if the loader support the current file information.
  57982. * @param extension defines the file extension of the file being loaded
  57983. * @param mimeType defines the optional mime type of the file being loaded
  57984. * @returns true if the loader can load the specified file
  57985. */
  57986. canLoad(extension: string, mimeType?: string): boolean;
  57987. /**
  57988. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57989. * @param data contains the texture data
  57990. * @param texture defines the BabylonJS internal texture
  57991. * @param createPolynomials will be true if polynomials have been requested
  57992. * @param onLoad defines the callback to trigger once the texture is ready
  57993. * @param onError defines the callback to trigger in case of error
  57994. */
  57995. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57996. /**
  57997. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57998. * @param data contains the texture data
  57999. * @param texture defines the BabylonJS internal texture
  58000. * @param callback defines the method to call once ready to upload
  58001. */
  58002. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58003. }
  58004. }
  58005. declare module BABYLON {
  58006. /** @hidden */
  58007. export var _forceSceneHelpersToBundle: boolean;
  58008. interface Scene {
  58009. /**
  58010. * Creates a default light for the scene.
  58011. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58012. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58013. */
  58014. createDefaultLight(replace?: boolean): void;
  58015. /**
  58016. * Creates a default camera for the scene.
  58017. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58018. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58019. * @param replace has default false, when true replaces the active camera in the scene
  58020. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58021. */
  58022. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58023. /**
  58024. * Creates a default camera and a default light.
  58025. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58026. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58027. * @param replace has the default false, when true replaces the active camera/light in the scene
  58028. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58029. */
  58030. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58031. /**
  58032. * Creates a new sky box
  58033. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58034. * @param environmentTexture defines the texture to use as environment texture
  58035. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58036. * @param scale defines the overall scale of the skybox
  58037. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58038. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58039. * @returns a new mesh holding the sky box
  58040. */
  58041. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58042. /**
  58043. * Creates a new environment
  58044. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58045. * @param options defines the options you can use to configure the environment
  58046. * @returns the new EnvironmentHelper
  58047. */
  58048. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58049. /**
  58050. * Creates a new VREXperienceHelper
  58051. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58052. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58053. * @returns a new VREXperienceHelper
  58054. */
  58055. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58056. /**
  58057. * Creates a new WebXRDefaultExperience
  58058. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58059. * @param options experience options
  58060. * @returns a promise for a new WebXRDefaultExperience
  58061. */
  58062. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58063. }
  58064. }
  58065. declare module BABYLON {
  58066. /**
  58067. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58068. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58069. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58070. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58071. */
  58072. export class VideoDome extends TextureDome<VideoTexture> {
  58073. /**
  58074. * Define the video source as a Monoscopic panoramic 360 video.
  58075. */
  58076. static readonly MODE_MONOSCOPIC: number;
  58077. /**
  58078. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58079. */
  58080. static readonly MODE_TOPBOTTOM: number;
  58081. /**
  58082. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58083. */
  58084. static readonly MODE_SIDEBYSIDE: number;
  58085. /**
  58086. * Get the video texture associated with this video dome
  58087. */
  58088. get videoTexture(): VideoTexture;
  58089. /**
  58090. * Get the video mode of this dome
  58091. */
  58092. get videoMode(): number;
  58093. /**
  58094. * Set the video mode of this dome.
  58095. * @see textureMode
  58096. */
  58097. set videoMode(value: number);
  58098. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58099. }
  58100. }
  58101. declare module BABYLON {
  58102. /**
  58103. * This class can be used to get instrumentation data from a Babylon engine
  58104. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58105. */
  58106. export class EngineInstrumentation implements IDisposable {
  58107. /**
  58108. * Define the instrumented engine.
  58109. */
  58110. engine: Engine;
  58111. private _captureGPUFrameTime;
  58112. private _gpuFrameTimeToken;
  58113. private _gpuFrameTime;
  58114. private _captureShaderCompilationTime;
  58115. private _shaderCompilationTime;
  58116. private _onBeginFrameObserver;
  58117. private _onEndFrameObserver;
  58118. private _onBeforeShaderCompilationObserver;
  58119. private _onAfterShaderCompilationObserver;
  58120. /**
  58121. * Gets the perf counter used for GPU frame time
  58122. */
  58123. get gpuFrameTimeCounter(): PerfCounter;
  58124. /**
  58125. * Gets the GPU frame time capture status
  58126. */
  58127. get captureGPUFrameTime(): boolean;
  58128. /**
  58129. * Enable or disable the GPU frame time capture
  58130. */
  58131. set captureGPUFrameTime(value: boolean);
  58132. /**
  58133. * Gets the perf counter used for shader compilation time
  58134. */
  58135. get shaderCompilationTimeCounter(): PerfCounter;
  58136. /**
  58137. * Gets the shader compilation time capture status
  58138. */
  58139. get captureShaderCompilationTime(): boolean;
  58140. /**
  58141. * Enable or disable the shader compilation time capture
  58142. */
  58143. set captureShaderCompilationTime(value: boolean);
  58144. /**
  58145. * Instantiates a new engine instrumentation.
  58146. * This class can be used to get instrumentation data from a Babylon engine
  58147. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58148. * @param engine Defines the engine to instrument
  58149. */
  58150. constructor(
  58151. /**
  58152. * Define the instrumented engine.
  58153. */
  58154. engine: Engine);
  58155. /**
  58156. * Dispose and release associated resources.
  58157. */
  58158. dispose(): void;
  58159. }
  58160. }
  58161. declare module BABYLON {
  58162. /**
  58163. * This class can be used to get instrumentation data from a Babylon engine
  58164. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58165. */
  58166. export class SceneInstrumentation implements IDisposable {
  58167. /**
  58168. * Defines the scene to instrument
  58169. */
  58170. scene: Scene;
  58171. private _captureActiveMeshesEvaluationTime;
  58172. private _activeMeshesEvaluationTime;
  58173. private _captureRenderTargetsRenderTime;
  58174. private _renderTargetsRenderTime;
  58175. private _captureFrameTime;
  58176. private _frameTime;
  58177. private _captureRenderTime;
  58178. private _renderTime;
  58179. private _captureInterFrameTime;
  58180. private _interFrameTime;
  58181. private _captureParticlesRenderTime;
  58182. private _particlesRenderTime;
  58183. private _captureSpritesRenderTime;
  58184. private _spritesRenderTime;
  58185. private _capturePhysicsTime;
  58186. private _physicsTime;
  58187. private _captureAnimationsTime;
  58188. private _animationsTime;
  58189. private _captureCameraRenderTime;
  58190. private _cameraRenderTime;
  58191. private _onBeforeActiveMeshesEvaluationObserver;
  58192. private _onAfterActiveMeshesEvaluationObserver;
  58193. private _onBeforeRenderTargetsRenderObserver;
  58194. private _onAfterRenderTargetsRenderObserver;
  58195. private _onAfterRenderObserver;
  58196. private _onBeforeDrawPhaseObserver;
  58197. private _onAfterDrawPhaseObserver;
  58198. private _onBeforeAnimationsObserver;
  58199. private _onBeforeParticlesRenderingObserver;
  58200. private _onAfterParticlesRenderingObserver;
  58201. private _onBeforeSpritesRenderingObserver;
  58202. private _onAfterSpritesRenderingObserver;
  58203. private _onBeforePhysicsObserver;
  58204. private _onAfterPhysicsObserver;
  58205. private _onAfterAnimationsObserver;
  58206. private _onBeforeCameraRenderObserver;
  58207. private _onAfterCameraRenderObserver;
  58208. /**
  58209. * Gets the perf counter used for active meshes evaluation time
  58210. */
  58211. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58212. /**
  58213. * Gets the active meshes evaluation time capture status
  58214. */
  58215. get captureActiveMeshesEvaluationTime(): boolean;
  58216. /**
  58217. * Enable or disable the active meshes evaluation time capture
  58218. */
  58219. set captureActiveMeshesEvaluationTime(value: boolean);
  58220. /**
  58221. * Gets the perf counter used for render targets render time
  58222. */
  58223. get renderTargetsRenderTimeCounter(): PerfCounter;
  58224. /**
  58225. * Gets the render targets render time capture status
  58226. */
  58227. get captureRenderTargetsRenderTime(): boolean;
  58228. /**
  58229. * Enable or disable the render targets render time capture
  58230. */
  58231. set captureRenderTargetsRenderTime(value: boolean);
  58232. /**
  58233. * Gets the perf counter used for particles render time
  58234. */
  58235. get particlesRenderTimeCounter(): PerfCounter;
  58236. /**
  58237. * Gets the particles render time capture status
  58238. */
  58239. get captureParticlesRenderTime(): boolean;
  58240. /**
  58241. * Enable or disable the particles render time capture
  58242. */
  58243. set captureParticlesRenderTime(value: boolean);
  58244. /**
  58245. * Gets the perf counter used for sprites render time
  58246. */
  58247. get spritesRenderTimeCounter(): PerfCounter;
  58248. /**
  58249. * Gets the sprites render time capture status
  58250. */
  58251. get captureSpritesRenderTime(): boolean;
  58252. /**
  58253. * Enable or disable the sprites render time capture
  58254. */
  58255. set captureSpritesRenderTime(value: boolean);
  58256. /**
  58257. * Gets the perf counter used for physics time
  58258. */
  58259. get physicsTimeCounter(): PerfCounter;
  58260. /**
  58261. * Gets the physics time capture status
  58262. */
  58263. get capturePhysicsTime(): boolean;
  58264. /**
  58265. * Enable or disable the physics time capture
  58266. */
  58267. set capturePhysicsTime(value: boolean);
  58268. /**
  58269. * Gets the perf counter used for animations time
  58270. */
  58271. get animationsTimeCounter(): PerfCounter;
  58272. /**
  58273. * Gets the animations time capture status
  58274. */
  58275. get captureAnimationsTime(): boolean;
  58276. /**
  58277. * Enable or disable the animations time capture
  58278. */
  58279. set captureAnimationsTime(value: boolean);
  58280. /**
  58281. * Gets the perf counter used for frame time capture
  58282. */
  58283. get frameTimeCounter(): PerfCounter;
  58284. /**
  58285. * Gets the frame time capture status
  58286. */
  58287. get captureFrameTime(): boolean;
  58288. /**
  58289. * Enable or disable the frame time capture
  58290. */
  58291. set captureFrameTime(value: boolean);
  58292. /**
  58293. * Gets the perf counter used for inter-frames time capture
  58294. */
  58295. get interFrameTimeCounter(): PerfCounter;
  58296. /**
  58297. * Gets the inter-frames time capture status
  58298. */
  58299. get captureInterFrameTime(): boolean;
  58300. /**
  58301. * Enable or disable the inter-frames time capture
  58302. */
  58303. set captureInterFrameTime(value: boolean);
  58304. /**
  58305. * Gets the perf counter used for render time capture
  58306. */
  58307. get renderTimeCounter(): PerfCounter;
  58308. /**
  58309. * Gets the render time capture status
  58310. */
  58311. get captureRenderTime(): boolean;
  58312. /**
  58313. * Enable or disable the render time capture
  58314. */
  58315. set captureRenderTime(value: boolean);
  58316. /**
  58317. * Gets the perf counter used for camera render time capture
  58318. */
  58319. get cameraRenderTimeCounter(): PerfCounter;
  58320. /**
  58321. * Gets the camera render time capture status
  58322. */
  58323. get captureCameraRenderTime(): boolean;
  58324. /**
  58325. * Enable or disable the camera render time capture
  58326. */
  58327. set captureCameraRenderTime(value: boolean);
  58328. /**
  58329. * Gets the perf counter used for draw calls
  58330. */
  58331. get drawCallsCounter(): PerfCounter;
  58332. /**
  58333. * Instantiates a new scene instrumentation.
  58334. * This class can be used to get instrumentation data from a Babylon engine
  58335. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58336. * @param scene Defines the scene to instrument
  58337. */
  58338. constructor(
  58339. /**
  58340. * Defines the scene to instrument
  58341. */
  58342. scene: Scene);
  58343. /**
  58344. * Dispose and release associated resources.
  58345. */
  58346. dispose(): void;
  58347. }
  58348. }
  58349. declare module BABYLON {
  58350. /** @hidden */
  58351. export var glowMapGenerationPixelShader: {
  58352. name: string;
  58353. shader: string;
  58354. };
  58355. }
  58356. declare module BABYLON {
  58357. /** @hidden */
  58358. export var glowMapGenerationVertexShader: {
  58359. name: string;
  58360. shader: string;
  58361. };
  58362. }
  58363. declare module BABYLON {
  58364. /**
  58365. * Effect layer options. This helps customizing the behaviour
  58366. * of the effect layer.
  58367. */
  58368. export interface IEffectLayerOptions {
  58369. /**
  58370. * Multiplication factor apply to the canvas size to compute the render target size
  58371. * used to generated the objects (the smaller the faster).
  58372. */
  58373. mainTextureRatio: number;
  58374. /**
  58375. * Enforces a fixed size texture to ensure effect stability across devices.
  58376. */
  58377. mainTextureFixedSize?: number;
  58378. /**
  58379. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58380. */
  58381. alphaBlendingMode: number;
  58382. /**
  58383. * The camera attached to the layer.
  58384. */
  58385. camera: Nullable<Camera>;
  58386. /**
  58387. * The rendering group to draw the layer in.
  58388. */
  58389. renderingGroupId: number;
  58390. }
  58391. /**
  58392. * The effect layer Helps adding post process effect blended with the main pass.
  58393. *
  58394. * This can be for instance use to generate glow or higlight effects on the scene.
  58395. *
  58396. * The effect layer class can not be used directly and is intented to inherited from to be
  58397. * customized per effects.
  58398. */
  58399. export abstract class EffectLayer {
  58400. private _vertexBuffers;
  58401. private _indexBuffer;
  58402. private _cachedDefines;
  58403. private _effectLayerMapGenerationEffect;
  58404. private _effectLayerOptions;
  58405. private _mergeEffect;
  58406. protected _scene: Scene;
  58407. protected _engine: Engine;
  58408. protected _maxSize: number;
  58409. protected _mainTextureDesiredSize: ISize;
  58410. protected _mainTexture: RenderTargetTexture;
  58411. protected _shouldRender: boolean;
  58412. protected _postProcesses: PostProcess[];
  58413. protected _textures: BaseTexture[];
  58414. protected _emissiveTextureAndColor: {
  58415. texture: Nullable<BaseTexture>;
  58416. color: Color4;
  58417. };
  58418. /**
  58419. * The name of the layer
  58420. */
  58421. name: string;
  58422. /**
  58423. * The clear color of the texture used to generate the glow map.
  58424. */
  58425. neutralColor: Color4;
  58426. /**
  58427. * Specifies whether the highlight layer is enabled or not.
  58428. */
  58429. isEnabled: boolean;
  58430. /**
  58431. * Gets the camera attached to the layer.
  58432. */
  58433. get camera(): Nullable<Camera>;
  58434. /**
  58435. * Gets the rendering group id the layer should render in.
  58436. */
  58437. get renderingGroupId(): number;
  58438. set renderingGroupId(renderingGroupId: number);
  58439. /**
  58440. * An event triggered when the effect layer has been disposed.
  58441. */
  58442. onDisposeObservable: Observable<EffectLayer>;
  58443. /**
  58444. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58445. */
  58446. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58447. /**
  58448. * An event triggered when the generated texture is being merged in the scene.
  58449. */
  58450. onBeforeComposeObservable: Observable<EffectLayer>;
  58451. /**
  58452. * An event triggered when the mesh is rendered into the effect render target.
  58453. */
  58454. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58455. /**
  58456. * An event triggered after the mesh has been rendered into the effect render target.
  58457. */
  58458. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58459. /**
  58460. * An event triggered when the generated texture has been merged in the scene.
  58461. */
  58462. onAfterComposeObservable: Observable<EffectLayer>;
  58463. /**
  58464. * An event triggered when the efffect layer changes its size.
  58465. */
  58466. onSizeChangedObservable: Observable<EffectLayer>;
  58467. /** @hidden */
  58468. static _SceneComponentInitialization: (scene: Scene) => void;
  58469. /**
  58470. * Instantiates a new effect Layer and references it in the scene.
  58471. * @param name The name of the layer
  58472. * @param scene The scene to use the layer in
  58473. */
  58474. constructor(
  58475. /** The Friendly of the effect in the scene */
  58476. name: string, scene: Scene);
  58477. /**
  58478. * Get the effect name of the layer.
  58479. * @return The effect name
  58480. */
  58481. abstract getEffectName(): string;
  58482. /**
  58483. * Checks for the readiness of the element composing the layer.
  58484. * @param subMesh the mesh to check for
  58485. * @param useInstances specify whether or not to use instances to render the mesh
  58486. * @return true if ready otherwise, false
  58487. */
  58488. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58489. /**
  58490. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58491. * @returns true if the effect requires stencil during the main canvas render pass.
  58492. */
  58493. abstract needStencil(): boolean;
  58494. /**
  58495. * Create the merge effect. This is the shader use to blit the information back
  58496. * to the main canvas at the end of the scene rendering.
  58497. * @returns The effect containing the shader used to merge the effect on the main canvas
  58498. */
  58499. protected abstract _createMergeEffect(): Effect;
  58500. /**
  58501. * Creates the render target textures and post processes used in the effect layer.
  58502. */
  58503. protected abstract _createTextureAndPostProcesses(): void;
  58504. /**
  58505. * Implementation specific of rendering the generating effect on the main canvas.
  58506. * @param effect The effect used to render through
  58507. */
  58508. protected abstract _internalRender(effect: Effect): void;
  58509. /**
  58510. * Sets the required values for both the emissive texture and and the main color.
  58511. */
  58512. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58513. /**
  58514. * Free any resources and references associated to a mesh.
  58515. * Internal use
  58516. * @param mesh The mesh to free.
  58517. */
  58518. abstract _disposeMesh(mesh: Mesh): void;
  58519. /**
  58520. * Serializes this layer (Glow or Highlight for example)
  58521. * @returns a serialized layer object
  58522. */
  58523. abstract serialize?(): any;
  58524. /**
  58525. * Initializes the effect layer with the required options.
  58526. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58527. */
  58528. protected _init(options: Partial<IEffectLayerOptions>): void;
  58529. /**
  58530. * Generates the index buffer of the full screen quad blending to the main canvas.
  58531. */
  58532. private _generateIndexBuffer;
  58533. /**
  58534. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58535. */
  58536. private _generateVertexBuffer;
  58537. /**
  58538. * Sets the main texture desired size which is the closest power of two
  58539. * of the engine canvas size.
  58540. */
  58541. private _setMainTextureSize;
  58542. /**
  58543. * Creates the main texture for the effect layer.
  58544. */
  58545. protected _createMainTexture(): void;
  58546. /**
  58547. * Adds specific effects defines.
  58548. * @param defines The defines to add specifics to.
  58549. */
  58550. protected _addCustomEffectDefines(defines: string[]): void;
  58551. /**
  58552. * Checks for the readiness of the element composing the layer.
  58553. * @param subMesh the mesh to check for
  58554. * @param useInstances specify whether or not to use instances to render the mesh
  58555. * @param emissiveTexture the associated emissive texture used to generate the glow
  58556. * @return true if ready otherwise, false
  58557. */
  58558. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58559. /**
  58560. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58561. */
  58562. render(): void;
  58563. /**
  58564. * Determine if a given mesh will be used in the current effect.
  58565. * @param mesh mesh to test
  58566. * @returns true if the mesh will be used
  58567. */
  58568. hasMesh(mesh: AbstractMesh): boolean;
  58569. /**
  58570. * Returns true if the layer contains information to display, otherwise false.
  58571. * @returns true if the glow layer should be rendered
  58572. */
  58573. shouldRender(): boolean;
  58574. /**
  58575. * Returns true if the mesh should render, otherwise false.
  58576. * @param mesh The mesh to render
  58577. * @returns true if it should render otherwise false
  58578. */
  58579. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58580. /**
  58581. * Returns true if the mesh can be rendered, otherwise false.
  58582. * @param mesh The mesh to render
  58583. * @param material The material used on the mesh
  58584. * @returns true if it can be rendered otherwise false
  58585. */
  58586. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58587. /**
  58588. * Returns true if the mesh should render, otherwise false.
  58589. * @param mesh The mesh to render
  58590. * @returns true if it should render otherwise false
  58591. */
  58592. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58593. /**
  58594. * Renders the submesh passed in parameter to the generation map.
  58595. */
  58596. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58597. /**
  58598. * Defines whether the current material of the mesh should be use to render the effect.
  58599. * @param mesh defines the current mesh to render
  58600. */
  58601. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58602. /**
  58603. * Rebuild the required buffers.
  58604. * @hidden Internal use only.
  58605. */
  58606. _rebuild(): void;
  58607. /**
  58608. * Dispose only the render target textures and post process.
  58609. */
  58610. private _disposeTextureAndPostProcesses;
  58611. /**
  58612. * Dispose the highlight layer and free resources.
  58613. */
  58614. dispose(): void;
  58615. /**
  58616. * Gets the class name of the effect layer
  58617. * @returns the string with the class name of the effect layer
  58618. */
  58619. getClassName(): string;
  58620. /**
  58621. * Creates an effect layer from parsed effect layer data
  58622. * @param parsedEffectLayer defines effect layer data
  58623. * @param scene defines the current scene
  58624. * @param rootUrl defines the root URL containing the effect layer information
  58625. * @returns a parsed effect Layer
  58626. */
  58627. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58628. }
  58629. }
  58630. declare module BABYLON {
  58631. interface AbstractScene {
  58632. /**
  58633. * The list of effect layers (highlights/glow) added to the scene
  58634. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58635. * @see https://doc.babylonjs.com/how_to/glow_layer
  58636. */
  58637. effectLayers: Array<EffectLayer>;
  58638. /**
  58639. * Removes the given effect layer from this scene.
  58640. * @param toRemove defines the effect layer to remove
  58641. * @returns the index of the removed effect layer
  58642. */
  58643. removeEffectLayer(toRemove: EffectLayer): number;
  58644. /**
  58645. * Adds the given effect layer to this scene
  58646. * @param newEffectLayer defines the effect layer to add
  58647. */
  58648. addEffectLayer(newEffectLayer: EffectLayer): void;
  58649. }
  58650. /**
  58651. * Defines the layer scene component responsible to manage any effect layers
  58652. * in a given scene.
  58653. */
  58654. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58655. /**
  58656. * The component name helpfull to identify the component in the list of scene components.
  58657. */
  58658. readonly name: string;
  58659. /**
  58660. * The scene the component belongs to.
  58661. */
  58662. scene: Scene;
  58663. private _engine;
  58664. private _renderEffects;
  58665. private _needStencil;
  58666. private _previousStencilState;
  58667. /**
  58668. * Creates a new instance of the component for the given scene
  58669. * @param scene Defines the scene to register the component in
  58670. */
  58671. constructor(scene: Scene);
  58672. /**
  58673. * Registers the component in a given scene
  58674. */
  58675. register(): void;
  58676. /**
  58677. * Rebuilds the elements related to this component in case of
  58678. * context lost for instance.
  58679. */
  58680. rebuild(): void;
  58681. /**
  58682. * Serializes the component data to the specified json object
  58683. * @param serializationObject The object to serialize to
  58684. */
  58685. serialize(serializationObject: any): void;
  58686. /**
  58687. * Adds all the elements from the container to the scene
  58688. * @param container the container holding the elements
  58689. */
  58690. addFromContainer(container: AbstractScene): void;
  58691. /**
  58692. * Removes all the elements in the container from the scene
  58693. * @param container contains the elements to remove
  58694. * @param dispose if the removed element should be disposed (default: false)
  58695. */
  58696. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58697. /**
  58698. * Disposes the component and the associated ressources.
  58699. */
  58700. dispose(): void;
  58701. private _isReadyForMesh;
  58702. private _renderMainTexture;
  58703. private _setStencil;
  58704. private _setStencilBack;
  58705. private _draw;
  58706. private _drawCamera;
  58707. private _drawRenderingGroup;
  58708. }
  58709. }
  58710. declare module BABYLON {
  58711. /** @hidden */
  58712. export var glowMapMergePixelShader: {
  58713. name: string;
  58714. shader: string;
  58715. };
  58716. }
  58717. declare module BABYLON {
  58718. /** @hidden */
  58719. export var glowMapMergeVertexShader: {
  58720. name: string;
  58721. shader: string;
  58722. };
  58723. }
  58724. declare module BABYLON {
  58725. interface AbstractScene {
  58726. /**
  58727. * Return a the first highlight layer of the scene with a given name.
  58728. * @param name The name of the highlight layer to look for.
  58729. * @return The highlight layer if found otherwise null.
  58730. */
  58731. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58732. }
  58733. /**
  58734. * Glow layer options. This helps customizing the behaviour
  58735. * of the glow layer.
  58736. */
  58737. export interface IGlowLayerOptions {
  58738. /**
  58739. * Multiplication factor apply to the canvas size to compute the render target size
  58740. * used to generated the glowing objects (the smaller the faster).
  58741. */
  58742. mainTextureRatio: number;
  58743. /**
  58744. * Enforces a fixed size texture to ensure resize independant blur.
  58745. */
  58746. mainTextureFixedSize?: number;
  58747. /**
  58748. * How big is the kernel of the blur texture.
  58749. */
  58750. blurKernelSize: number;
  58751. /**
  58752. * The camera attached to the layer.
  58753. */
  58754. camera: Nullable<Camera>;
  58755. /**
  58756. * Enable MSAA by chosing the number of samples.
  58757. */
  58758. mainTextureSamples?: number;
  58759. /**
  58760. * The rendering group to draw the layer in.
  58761. */
  58762. renderingGroupId: number;
  58763. }
  58764. /**
  58765. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58766. *
  58767. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58768. *
  58769. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58770. */
  58771. export class GlowLayer extends EffectLayer {
  58772. /**
  58773. * Effect Name of the layer.
  58774. */
  58775. static readonly EffectName: string;
  58776. /**
  58777. * The default blur kernel size used for the glow.
  58778. */
  58779. static DefaultBlurKernelSize: number;
  58780. /**
  58781. * The default texture size ratio used for the glow.
  58782. */
  58783. static DefaultTextureRatio: number;
  58784. /**
  58785. * Sets the kernel size of the blur.
  58786. */
  58787. set blurKernelSize(value: number);
  58788. /**
  58789. * Gets the kernel size of the blur.
  58790. */
  58791. get blurKernelSize(): number;
  58792. /**
  58793. * Sets the glow intensity.
  58794. */
  58795. set intensity(value: number);
  58796. /**
  58797. * Gets the glow intensity.
  58798. */
  58799. get intensity(): number;
  58800. private _options;
  58801. private _intensity;
  58802. private _horizontalBlurPostprocess1;
  58803. private _verticalBlurPostprocess1;
  58804. private _horizontalBlurPostprocess2;
  58805. private _verticalBlurPostprocess2;
  58806. private _blurTexture1;
  58807. private _blurTexture2;
  58808. private _postProcesses1;
  58809. private _postProcesses2;
  58810. private _includedOnlyMeshes;
  58811. private _excludedMeshes;
  58812. private _meshesUsingTheirOwnMaterials;
  58813. /**
  58814. * Callback used to let the user override the color selection on a per mesh basis
  58815. */
  58816. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58817. /**
  58818. * Callback used to let the user override the texture selection on a per mesh basis
  58819. */
  58820. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58821. /**
  58822. * Instantiates a new glow Layer and references it to the scene.
  58823. * @param name The name of the layer
  58824. * @param scene The scene to use the layer in
  58825. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58826. */
  58827. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58828. /**
  58829. * Get the effect name of the layer.
  58830. * @return The effect name
  58831. */
  58832. getEffectName(): string;
  58833. /**
  58834. * Create the merge effect. This is the shader use to blit the information back
  58835. * to the main canvas at the end of the scene rendering.
  58836. */
  58837. protected _createMergeEffect(): Effect;
  58838. /**
  58839. * Creates the render target textures and post processes used in the glow layer.
  58840. */
  58841. protected _createTextureAndPostProcesses(): void;
  58842. /**
  58843. * Checks for the readiness of the element composing the layer.
  58844. * @param subMesh the mesh to check for
  58845. * @param useInstances specify wether or not to use instances to render the mesh
  58846. * @param emissiveTexture the associated emissive texture used to generate the glow
  58847. * @return true if ready otherwise, false
  58848. */
  58849. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58850. /**
  58851. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58852. */
  58853. needStencil(): boolean;
  58854. /**
  58855. * Returns true if the mesh can be rendered, otherwise false.
  58856. * @param mesh The mesh to render
  58857. * @param material The material used on the mesh
  58858. * @returns true if it can be rendered otherwise false
  58859. */
  58860. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58861. /**
  58862. * Implementation specific of rendering the generating effect on the main canvas.
  58863. * @param effect The effect used to render through
  58864. */
  58865. protected _internalRender(effect: Effect): void;
  58866. /**
  58867. * Sets the required values for both the emissive texture and and the main color.
  58868. */
  58869. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58870. /**
  58871. * Returns true if the mesh should render, otherwise false.
  58872. * @param mesh The mesh to render
  58873. * @returns true if it should render otherwise false
  58874. */
  58875. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58876. /**
  58877. * Adds specific effects defines.
  58878. * @param defines The defines to add specifics to.
  58879. */
  58880. protected _addCustomEffectDefines(defines: string[]): void;
  58881. /**
  58882. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58883. * @param mesh The mesh to exclude from the glow layer
  58884. */
  58885. addExcludedMesh(mesh: Mesh): void;
  58886. /**
  58887. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58888. * @param mesh The mesh to remove
  58889. */
  58890. removeExcludedMesh(mesh: Mesh): void;
  58891. /**
  58892. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58893. * @param mesh The mesh to include in the glow layer
  58894. */
  58895. addIncludedOnlyMesh(mesh: Mesh): void;
  58896. /**
  58897. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58898. * @param mesh The mesh to remove
  58899. */
  58900. removeIncludedOnlyMesh(mesh: Mesh): void;
  58901. /**
  58902. * Determine if a given mesh will be used in the glow layer
  58903. * @param mesh The mesh to test
  58904. * @returns true if the mesh will be highlighted by the current glow layer
  58905. */
  58906. hasMesh(mesh: AbstractMesh): boolean;
  58907. /**
  58908. * Defines whether the current material of the mesh should be use to render the effect.
  58909. * @param mesh defines the current mesh to render
  58910. */
  58911. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58912. /**
  58913. * Add a mesh to be rendered through its own material and not with emissive only.
  58914. * @param mesh The mesh for which we need to use its material
  58915. */
  58916. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58917. /**
  58918. * Remove a mesh from being rendered through its own material and not with emissive only.
  58919. * @param mesh The mesh for which we need to not use its material
  58920. */
  58921. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58922. /**
  58923. * Free any resources and references associated to a mesh.
  58924. * Internal use
  58925. * @param mesh The mesh to free.
  58926. * @hidden
  58927. */
  58928. _disposeMesh(mesh: Mesh): void;
  58929. /**
  58930. * Gets the class name of the effect layer
  58931. * @returns the string with the class name of the effect layer
  58932. */
  58933. getClassName(): string;
  58934. /**
  58935. * Serializes this glow layer
  58936. * @returns a serialized glow layer object
  58937. */
  58938. serialize(): any;
  58939. /**
  58940. * Creates a Glow Layer from parsed glow layer data
  58941. * @param parsedGlowLayer defines glow layer data
  58942. * @param scene defines the current scene
  58943. * @param rootUrl defines the root URL containing the glow layer information
  58944. * @returns a parsed Glow Layer
  58945. */
  58946. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58947. }
  58948. }
  58949. declare module BABYLON {
  58950. /** @hidden */
  58951. export var glowBlurPostProcessPixelShader: {
  58952. name: string;
  58953. shader: string;
  58954. };
  58955. }
  58956. declare module BABYLON {
  58957. interface AbstractScene {
  58958. /**
  58959. * Return a the first highlight layer of the scene with a given name.
  58960. * @param name The name of the highlight layer to look for.
  58961. * @return The highlight layer if found otherwise null.
  58962. */
  58963. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58964. }
  58965. /**
  58966. * Highlight layer options. This helps customizing the behaviour
  58967. * of the highlight layer.
  58968. */
  58969. export interface IHighlightLayerOptions {
  58970. /**
  58971. * Multiplication factor apply to the canvas size to compute the render target size
  58972. * used to generated the glowing objects (the smaller the faster).
  58973. */
  58974. mainTextureRatio: number;
  58975. /**
  58976. * Enforces a fixed size texture to ensure resize independant blur.
  58977. */
  58978. mainTextureFixedSize?: number;
  58979. /**
  58980. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58981. * of the picture to blur (the smaller the faster).
  58982. */
  58983. blurTextureSizeRatio: number;
  58984. /**
  58985. * How big in texel of the blur texture is the vertical blur.
  58986. */
  58987. blurVerticalSize: number;
  58988. /**
  58989. * How big in texel of the blur texture is the horizontal blur.
  58990. */
  58991. blurHorizontalSize: number;
  58992. /**
  58993. * Alpha blending mode used to apply the blur. Default is combine.
  58994. */
  58995. alphaBlendingMode: number;
  58996. /**
  58997. * The camera attached to the layer.
  58998. */
  58999. camera: Nullable<Camera>;
  59000. /**
  59001. * Should we display highlight as a solid stroke?
  59002. */
  59003. isStroke?: boolean;
  59004. /**
  59005. * The rendering group to draw the layer in.
  59006. */
  59007. renderingGroupId: number;
  59008. }
  59009. /**
  59010. * The highlight layer Helps adding a glow effect around a mesh.
  59011. *
  59012. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59013. * glowy meshes to your scene.
  59014. *
  59015. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59016. */
  59017. export class HighlightLayer extends EffectLayer {
  59018. name: string;
  59019. /**
  59020. * Effect Name of the highlight layer.
  59021. */
  59022. static readonly EffectName: string;
  59023. /**
  59024. * The neutral color used during the preparation of the glow effect.
  59025. * This is black by default as the blend operation is a blend operation.
  59026. */
  59027. static NeutralColor: Color4;
  59028. /**
  59029. * Stencil value used for glowing meshes.
  59030. */
  59031. static GlowingMeshStencilReference: number;
  59032. /**
  59033. * Stencil value used for the other meshes in the scene.
  59034. */
  59035. static NormalMeshStencilReference: number;
  59036. /**
  59037. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59038. */
  59039. innerGlow: boolean;
  59040. /**
  59041. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59042. */
  59043. outerGlow: boolean;
  59044. /**
  59045. * Specifies the horizontal size of the blur.
  59046. */
  59047. set blurHorizontalSize(value: number);
  59048. /**
  59049. * Specifies the vertical size of the blur.
  59050. */
  59051. set blurVerticalSize(value: number);
  59052. /**
  59053. * Gets the horizontal size of the blur.
  59054. */
  59055. get blurHorizontalSize(): number;
  59056. /**
  59057. * Gets the vertical size of the blur.
  59058. */
  59059. get blurVerticalSize(): number;
  59060. /**
  59061. * An event triggered when the highlight layer is being blurred.
  59062. */
  59063. onBeforeBlurObservable: Observable<HighlightLayer>;
  59064. /**
  59065. * An event triggered when the highlight layer has been blurred.
  59066. */
  59067. onAfterBlurObservable: Observable<HighlightLayer>;
  59068. private _instanceGlowingMeshStencilReference;
  59069. private _options;
  59070. private _downSamplePostprocess;
  59071. private _horizontalBlurPostprocess;
  59072. private _verticalBlurPostprocess;
  59073. private _blurTexture;
  59074. private _meshes;
  59075. private _excludedMeshes;
  59076. /**
  59077. * Instantiates a new highlight Layer and references it to the scene..
  59078. * @param name The name of the layer
  59079. * @param scene The scene to use the layer in
  59080. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59081. */
  59082. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59083. /**
  59084. * Get the effect name of the layer.
  59085. * @return The effect name
  59086. */
  59087. getEffectName(): string;
  59088. /**
  59089. * Create the merge effect. This is the shader use to blit the information back
  59090. * to the main canvas at the end of the scene rendering.
  59091. */
  59092. protected _createMergeEffect(): Effect;
  59093. /**
  59094. * Creates the render target textures and post processes used in the highlight layer.
  59095. */
  59096. protected _createTextureAndPostProcesses(): void;
  59097. /**
  59098. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59099. */
  59100. needStencil(): boolean;
  59101. /**
  59102. * Checks for the readiness of the element composing the layer.
  59103. * @param subMesh the mesh to check for
  59104. * @param useInstances specify wether or not to use instances to render the mesh
  59105. * @param emissiveTexture the associated emissive texture used to generate the glow
  59106. * @return true if ready otherwise, false
  59107. */
  59108. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59109. /**
  59110. * Implementation specific of rendering the generating effect on the main canvas.
  59111. * @param effect The effect used to render through
  59112. */
  59113. protected _internalRender(effect: Effect): void;
  59114. /**
  59115. * Returns true if the layer contains information to display, otherwise false.
  59116. */
  59117. shouldRender(): boolean;
  59118. /**
  59119. * Returns true if the mesh should render, otherwise false.
  59120. * @param mesh The mesh to render
  59121. * @returns true if it should render otherwise false
  59122. */
  59123. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59124. /**
  59125. * Returns true if the mesh can be rendered, otherwise false.
  59126. * @param mesh The mesh to render
  59127. * @param material The material used on the mesh
  59128. * @returns true if it can be rendered otherwise false
  59129. */
  59130. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59131. /**
  59132. * Adds specific effects defines.
  59133. * @param defines The defines to add specifics to.
  59134. */
  59135. protected _addCustomEffectDefines(defines: string[]): void;
  59136. /**
  59137. * Sets the required values for both the emissive texture and and the main color.
  59138. */
  59139. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59140. /**
  59141. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59142. * @param mesh The mesh to exclude from the highlight layer
  59143. */
  59144. addExcludedMesh(mesh: Mesh): void;
  59145. /**
  59146. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59147. * @param mesh The mesh to highlight
  59148. */
  59149. removeExcludedMesh(mesh: Mesh): void;
  59150. /**
  59151. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59152. * @param mesh mesh to test
  59153. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59154. */
  59155. hasMesh(mesh: AbstractMesh): boolean;
  59156. /**
  59157. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59158. * @param mesh The mesh to highlight
  59159. * @param color The color of the highlight
  59160. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59161. */
  59162. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59163. /**
  59164. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59165. * @param mesh The mesh to highlight
  59166. */
  59167. removeMesh(mesh: Mesh): void;
  59168. /**
  59169. * Remove all the meshes currently referenced in the highlight layer
  59170. */
  59171. removeAllMeshes(): void;
  59172. /**
  59173. * Force the stencil to the normal expected value for none glowing parts
  59174. */
  59175. private _defaultStencilReference;
  59176. /**
  59177. * Free any resources and references associated to a mesh.
  59178. * Internal use
  59179. * @param mesh The mesh to free.
  59180. * @hidden
  59181. */
  59182. _disposeMesh(mesh: Mesh): void;
  59183. /**
  59184. * Dispose the highlight layer and free resources.
  59185. */
  59186. dispose(): void;
  59187. /**
  59188. * Gets the class name of the effect layer
  59189. * @returns the string with the class name of the effect layer
  59190. */
  59191. getClassName(): string;
  59192. /**
  59193. * Serializes this Highlight layer
  59194. * @returns a serialized Highlight layer object
  59195. */
  59196. serialize(): any;
  59197. /**
  59198. * Creates a Highlight layer from parsed Highlight layer data
  59199. * @param parsedHightlightLayer defines the Highlight layer data
  59200. * @param scene defines the current scene
  59201. * @param rootUrl defines the root URL containing the Highlight layer information
  59202. * @returns a parsed Highlight layer
  59203. */
  59204. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59205. }
  59206. }
  59207. declare module BABYLON {
  59208. interface AbstractScene {
  59209. /**
  59210. * The list of layers (background and foreground) of the scene
  59211. */
  59212. layers: Array<Layer>;
  59213. }
  59214. /**
  59215. * Defines the layer scene component responsible to manage any layers
  59216. * in a given scene.
  59217. */
  59218. export class LayerSceneComponent implements ISceneComponent {
  59219. /**
  59220. * The component name helpfull to identify the component in the list of scene components.
  59221. */
  59222. readonly name: string;
  59223. /**
  59224. * The scene the component belongs to.
  59225. */
  59226. scene: Scene;
  59227. private _engine;
  59228. /**
  59229. * Creates a new instance of the component for the given scene
  59230. * @param scene Defines the scene to register the component in
  59231. */
  59232. constructor(scene: Scene);
  59233. /**
  59234. * Registers the component in a given scene
  59235. */
  59236. register(): void;
  59237. /**
  59238. * Rebuilds the elements related to this component in case of
  59239. * context lost for instance.
  59240. */
  59241. rebuild(): void;
  59242. /**
  59243. * Disposes the component and the associated ressources.
  59244. */
  59245. dispose(): void;
  59246. private _draw;
  59247. private _drawCameraPredicate;
  59248. private _drawCameraBackground;
  59249. private _drawCameraForeground;
  59250. private _drawRenderTargetPredicate;
  59251. private _drawRenderTargetBackground;
  59252. private _drawRenderTargetForeground;
  59253. /**
  59254. * Adds all the elements from the container to the scene
  59255. * @param container the container holding the elements
  59256. */
  59257. addFromContainer(container: AbstractScene): void;
  59258. /**
  59259. * Removes all the elements in the container from the scene
  59260. * @param container contains the elements to remove
  59261. * @param dispose if the removed element should be disposed (default: false)
  59262. */
  59263. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59264. }
  59265. }
  59266. declare module BABYLON {
  59267. /** @hidden */
  59268. export var layerPixelShader: {
  59269. name: string;
  59270. shader: string;
  59271. };
  59272. }
  59273. declare module BABYLON {
  59274. /** @hidden */
  59275. export var layerVertexShader: {
  59276. name: string;
  59277. shader: string;
  59278. };
  59279. }
  59280. declare module BABYLON {
  59281. /**
  59282. * This represents a full screen 2d layer.
  59283. * This can be useful to display a picture in the background of your scene for instance.
  59284. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59285. */
  59286. export class Layer {
  59287. /**
  59288. * Define the name of the layer.
  59289. */
  59290. name: string;
  59291. /**
  59292. * Define the texture the layer should display.
  59293. */
  59294. texture: Nullable<Texture>;
  59295. /**
  59296. * Is the layer in background or foreground.
  59297. */
  59298. isBackground: boolean;
  59299. /**
  59300. * Define the color of the layer (instead of texture).
  59301. */
  59302. color: Color4;
  59303. /**
  59304. * Define the scale of the layer in order to zoom in out of the texture.
  59305. */
  59306. scale: Vector2;
  59307. /**
  59308. * Define an offset for the layer in order to shift the texture.
  59309. */
  59310. offset: Vector2;
  59311. /**
  59312. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59313. */
  59314. alphaBlendingMode: number;
  59315. /**
  59316. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59317. * Alpha test will not mix with the background color in case of transparency.
  59318. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59319. */
  59320. alphaTest: boolean;
  59321. /**
  59322. * Define a mask to restrict the layer to only some of the scene cameras.
  59323. */
  59324. layerMask: number;
  59325. /**
  59326. * Define the list of render target the layer is visible into.
  59327. */
  59328. renderTargetTextures: RenderTargetTexture[];
  59329. /**
  59330. * Define if the layer is only used in renderTarget or if it also
  59331. * renders in the main frame buffer of the canvas.
  59332. */
  59333. renderOnlyInRenderTargetTextures: boolean;
  59334. private _scene;
  59335. private _vertexBuffers;
  59336. private _indexBuffer;
  59337. private _effect;
  59338. private _previousDefines;
  59339. /**
  59340. * An event triggered when the layer is disposed.
  59341. */
  59342. onDisposeObservable: Observable<Layer>;
  59343. private _onDisposeObserver;
  59344. /**
  59345. * Back compatibility with callback before the onDisposeObservable existed.
  59346. * The set callback will be triggered when the layer has been disposed.
  59347. */
  59348. set onDispose(callback: () => void);
  59349. /**
  59350. * An event triggered before rendering the scene
  59351. */
  59352. onBeforeRenderObservable: Observable<Layer>;
  59353. private _onBeforeRenderObserver;
  59354. /**
  59355. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59356. * The set callback will be triggered just before rendering the layer.
  59357. */
  59358. set onBeforeRender(callback: () => void);
  59359. /**
  59360. * An event triggered after rendering the scene
  59361. */
  59362. onAfterRenderObservable: Observable<Layer>;
  59363. private _onAfterRenderObserver;
  59364. /**
  59365. * Back compatibility with callback before the onAfterRenderObservable existed.
  59366. * The set callback will be triggered just after rendering the layer.
  59367. */
  59368. set onAfterRender(callback: () => void);
  59369. /**
  59370. * Instantiates a new layer.
  59371. * This represents a full screen 2d layer.
  59372. * This can be useful to display a picture in the background of your scene for instance.
  59373. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59374. * @param name Define the name of the layer in the scene
  59375. * @param imgUrl Define the url of the texture to display in the layer
  59376. * @param scene Define the scene the layer belongs to
  59377. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59378. * @param color Defines a color for the layer
  59379. */
  59380. constructor(
  59381. /**
  59382. * Define the name of the layer.
  59383. */
  59384. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59385. private _createIndexBuffer;
  59386. /** @hidden */
  59387. _rebuild(): void;
  59388. /**
  59389. * Renders the layer in the scene.
  59390. */
  59391. render(): void;
  59392. /**
  59393. * Disposes and releases the associated ressources.
  59394. */
  59395. dispose(): void;
  59396. }
  59397. }
  59398. declare module BABYLON {
  59399. /** @hidden */
  59400. export var lensFlarePixelShader: {
  59401. name: string;
  59402. shader: string;
  59403. };
  59404. }
  59405. declare module BABYLON {
  59406. /** @hidden */
  59407. export var lensFlareVertexShader: {
  59408. name: string;
  59409. shader: string;
  59410. };
  59411. }
  59412. declare module BABYLON {
  59413. /**
  59414. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59415. * It is usually composed of several `lensFlare`.
  59416. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59417. */
  59418. export class LensFlareSystem {
  59419. /**
  59420. * Define the name of the lens flare system
  59421. */
  59422. name: string;
  59423. /**
  59424. * List of lens flares used in this system.
  59425. */
  59426. lensFlares: LensFlare[];
  59427. /**
  59428. * Define a limit from the border the lens flare can be visible.
  59429. */
  59430. borderLimit: number;
  59431. /**
  59432. * Define a viewport border we do not want to see the lens flare in.
  59433. */
  59434. viewportBorder: number;
  59435. /**
  59436. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59437. */
  59438. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59439. /**
  59440. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59441. */
  59442. layerMask: number;
  59443. /**
  59444. * Define the id of the lens flare system in the scene.
  59445. * (equal to name by default)
  59446. */
  59447. id: string;
  59448. private _scene;
  59449. private _emitter;
  59450. private _vertexBuffers;
  59451. private _indexBuffer;
  59452. private _effect;
  59453. private _positionX;
  59454. private _positionY;
  59455. private _isEnabled;
  59456. /** @hidden */
  59457. static _SceneComponentInitialization: (scene: Scene) => void;
  59458. /**
  59459. * Instantiates a lens flare system.
  59460. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59461. * It is usually composed of several `lensFlare`.
  59462. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59463. * @param name Define the name of the lens flare system in the scene
  59464. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59465. * @param scene Define the scene the lens flare system belongs to
  59466. */
  59467. constructor(
  59468. /**
  59469. * Define the name of the lens flare system
  59470. */
  59471. name: string, emitter: any, scene: Scene);
  59472. /**
  59473. * Define if the lens flare system is enabled.
  59474. */
  59475. get isEnabled(): boolean;
  59476. set isEnabled(value: boolean);
  59477. /**
  59478. * Get the scene the effects belongs to.
  59479. * @returns the scene holding the lens flare system
  59480. */
  59481. getScene(): Scene;
  59482. /**
  59483. * Get the emitter of the lens flare system.
  59484. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59485. * @returns the emitter of the lens flare system
  59486. */
  59487. getEmitter(): any;
  59488. /**
  59489. * Set the emitter of the lens flare system.
  59490. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59491. * @param newEmitter Define the new emitter of the system
  59492. */
  59493. setEmitter(newEmitter: any): void;
  59494. /**
  59495. * Get the lens flare system emitter position.
  59496. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59497. * @returns the position
  59498. */
  59499. getEmitterPosition(): Vector3;
  59500. /**
  59501. * @hidden
  59502. */
  59503. computeEffectivePosition(globalViewport: Viewport): boolean;
  59504. /** @hidden */
  59505. _isVisible(): boolean;
  59506. /**
  59507. * @hidden
  59508. */
  59509. render(): boolean;
  59510. /**
  59511. * Dispose and release the lens flare with its associated resources.
  59512. */
  59513. dispose(): void;
  59514. /**
  59515. * Parse a lens flare system from a JSON repressentation
  59516. * @param parsedLensFlareSystem Define the JSON to parse
  59517. * @param scene Define the scene the parsed system should be instantiated in
  59518. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59519. * @returns the parsed system
  59520. */
  59521. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59522. /**
  59523. * Serialize the current Lens Flare System into a JSON representation.
  59524. * @returns the serialized JSON
  59525. */
  59526. serialize(): any;
  59527. }
  59528. }
  59529. declare module BABYLON {
  59530. /**
  59531. * This represents one of the lens effect in a `lensFlareSystem`.
  59532. * It controls one of the indiviual texture used in the effect.
  59533. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59534. */
  59535. export class LensFlare {
  59536. /**
  59537. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59538. */
  59539. size: number;
  59540. /**
  59541. * 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.
  59542. */
  59543. position: number;
  59544. /**
  59545. * Define the lens color.
  59546. */
  59547. color: Color3;
  59548. /**
  59549. * Define the lens texture.
  59550. */
  59551. texture: Nullable<Texture>;
  59552. /**
  59553. * Define the alpha mode to render this particular lens.
  59554. */
  59555. alphaMode: number;
  59556. private _system;
  59557. /**
  59558. * Creates a new Lens Flare.
  59559. * This represents one of the lens effect in a `lensFlareSystem`.
  59560. * It controls one of the indiviual texture used in the effect.
  59561. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59562. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59563. * @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.
  59564. * @param color Define the lens color
  59565. * @param imgUrl Define the lens texture url
  59566. * @param system Define the `lensFlareSystem` this flare is part of
  59567. * @returns The newly created Lens Flare
  59568. */
  59569. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59570. /**
  59571. * Instantiates a new Lens Flare.
  59572. * This represents one of the lens effect in a `lensFlareSystem`.
  59573. * It controls one of the indiviual texture used in the effect.
  59574. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59575. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59576. * @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.
  59577. * @param color Define the lens color
  59578. * @param imgUrl Define the lens texture url
  59579. * @param system Define the `lensFlareSystem` this flare is part of
  59580. */
  59581. constructor(
  59582. /**
  59583. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59584. */
  59585. size: number,
  59586. /**
  59587. * 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.
  59588. */
  59589. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59590. /**
  59591. * Dispose and release the lens flare with its associated resources.
  59592. */
  59593. dispose(): void;
  59594. }
  59595. }
  59596. declare module BABYLON {
  59597. interface AbstractScene {
  59598. /**
  59599. * The list of lens flare system added to the scene
  59600. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59601. */
  59602. lensFlareSystems: Array<LensFlareSystem>;
  59603. /**
  59604. * Removes the given lens flare system from this scene.
  59605. * @param toRemove The lens flare system to remove
  59606. * @returns The index of the removed lens flare system
  59607. */
  59608. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59609. /**
  59610. * Adds the given lens flare system to this scene
  59611. * @param newLensFlareSystem The lens flare system to add
  59612. */
  59613. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59614. /**
  59615. * Gets a lens flare system using its name
  59616. * @param name defines the name to look for
  59617. * @returns the lens flare system or null if not found
  59618. */
  59619. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59620. /**
  59621. * Gets a lens flare system using its id
  59622. * @param id defines the id to look for
  59623. * @returns the lens flare system or null if not found
  59624. */
  59625. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59626. }
  59627. /**
  59628. * Defines the lens flare scene component responsible to manage any lens flares
  59629. * in a given scene.
  59630. */
  59631. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59632. /**
  59633. * The component name helpfull to identify the component in the list of scene components.
  59634. */
  59635. readonly name: string;
  59636. /**
  59637. * The scene the component belongs to.
  59638. */
  59639. scene: Scene;
  59640. /**
  59641. * Creates a new instance of the component for the given scene
  59642. * @param scene Defines the scene to register the component in
  59643. */
  59644. constructor(scene: Scene);
  59645. /**
  59646. * Registers the component in a given scene
  59647. */
  59648. register(): void;
  59649. /**
  59650. * Rebuilds the elements related to this component in case of
  59651. * context lost for instance.
  59652. */
  59653. rebuild(): void;
  59654. /**
  59655. * Adds all the elements from the container to the scene
  59656. * @param container the container holding the elements
  59657. */
  59658. addFromContainer(container: AbstractScene): void;
  59659. /**
  59660. * Removes all the elements in the container from the scene
  59661. * @param container contains the elements to remove
  59662. * @param dispose if the removed element should be disposed (default: false)
  59663. */
  59664. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59665. /**
  59666. * Serializes the component data to the specified json object
  59667. * @param serializationObject The object to serialize to
  59668. */
  59669. serialize(serializationObject: any): void;
  59670. /**
  59671. * Disposes the component and the associated ressources.
  59672. */
  59673. dispose(): void;
  59674. private _draw;
  59675. }
  59676. }
  59677. declare module BABYLON {
  59678. /** @hidden */
  59679. export var depthPixelShader: {
  59680. name: string;
  59681. shader: string;
  59682. };
  59683. }
  59684. declare module BABYLON {
  59685. /** @hidden */
  59686. export var depthVertexShader: {
  59687. name: string;
  59688. shader: string;
  59689. };
  59690. }
  59691. declare module BABYLON {
  59692. /**
  59693. * This represents a depth renderer in Babylon.
  59694. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59695. */
  59696. export class DepthRenderer {
  59697. private _scene;
  59698. private _depthMap;
  59699. private _effect;
  59700. private readonly _storeNonLinearDepth;
  59701. private readonly _clearColor;
  59702. /** Get if the depth renderer is using packed depth or not */
  59703. readonly isPacked: boolean;
  59704. private _cachedDefines;
  59705. private _camera;
  59706. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59707. enabled: boolean;
  59708. /**
  59709. * Specifiess that the depth renderer will only be used within
  59710. * the camera it is created for.
  59711. * This can help forcing its rendering during the camera processing.
  59712. */
  59713. useOnlyInActiveCamera: boolean;
  59714. /** @hidden */
  59715. static _SceneComponentInitialization: (scene: Scene) => void;
  59716. /**
  59717. * Instantiates a depth renderer
  59718. * @param scene The scene the renderer belongs to
  59719. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59720. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59721. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59722. */
  59723. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59724. /**
  59725. * Creates the depth rendering effect and checks if the effect is ready.
  59726. * @param subMesh The submesh to be used to render the depth map of
  59727. * @param useInstances If multiple world instances should be used
  59728. * @returns if the depth renderer is ready to render the depth map
  59729. */
  59730. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59731. /**
  59732. * Gets the texture which the depth map will be written to.
  59733. * @returns The depth map texture
  59734. */
  59735. getDepthMap(): RenderTargetTexture;
  59736. /**
  59737. * Disposes of the depth renderer.
  59738. */
  59739. dispose(): void;
  59740. }
  59741. }
  59742. declare module BABYLON {
  59743. /** @hidden */
  59744. export var minmaxReduxPixelShader: {
  59745. name: string;
  59746. shader: string;
  59747. };
  59748. }
  59749. declare module BABYLON {
  59750. /**
  59751. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59752. * and maximum values from all values of the texture.
  59753. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59754. * The source values are read from the red channel of the texture.
  59755. */
  59756. export class MinMaxReducer {
  59757. /**
  59758. * Observable triggered when the computation has been performed
  59759. */
  59760. onAfterReductionPerformed: Observable<{
  59761. min: number;
  59762. max: number;
  59763. }>;
  59764. protected _camera: Camera;
  59765. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59766. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59767. protected _postProcessManager: PostProcessManager;
  59768. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59769. protected _forceFullscreenViewport: boolean;
  59770. /**
  59771. * Creates a min/max reducer
  59772. * @param camera The camera to use for the post processes
  59773. */
  59774. constructor(camera: Camera);
  59775. /**
  59776. * Gets the texture used to read the values from.
  59777. */
  59778. get sourceTexture(): Nullable<RenderTargetTexture>;
  59779. /**
  59780. * Sets the source texture to read the values from.
  59781. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59782. * because in such textures '1' value must not be taken into account to compute the maximum
  59783. * as this value is used to clear the texture.
  59784. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59785. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59786. * @param depthRedux Indicates if the texture is a depth texture or not
  59787. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59788. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59789. */
  59790. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59791. /**
  59792. * Defines the refresh rate of the computation.
  59793. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59794. */
  59795. get refreshRate(): number;
  59796. set refreshRate(value: number);
  59797. protected _activated: boolean;
  59798. /**
  59799. * Gets the activation status of the reducer
  59800. */
  59801. get activated(): boolean;
  59802. /**
  59803. * Activates the reduction computation.
  59804. * When activated, the observers registered in onAfterReductionPerformed are
  59805. * called after the compuation is performed
  59806. */
  59807. activate(): void;
  59808. /**
  59809. * Deactivates the reduction computation.
  59810. */
  59811. deactivate(): void;
  59812. /**
  59813. * Disposes the min/max reducer
  59814. * @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.
  59815. */
  59816. dispose(disposeAll?: boolean): void;
  59817. }
  59818. }
  59819. declare module BABYLON {
  59820. /**
  59821. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59822. */
  59823. export class DepthReducer extends MinMaxReducer {
  59824. private _depthRenderer;
  59825. private _depthRendererId;
  59826. /**
  59827. * Gets the depth renderer used for the computation.
  59828. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59829. */
  59830. get depthRenderer(): Nullable<DepthRenderer>;
  59831. /**
  59832. * Creates a depth reducer
  59833. * @param camera The camera used to render the depth texture
  59834. */
  59835. constructor(camera: Camera);
  59836. /**
  59837. * Sets the depth renderer to use to generate the depth map
  59838. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59839. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59840. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59841. */
  59842. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59843. /** @hidden */
  59844. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59845. /**
  59846. * Activates the reduction computation.
  59847. * When activated, the observers registered in onAfterReductionPerformed are
  59848. * called after the compuation is performed
  59849. */
  59850. activate(): void;
  59851. /**
  59852. * Deactivates the reduction computation.
  59853. */
  59854. deactivate(): void;
  59855. /**
  59856. * Disposes the depth reducer
  59857. * @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.
  59858. */
  59859. dispose(disposeAll?: boolean): void;
  59860. }
  59861. }
  59862. declare module BABYLON {
  59863. /**
  59864. * A CSM implementation allowing casting shadows on large scenes.
  59865. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59866. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59867. */
  59868. export class CascadedShadowGenerator extends ShadowGenerator {
  59869. private static readonly frustumCornersNDCSpace;
  59870. /**
  59871. * Name of the CSM class
  59872. */
  59873. static CLASSNAME: string;
  59874. /**
  59875. * Defines the default number of cascades used by the CSM.
  59876. */
  59877. static readonly DEFAULT_CASCADES_COUNT: number;
  59878. /**
  59879. * Defines the minimum number of cascades used by the CSM.
  59880. */
  59881. static readonly MIN_CASCADES_COUNT: number;
  59882. /**
  59883. * Defines the maximum number of cascades used by the CSM.
  59884. */
  59885. static readonly MAX_CASCADES_COUNT: number;
  59886. protected _validateFilter(filter: number): number;
  59887. /**
  59888. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59889. */
  59890. penumbraDarkness: number;
  59891. private _numCascades;
  59892. /**
  59893. * Gets or set the number of cascades used by the CSM.
  59894. */
  59895. get numCascades(): number;
  59896. set numCascades(value: number);
  59897. /**
  59898. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59899. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59900. */
  59901. stabilizeCascades: boolean;
  59902. private _freezeShadowCastersBoundingInfo;
  59903. private _freezeShadowCastersBoundingInfoObservable;
  59904. /**
  59905. * Enables or disables the shadow casters bounding info computation.
  59906. * If your shadow casters don't move, you can disable this feature.
  59907. * If it is enabled, the bounding box computation is done every frame.
  59908. */
  59909. get freezeShadowCastersBoundingInfo(): boolean;
  59910. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59911. private _scbiMin;
  59912. private _scbiMax;
  59913. protected _computeShadowCastersBoundingInfo(): void;
  59914. protected _shadowCastersBoundingInfo: BoundingInfo;
  59915. /**
  59916. * Gets or sets the shadow casters bounding info.
  59917. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59918. * so that the system won't overwrite the bounds you provide
  59919. */
  59920. get shadowCastersBoundingInfo(): BoundingInfo;
  59921. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59922. protected _breaksAreDirty: boolean;
  59923. protected _minDistance: number;
  59924. protected _maxDistance: number;
  59925. /**
  59926. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59927. *
  59928. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59929. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59930. * @param min minimal distance for the breaks (default to 0.)
  59931. * @param max maximal distance for the breaks (default to 1.)
  59932. */
  59933. setMinMaxDistance(min: number, max: number): void;
  59934. /** Gets the minimal distance used in the cascade break computation */
  59935. get minDistance(): number;
  59936. /** Gets the maximal distance used in the cascade break computation */
  59937. get maxDistance(): number;
  59938. /**
  59939. * Gets the class name of that object
  59940. * @returns "CascadedShadowGenerator"
  59941. */
  59942. getClassName(): string;
  59943. private _cascadeMinExtents;
  59944. private _cascadeMaxExtents;
  59945. /**
  59946. * Gets a cascade minimum extents
  59947. * @param cascadeIndex index of the cascade
  59948. * @returns the minimum cascade extents
  59949. */
  59950. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59951. /**
  59952. * Gets a cascade maximum extents
  59953. * @param cascadeIndex index of the cascade
  59954. * @returns the maximum cascade extents
  59955. */
  59956. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59957. private _cascades;
  59958. private _currentLayer;
  59959. private _viewSpaceFrustumsZ;
  59960. private _viewMatrices;
  59961. private _projectionMatrices;
  59962. private _transformMatrices;
  59963. private _transformMatricesAsArray;
  59964. private _frustumLengths;
  59965. private _lightSizeUVCorrection;
  59966. private _depthCorrection;
  59967. private _frustumCornersWorldSpace;
  59968. private _frustumCenter;
  59969. private _shadowCameraPos;
  59970. private _shadowMaxZ;
  59971. /**
  59972. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59973. * It defaults to camera.maxZ
  59974. */
  59975. get shadowMaxZ(): number;
  59976. /**
  59977. * Sets the shadow max z distance.
  59978. */
  59979. set shadowMaxZ(value: number);
  59980. protected _debug: boolean;
  59981. /**
  59982. * Gets or sets the debug flag.
  59983. * When enabled, the cascades are materialized by different colors on the screen.
  59984. */
  59985. get debug(): boolean;
  59986. set debug(dbg: boolean);
  59987. private _depthClamp;
  59988. /**
  59989. * Gets or sets the depth clamping value.
  59990. *
  59991. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59992. * to account for the shadow casters far away.
  59993. *
  59994. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59995. */
  59996. get depthClamp(): boolean;
  59997. set depthClamp(value: boolean);
  59998. private _cascadeBlendPercentage;
  59999. /**
  60000. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60001. * It defaults to 0.1 (10% blending).
  60002. */
  60003. get cascadeBlendPercentage(): number;
  60004. set cascadeBlendPercentage(value: number);
  60005. private _lambda;
  60006. /**
  60007. * Gets or set the lambda parameter.
  60008. * This parameter is used to split the camera frustum and create the cascades.
  60009. * 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.
  60010. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60011. */
  60012. get lambda(): number;
  60013. set lambda(value: number);
  60014. /**
  60015. * Gets the view matrix corresponding to a given cascade
  60016. * @param cascadeNum cascade to retrieve the view matrix from
  60017. * @returns the cascade view matrix
  60018. */
  60019. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60020. /**
  60021. * Gets the projection matrix corresponding to a given cascade
  60022. * @param cascadeNum cascade to retrieve the projection matrix from
  60023. * @returns the cascade projection matrix
  60024. */
  60025. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60026. /**
  60027. * Gets the transformation matrix corresponding to a given cascade
  60028. * @param cascadeNum cascade to retrieve the transformation matrix from
  60029. * @returns the cascade transformation matrix
  60030. */
  60031. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60032. private _depthRenderer;
  60033. /**
  60034. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60035. *
  60036. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60037. *
  60038. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60039. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60040. * @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
  60041. */
  60042. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60043. private _depthReducer;
  60044. private _autoCalcDepthBounds;
  60045. /**
  60046. * Gets or sets the autoCalcDepthBounds property.
  60047. *
  60048. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60049. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60050. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60051. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60052. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60053. */
  60054. get autoCalcDepthBounds(): boolean;
  60055. set autoCalcDepthBounds(value: boolean);
  60056. /**
  60057. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60058. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60059. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60060. * for setting the refresh rate on the renderer yourself!
  60061. */
  60062. get autoCalcDepthBoundsRefreshRate(): number;
  60063. set autoCalcDepthBoundsRefreshRate(value: number);
  60064. /**
  60065. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60066. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60067. * you change the camera near/far planes!
  60068. */
  60069. splitFrustum(): void;
  60070. private _splitFrustum;
  60071. private _computeMatrices;
  60072. private _computeFrustumInWorldSpace;
  60073. private _computeCascadeFrustum;
  60074. /**
  60075. * Support test.
  60076. */
  60077. static get IsSupported(): boolean;
  60078. /** @hidden */
  60079. static _SceneComponentInitialization: (scene: Scene) => void;
  60080. /**
  60081. * Creates a Cascaded Shadow Generator object.
  60082. * A ShadowGenerator is the required tool to use the shadows.
  60083. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60084. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60085. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60086. * @param light The directional light object generating the shadows.
  60087. * @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.
  60088. */
  60089. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60090. protected _initializeGenerator(): void;
  60091. protected _createTargetRenderTexture(): void;
  60092. protected _initializeShadowMap(): void;
  60093. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60094. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60095. /**
  60096. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60097. * @param defines Defines of the material we want to update
  60098. * @param lightIndex Index of the light in the enabled light list of the material
  60099. */
  60100. prepareDefines(defines: any, lightIndex: number): void;
  60101. /**
  60102. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60103. * defined in the generator but impacting the effect).
  60104. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60105. * @param effect The effect we are binfing the information for
  60106. */
  60107. bindShadowLight(lightIndex: string, effect: Effect): void;
  60108. /**
  60109. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60110. * (eq to view projection * shadow projection matrices)
  60111. * @returns The transform matrix used to create the shadow map
  60112. */
  60113. getTransformMatrix(): Matrix;
  60114. /**
  60115. * Disposes the ShadowGenerator.
  60116. * Returns nothing.
  60117. */
  60118. dispose(): void;
  60119. /**
  60120. * Serializes the shadow generator setup to a json object.
  60121. * @returns The serialized JSON object
  60122. */
  60123. serialize(): any;
  60124. /**
  60125. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60126. * @param parsedShadowGenerator The JSON object to parse
  60127. * @param scene The scene to create the shadow map for
  60128. * @returns The parsed shadow generator
  60129. */
  60130. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60131. }
  60132. }
  60133. declare module BABYLON {
  60134. /**
  60135. * Defines the shadow generator component responsible to manage any shadow generators
  60136. * in a given scene.
  60137. */
  60138. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60139. /**
  60140. * The component name helpfull to identify the component in the list of scene components.
  60141. */
  60142. readonly name: string;
  60143. /**
  60144. * The scene the component belongs to.
  60145. */
  60146. scene: Scene;
  60147. /**
  60148. * Creates a new instance of the component for the given scene
  60149. * @param scene Defines the scene to register the component in
  60150. */
  60151. constructor(scene: Scene);
  60152. /**
  60153. * Registers the component in a given scene
  60154. */
  60155. register(): void;
  60156. /**
  60157. * Rebuilds the elements related to this component in case of
  60158. * context lost for instance.
  60159. */
  60160. rebuild(): void;
  60161. /**
  60162. * Serializes the component data to the specified json object
  60163. * @param serializationObject The object to serialize to
  60164. */
  60165. serialize(serializationObject: any): void;
  60166. /**
  60167. * Adds all the elements from the container to the scene
  60168. * @param container the container holding the elements
  60169. */
  60170. addFromContainer(container: AbstractScene): void;
  60171. /**
  60172. * Removes all the elements in the container from the scene
  60173. * @param container contains the elements to remove
  60174. * @param dispose if the removed element should be disposed (default: false)
  60175. */
  60176. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60177. /**
  60178. * Rebuilds the elements related to this component in case of
  60179. * context lost for instance.
  60180. */
  60181. dispose(): void;
  60182. private _gatherRenderTargets;
  60183. }
  60184. }
  60185. declare module BABYLON {
  60186. /**
  60187. * A point light is a light defined by an unique point in world space.
  60188. * The light is emitted in every direction from this point.
  60189. * A good example of a point light is a standard light bulb.
  60190. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60191. */
  60192. export class PointLight extends ShadowLight {
  60193. private _shadowAngle;
  60194. /**
  60195. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60196. * This specifies what angle the shadow will use to be created.
  60197. *
  60198. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60199. */
  60200. get shadowAngle(): number;
  60201. /**
  60202. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60203. * This specifies what angle the shadow will use to be created.
  60204. *
  60205. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60206. */
  60207. set shadowAngle(value: number);
  60208. /**
  60209. * Gets the direction if it has been set.
  60210. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60211. */
  60212. get direction(): Vector3;
  60213. /**
  60214. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60215. */
  60216. set direction(value: Vector3);
  60217. /**
  60218. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60219. * A PointLight emits the light in every direction.
  60220. * It can cast shadows.
  60221. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60222. * ```javascript
  60223. * var pointLight = new PointLight("pl", camera.position, scene);
  60224. * ```
  60225. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60226. * @param name The light friendly name
  60227. * @param position The position of the point light in the scene
  60228. * @param scene The scene the lights belongs to
  60229. */
  60230. constructor(name: string, position: Vector3, scene: Scene);
  60231. /**
  60232. * Returns the string "PointLight"
  60233. * @returns the class name
  60234. */
  60235. getClassName(): string;
  60236. /**
  60237. * Returns the integer 0.
  60238. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60239. */
  60240. getTypeID(): number;
  60241. /**
  60242. * Specifies wether or not the shadowmap should be a cube texture.
  60243. * @returns true if the shadowmap needs to be a cube texture.
  60244. */
  60245. needCube(): boolean;
  60246. /**
  60247. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60248. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60249. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60250. */
  60251. getShadowDirection(faceIndex?: number): Vector3;
  60252. /**
  60253. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60254. * - fov = PI / 2
  60255. * - aspect ratio : 1.0
  60256. * - z-near and far equal to the active camera minZ and maxZ.
  60257. * Returns the PointLight.
  60258. */
  60259. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60260. protected _buildUniformLayout(): void;
  60261. /**
  60262. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60263. * @param effect The effect to update
  60264. * @param lightIndex The index of the light in the effect to update
  60265. * @returns The point light
  60266. */
  60267. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60268. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60269. /**
  60270. * Prepares the list of defines specific to the light type.
  60271. * @param defines the list of defines
  60272. * @param lightIndex defines the index of the light for the effect
  60273. */
  60274. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60275. }
  60276. }
  60277. declare module BABYLON {
  60278. /**
  60279. * Header information of HDR texture files.
  60280. */
  60281. export interface HDRInfo {
  60282. /**
  60283. * The height of the texture in pixels.
  60284. */
  60285. height: number;
  60286. /**
  60287. * The width of the texture in pixels.
  60288. */
  60289. width: number;
  60290. /**
  60291. * The index of the beginning of the data in the binary file.
  60292. */
  60293. dataPosition: number;
  60294. }
  60295. /**
  60296. * This groups tools to convert HDR texture to native colors array.
  60297. */
  60298. export class HDRTools {
  60299. private static Ldexp;
  60300. private static Rgbe2float;
  60301. private static readStringLine;
  60302. /**
  60303. * Reads header information from an RGBE texture stored in a native array.
  60304. * More information on this format are available here:
  60305. * https://en.wikipedia.org/wiki/RGBE_image_format
  60306. *
  60307. * @param uint8array The binary file stored in native array.
  60308. * @return The header information.
  60309. */
  60310. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60311. /**
  60312. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60313. * This RGBE texture needs to store the information as a panorama.
  60314. *
  60315. * More information on this format are available here:
  60316. * https://en.wikipedia.org/wiki/RGBE_image_format
  60317. *
  60318. * @param buffer The binary file stored in an array buffer.
  60319. * @param size The expected size of the extracted cubemap.
  60320. * @return The Cube Map information.
  60321. */
  60322. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60323. /**
  60324. * Returns the pixels data extracted from an RGBE texture.
  60325. * This pixels will be stored left to right up to down in the R G B order in one array.
  60326. *
  60327. * More information on this format are available here:
  60328. * https://en.wikipedia.org/wiki/RGBE_image_format
  60329. *
  60330. * @param uint8array The binary file stored in an array buffer.
  60331. * @param hdrInfo The header information of the file.
  60332. * @return The pixels data in RGB right to left up to down order.
  60333. */
  60334. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60335. private static RGBE_ReadPixels_RLE;
  60336. private static RGBE_ReadPixels_NOT_RLE;
  60337. }
  60338. }
  60339. declare module BABYLON {
  60340. /**
  60341. * Effect Render Options
  60342. */
  60343. export interface IEffectRendererOptions {
  60344. /**
  60345. * Defines the vertices positions.
  60346. */
  60347. positions?: number[];
  60348. /**
  60349. * Defines the indices.
  60350. */
  60351. indices?: number[];
  60352. }
  60353. /**
  60354. * Helper class to render one or more effects.
  60355. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60356. */
  60357. export class EffectRenderer {
  60358. private engine;
  60359. private static _DefaultOptions;
  60360. private _vertexBuffers;
  60361. private _indexBuffer;
  60362. private _fullscreenViewport;
  60363. /**
  60364. * Creates an effect renderer
  60365. * @param engine the engine to use for rendering
  60366. * @param options defines the options of the effect renderer
  60367. */
  60368. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60369. /**
  60370. * Sets the current viewport in normalized coordinates 0-1
  60371. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60372. */
  60373. setViewport(viewport?: Viewport): void;
  60374. /**
  60375. * Binds the embedded attributes buffer to the effect.
  60376. * @param effect Defines the effect to bind the attributes for
  60377. */
  60378. bindBuffers(effect: Effect): void;
  60379. /**
  60380. * Sets the current effect wrapper to use during draw.
  60381. * The effect needs to be ready before calling this api.
  60382. * This also sets the default full screen position attribute.
  60383. * @param effectWrapper Defines the effect to draw with
  60384. */
  60385. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60386. /**
  60387. * Restores engine states
  60388. */
  60389. restoreStates(): void;
  60390. /**
  60391. * Draws a full screen quad.
  60392. */
  60393. draw(): void;
  60394. private isRenderTargetTexture;
  60395. /**
  60396. * renders one or more effects to a specified texture
  60397. * @param effectWrapper the effect to renderer
  60398. * @param outputTexture texture to draw to, if null it will render to the screen.
  60399. */
  60400. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60401. /**
  60402. * Disposes of the effect renderer
  60403. */
  60404. dispose(): void;
  60405. }
  60406. /**
  60407. * Options to create an EffectWrapper
  60408. */
  60409. interface EffectWrapperCreationOptions {
  60410. /**
  60411. * Engine to use to create the effect
  60412. */
  60413. engine: ThinEngine;
  60414. /**
  60415. * Fragment shader for the effect
  60416. */
  60417. fragmentShader: string;
  60418. /**
  60419. * Use the shader store instead of direct source code
  60420. */
  60421. useShaderStore?: boolean;
  60422. /**
  60423. * Vertex shader for the effect
  60424. */
  60425. vertexShader?: string;
  60426. /**
  60427. * Attributes to use in the shader
  60428. */
  60429. attributeNames?: Array<string>;
  60430. /**
  60431. * Uniforms to use in the shader
  60432. */
  60433. uniformNames?: Array<string>;
  60434. /**
  60435. * Texture sampler names to use in the shader
  60436. */
  60437. samplerNames?: Array<string>;
  60438. /**
  60439. * Defines to use in the shader
  60440. */
  60441. defines?: Array<string>;
  60442. /**
  60443. * Callback when effect is compiled
  60444. */
  60445. onCompiled?: Nullable<(effect: Effect) => void>;
  60446. /**
  60447. * The friendly name of the effect displayed in Spector.
  60448. */
  60449. name?: string;
  60450. }
  60451. /**
  60452. * Wraps an effect to be used for rendering
  60453. */
  60454. export class EffectWrapper {
  60455. /**
  60456. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60457. */
  60458. onApplyObservable: Observable<{}>;
  60459. /**
  60460. * The underlying effect
  60461. */
  60462. effect: Effect;
  60463. /**
  60464. * Creates an effect to be renderer
  60465. * @param creationOptions options to create the effect
  60466. */
  60467. constructor(creationOptions: EffectWrapperCreationOptions);
  60468. /**
  60469. * Disposes of the effect wrapper
  60470. */
  60471. dispose(): void;
  60472. }
  60473. }
  60474. declare module BABYLON {
  60475. /** @hidden */
  60476. export var hdrFilteringVertexShader: {
  60477. name: string;
  60478. shader: string;
  60479. };
  60480. }
  60481. declare module BABYLON {
  60482. /** @hidden */
  60483. export var hdrFilteringPixelShader: {
  60484. name: string;
  60485. shader: string;
  60486. };
  60487. }
  60488. declare module BABYLON {
  60489. /**
  60490. * Options for texture filtering
  60491. */
  60492. interface IHDRFilteringOptions {
  60493. /**
  60494. * Scales pixel intensity for the input HDR map.
  60495. */
  60496. hdrScale?: number;
  60497. /**
  60498. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60499. */
  60500. quality?: number;
  60501. }
  60502. /**
  60503. * Filters HDR maps to get correct renderings of PBR reflections
  60504. */
  60505. export class HDRFiltering {
  60506. private _engine;
  60507. private _effectRenderer;
  60508. private _effectWrapper;
  60509. private _lodGenerationOffset;
  60510. private _lodGenerationScale;
  60511. /**
  60512. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60513. * you care about baking speed.
  60514. */
  60515. quality: number;
  60516. /**
  60517. * Scales pixel intensity for the input HDR map.
  60518. */
  60519. hdrScale: number;
  60520. /**
  60521. * Instantiates HDR filter for reflection maps
  60522. *
  60523. * @param engine Thin engine
  60524. * @param options Options
  60525. */
  60526. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60527. private _createRenderTarget;
  60528. private _prefilterInternal;
  60529. private _createEffect;
  60530. /**
  60531. * Get a value indicating if the filter is ready to be used
  60532. * @param texture Texture to filter
  60533. * @returns true if the filter is ready
  60534. */
  60535. isReady(texture: BaseTexture): boolean;
  60536. /**
  60537. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60538. * Prefiltering will be invoked at the end of next rendering pass.
  60539. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60540. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60541. * @param texture Texture to filter
  60542. * @param onFinished Callback when filtering is done
  60543. * @return Promise called when prefiltering is done
  60544. */
  60545. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60546. }
  60547. }
  60548. declare module BABYLON {
  60549. /**
  60550. * This represents a texture coming from an HDR input.
  60551. *
  60552. * The only supported format is currently panorama picture stored in RGBE format.
  60553. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60554. */
  60555. export class HDRCubeTexture extends BaseTexture {
  60556. private static _facesMapping;
  60557. private _generateHarmonics;
  60558. private _noMipmap;
  60559. private _prefilterOnLoad;
  60560. private _textureMatrix;
  60561. private _size;
  60562. private _onLoad;
  60563. private _onError;
  60564. /**
  60565. * The texture URL.
  60566. */
  60567. url: string;
  60568. protected _isBlocking: boolean;
  60569. /**
  60570. * Sets wether or not the texture is blocking during loading.
  60571. */
  60572. set isBlocking(value: boolean);
  60573. /**
  60574. * Gets wether or not the texture is blocking during loading.
  60575. */
  60576. get isBlocking(): boolean;
  60577. protected _rotationY: number;
  60578. /**
  60579. * Sets texture matrix rotation angle around Y axis in radians.
  60580. */
  60581. set rotationY(value: number);
  60582. /**
  60583. * Gets texture matrix rotation angle around Y axis radians.
  60584. */
  60585. get rotationY(): number;
  60586. /**
  60587. * Gets or sets the center of the bounding box associated with the cube texture
  60588. * It must define where the camera used to render the texture was set
  60589. */
  60590. boundingBoxPosition: Vector3;
  60591. private _boundingBoxSize;
  60592. /**
  60593. * Gets or sets the size of the bounding box associated with the cube texture
  60594. * When defined, the cubemap will switch to local mode
  60595. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60596. * @example https://www.babylonjs-playground.com/#RNASML
  60597. */
  60598. set boundingBoxSize(value: Vector3);
  60599. get boundingBoxSize(): Vector3;
  60600. /**
  60601. * Instantiates an HDRTexture from the following parameters.
  60602. *
  60603. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60604. * @param sceneOrEngine The scene or engine the texture will be used in
  60605. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60606. * @param noMipmap Forces to not generate the mipmap if true
  60607. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60608. * @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)
  60609. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60610. */
  60611. 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>);
  60612. /**
  60613. * Get the current class name of the texture useful for serialization or dynamic coding.
  60614. * @returns "HDRCubeTexture"
  60615. */
  60616. getClassName(): string;
  60617. /**
  60618. * Occurs when the file is raw .hdr file.
  60619. */
  60620. private loadTexture;
  60621. clone(): HDRCubeTexture;
  60622. delayLoad(): void;
  60623. /**
  60624. * Get the texture reflection matrix used to rotate/transform the reflection.
  60625. * @returns the reflection matrix
  60626. */
  60627. getReflectionTextureMatrix(): Matrix;
  60628. /**
  60629. * Set the texture reflection matrix used to rotate/transform the reflection.
  60630. * @param value Define the reflection matrix to set
  60631. */
  60632. setReflectionTextureMatrix(value: Matrix): void;
  60633. /**
  60634. * Parses a JSON representation of an HDR Texture in order to create the texture
  60635. * @param parsedTexture Define the JSON representation
  60636. * @param scene Define the scene the texture should be created in
  60637. * @param rootUrl Define the root url in case we need to load relative dependencies
  60638. * @returns the newly created texture after parsing
  60639. */
  60640. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60641. serialize(): any;
  60642. }
  60643. }
  60644. declare module BABYLON {
  60645. /**
  60646. * Class used to control physics engine
  60647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60648. */
  60649. export class PhysicsEngine implements IPhysicsEngine {
  60650. private _physicsPlugin;
  60651. /**
  60652. * Global value used to control the smallest number supported by the simulation
  60653. */
  60654. static Epsilon: number;
  60655. private _impostors;
  60656. private _joints;
  60657. private _subTimeStep;
  60658. /**
  60659. * Gets the gravity vector used by the simulation
  60660. */
  60661. gravity: Vector3;
  60662. /**
  60663. * Factory used to create the default physics plugin.
  60664. * @returns The default physics plugin
  60665. */
  60666. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60667. /**
  60668. * Creates a new Physics Engine
  60669. * @param gravity defines the gravity vector used by the simulation
  60670. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60671. */
  60672. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60673. /**
  60674. * Sets the gravity vector used by the simulation
  60675. * @param gravity defines the gravity vector to use
  60676. */
  60677. setGravity(gravity: Vector3): void;
  60678. /**
  60679. * Set the time step of the physics engine.
  60680. * Default is 1/60.
  60681. * To slow it down, enter 1/600 for example.
  60682. * To speed it up, 1/30
  60683. * @param newTimeStep defines the new timestep to apply to this world.
  60684. */
  60685. setTimeStep(newTimeStep?: number): void;
  60686. /**
  60687. * Get the time step of the physics engine.
  60688. * @returns the current time step
  60689. */
  60690. getTimeStep(): number;
  60691. /**
  60692. * Set the sub time step of the physics engine.
  60693. * Default is 0 meaning there is no sub steps
  60694. * To increase physics resolution precision, set a small value (like 1 ms)
  60695. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60696. */
  60697. setSubTimeStep(subTimeStep?: number): void;
  60698. /**
  60699. * Get the sub time step of the physics engine.
  60700. * @returns the current sub time step
  60701. */
  60702. getSubTimeStep(): number;
  60703. /**
  60704. * Release all resources
  60705. */
  60706. dispose(): void;
  60707. /**
  60708. * Gets the name of the current physics plugin
  60709. * @returns the name of the plugin
  60710. */
  60711. getPhysicsPluginName(): string;
  60712. /**
  60713. * Adding a new impostor for the impostor tracking.
  60714. * This will be done by the impostor itself.
  60715. * @param impostor the impostor to add
  60716. */
  60717. addImpostor(impostor: PhysicsImpostor): void;
  60718. /**
  60719. * Remove an impostor from the engine.
  60720. * This impostor and its mesh will not longer be updated by the physics engine.
  60721. * @param impostor the impostor to remove
  60722. */
  60723. removeImpostor(impostor: PhysicsImpostor): void;
  60724. /**
  60725. * Add a joint to the physics engine
  60726. * @param mainImpostor defines the main impostor to which the joint is added.
  60727. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60728. * @param joint defines the joint that will connect both impostors.
  60729. */
  60730. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60731. /**
  60732. * Removes a joint from the simulation
  60733. * @param mainImpostor defines the impostor used with the joint
  60734. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60735. * @param joint defines the joint to remove
  60736. */
  60737. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60738. /**
  60739. * Called by the scene. No need to call it.
  60740. * @param delta defines the timespam between frames
  60741. */
  60742. _step(delta: number): void;
  60743. /**
  60744. * Gets the current plugin used to run the simulation
  60745. * @returns current plugin
  60746. */
  60747. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60748. /**
  60749. * Gets the list of physic impostors
  60750. * @returns an array of PhysicsImpostor
  60751. */
  60752. getImpostors(): Array<PhysicsImpostor>;
  60753. /**
  60754. * Gets the impostor for a physics enabled object
  60755. * @param object defines the object impersonated by the impostor
  60756. * @returns the PhysicsImpostor or null if not found
  60757. */
  60758. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60759. /**
  60760. * Gets the impostor for a physics body object
  60761. * @param body defines physics body used by the impostor
  60762. * @returns the PhysicsImpostor or null if not found
  60763. */
  60764. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60765. /**
  60766. * Does a raycast in the physics world
  60767. * @param from when should the ray start?
  60768. * @param to when should the ray end?
  60769. * @returns PhysicsRaycastResult
  60770. */
  60771. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60772. }
  60773. }
  60774. declare module BABYLON {
  60775. /** @hidden */
  60776. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60777. private _useDeltaForWorldStep;
  60778. world: any;
  60779. name: string;
  60780. private _physicsMaterials;
  60781. private _fixedTimeStep;
  60782. private _cannonRaycastResult;
  60783. private _raycastResult;
  60784. private _physicsBodysToRemoveAfterStep;
  60785. private _firstFrame;
  60786. BJSCANNON: any;
  60787. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60788. setGravity(gravity: Vector3): void;
  60789. setTimeStep(timeStep: number): void;
  60790. getTimeStep(): number;
  60791. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60792. private _removeMarkedPhysicsBodiesFromWorld;
  60793. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60794. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60795. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60796. private _processChildMeshes;
  60797. removePhysicsBody(impostor: PhysicsImpostor): void;
  60798. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60799. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60800. private _addMaterial;
  60801. private _checkWithEpsilon;
  60802. private _createShape;
  60803. private _createHeightmap;
  60804. private _minus90X;
  60805. private _plus90X;
  60806. private _tmpPosition;
  60807. private _tmpDeltaPosition;
  60808. private _tmpUnityRotation;
  60809. private _updatePhysicsBodyTransformation;
  60810. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60811. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60812. isSupported(): boolean;
  60813. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60814. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60815. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60816. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60817. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60818. getBodyMass(impostor: PhysicsImpostor): number;
  60819. getBodyFriction(impostor: PhysicsImpostor): number;
  60820. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60821. getBodyRestitution(impostor: PhysicsImpostor): number;
  60822. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60823. sleepBody(impostor: PhysicsImpostor): void;
  60824. wakeUpBody(impostor: PhysicsImpostor): void;
  60825. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60826. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60827. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60828. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60829. getRadius(impostor: PhysicsImpostor): number;
  60830. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60831. dispose(): void;
  60832. private _extendNamespace;
  60833. /**
  60834. * Does a raycast in the physics world
  60835. * @param from when should the ray start?
  60836. * @param to when should the ray end?
  60837. * @returns PhysicsRaycastResult
  60838. */
  60839. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60840. }
  60841. }
  60842. declare module BABYLON {
  60843. /** @hidden */
  60844. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60845. private _useDeltaForWorldStep;
  60846. world: any;
  60847. name: string;
  60848. BJSOIMO: any;
  60849. private _raycastResult;
  60850. private _fixedTimeStep;
  60851. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60852. setGravity(gravity: Vector3): void;
  60853. setTimeStep(timeStep: number): void;
  60854. getTimeStep(): number;
  60855. private _tmpImpostorsArray;
  60856. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60857. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60858. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60859. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60860. private _tmpPositionVector;
  60861. removePhysicsBody(impostor: PhysicsImpostor): void;
  60862. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60863. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60864. isSupported(): boolean;
  60865. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60866. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60867. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60868. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60869. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60870. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60871. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60872. getBodyMass(impostor: PhysicsImpostor): number;
  60873. getBodyFriction(impostor: PhysicsImpostor): number;
  60874. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60875. getBodyRestitution(impostor: PhysicsImpostor): number;
  60876. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60877. sleepBody(impostor: PhysicsImpostor): void;
  60878. wakeUpBody(impostor: PhysicsImpostor): void;
  60879. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60880. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60881. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60882. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60883. getRadius(impostor: PhysicsImpostor): number;
  60884. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60885. dispose(): void;
  60886. /**
  60887. * Does a raycast in the physics world
  60888. * @param from when should the ray start?
  60889. * @param to when should the ray end?
  60890. * @returns PhysicsRaycastResult
  60891. */
  60892. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60893. }
  60894. }
  60895. declare module BABYLON {
  60896. /**
  60897. * AmmoJS Physics plugin
  60898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60899. * @see https://github.com/kripken/ammo.js/
  60900. */
  60901. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60902. private _useDeltaForWorldStep;
  60903. /**
  60904. * Reference to the Ammo library
  60905. */
  60906. bjsAMMO: any;
  60907. /**
  60908. * Created ammoJS world which physics bodies are added to
  60909. */
  60910. world: any;
  60911. /**
  60912. * Name of the plugin
  60913. */
  60914. name: string;
  60915. private _timeStep;
  60916. private _fixedTimeStep;
  60917. private _maxSteps;
  60918. private _tmpQuaternion;
  60919. private _tmpAmmoTransform;
  60920. private _tmpAmmoQuaternion;
  60921. private _tmpAmmoConcreteContactResultCallback;
  60922. private _collisionConfiguration;
  60923. private _dispatcher;
  60924. private _overlappingPairCache;
  60925. private _solver;
  60926. private _softBodySolver;
  60927. private _tmpAmmoVectorA;
  60928. private _tmpAmmoVectorB;
  60929. private _tmpAmmoVectorC;
  60930. private _tmpAmmoVectorD;
  60931. private _tmpContactCallbackResult;
  60932. private _tmpAmmoVectorRCA;
  60933. private _tmpAmmoVectorRCB;
  60934. private _raycastResult;
  60935. private static readonly DISABLE_COLLISION_FLAG;
  60936. private static readonly KINEMATIC_FLAG;
  60937. private static readonly DISABLE_DEACTIVATION_FLAG;
  60938. /**
  60939. * Initializes the ammoJS plugin
  60940. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60941. * @param ammoInjection can be used to inject your own ammo reference
  60942. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60943. */
  60944. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60945. /**
  60946. * Sets the gravity of the physics world (m/(s^2))
  60947. * @param gravity Gravity to set
  60948. */
  60949. setGravity(gravity: Vector3): void;
  60950. /**
  60951. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60952. * @param timeStep timestep to use in seconds
  60953. */
  60954. setTimeStep(timeStep: number): void;
  60955. /**
  60956. * 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)
  60957. * @param fixedTimeStep fixedTimeStep to use in seconds
  60958. */
  60959. setFixedTimeStep(fixedTimeStep: number): void;
  60960. /**
  60961. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60962. * @param maxSteps the maximum number of steps by the physics engine per frame
  60963. */
  60964. setMaxSteps(maxSteps: number): void;
  60965. /**
  60966. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60967. * @returns the current timestep in seconds
  60968. */
  60969. getTimeStep(): number;
  60970. /**
  60971. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60972. */
  60973. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60974. private _isImpostorInContact;
  60975. private _isImpostorPairInContact;
  60976. private _stepSimulation;
  60977. /**
  60978. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60979. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60980. * After the step the babylon meshes are set to the position of the physics imposters
  60981. * @param delta amount of time to step forward
  60982. * @param impostors array of imposters to update before/after the step
  60983. */
  60984. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60985. /**
  60986. * Update babylon mesh to match physics world object
  60987. * @param impostor imposter to match
  60988. */
  60989. private _afterSoftStep;
  60990. /**
  60991. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60992. * @param impostor imposter to match
  60993. */
  60994. private _ropeStep;
  60995. /**
  60996. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60997. * @param impostor imposter to match
  60998. */
  60999. private _softbodyOrClothStep;
  61000. private _tmpMatrix;
  61001. /**
  61002. * Applies an impulse on the imposter
  61003. * @param impostor imposter to apply impulse to
  61004. * @param force amount of force to be applied to the imposter
  61005. * @param contactPoint the location to apply the impulse on the imposter
  61006. */
  61007. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61008. /**
  61009. * Applies a force on the imposter
  61010. * @param impostor imposter to apply force
  61011. * @param force amount of force to be applied to the imposter
  61012. * @param contactPoint the location to apply the force on the imposter
  61013. */
  61014. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61015. /**
  61016. * Creates a physics body using the plugin
  61017. * @param impostor the imposter to create the physics body on
  61018. */
  61019. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61020. /**
  61021. * Removes the physics body from the imposter and disposes of the body's memory
  61022. * @param impostor imposter to remove the physics body from
  61023. */
  61024. removePhysicsBody(impostor: PhysicsImpostor): void;
  61025. /**
  61026. * Generates a joint
  61027. * @param impostorJoint the imposter joint to create the joint with
  61028. */
  61029. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61030. /**
  61031. * Removes a joint
  61032. * @param impostorJoint the imposter joint to remove the joint from
  61033. */
  61034. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61035. private _addMeshVerts;
  61036. /**
  61037. * Initialise the soft body vertices to match its object's (mesh) vertices
  61038. * Softbody vertices (nodes) are in world space and to match this
  61039. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61040. * @param impostor to create the softbody for
  61041. */
  61042. private _softVertexData;
  61043. /**
  61044. * Create an impostor's soft body
  61045. * @param impostor to create the softbody for
  61046. */
  61047. private _createSoftbody;
  61048. /**
  61049. * Create cloth for an impostor
  61050. * @param impostor to create the softbody for
  61051. */
  61052. private _createCloth;
  61053. /**
  61054. * Create rope for an impostor
  61055. * @param impostor to create the softbody for
  61056. */
  61057. private _createRope;
  61058. /**
  61059. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61060. * @param impostor to create the custom physics shape for
  61061. */
  61062. private _createCustom;
  61063. private _addHullVerts;
  61064. private _createShape;
  61065. /**
  61066. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61067. * @param impostor imposter containing the physics body and babylon object
  61068. */
  61069. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61070. /**
  61071. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61072. * @param impostor imposter containing the physics body and babylon object
  61073. * @param newPosition new position
  61074. * @param newRotation new rotation
  61075. */
  61076. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61077. /**
  61078. * If this plugin is supported
  61079. * @returns true if its supported
  61080. */
  61081. isSupported(): boolean;
  61082. /**
  61083. * Sets the linear velocity of the physics body
  61084. * @param impostor imposter to set the velocity on
  61085. * @param velocity velocity to set
  61086. */
  61087. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61088. /**
  61089. * Sets the angular velocity of the physics body
  61090. * @param impostor imposter to set the velocity on
  61091. * @param velocity velocity to set
  61092. */
  61093. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61094. /**
  61095. * gets the linear velocity
  61096. * @param impostor imposter to get linear velocity from
  61097. * @returns linear velocity
  61098. */
  61099. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61100. /**
  61101. * gets the angular velocity
  61102. * @param impostor imposter to get angular velocity from
  61103. * @returns angular velocity
  61104. */
  61105. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61106. /**
  61107. * Sets the mass of physics body
  61108. * @param impostor imposter to set the mass on
  61109. * @param mass mass to set
  61110. */
  61111. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61112. /**
  61113. * Gets the mass of the physics body
  61114. * @param impostor imposter to get the mass from
  61115. * @returns mass
  61116. */
  61117. getBodyMass(impostor: PhysicsImpostor): number;
  61118. /**
  61119. * Gets friction of the impostor
  61120. * @param impostor impostor to get friction from
  61121. * @returns friction value
  61122. */
  61123. getBodyFriction(impostor: PhysicsImpostor): number;
  61124. /**
  61125. * Sets friction of the impostor
  61126. * @param impostor impostor to set friction on
  61127. * @param friction friction value
  61128. */
  61129. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61130. /**
  61131. * Gets restitution of the impostor
  61132. * @param impostor impostor to get restitution from
  61133. * @returns restitution value
  61134. */
  61135. getBodyRestitution(impostor: PhysicsImpostor): number;
  61136. /**
  61137. * Sets resitution of the impostor
  61138. * @param impostor impostor to set resitution on
  61139. * @param restitution resitution value
  61140. */
  61141. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61142. /**
  61143. * Gets pressure inside the impostor
  61144. * @param impostor impostor to get pressure from
  61145. * @returns pressure value
  61146. */
  61147. getBodyPressure(impostor: PhysicsImpostor): number;
  61148. /**
  61149. * Sets pressure inside a soft body impostor
  61150. * Cloth and rope must remain 0 pressure
  61151. * @param impostor impostor to set pressure on
  61152. * @param pressure pressure value
  61153. */
  61154. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61155. /**
  61156. * Gets stiffness of the impostor
  61157. * @param impostor impostor to get stiffness from
  61158. * @returns pressure value
  61159. */
  61160. getBodyStiffness(impostor: PhysicsImpostor): number;
  61161. /**
  61162. * Sets stiffness of the impostor
  61163. * @param impostor impostor to set stiffness on
  61164. * @param stiffness stiffness value from 0 to 1
  61165. */
  61166. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61167. /**
  61168. * Gets velocityIterations of the impostor
  61169. * @param impostor impostor to get velocity iterations from
  61170. * @returns velocityIterations value
  61171. */
  61172. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61173. /**
  61174. * Sets velocityIterations of the impostor
  61175. * @param impostor impostor to set velocity iterations on
  61176. * @param velocityIterations velocityIterations value
  61177. */
  61178. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61179. /**
  61180. * Gets positionIterations of the impostor
  61181. * @param impostor impostor to get position iterations from
  61182. * @returns positionIterations value
  61183. */
  61184. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61185. /**
  61186. * Sets positionIterations of the impostor
  61187. * @param impostor impostor to set position on
  61188. * @param positionIterations positionIterations value
  61189. */
  61190. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61191. /**
  61192. * Append an anchor to a cloth object
  61193. * @param impostor is the cloth impostor to add anchor to
  61194. * @param otherImpostor is the rigid impostor to anchor to
  61195. * @param width ratio across width from 0 to 1
  61196. * @param height ratio up height from 0 to 1
  61197. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61198. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61199. */
  61200. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61201. /**
  61202. * Append an hook to a rope object
  61203. * @param impostor is the rope impostor to add hook to
  61204. * @param otherImpostor is the rigid impostor to hook to
  61205. * @param length ratio along the rope from 0 to 1
  61206. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61207. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61208. */
  61209. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61210. /**
  61211. * Sleeps the physics body and stops it from being active
  61212. * @param impostor impostor to sleep
  61213. */
  61214. sleepBody(impostor: PhysicsImpostor): void;
  61215. /**
  61216. * Activates the physics body
  61217. * @param impostor impostor to activate
  61218. */
  61219. wakeUpBody(impostor: PhysicsImpostor): void;
  61220. /**
  61221. * Updates the distance parameters of the joint
  61222. * @param joint joint to update
  61223. * @param maxDistance maximum distance of the joint
  61224. * @param minDistance minimum distance of the joint
  61225. */
  61226. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61227. /**
  61228. * Sets a motor on the joint
  61229. * @param joint joint to set motor on
  61230. * @param speed speed of the motor
  61231. * @param maxForce maximum force of the motor
  61232. * @param motorIndex index of the motor
  61233. */
  61234. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61235. /**
  61236. * Sets the motors limit
  61237. * @param joint joint to set limit on
  61238. * @param upperLimit upper limit
  61239. * @param lowerLimit lower limit
  61240. */
  61241. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61242. /**
  61243. * Syncs the position and rotation of a mesh with the impostor
  61244. * @param mesh mesh to sync
  61245. * @param impostor impostor to update the mesh with
  61246. */
  61247. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61248. /**
  61249. * Gets the radius of the impostor
  61250. * @param impostor impostor to get radius from
  61251. * @returns the radius
  61252. */
  61253. getRadius(impostor: PhysicsImpostor): number;
  61254. /**
  61255. * Gets the box size of the impostor
  61256. * @param impostor impostor to get box size from
  61257. * @param result the resulting box size
  61258. */
  61259. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61260. /**
  61261. * Disposes of the impostor
  61262. */
  61263. dispose(): void;
  61264. /**
  61265. * Does a raycast in the physics world
  61266. * @param from when should the ray start?
  61267. * @param to when should the ray end?
  61268. * @returns PhysicsRaycastResult
  61269. */
  61270. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61271. }
  61272. }
  61273. declare module BABYLON {
  61274. interface AbstractScene {
  61275. /**
  61276. * The list of reflection probes added to the scene
  61277. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61278. */
  61279. reflectionProbes: Array<ReflectionProbe>;
  61280. /**
  61281. * Removes the given reflection probe from this scene.
  61282. * @param toRemove The reflection probe to remove
  61283. * @returns The index of the removed reflection probe
  61284. */
  61285. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61286. /**
  61287. * Adds the given reflection probe to this scene.
  61288. * @param newReflectionProbe The reflection probe to add
  61289. */
  61290. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61291. }
  61292. /**
  61293. * Class used to generate realtime reflection / refraction cube textures
  61294. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61295. */
  61296. export class ReflectionProbe {
  61297. /** defines the name of the probe */
  61298. name: string;
  61299. private _scene;
  61300. private _renderTargetTexture;
  61301. private _projectionMatrix;
  61302. private _viewMatrix;
  61303. private _target;
  61304. private _add;
  61305. private _attachedMesh;
  61306. private _invertYAxis;
  61307. /** Gets or sets probe position (center of the cube map) */
  61308. position: Vector3;
  61309. /**
  61310. * Creates a new reflection probe
  61311. * @param name defines the name of the probe
  61312. * @param size defines the texture resolution (for each face)
  61313. * @param scene defines the hosting scene
  61314. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61315. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61316. */
  61317. constructor(
  61318. /** defines the name of the probe */
  61319. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61320. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61321. get samples(): number;
  61322. set samples(value: number);
  61323. /** Gets or sets the refresh rate to use (on every frame by default) */
  61324. get refreshRate(): number;
  61325. set refreshRate(value: number);
  61326. /**
  61327. * Gets the hosting scene
  61328. * @returns a Scene
  61329. */
  61330. getScene(): Scene;
  61331. /** Gets the internal CubeTexture used to render to */
  61332. get cubeTexture(): RenderTargetTexture;
  61333. /** Gets the list of meshes to render */
  61334. get renderList(): Nullable<AbstractMesh[]>;
  61335. /**
  61336. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61337. * @param mesh defines the mesh to attach to
  61338. */
  61339. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61340. /**
  61341. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61342. * @param renderingGroupId The rendering group id corresponding to its index
  61343. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61344. */
  61345. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61346. /**
  61347. * Clean all associated resources
  61348. */
  61349. dispose(): void;
  61350. /**
  61351. * Converts the reflection probe information to a readable string for debug purpose.
  61352. * @param fullDetails Supports for multiple levels of logging within scene loading
  61353. * @returns the human readable reflection probe info
  61354. */
  61355. toString(fullDetails?: boolean): string;
  61356. /**
  61357. * Get the class name of the relfection probe.
  61358. * @returns "ReflectionProbe"
  61359. */
  61360. getClassName(): string;
  61361. /**
  61362. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61363. * @returns The JSON representation of the texture
  61364. */
  61365. serialize(): any;
  61366. /**
  61367. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61368. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61369. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61370. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61371. * @returns The parsed reflection probe if successful
  61372. */
  61373. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61374. }
  61375. }
  61376. declare module BABYLON {
  61377. /** @hidden */
  61378. export var _BabylonLoaderRegistered: boolean;
  61379. /**
  61380. * Helps setting up some configuration for the babylon file loader.
  61381. */
  61382. export class BabylonFileLoaderConfiguration {
  61383. /**
  61384. * The loader does not allow injecting custom physix engine into the plugins.
  61385. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61386. * So you could set this variable to your engine import to make it work.
  61387. */
  61388. static LoaderInjectedPhysicsEngine: any;
  61389. }
  61390. }
  61391. declare module BABYLON {
  61392. /**
  61393. * The Physically based simple base material of BJS.
  61394. *
  61395. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61396. * It is used as the base class for both the specGloss and metalRough conventions.
  61397. */
  61398. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61399. /**
  61400. * Number of Simultaneous lights allowed on the material.
  61401. */
  61402. maxSimultaneousLights: number;
  61403. /**
  61404. * If sets to true, disables all the lights affecting the material.
  61405. */
  61406. disableLighting: boolean;
  61407. /**
  61408. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61409. */
  61410. environmentTexture: BaseTexture;
  61411. /**
  61412. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61413. */
  61414. invertNormalMapX: boolean;
  61415. /**
  61416. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61417. */
  61418. invertNormalMapY: boolean;
  61419. /**
  61420. * Normal map used in the model.
  61421. */
  61422. normalTexture: BaseTexture;
  61423. /**
  61424. * Emissivie color used to self-illuminate the model.
  61425. */
  61426. emissiveColor: Color3;
  61427. /**
  61428. * Emissivie texture used to self-illuminate the model.
  61429. */
  61430. emissiveTexture: BaseTexture;
  61431. /**
  61432. * Occlusion Channel Strenght.
  61433. */
  61434. occlusionStrength: number;
  61435. /**
  61436. * Occlusion Texture of the material (adding extra occlusion effects).
  61437. */
  61438. occlusionTexture: BaseTexture;
  61439. /**
  61440. * Defines the alpha limits in alpha test mode.
  61441. */
  61442. alphaCutOff: number;
  61443. /**
  61444. * Gets the current double sided mode.
  61445. */
  61446. get doubleSided(): boolean;
  61447. /**
  61448. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61449. */
  61450. set doubleSided(value: boolean);
  61451. /**
  61452. * Stores the pre-calculated light information of a mesh in a texture.
  61453. */
  61454. lightmapTexture: BaseTexture;
  61455. /**
  61456. * If true, the light map contains occlusion information instead of lighting info.
  61457. */
  61458. useLightmapAsShadowmap: boolean;
  61459. /**
  61460. * Instantiates a new PBRMaterial instance.
  61461. *
  61462. * @param name The material name
  61463. * @param scene The scene the material will be use in.
  61464. */
  61465. constructor(name: string, scene: Scene);
  61466. getClassName(): string;
  61467. }
  61468. }
  61469. declare module BABYLON {
  61470. /**
  61471. * The PBR material of BJS following the metal roughness convention.
  61472. *
  61473. * This fits to the PBR convention in the GLTF definition:
  61474. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61475. */
  61476. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61477. /**
  61478. * The base color has two different interpretations depending on the value of metalness.
  61479. * When the material is a metal, the base color is the specific measured reflectance value
  61480. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61481. * of the material.
  61482. */
  61483. baseColor: Color3;
  61484. /**
  61485. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61486. * well as opacity information in the alpha channel.
  61487. */
  61488. baseTexture: BaseTexture;
  61489. /**
  61490. * Specifies the metallic scalar value of the material.
  61491. * Can also be used to scale the metalness values of the metallic texture.
  61492. */
  61493. metallic: number;
  61494. /**
  61495. * Specifies the roughness scalar value of the material.
  61496. * Can also be used to scale the roughness values of the metallic texture.
  61497. */
  61498. roughness: number;
  61499. /**
  61500. * Texture containing both the metallic value in the B channel and the
  61501. * roughness value in the G channel to keep better precision.
  61502. */
  61503. metallicRoughnessTexture: BaseTexture;
  61504. /**
  61505. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61506. *
  61507. * @param name The material name
  61508. * @param scene The scene the material will be use in.
  61509. */
  61510. constructor(name: string, scene: Scene);
  61511. /**
  61512. * Return the currrent class name of the material.
  61513. */
  61514. getClassName(): string;
  61515. /**
  61516. * Makes a duplicate of the current material.
  61517. * @param name - name to use for the new material.
  61518. */
  61519. clone(name: string): PBRMetallicRoughnessMaterial;
  61520. /**
  61521. * Serialize the material to a parsable JSON object.
  61522. */
  61523. serialize(): any;
  61524. /**
  61525. * Parses a JSON object correponding to the serialize function.
  61526. */
  61527. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61528. }
  61529. }
  61530. declare module BABYLON {
  61531. /**
  61532. * The PBR material of BJS following the specular glossiness convention.
  61533. *
  61534. * This fits to the PBR convention in the GLTF definition:
  61535. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61536. */
  61537. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61538. /**
  61539. * Specifies the diffuse color of the material.
  61540. */
  61541. diffuseColor: Color3;
  61542. /**
  61543. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61544. * channel.
  61545. */
  61546. diffuseTexture: BaseTexture;
  61547. /**
  61548. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61549. */
  61550. specularColor: Color3;
  61551. /**
  61552. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61553. */
  61554. glossiness: number;
  61555. /**
  61556. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61557. */
  61558. specularGlossinessTexture: BaseTexture;
  61559. /**
  61560. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61561. *
  61562. * @param name The material name
  61563. * @param scene The scene the material will be use in.
  61564. */
  61565. constructor(name: string, scene: Scene);
  61566. /**
  61567. * Return the currrent class name of the material.
  61568. */
  61569. getClassName(): string;
  61570. /**
  61571. * Makes a duplicate of the current material.
  61572. * @param name - name to use for the new material.
  61573. */
  61574. clone(name: string): PBRSpecularGlossinessMaterial;
  61575. /**
  61576. * Serialize the material to a parsable JSON object.
  61577. */
  61578. serialize(): any;
  61579. /**
  61580. * Parses a JSON object correponding to the serialize function.
  61581. */
  61582. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61583. }
  61584. }
  61585. declare module BABYLON {
  61586. /**
  61587. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61588. * It can help converting any input color in a desired output one. This can then be used to create effects
  61589. * from sepia, black and white to sixties or futuristic rendering...
  61590. *
  61591. * The only supported format is currently 3dl.
  61592. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61593. */
  61594. export class ColorGradingTexture extends BaseTexture {
  61595. /**
  61596. * The texture URL.
  61597. */
  61598. url: string;
  61599. /**
  61600. * Empty line regex stored for GC.
  61601. */
  61602. private static _noneEmptyLineRegex;
  61603. private _textureMatrix;
  61604. private _onLoad;
  61605. /**
  61606. * Instantiates a ColorGradingTexture from the following parameters.
  61607. *
  61608. * @param url The location of the color gradind data (currently only supporting 3dl)
  61609. * @param sceneOrEngine The scene or engine the texture will be used in
  61610. * @param onLoad defines a callback triggered when the texture has been loaded
  61611. */
  61612. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61613. /**
  61614. * Fires the onload event from the constructor if requested.
  61615. */
  61616. private _triggerOnLoad;
  61617. /**
  61618. * Returns the texture matrix used in most of the material.
  61619. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61620. */
  61621. getTextureMatrix(): Matrix;
  61622. /**
  61623. * Occurs when the file being loaded is a .3dl LUT file.
  61624. */
  61625. private load3dlTexture;
  61626. /**
  61627. * Starts the loading process of the texture.
  61628. */
  61629. private loadTexture;
  61630. /**
  61631. * Clones the color gradind texture.
  61632. */
  61633. clone(): ColorGradingTexture;
  61634. /**
  61635. * Called during delayed load for textures.
  61636. */
  61637. delayLoad(): void;
  61638. /**
  61639. * Parses a color grading texture serialized by Babylon.
  61640. * @param parsedTexture The texture information being parsedTexture
  61641. * @param scene The scene to load the texture in
  61642. * @param rootUrl The root url of the data assets to load
  61643. * @return A color gradind texture
  61644. */
  61645. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61646. /**
  61647. * Serializes the LUT texture to json format.
  61648. */
  61649. serialize(): any;
  61650. }
  61651. }
  61652. declare module BABYLON {
  61653. /**
  61654. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61655. */
  61656. export class EquiRectangularCubeTexture extends BaseTexture {
  61657. /** The six faces of the cube. */
  61658. private static _FacesMapping;
  61659. private _noMipmap;
  61660. private _onLoad;
  61661. private _onError;
  61662. /** The size of the cubemap. */
  61663. private _size;
  61664. /** The buffer of the image. */
  61665. private _buffer;
  61666. /** The width of the input image. */
  61667. private _width;
  61668. /** The height of the input image. */
  61669. private _height;
  61670. /** The URL to the image. */
  61671. url: string;
  61672. /**
  61673. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61674. * @param url The location of the image
  61675. * @param scene The scene the texture will be used in
  61676. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61677. * @param noMipmap Forces to not generate the mipmap if true
  61678. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61679. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61680. * @param onLoad — defines a callback called when texture is loaded
  61681. * @param onError — defines a callback called if there is an error
  61682. */
  61683. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61684. /**
  61685. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61686. */
  61687. private loadImage;
  61688. /**
  61689. * Convert the image buffer into a cubemap and create a CubeTexture.
  61690. */
  61691. private loadTexture;
  61692. /**
  61693. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61694. * @param buffer The ArrayBuffer that should be converted.
  61695. * @returns The buffer as Float32Array.
  61696. */
  61697. private getFloat32ArrayFromArrayBuffer;
  61698. /**
  61699. * Get the current class name of the texture useful for serialization or dynamic coding.
  61700. * @returns "EquiRectangularCubeTexture"
  61701. */
  61702. getClassName(): string;
  61703. /**
  61704. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61705. * @returns A clone of the current EquiRectangularCubeTexture.
  61706. */
  61707. clone(): EquiRectangularCubeTexture;
  61708. }
  61709. }
  61710. declare module BABYLON {
  61711. /**
  61712. * Defines the options related to the creation of an HtmlElementTexture
  61713. */
  61714. export interface IHtmlElementTextureOptions {
  61715. /**
  61716. * Defines wether mip maps should be created or not.
  61717. */
  61718. generateMipMaps?: boolean;
  61719. /**
  61720. * Defines the sampling mode of the texture.
  61721. */
  61722. samplingMode?: number;
  61723. /**
  61724. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61725. */
  61726. engine: Nullable<ThinEngine>;
  61727. /**
  61728. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61729. */
  61730. scene: Nullable<Scene>;
  61731. }
  61732. /**
  61733. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61734. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61735. * is automatically managed.
  61736. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61737. * in your application.
  61738. *
  61739. * As the update is not automatic, you need to call them manually.
  61740. */
  61741. export class HtmlElementTexture extends BaseTexture {
  61742. /**
  61743. * The texture URL.
  61744. */
  61745. element: HTMLVideoElement | HTMLCanvasElement;
  61746. private static readonly DefaultOptions;
  61747. private _textureMatrix;
  61748. private _isVideo;
  61749. private _generateMipMaps;
  61750. private _samplingMode;
  61751. /**
  61752. * Instantiates a HtmlElementTexture from the following parameters.
  61753. *
  61754. * @param name Defines the name of the texture
  61755. * @param element Defines the video or canvas the texture is filled with
  61756. * @param options Defines the other none mandatory texture creation options
  61757. */
  61758. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61759. private _createInternalTexture;
  61760. /**
  61761. * Returns the texture matrix used in most of the material.
  61762. */
  61763. getTextureMatrix(): Matrix;
  61764. /**
  61765. * Updates the content of the texture.
  61766. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61767. */
  61768. update(invertY?: Nullable<boolean>): void;
  61769. }
  61770. }
  61771. declare module BABYLON {
  61772. /**
  61773. * Based on jsTGALoader - Javascript loader for TGA file
  61774. * By Vincent Thibault
  61775. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61776. */
  61777. export class TGATools {
  61778. private static _TYPE_INDEXED;
  61779. private static _TYPE_RGB;
  61780. private static _TYPE_GREY;
  61781. private static _TYPE_RLE_INDEXED;
  61782. private static _TYPE_RLE_RGB;
  61783. private static _TYPE_RLE_GREY;
  61784. private static _ORIGIN_MASK;
  61785. private static _ORIGIN_SHIFT;
  61786. private static _ORIGIN_BL;
  61787. private static _ORIGIN_BR;
  61788. private static _ORIGIN_UL;
  61789. private static _ORIGIN_UR;
  61790. /**
  61791. * Gets the header of a TGA file
  61792. * @param data defines the TGA data
  61793. * @returns the header
  61794. */
  61795. static GetTGAHeader(data: Uint8Array): any;
  61796. /**
  61797. * Uploads TGA content to a Babylon Texture
  61798. * @hidden
  61799. */
  61800. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61801. /** @hidden */
  61802. 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;
  61803. /** @hidden */
  61804. 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;
  61805. /** @hidden */
  61806. 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;
  61807. /** @hidden */
  61808. 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;
  61809. /** @hidden */
  61810. 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;
  61811. /** @hidden */
  61812. 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;
  61813. }
  61814. }
  61815. declare module BABYLON {
  61816. /**
  61817. * Implementation of the TGA Texture Loader.
  61818. * @hidden
  61819. */
  61820. export class _TGATextureLoader implements IInternalTextureLoader {
  61821. /**
  61822. * Defines wether the loader supports cascade loading the different faces.
  61823. */
  61824. readonly supportCascades: boolean;
  61825. /**
  61826. * This returns if the loader support the current file information.
  61827. * @param extension defines the file extension of the file being loaded
  61828. * @returns true if the loader can load the specified file
  61829. */
  61830. canLoad(extension: string): boolean;
  61831. /**
  61832. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61833. * @param data contains the texture data
  61834. * @param texture defines the BabylonJS internal texture
  61835. * @param createPolynomials will be true if polynomials have been requested
  61836. * @param onLoad defines the callback to trigger once the texture is ready
  61837. * @param onError defines the callback to trigger in case of error
  61838. */
  61839. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61840. /**
  61841. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61842. * @param data contains the texture data
  61843. * @param texture defines the BabylonJS internal texture
  61844. * @param callback defines the method to call once ready to upload
  61845. */
  61846. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61847. }
  61848. }
  61849. declare module BABYLON {
  61850. /**
  61851. * Info about the .basis files
  61852. */
  61853. class BasisFileInfo {
  61854. /**
  61855. * If the file has alpha
  61856. */
  61857. hasAlpha: boolean;
  61858. /**
  61859. * Info about each image of the basis file
  61860. */
  61861. images: Array<{
  61862. levels: Array<{
  61863. width: number;
  61864. height: number;
  61865. transcodedPixels: ArrayBufferView;
  61866. }>;
  61867. }>;
  61868. }
  61869. /**
  61870. * Result of transcoding a basis file
  61871. */
  61872. class TranscodeResult {
  61873. /**
  61874. * Info about the .basis file
  61875. */
  61876. fileInfo: BasisFileInfo;
  61877. /**
  61878. * Format to use when loading the file
  61879. */
  61880. format: number;
  61881. }
  61882. /**
  61883. * Configuration options for the Basis transcoder
  61884. */
  61885. export class BasisTranscodeConfiguration {
  61886. /**
  61887. * Supported compression formats used to determine the supported output format of the transcoder
  61888. */
  61889. supportedCompressionFormats?: {
  61890. /**
  61891. * etc1 compression format
  61892. */
  61893. etc1?: boolean;
  61894. /**
  61895. * s3tc compression format
  61896. */
  61897. s3tc?: boolean;
  61898. /**
  61899. * pvrtc compression format
  61900. */
  61901. pvrtc?: boolean;
  61902. /**
  61903. * etc2 compression format
  61904. */
  61905. etc2?: boolean;
  61906. };
  61907. /**
  61908. * If mipmap levels should be loaded for transcoded images (Default: true)
  61909. */
  61910. loadMipmapLevels?: boolean;
  61911. /**
  61912. * Index of a single image to load (Default: all images)
  61913. */
  61914. loadSingleImage?: number;
  61915. }
  61916. /**
  61917. * Used to load .Basis files
  61918. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61919. */
  61920. export class BasisTools {
  61921. private static _IgnoreSupportedFormats;
  61922. /**
  61923. * URL to use when loading the basis transcoder
  61924. */
  61925. static JSModuleURL: string;
  61926. /**
  61927. * URL to use when loading the wasm module for the transcoder
  61928. */
  61929. static WasmModuleURL: string;
  61930. /**
  61931. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61932. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61933. * @returns internal format corresponding to the Basis format
  61934. */
  61935. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61936. private static _WorkerPromise;
  61937. private static _Worker;
  61938. private static _actionId;
  61939. private static _CreateWorkerAsync;
  61940. /**
  61941. * Transcodes a loaded image file to compressed pixel data
  61942. * @param data image data to transcode
  61943. * @param config configuration options for the transcoding
  61944. * @returns a promise resulting in the transcoded image
  61945. */
  61946. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61947. /**
  61948. * Loads a texture from the transcode result
  61949. * @param texture texture load to
  61950. * @param transcodeResult the result of transcoding the basis file to load from
  61951. */
  61952. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61953. }
  61954. }
  61955. declare module BABYLON {
  61956. /**
  61957. * Loader for .basis file format
  61958. */
  61959. export class _BasisTextureLoader implements IInternalTextureLoader {
  61960. /**
  61961. * Defines whether the loader supports cascade loading the different faces.
  61962. */
  61963. readonly supportCascades: boolean;
  61964. /**
  61965. * This returns if the loader support the current file information.
  61966. * @param extension defines the file extension of the file being loaded
  61967. * @returns true if the loader can load the specified file
  61968. */
  61969. canLoad(extension: string): boolean;
  61970. /**
  61971. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61972. * @param data contains the texture data
  61973. * @param texture defines the BabylonJS internal texture
  61974. * @param createPolynomials will be true if polynomials have been requested
  61975. * @param onLoad defines the callback to trigger once the texture is ready
  61976. * @param onError defines the callback to trigger in case of error
  61977. */
  61978. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61979. /**
  61980. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61981. * @param data contains the texture data
  61982. * @param texture defines the BabylonJS internal texture
  61983. * @param callback defines the method to call once ready to upload
  61984. */
  61985. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61986. }
  61987. }
  61988. declare module BABYLON {
  61989. /**
  61990. * Defines the basic options interface of a TexturePacker Frame
  61991. */
  61992. export interface ITexturePackerFrame {
  61993. /**
  61994. * The frame ID
  61995. */
  61996. id: number;
  61997. /**
  61998. * The frames Scale
  61999. */
  62000. scale: Vector2;
  62001. /**
  62002. * The Frames offset
  62003. */
  62004. offset: Vector2;
  62005. }
  62006. /**
  62007. * This is a support class for frame Data on texture packer sets.
  62008. */
  62009. export class TexturePackerFrame implements ITexturePackerFrame {
  62010. /**
  62011. * The frame ID
  62012. */
  62013. id: number;
  62014. /**
  62015. * The frames Scale
  62016. */
  62017. scale: Vector2;
  62018. /**
  62019. * The Frames offset
  62020. */
  62021. offset: Vector2;
  62022. /**
  62023. * Initializes a texture package frame.
  62024. * @param id The numerical frame identifier
  62025. * @param scale Scalar Vector2 for UV frame
  62026. * @param offset Vector2 for the frame position in UV units.
  62027. * @returns TexturePackerFrame
  62028. */
  62029. constructor(id: number, scale: Vector2, offset: Vector2);
  62030. }
  62031. }
  62032. declare module BABYLON {
  62033. /**
  62034. * Defines the basic options interface of a TexturePacker
  62035. */
  62036. export interface ITexturePackerOptions {
  62037. /**
  62038. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62039. */
  62040. map?: string[];
  62041. /**
  62042. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62043. */
  62044. uvsIn?: string;
  62045. /**
  62046. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62047. */
  62048. uvsOut?: string;
  62049. /**
  62050. * number representing the layout style. Defaults to LAYOUT_STRIP
  62051. */
  62052. layout?: number;
  62053. /**
  62054. * number of columns if using custom column count layout(2). This defaults to 4.
  62055. */
  62056. colnum?: number;
  62057. /**
  62058. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62059. */
  62060. updateInputMeshes?: boolean;
  62061. /**
  62062. * boolean flag to dispose all the source textures. Defaults to true.
  62063. */
  62064. disposeSources?: boolean;
  62065. /**
  62066. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62067. */
  62068. fillBlanks?: boolean;
  62069. /**
  62070. * string value representing the context fill style color. Defaults to 'black'.
  62071. */
  62072. customFillColor?: string;
  62073. /**
  62074. * Width and Height Value of each Frame in the TexturePacker Sets
  62075. */
  62076. frameSize?: number;
  62077. /**
  62078. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62079. */
  62080. paddingRatio?: number;
  62081. /**
  62082. * Number that declares the fill method for the padding gutter.
  62083. */
  62084. paddingMode?: number;
  62085. /**
  62086. * If in SUBUV_COLOR padding mode what color to use.
  62087. */
  62088. paddingColor?: Color3 | Color4;
  62089. }
  62090. /**
  62091. * Defines the basic interface of a TexturePacker JSON File
  62092. */
  62093. export interface ITexturePackerJSON {
  62094. /**
  62095. * The frame ID
  62096. */
  62097. name: string;
  62098. /**
  62099. * The base64 channel data
  62100. */
  62101. sets: any;
  62102. /**
  62103. * The options of the Packer
  62104. */
  62105. options: ITexturePackerOptions;
  62106. /**
  62107. * The frame data of the Packer
  62108. */
  62109. frames: Array<number>;
  62110. }
  62111. /**
  62112. * This is a support class that generates a series of packed texture sets.
  62113. * @see https://doc.babylonjs.com/babylon101/materials
  62114. */
  62115. export class TexturePacker {
  62116. /** Packer Layout Constant 0 */
  62117. static readonly LAYOUT_STRIP: number;
  62118. /** Packer Layout Constant 1 */
  62119. static readonly LAYOUT_POWER2: number;
  62120. /** Packer Layout Constant 2 */
  62121. static readonly LAYOUT_COLNUM: number;
  62122. /** Packer Layout Constant 0 */
  62123. static readonly SUBUV_WRAP: number;
  62124. /** Packer Layout Constant 1 */
  62125. static readonly SUBUV_EXTEND: number;
  62126. /** Packer Layout Constant 2 */
  62127. static readonly SUBUV_COLOR: number;
  62128. /** The Name of the Texture Package */
  62129. name: string;
  62130. /** The scene scope of the TexturePacker */
  62131. scene: Scene;
  62132. /** The Meshes to target */
  62133. meshes: AbstractMesh[];
  62134. /** Arguments passed with the Constructor */
  62135. options: ITexturePackerOptions;
  62136. /** The promise that is started upon initialization */
  62137. promise: Nullable<Promise<TexturePacker | string>>;
  62138. /** The Container object for the channel sets that are generated */
  62139. sets: object;
  62140. /** The Container array for the frames that are generated */
  62141. frames: TexturePackerFrame[];
  62142. /** The expected number of textures the system is parsing. */
  62143. private _expecting;
  62144. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62145. private _paddingValue;
  62146. /**
  62147. * Initializes a texture package series from an array of meshes or a single mesh.
  62148. * @param name The name of the package
  62149. * @param meshes The target meshes to compose the package from
  62150. * @param options The arguments that texture packer should follow while building.
  62151. * @param scene The scene which the textures are scoped to.
  62152. * @returns TexturePacker
  62153. */
  62154. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62155. /**
  62156. * Starts the package process
  62157. * @param resolve The promises resolution function
  62158. * @returns TexturePacker
  62159. */
  62160. private _createFrames;
  62161. /**
  62162. * Calculates the Size of the Channel Sets
  62163. * @returns Vector2
  62164. */
  62165. private _calculateSize;
  62166. /**
  62167. * Calculates the UV data for the frames.
  62168. * @param baseSize the base frameSize
  62169. * @param padding the base frame padding
  62170. * @param dtSize size of the Dynamic Texture for that channel
  62171. * @param dtUnits is 1/dtSize
  62172. * @param update flag to update the input meshes
  62173. */
  62174. private _calculateMeshUVFrames;
  62175. /**
  62176. * Calculates the frames Offset.
  62177. * @param index of the frame
  62178. * @returns Vector2
  62179. */
  62180. private _getFrameOffset;
  62181. /**
  62182. * Updates a Mesh to the frame data
  62183. * @param mesh that is the target
  62184. * @param frameID or the frame index
  62185. */
  62186. private _updateMeshUV;
  62187. /**
  62188. * Updates a Meshes materials to use the texture packer channels
  62189. * @param m is the mesh to target
  62190. * @param force all channels on the packer to be set.
  62191. */
  62192. private _updateTextureReferences;
  62193. /**
  62194. * Public method to set a Mesh to a frame
  62195. * @param m that is the target
  62196. * @param frameID or the frame index
  62197. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62198. */
  62199. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62200. /**
  62201. * Starts the async promise to compile the texture packer.
  62202. * @returns Promise<void>
  62203. */
  62204. processAsync(): Promise<void>;
  62205. /**
  62206. * Disposes all textures associated with this packer
  62207. */
  62208. dispose(): void;
  62209. /**
  62210. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62211. * @param imageType is the image type to use.
  62212. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62213. */
  62214. download(imageType?: string, quality?: number): void;
  62215. /**
  62216. * Public method to load a texturePacker JSON file.
  62217. * @param data of the JSON file in string format.
  62218. */
  62219. updateFromJSON(data: string): void;
  62220. }
  62221. }
  62222. declare module BABYLON {
  62223. /**
  62224. * 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.
  62225. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62226. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62227. */
  62228. export class CustomProceduralTexture extends ProceduralTexture {
  62229. private _animate;
  62230. private _time;
  62231. private _config;
  62232. private _texturePath;
  62233. /**
  62234. * Instantiates a new Custom Procedural Texture.
  62235. * 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.
  62236. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62237. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62238. * @param name Define the name of the texture
  62239. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62240. * @param size Define the size of the texture to create
  62241. * @param scene Define the scene the texture belongs to
  62242. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62243. * @param generateMipMaps Define if the texture should creates mip maps or not
  62244. */
  62245. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62246. private _loadJson;
  62247. /**
  62248. * Is the texture ready to be used ? (rendered at least once)
  62249. * @returns true if ready, otherwise, false.
  62250. */
  62251. isReady(): boolean;
  62252. /**
  62253. * Render the texture to its associated render target.
  62254. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62255. */
  62256. render(useCameraPostProcess?: boolean): void;
  62257. /**
  62258. * Update the list of dependant textures samplers in the shader.
  62259. */
  62260. updateTextures(): void;
  62261. /**
  62262. * Update the uniform values of the procedural texture in the shader.
  62263. */
  62264. updateShaderUniforms(): void;
  62265. /**
  62266. * Define if the texture animates or not.
  62267. */
  62268. get animate(): boolean;
  62269. set animate(value: boolean);
  62270. }
  62271. }
  62272. declare module BABYLON {
  62273. /** @hidden */
  62274. export var noisePixelShader: {
  62275. name: string;
  62276. shader: string;
  62277. };
  62278. }
  62279. declare module BABYLON {
  62280. /**
  62281. * Class used to generate noise procedural textures
  62282. */
  62283. export class NoiseProceduralTexture extends ProceduralTexture {
  62284. /** Gets or sets the start time (default is 0) */
  62285. time: number;
  62286. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62287. brightness: number;
  62288. /** Defines the number of octaves to process */
  62289. octaves: number;
  62290. /** Defines the level of persistence (0.8 by default) */
  62291. persistence: number;
  62292. /** Gets or sets animation speed factor (default is 1) */
  62293. animationSpeedFactor: number;
  62294. /**
  62295. * Creates a new NoiseProceduralTexture
  62296. * @param name defines the name fo the texture
  62297. * @param size defines the size of the texture (default is 256)
  62298. * @param scene defines the hosting scene
  62299. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62300. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62301. */
  62302. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62303. private _updateShaderUniforms;
  62304. protected _getDefines(): string;
  62305. /** Generate the current state of the procedural texture */
  62306. render(useCameraPostProcess?: boolean): void;
  62307. /**
  62308. * Serializes this noise procedural texture
  62309. * @returns a serialized noise procedural texture object
  62310. */
  62311. serialize(): any;
  62312. /**
  62313. * Clone the texture.
  62314. * @returns the cloned texture
  62315. */
  62316. clone(): NoiseProceduralTexture;
  62317. /**
  62318. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62319. * @param parsedTexture defines parsed texture data
  62320. * @param scene defines the current scene
  62321. * @param rootUrl defines the root URL containing noise procedural texture information
  62322. * @returns a parsed NoiseProceduralTexture
  62323. */
  62324. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62325. }
  62326. }
  62327. declare module BABYLON {
  62328. /**
  62329. * Raw cube texture where the raw buffers are passed in
  62330. */
  62331. export class RawCubeTexture extends CubeTexture {
  62332. /**
  62333. * Creates a cube texture where the raw buffers are passed in.
  62334. * @param scene defines the scene the texture is attached to
  62335. * @param data defines the array of data to use to create each face
  62336. * @param size defines the size of the textures
  62337. * @param format defines the format of the data
  62338. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62339. * @param generateMipMaps defines if the engine should generate the mip levels
  62340. * @param invertY defines if data must be stored with Y axis inverted
  62341. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62342. * @param compression defines the compression used (null by default)
  62343. */
  62344. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62345. /**
  62346. * Updates the raw cube texture.
  62347. * @param data defines the data to store
  62348. * @param format defines the data format
  62349. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62350. * @param invertY defines if data must be stored with Y axis inverted
  62351. * @param compression defines the compression used (null by default)
  62352. * @param level defines which level of the texture to update
  62353. */
  62354. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62355. /**
  62356. * Updates a raw cube texture with RGBD encoded data.
  62357. * @param data defines the array of data [mipmap][face] to use to create each face
  62358. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62359. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62360. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62361. * @returns a promsie that resolves when the operation is complete
  62362. */
  62363. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62364. /**
  62365. * Clones the raw cube texture.
  62366. * @return a new cube texture
  62367. */
  62368. clone(): CubeTexture;
  62369. /** @hidden */
  62370. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62371. }
  62372. }
  62373. declare module BABYLON {
  62374. /**
  62375. * Class used to store 2D array textures containing user data
  62376. */
  62377. export class RawTexture2DArray extends Texture {
  62378. /** Gets or sets the texture format to use */
  62379. format: number;
  62380. /**
  62381. * Create a new RawTexture2DArray
  62382. * @param data defines the data of the texture
  62383. * @param width defines the width of the texture
  62384. * @param height defines the height of the texture
  62385. * @param depth defines the number of layers of the texture
  62386. * @param format defines the texture format to use
  62387. * @param scene defines the hosting scene
  62388. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62389. * @param invertY defines if texture must be stored with Y axis inverted
  62390. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62391. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62392. */
  62393. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62394. /** Gets or sets the texture format to use */
  62395. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62396. /**
  62397. * Update the texture with new data
  62398. * @param data defines the data to store in the texture
  62399. */
  62400. update(data: ArrayBufferView): void;
  62401. }
  62402. }
  62403. declare module BABYLON {
  62404. /**
  62405. * Class used to store 3D textures containing user data
  62406. */
  62407. export class RawTexture3D extends Texture {
  62408. /** Gets or sets the texture format to use */
  62409. format: number;
  62410. /**
  62411. * Create a new RawTexture3D
  62412. * @param data defines the data of the texture
  62413. * @param width defines the width of the texture
  62414. * @param height defines the height of the texture
  62415. * @param depth defines the depth of the texture
  62416. * @param format defines the texture format to use
  62417. * @param scene defines the hosting scene
  62418. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62419. * @param invertY defines if texture must be stored with Y axis inverted
  62420. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62421. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62422. */
  62423. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62424. /** Gets or sets the texture format to use */
  62425. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62426. /**
  62427. * Update the texture with new data
  62428. * @param data defines the data to store in the texture
  62429. */
  62430. update(data: ArrayBufferView): void;
  62431. }
  62432. }
  62433. declare module BABYLON {
  62434. /**
  62435. * Creates a refraction texture used by refraction channel of the standard material.
  62436. * It is like a mirror but to see through a material.
  62437. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62438. */
  62439. export class RefractionTexture extends RenderTargetTexture {
  62440. /**
  62441. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62442. * 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.
  62443. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62444. */
  62445. refractionPlane: Plane;
  62446. /**
  62447. * Define how deep under the surface we should see.
  62448. */
  62449. depth: number;
  62450. /**
  62451. * Creates a refraction texture used by refraction channel of the standard material.
  62452. * It is like a mirror but to see through a material.
  62453. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62454. * @param name Define the texture name
  62455. * @param size Define the size of the underlying texture
  62456. * @param scene Define the scene the refraction belongs to
  62457. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62458. */
  62459. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62460. /**
  62461. * Clone the refraction texture.
  62462. * @returns the cloned texture
  62463. */
  62464. clone(): RefractionTexture;
  62465. /**
  62466. * Serialize the texture to a JSON representation you could use in Parse later on
  62467. * @returns the serialized JSON representation
  62468. */
  62469. serialize(): any;
  62470. }
  62471. }
  62472. declare module BABYLON {
  62473. /**
  62474. * Block used to add support for vertex skinning (bones)
  62475. */
  62476. export class BonesBlock extends NodeMaterialBlock {
  62477. /**
  62478. * Creates a new BonesBlock
  62479. * @param name defines the block name
  62480. */
  62481. constructor(name: string);
  62482. /**
  62483. * Initialize the block and prepare the context for build
  62484. * @param state defines the state that will be used for the build
  62485. */
  62486. initialize(state: NodeMaterialBuildState): void;
  62487. /**
  62488. * Gets the current class name
  62489. * @returns the class name
  62490. */
  62491. getClassName(): string;
  62492. /**
  62493. * Gets the matrix indices input component
  62494. */
  62495. get matricesIndices(): NodeMaterialConnectionPoint;
  62496. /**
  62497. * Gets the matrix weights input component
  62498. */
  62499. get matricesWeights(): NodeMaterialConnectionPoint;
  62500. /**
  62501. * Gets the extra matrix indices input component
  62502. */
  62503. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62504. /**
  62505. * Gets the extra matrix weights input component
  62506. */
  62507. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62508. /**
  62509. * Gets the world input component
  62510. */
  62511. get world(): NodeMaterialConnectionPoint;
  62512. /**
  62513. * Gets the output component
  62514. */
  62515. get output(): NodeMaterialConnectionPoint;
  62516. autoConfigure(material: NodeMaterial): void;
  62517. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62518. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62519. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62520. protected _buildBlock(state: NodeMaterialBuildState): this;
  62521. }
  62522. }
  62523. declare module BABYLON {
  62524. /**
  62525. * Block used to add support for instances
  62526. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62527. */
  62528. export class InstancesBlock extends NodeMaterialBlock {
  62529. /**
  62530. * Creates a new InstancesBlock
  62531. * @param name defines the block name
  62532. */
  62533. constructor(name: string);
  62534. /**
  62535. * Gets the current class name
  62536. * @returns the class name
  62537. */
  62538. getClassName(): string;
  62539. /**
  62540. * Gets the first world row input component
  62541. */
  62542. get world0(): NodeMaterialConnectionPoint;
  62543. /**
  62544. * Gets the second world row input component
  62545. */
  62546. get world1(): NodeMaterialConnectionPoint;
  62547. /**
  62548. * Gets the third world row input component
  62549. */
  62550. get world2(): NodeMaterialConnectionPoint;
  62551. /**
  62552. * Gets the forth world row input component
  62553. */
  62554. get world3(): NodeMaterialConnectionPoint;
  62555. /**
  62556. * Gets the world input component
  62557. */
  62558. get world(): NodeMaterialConnectionPoint;
  62559. /**
  62560. * Gets the output component
  62561. */
  62562. get output(): NodeMaterialConnectionPoint;
  62563. /**
  62564. * Gets the isntanceID component
  62565. */
  62566. get instanceID(): NodeMaterialConnectionPoint;
  62567. autoConfigure(material: NodeMaterial): void;
  62568. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62569. protected _buildBlock(state: NodeMaterialBuildState): this;
  62570. }
  62571. }
  62572. declare module BABYLON {
  62573. /**
  62574. * Block used to add morph targets support to vertex shader
  62575. */
  62576. export class MorphTargetsBlock extends NodeMaterialBlock {
  62577. private _repeatableContentAnchor;
  62578. /**
  62579. * Create a new MorphTargetsBlock
  62580. * @param name defines the block name
  62581. */
  62582. constructor(name: string);
  62583. /**
  62584. * Gets the current class name
  62585. * @returns the class name
  62586. */
  62587. getClassName(): string;
  62588. /**
  62589. * Gets the position input component
  62590. */
  62591. get position(): NodeMaterialConnectionPoint;
  62592. /**
  62593. * Gets the normal input component
  62594. */
  62595. get normal(): NodeMaterialConnectionPoint;
  62596. /**
  62597. * Gets the tangent input component
  62598. */
  62599. get tangent(): NodeMaterialConnectionPoint;
  62600. /**
  62601. * Gets the tangent input component
  62602. */
  62603. get uv(): NodeMaterialConnectionPoint;
  62604. /**
  62605. * Gets the position output component
  62606. */
  62607. get positionOutput(): NodeMaterialConnectionPoint;
  62608. /**
  62609. * Gets the normal output component
  62610. */
  62611. get normalOutput(): NodeMaterialConnectionPoint;
  62612. /**
  62613. * Gets the tangent output component
  62614. */
  62615. get tangentOutput(): NodeMaterialConnectionPoint;
  62616. /**
  62617. * Gets the tangent output component
  62618. */
  62619. get uvOutput(): NodeMaterialConnectionPoint;
  62620. initialize(state: NodeMaterialBuildState): void;
  62621. autoConfigure(material: NodeMaterial): void;
  62622. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62623. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62624. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62625. protected _buildBlock(state: NodeMaterialBuildState): this;
  62626. }
  62627. }
  62628. declare module BABYLON {
  62629. /**
  62630. * Block used to get data information from a light
  62631. */
  62632. export class LightInformationBlock extends NodeMaterialBlock {
  62633. private _lightDataUniformName;
  62634. private _lightColorUniformName;
  62635. private _lightTypeDefineName;
  62636. /**
  62637. * Gets or sets the light associated with this block
  62638. */
  62639. light: Nullable<Light>;
  62640. /**
  62641. * Creates a new LightInformationBlock
  62642. * @param name defines the block name
  62643. */
  62644. constructor(name: string);
  62645. /**
  62646. * Gets the current class name
  62647. * @returns the class name
  62648. */
  62649. getClassName(): string;
  62650. /**
  62651. * Gets the world position input component
  62652. */
  62653. get worldPosition(): NodeMaterialConnectionPoint;
  62654. /**
  62655. * Gets the direction output component
  62656. */
  62657. get direction(): NodeMaterialConnectionPoint;
  62658. /**
  62659. * Gets the direction output component
  62660. */
  62661. get color(): NodeMaterialConnectionPoint;
  62662. /**
  62663. * Gets the direction output component
  62664. */
  62665. get intensity(): NodeMaterialConnectionPoint;
  62666. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62667. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62668. protected _buildBlock(state: NodeMaterialBuildState): this;
  62669. serialize(): any;
  62670. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62671. }
  62672. }
  62673. declare module BABYLON {
  62674. /**
  62675. * Block used to add image processing support to fragment shader
  62676. */
  62677. export class ImageProcessingBlock extends NodeMaterialBlock {
  62678. /**
  62679. * Create a new ImageProcessingBlock
  62680. * @param name defines the block name
  62681. */
  62682. constructor(name: string);
  62683. /**
  62684. * Gets the current class name
  62685. * @returns the class name
  62686. */
  62687. getClassName(): string;
  62688. /**
  62689. * Gets the color input component
  62690. */
  62691. get color(): NodeMaterialConnectionPoint;
  62692. /**
  62693. * Gets the output component
  62694. */
  62695. get output(): NodeMaterialConnectionPoint;
  62696. /**
  62697. * Initialize the block and prepare the context for build
  62698. * @param state defines the state that will be used for the build
  62699. */
  62700. initialize(state: NodeMaterialBuildState): void;
  62701. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62703. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62704. protected _buildBlock(state: NodeMaterialBuildState): this;
  62705. }
  62706. }
  62707. declare module BABYLON {
  62708. /**
  62709. * Block used to pertub normals based on a normal map
  62710. */
  62711. export class PerturbNormalBlock extends NodeMaterialBlock {
  62712. private _tangentSpaceParameterName;
  62713. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62714. invertX: boolean;
  62715. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62716. invertY: boolean;
  62717. /**
  62718. * Create a new PerturbNormalBlock
  62719. * @param name defines the block name
  62720. */
  62721. constructor(name: string);
  62722. /**
  62723. * Gets the current class name
  62724. * @returns the class name
  62725. */
  62726. getClassName(): string;
  62727. /**
  62728. * Gets the world position input component
  62729. */
  62730. get worldPosition(): NodeMaterialConnectionPoint;
  62731. /**
  62732. * Gets the world normal input component
  62733. */
  62734. get worldNormal(): NodeMaterialConnectionPoint;
  62735. /**
  62736. * Gets the world tangent input component
  62737. */
  62738. get worldTangent(): NodeMaterialConnectionPoint;
  62739. /**
  62740. * Gets the uv input component
  62741. */
  62742. get uv(): NodeMaterialConnectionPoint;
  62743. /**
  62744. * Gets the normal map color input component
  62745. */
  62746. get normalMapColor(): NodeMaterialConnectionPoint;
  62747. /**
  62748. * Gets the strength input component
  62749. */
  62750. get strength(): NodeMaterialConnectionPoint;
  62751. /**
  62752. * Gets the output component
  62753. */
  62754. get output(): NodeMaterialConnectionPoint;
  62755. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62756. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62757. autoConfigure(material: NodeMaterial): void;
  62758. protected _buildBlock(state: NodeMaterialBuildState): this;
  62759. protected _dumpPropertiesCode(): string;
  62760. serialize(): any;
  62761. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62762. }
  62763. }
  62764. declare module BABYLON {
  62765. /**
  62766. * Block used to discard a pixel if a value is smaller than a cutoff
  62767. */
  62768. export class DiscardBlock extends NodeMaterialBlock {
  62769. /**
  62770. * Create a new DiscardBlock
  62771. * @param name defines the block name
  62772. */
  62773. constructor(name: string);
  62774. /**
  62775. * Gets the current class name
  62776. * @returns the class name
  62777. */
  62778. getClassName(): string;
  62779. /**
  62780. * Gets the color input component
  62781. */
  62782. get value(): NodeMaterialConnectionPoint;
  62783. /**
  62784. * Gets the cutoff input component
  62785. */
  62786. get cutoff(): NodeMaterialConnectionPoint;
  62787. protected _buildBlock(state: NodeMaterialBuildState): this;
  62788. }
  62789. }
  62790. declare module BABYLON {
  62791. /**
  62792. * Block used to test if the fragment shader is front facing
  62793. */
  62794. export class FrontFacingBlock extends NodeMaterialBlock {
  62795. /**
  62796. * Creates a new FrontFacingBlock
  62797. * @param name defines the block name
  62798. */
  62799. constructor(name: string);
  62800. /**
  62801. * Gets the current class name
  62802. * @returns the class name
  62803. */
  62804. getClassName(): string;
  62805. /**
  62806. * Gets the output component
  62807. */
  62808. get output(): NodeMaterialConnectionPoint;
  62809. protected _buildBlock(state: NodeMaterialBuildState): this;
  62810. }
  62811. }
  62812. declare module BABYLON {
  62813. /**
  62814. * Block used to get the derivative value on x and y of a given input
  62815. */
  62816. export class DerivativeBlock extends NodeMaterialBlock {
  62817. /**
  62818. * Create a new DerivativeBlock
  62819. * @param name defines the block name
  62820. */
  62821. constructor(name: string);
  62822. /**
  62823. * Gets the current class name
  62824. * @returns the class name
  62825. */
  62826. getClassName(): string;
  62827. /**
  62828. * Gets the input component
  62829. */
  62830. get input(): NodeMaterialConnectionPoint;
  62831. /**
  62832. * Gets the derivative output on x
  62833. */
  62834. get dx(): NodeMaterialConnectionPoint;
  62835. /**
  62836. * Gets the derivative output on y
  62837. */
  62838. get dy(): NodeMaterialConnectionPoint;
  62839. protected _buildBlock(state: NodeMaterialBuildState): this;
  62840. }
  62841. }
  62842. declare module BABYLON {
  62843. /**
  62844. * Block used to make gl_FragCoord available
  62845. */
  62846. export class FragCoordBlock extends NodeMaterialBlock {
  62847. /**
  62848. * Creates a new FragCoordBlock
  62849. * @param name defines the block name
  62850. */
  62851. constructor(name: string);
  62852. /**
  62853. * Gets the current class name
  62854. * @returns the class name
  62855. */
  62856. getClassName(): string;
  62857. /**
  62858. * Gets the xy component
  62859. */
  62860. get xy(): NodeMaterialConnectionPoint;
  62861. /**
  62862. * Gets the xyz component
  62863. */
  62864. get xyz(): NodeMaterialConnectionPoint;
  62865. /**
  62866. * Gets the xyzw component
  62867. */
  62868. get xyzw(): NodeMaterialConnectionPoint;
  62869. /**
  62870. * Gets the x component
  62871. */
  62872. get x(): NodeMaterialConnectionPoint;
  62873. /**
  62874. * Gets the y component
  62875. */
  62876. get y(): NodeMaterialConnectionPoint;
  62877. /**
  62878. * Gets the z component
  62879. */
  62880. get z(): NodeMaterialConnectionPoint;
  62881. /**
  62882. * Gets the w component
  62883. */
  62884. get output(): NodeMaterialConnectionPoint;
  62885. protected writeOutputs(state: NodeMaterialBuildState): string;
  62886. protected _buildBlock(state: NodeMaterialBuildState): this;
  62887. }
  62888. }
  62889. declare module BABYLON {
  62890. /**
  62891. * Block used to get the screen sizes
  62892. */
  62893. export class ScreenSizeBlock extends NodeMaterialBlock {
  62894. private _varName;
  62895. private _scene;
  62896. /**
  62897. * Creates a new ScreenSizeBlock
  62898. * @param name defines the block name
  62899. */
  62900. constructor(name: string);
  62901. /**
  62902. * Gets the current class name
  62903. * @returns the class name
  62904. */
  62905. getClassName(): string;
  62906. /**
  62907. * Gets the xy component
  62908. */
  62909. get xy(): NodeMaterialConnectionPoint;
  62910. /**
  62911. * Gets the x component
  62912. */
  62913. get x(): NodeMaterialConnectionPoint;
  62914. /**
  62915. * Gets the y component
  62916. */
  62917. get y(): NodeMaterialConnectionPoint;
  62918. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62919. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62920. protected _buildBlock(state: NodeMaterialBuildState): this;
  62921. }
  62922. }
  62923. declare module BABYLON {
  62924. /**
  62925. * Block used to add support for scene fog
  62926. */
  62927. export class FogBlock extends NodeMaterialBlock {
  62928. private _fogDistanceName;
  62929. private _fogParameters;
  62930. /**
  62931. * Create a new FogBlock
  62932. * @param name defines the block name
  62933. */
  62934. constructor(name: string);
  62935. /**
  62936. * Gets the current class name
  62937. * @returns the class name
  62938. */
  62939. getClassName(): string;
  62940. /**
  62941. * Gets the world position input component
  62942. */
  62943. get worldPosition(): NodeMaterialConnectionPoint;
  62944. /**
  62945. * Gets the view input component
  62946. */
  62947. get view(): NodeMaterialConnectionPoint;
  62948. /**
  62949. * Gets the color input component
  62950. */
  62951. get input(): NodeMaterialConnectionPoint;
  62952. /**
  62953. * Gets the fog color input component
  62954. */
  62955. get fogColor(): NodeMaterialConnectionPoint;
  62956. /**
  62957. * Gets the output component
  62958. */
  62959. get output(): NodeMaterialConnectionPoint;
  62960. autoConfigure(material: NodeMaterial): void;
  62961. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62962. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62963. protected _buildBlock(state: NodeMaterialBuildState): this;
  62964. }
  62965. }
  62966. declare module BABYLON {
  62967. /**
  62968. * Block used to add light in the fragment shader
  62969. */
  62970. export class LightBlock extends NodeMaterialBlock {
  62971. private _lightId;
  62972. /**
  62973. * Gets or sets the light associated with this block
  62974. */
  62975. light: Nullable<Light>;
  62976. /**
  62977. * Create a new LightBlock
  62978. * @param name defines the block name
  62979. */
  62980. constructor(name: string);
  62981. /**
  62982. * Gets the current class name
  62983. * @returns the class name
  62984. */
  62985. getClassName(): string;
  62986. /**
  62987. * Gets the world position input component
  62988. */
  62989. get worldPosition(): NodeMaterialConnectionPoint;
  62990. /**
  62991. * Gets the world normal input component
  62992. */
  62993. get worldNormal(): NodeMaterialConnectionPoint;
  62994. /**
  62995. * Gets the camera (or eye) position component
  62996. */
  62997. get cameraPosition(): NodeMaterialConnectionPoint;
  62998. /**
  62999. * Gets the glossiness component
  63000. */
  63001. get glossiness(): NodeMaterialConnectionPoint;
  63002. /**
  63003. * Gets the glossinness power component
  63004. */
  63005. get glossPower(): NodeMaterialConnectionPoint;
  63006. /**
  63007. * Gets the diffuse color component
  63008. */
  63009. get diffuseColor(): NodeMaterialConnectionPoint;
  63010. /**
  63011. * Gets the specular color component
  63012. */
  63013. get specularColor(): NodeMaterialConnectionPoint;
  63014. /**
  63015. * Gets the diffuse output component
  63016. */
  63017. get diffuseOutput(): NodeMaterialConnectionPoint;
  63018. /**
  63019. * Gets the specular output component
  63020. */
  63021. get specularOutput(): NodeMaterialConnectionPoint;
  63022. /**
  63023. * Gets the shadow output component
  63024. */
  63025. get shadow(): NodeMaterialConnectionPoint;
  63026. autoConfigure(material: NodeMaterial): void;
  63027. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63028. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63029. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63030. private _injectVertexCode;
  63031. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63032. serialize(): any;
  63033. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63034. }
  63035. }
  63036. declare module BABYLON {
  63037. /**
  63038. * Block used to read a reflection texture from a sampler
  63039. */
  63040. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63041. /**
  63042. * Create a new ReflectionTextureBlock
  63043. * @param name defines the block name
  63044. */
  63045. constructor(name: string);
  63046. /**
  63047. * Gets the current class name
  63048. * @returns the class name
  63049. */
  63050. getClassName(): string;
  63051. /**
  63052. * Gets the world position input component
  63053. */
  63054. get position(): NodeMaterialConnectionPoint;
  63055. /**
  63056. * Gets the world position input component
  63057. */
  63058. get worldPosition(): NodeMaterialConnectionPoint;
  63059. /**
  63060. * Gets the world normal input component
  63061. */
  63062. get worldNormal(): NodeMaterialConnectionPoint;
  63063. /**
  63064. * Gets the world input component
  63065. */
  63066. get world(): NodeMaterialConnectionPoint;
  63067. /**
  63068. * Gets the camera (or eye) position component
  63069. */
  63070. get cameraPosition(): NodeMaterialConnectionPoint;
  63071. /**
  63072. * Gets the view input component
  63073. */
  63074. get view(): NodeMaterialConnectionPoint;
  63075. /**
  63076. * Gets the rgb output component
  63077. */
  63078. get rgb(): NodeMaterialConnectionPoint;
  63079. /**
  63080. * Gets the rgba output component
  63081. */
  63082. get rgba(): NodeMaterialConnectionPoint;
  63083. /**
  63084. * Gets the r output component
  63085. */
  63086. get r(): NodeMaterialConnectionPoint;
  63087. /**
  63088. * Gets the g output component
  63089. */
  63090. get g(): NodeMaterialConnectionPoint;
  63091. /**
  63092. * Gets the b output component
  63093. */
  63094. get b(): NodeMaterialConnectionPoint;
  63095. /**
  63096. * Gets the a output component
  63097. */
  63098. get a(): NodeMaterialConnectionPoint;
  63099. autoConfigure(material: NodeMaterial): void;
  63100. protected _buildBlock(state: NodeMaterialBuildState): this;
  63101. }
  63102. }
  63103. declare module BABYLON {
  63104. /**
  63105. * Block used to add 2 vectors
  63106. */
  63107. export class AddBlock extends NodeMaterialBlock {
  63108. /**
  63109. * Creates a new AddBlock
  63110. * @param name defines the block name
  63111. */
  63112. constructor(name: string);
  63113. /**
  63114. * Gets the current class name
  63115. * @returns the class name
  63116. */
  63117. getClassName(): string;
  63118. /**
  63119. * Gets the left operand input component
  63120. */
  63121. get left(): NodeMaterialConnectionPoint;
  63122. /**
  63123. * Gets the right operand input component
  63124. */
  63125. get right(): NodeMaterialConnectionPoint;
  63126. /**
  63127. * Gets the output component
  63128. */
  63129. get output(): NodeMaterialConnectionPoint;
  63130. protected _buildBlock(state: NodeMaterialBuildState): this;
  63131. }
  63132. }
  63133. declare module BABYLON {
  63134. /**
  63135. * Block used to scale a vector by a float
  63136. */
  63137. export class ScaleBlock extends NodeMaterialBlock {
  63138. /**
  63139. * Creates a new ScaleBlock
  63140. * @param name defines the block name
  63141. */
  63142. constructor(name: string);
  63143. /**
  63144. * Gets the current class name
  63145. * @returns the class name
  63146. */
  63147. getClassName(): string;
  63148. /**
  63149. * Gets the input component
  63150. */
  63151. get input(): NodeMaterialConnectionPoint;
  63152. /**
  63153. * Gets the factor input component
  63154. */
  63155. get factor(): NodeMaterialConnectionPoint;
  63156. /**
  63157. * Gets the output component
  63158. */
  63159. get output(): NodeMaterialConnectionPoint;
  63160. protected _buildBlock(state: NodeMaterialBuildState): this;
  63161. }
  63162. }
  63163. declare module BABYLON {
  63164. /**
  63165. * Block used to clamp a float
  63166. */
  63167. export class ClampBlock extends NodeMaterialBlock {
  63168. /** Gets or sets the minimum range */
  63169. minimum: number;
  63170. /** Gets or sets the maximum range */
  63171. maximum: number;
  63172. /**
  63173. * Creates a new ClampBlock
  63174. * @param name defines the block name
  63175. */
  63176. constructor(name: string);
  63177. /**
  63178. * Gets the current class name
  63179. * @returns the class name
  63180. */
  63181. getClassName(): string;
  63182. /**
  63183. * Gets the value input component
  63184. */
  63185. get value(): NodeMaterialConnectionPoint;
  63186. /**
  63187. * Gets the output component
  63188. */
  63189. get output(): NodeMaterialConnectionPoint;
  63190. protected _buildBlock(state: NodeMaterialBuildState): this;
  63191. protected _dumpPropertiesCode(): string;
  63192. serialize(): any;
  63193. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63194. }
  63195. }
  63196. declare module BABYLON {
  63197. /**
  63198. * Block used to apply a cross product between 2 vectors
  63199. */
  63200. export class CrossBlock extends NodeMaterialBlock {
  63201. /**
  63202. * Creates a new CrossBlock
  63203. * @param name defines the block name
  63204. */
  63205. constructor(name: string);
  63206. /**
  63207. * Gets the current class name
  63208. * @returns the class name
  63209. */
  63210. getClassName(): string;
  63211. /**
  63212. * Gets the left operand input component
  63213. */
  63214. get left(): NodeMaterialConnectionPoint;
  63215. /**
  63216. * Gets the right operand input component
  63217. */
  63218. get right(): NodeMaterialConnectionPoint;
  63219. /**
  63220. * Gets the output component
  63221. */
  63222. get output(): NodeMaterialConnectionPoint;
  63223. protected _buildBlock(state: NodeMaterialBuildState): this;
  63224. }
  63225. }
  63226. declare module BABYLON {
  63227. /**
  63228. * Block used to apply a dot product between 2 vectors
  63229. */
  63230. export class DotBlock extends NodeMaterialBlock {
  63231. /**
  63232. * Creates a new DotBlock
  63233. * @param name defines the block name
  63234. */
  63235. constructor(name: string);
  63236. /**
  63237. * Gets the current class name
  63238. * @returns the class name
  63239. */
  63240. getClassName(): string;
  63241. /**
  63242. * Gets the left operand input component
  63243. */
  63244. get left(): NodeMaterialConnectionPoint;
  63245. /**
  63246. * Gets the right operand input component
  63247. */
  63248. get right(): NodeMaterialConnectionPoint;
  63249. /**
  63250. * Gets the output component
  63251. */
  63252. get output(): NodeMaterialConnectionPoint;
  63253. protected _buildBlock(state: NodeMaterialBuildState): this;
  63254. }
  63255. }
  63256. declare module BABYLON {
  63257. /**
  63258. * Block used to normalize a vector
  63259. */
  63260. export class NormalizeBlock extends NodeMaterialBlock {
  63261. /**
  63262. * Creates a new NormalizeBlock
  63263. * @param name defines the block name
  63264. */
  63265. constructor(name: string);
  63266. /**
  63267. * Gets the current class name
  63268. * @returns the class name
  63269. */
  63270. getClassName(): string;
  63271. /**
  63272. * Gets the input component
  63273. */
  63274. get input(): NodeMaterialConnectionPoint;
  63275. /**
  63276. * Gets the output component
  63277. */
  63278. get output(): NodeMaterialConnectionPoint;
  63279. protected _buildBlock(state: NodeMaterialBuildState): this;
  63280. }
  63281. }
  63282. declare module BABYLON {
  63283. /**
  63284. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63285. */
  63286. export class ColorMergerBlock extends NodeMaterialBlock {
  63287. /**
  63288. * Create a new ColorMergerBlock
  63289. * @param name defines the block name
  63290. */
  63291. constructor(name: string);
  63292. /**
  63293. * Gets the current class name
  63294. * @returns the class name
  63295. */
  63296. getClassName(): string;
  63297. /**
  63298. * Gets the rgb component (input)
  63299. */
  63300. get rgbIn(): NodeMaterialConnectionPoint;
  63301. /**
  63302. * Gets the r component (input)
  63303. */
  63304. get r(): NodeMaterialConnectionPoint;
  63305. /**
  63306. * Gets the g component (input)
  63307. */
  63308. get g(): NodeMaterialConnectionPoint;
  63309. /**
  63310. * Gets the b component (input)
  63311. */
  63312. get b(): NodeMaterialConnectionPoint;
  63313. /**
  63314. * Gets the a component (input)
  63315. */
  63316. get a(): NodeMaterialConnectionPoint;
  63317. /**
  63318. * Gets the rgba component (output)
  63319. */
  63320. get rgba(): NodeMaterialConnectionPoint;
  63321. /**
  63322. * Gets the rgb component (output)
  63323. */
  63324. get rgbOut(): NodeMaterialConnectionPoint;
  63325. /**
  63326. * Gets the rgb component (output)
  63327. * @deprecated Please use rgbOut instead.
  63328. */
  63329. get rgb(): NodeMaterialConnectionPoint;
  63330. protected _buildBlock(state: NodeMaterialBuildState): this;
  63331. }
  63332. }
  63333. declare module BABYLON {
  63334. /**
  63335. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63336. */
  63337. export class VectorSplitterBlock extends NodeMaterialBlock {
  63338. /**
  63339. * Create a new VectorSplitterBlock
  63340. * @param name defines the block name
  63341. */
  63342. constructor(name: string);
  63343. /**
  63344. * Gets the current class name
  63345. * @returns the class name
  63346. */
  63347. getClassName(): string;
  63348. /**
  63349. * Gets the xyzw component (input)
  63350. */
  63351. get xyzw(): NodeMaterialConnectionPoint;
  63352. /**
  63353. * Gets the xyz component (input)
  63354. */
  63355. get xyzIn(): NodeMaterialConnectionPoint;
  63356. /**
  63357. * Gets the xy component (input)
  63358. */
  63359. get xyIn(): NodeMaterialConnectionPoint;
  63360. /**
  63361. * Gets the xyz component (output)
  63362. */
  63363. get xyzOut(): NodeMaterialConnectionPoint;
  63364. /**
  63365. * Gets the xy component (output)
  63366. */
  63367. get xyOut(): NodeMaterialConnectionPoint;
  63368. /**
  63369. * Gets the x component (output)
  63370. */
  63371. get x(): NodeMaterialConnectionPoint;
  63372. /**
  63373. * Gets the y component (output)
  63374. */
  63375. get y(): NodeMaterialConnectionPoint;
  63376. /**
  63377. * Gets the z component (output)
  63378. */
  63379. get z(): NodeMaterialConnectionPoint;
  63380. /**
  63381. * Gets the w component (output)
  63382. */
  63383. get w(): NodeMaterialConnectionPoint;
  63384. protected _inputRename(name: string): string;
  63385. protected _outputRename(name: string): string;
  63386. protected _buildBlock(state: NodeMaterialBuildState): this;
  63387. }
  63388. }
  63389. declare module BABYLON {
  63390. /**
  63391. * Block used to lerp between 2 values
  63392. */
  63393. export class LerpBlock extends NodeMaterialBlock {
  63394. /**
  63395. * Creates a new LerpBlock
  63396. * @param name defines the block name
  63397. */
  63398. constructor(name: string);
  63399. /**
  63400. * Gets the current class name
  63401. * @returns the class name
  63402. */
  63403. getClassName(): string;
  63404. /**
  63405. * Gets the left operand input component
  63406. */
  63407. get left(): NodeMaterialConnectionPoint;
  63408. /**
  63409. * Gets the right operand input component
  63410. */
  63411. get right(): NodeMaterialConnectionPoint;
  63412. /**
  63413. * Gets the gradient operand input component
  63414. */
  63415. get gradient(): NodeMaterialConnectionPoint;
  63416. /**
  63417. * Gets the output component
  63418. */
  63419. get output(): NodeMaterialConnectionPoint;
  63420. protected _buildBlock(state: NodeMaterialBuildState): this;
  63421. }
  63422. }
  63423. declare module BABYLON {
  63424. /**
  63425. * Block used to divide 2 vectors
  63426. */
  63427. export class DivideBlock extends NodeMaterialBlock {
  63428. /**
  63429. * Creates a new DivideBlock
  63430. * @param name defines the block name
  63431. */
  63432. constructor(name: string);
  63433. /**
  63434. * Gets the current class name
  63435. * @returns the class name
  63436. */
  63437. getClassName(): string;
  63438. /**
  63439. * Gets the left operand input component
  63440. */
  63441. get left(): NodeMaterialConnectionPoint;
  63442. /**
  63443. * Gets the right operand input component
  63444. */
  63445. get right(): NodeMaterialConnectionPoint;
  63446. /**
  63447. * Gets the output component
  63448. */
  63449. get output(): NodeMaterialConnectionPoint;
  63450. protected _buildBlock(state: NodeMaterialBuildState): this;
  63451. }
  63452. }
  63453. declare module BABYLON {
  63454. /**
  63455. * Block used to subtract 2 vectors
  63456. */
  63457. export class SubtractBlock extends NodeMaterialBlock {
  63458. /**
  63459. * Creates a new SubtractBlock
  63460. * @param name defines the block name
  63461. */
  63462. constructor(name: string);
  63463. /**
  63464. * Gets the current class name
  63465. * @returns the class name
  63466. */
  63467. getClassName(): string;
  63468. /**
  63469. * Gets the left operand input component
  63470. */
  63471. get left(): NodeMaterialConnectionPoint;
  63472. /**
  63473. * Gets the right operand input component
  63474. */
  63475. get right(): NodeMaterialConnectionPoint;
  63476. /**
  63477. * Gets the output component
  63478. */
  63479. get output(): NodeMaterialConnectionPoint;
  63480. protected _buildBlock(state: NodeMaterialBuildState): this;
  63481. }
  63482. }
  63483. declare module BABYLON {
  63484. /**
  63485. * Block used to step a value
  63486. */
  63487. export class StepBlock extends NodeMaterialBlock {
  63488. /**
  63489. * Creates a new StepBlock
  63490. * @param name defines the block name
  63491. */
  63492. constructor(name: string);
  63493. /**
  63494. * Gets the current class name
  63495. * @returns the class name
  63496. */
  63497. getClassName(): string;
  63498. /**
  63499. * Gets the value operand input component
  63500. */
  63501. get value(): NodeMaterialConnectionPoint;
  63502. /**
  63503. * Gets the edge operand input component
  63504. */
  63505. get edge(): NodeMaterialConnectionPoint;
  63506. /**
  63507. * Gets the output component
  63508. */
  63509. get output(): NodeMaterialConnectionPoint;
  63510. protected _buildBlock(state: NodeMaterialBuildState): this;
  63511. }
  63512. }
  63513. declare module BABYLON {
  63514. /**
  63515. * Block used to get the opposite (1 - x) of a value
  63516. */
  63517. export class OneMinusBlock extends NodeMaterialBlock {
  63518. /**
  63519. * Creates a new OneMinusBlock
  63520. * @param name defines the block name
  63521. */
  63522. constructor(name: string);
  63523. /**
  63524. * Gets the current class name
  63525. * @returns the class name
  63526. */
  63527. getClassName(): string;
  63528. /**
  63529. * Gets the input component
  63530. */
  63531. get input(): NodeMaterialConnectionPoint;
  63532. /**
  63533. * Gets the output component
  63534. */
  63535. get output(): NodeMaterialConnectionPoint;
  63536. protected _buildBlock(state: NodeMaterialBuildState): this;
  63537. }
  63538. }
  63539. declare module BABYLON {
  63540. /**
  63541. * Block used to get the view direction
  63542. */
  63543. export class ViewDirectionBlock extends NodeMaterialBlock {
  63544. /**
  63545. * Creates a new ViewDirectionBlock
  63546. * @param name defines the block name
  63547. */
  63548. constructor(name: string);
  63549. /**
  63550. * Gets the current class name
  63551. * @returns the class name
  63552. */
  63553. getClassName(): string;
  63554. /**
  63555. * Gets the world position component
  63556. */
  63557. get worldPosition(): NodeMaterialConnectionPoint;
  63558. /**
  63559. * Gets the camera position component
  63560. */
  63561. get cameraPosition(): NodeMaterialConnectionPoint;
  63562. /**
  63563. * Gets the output component
  63564. */
  63565. get output(): NodeMaterialConnectionPoint;
  63566. autoConfigure(material: NodeMaterial): void;
  63567. protected _buildBlock(state: NodeMaterialBuildState): this;
  63568. }
  63569. }
  63570. declare module BABYLON {
  63571. /**
  63572. * Block used to compute fresnel value
  63573. */
  63574. export class FresnelBlock extends NodeMaterialBlock {
  63575. /**
  63576. * Create a new FresnelBlock
  63577. * @param name defines the block name
  63578. */
  63579. constructor(name: string);
  63580. /**
  63581. * Gets the current class name
  63582. * @returns the class name
  63583. */
  63584. getClassName(): string;
  63585. /**
  63586. * Gets the world normal input component
  63587. */
  63588. get worldNormal(): NodeMaterialConnectionPoint;
  63589. /**
  63590. * Gets the view direction input component
  63591. */
  63592. get viewDirection(): NodeMaterialConnectionPoint;
  63593. /**
  63594. * Gets the bias input component
  63595. */
  63596. get bias(): NodeMaterialConnectionPoint;
  63597. /**
  63598. * Gets the camera (or eye) position component
  63599. */
  63600. get power(): NodeMaterialConnectionPoint;
  63601. /**
  63602. * Gets the fresnel output component
  63603. */
  63604. get fresnel(): NodeMaterialConnectionPoint;
  63605. autoConfigure(material: NodeMaterial): void;
  63606. protected _buildBlock(state: NodeMaterialBuildState): this;
  63607. }
  63608. }
  63609. declare module BABYLON {
  63610. /**
  63611. * Block used to get the max of 2 values
  63612. */
  63613. export class MaxBlock extends NodeMaterialBlock {
  63614. /**
  63615. * Creates a new MaxBlock
  63616. * @param name defines the block name
  63617. */
  63618. constructor(name: string);
  63619. /**
  63620. * Gets the current class name
  63621. * @returns the class name
  63622. */
  63623. getClassName(): string;
  63624. /**
  63625. * Gets the left operand input component
  63626. */
  63627. get left(): NodeMaterialConnectionPoint;
  63628. /**
  63629. * Gets the right operand input component
  63630. */
  63631. get right(): NodeMaterialConnectionPoint;
  63632. /**
  63633. * Gets the output component
  63634. */
  63635. get output(): NodeMaterialConnectionPoint;
  63636. protected _buildBlock(state: NodeMaterialBuildState): this;
  63637. }
  63638. }
  63639. declare module BABYLON {
  63640. /**
  63641. * Block used to get the min of 2 values
  63642. */
  63643. export class MinBlock extends NodeMaterialBlock {
  63644. /**
  63645. * Creates a new MinBlock
  63646. * @param name defines the block name
  63647. */
  63648. constructor(name: string);
  63649. /**
  63650. * Gets the current class name
  63651. * @returns the class name
  63652. */
  63653. getClassName(): string;
  63654. /**
  63655. * Gets the left operand input component
  63656. */
  63657. get left(): NodeMaterialConnectionPoint;
  63658. /**
  63659. * Gets the right operand input component
  63660. */
  63661. get right(): NodeMaterialConnectionPoint;
  63662. /**
  63663. * Gets the output component
  63664. */
  63665. get output(): NodeMaterialConnectionPoint;
  63666. protected _buildBlock(state: NodeMaterialBuildState): this;
  63667. }
  63668. }
  63669. declare module BABYLON {
  63670. /**
  63671. * Block used to get the distance between 2 values
  63672. */
  63673. export class DistanceBlock extends NodeMaterialBlock {
  63674. /**
  63675. * Creates a new DistanceBlock
  63676. * @param name defines the block name
  63677. */
  63678. constructor(name: string);
  63679. /**
  63680. * Gets the current class name
  63681. * @returns the class name
  63682. */
  63683. getClassName(): string;
  63684. /**
  63685. * Gets the left operand input component
  63686. */
  63687. get left(): NodeMaterialConnectionPoint;
  63688. /**
  63689. * Gets the right operand input component
  63690. */
  63691. get right(): NodeMaterialConnectionPoint;
  63692. /**
  63693. * Gets the output component
  63694. */
  63695. get output(): NodeMaterialConnectionPoint;
  63696. protected _buildBlock(state: NodeMaterialBuildState): this;
  63697. }
  63698. }
  63699. declare module BABYLON {
  63700. /**
  63701. * Block used to get the length of a vector
  63702. */
  63703. export class LengthBlock extends NodeMaterialBlock {
  63704. /**
  63705. * Creates a new LengthBlock
  63706. * @param name defines the block name
  63707. */
  63708. constructor(name: string);
  63709. /**
  63710. * Gets the current class name
  63711. * @returns the class name
  63712. */
  63713. getClassName(): string;
  63714. /**
  63715. * Gets the value input component
  63716. */
  63717. get value(): NodeMaterialConnectionPoint;
  63718. /**
  63719. * Gets the output component
  63720. */
  63721. get output(): NodeMaterialConnectionPoint;
  63722. protected _buildBlock(state: NodeMaterialBuildState): this;
  63723. }
  63724. }
  63725. declare module BABYLON {
  63726. /**
  63727. * Block used to get negative version of a value (i.e. x * -1)
  63728. */
  63729. export class NegateBlock extends NodeMaterialBlock {
  63730. /**
  63731. * Creates a new NegateBlock
  63732. * @param name defines the block name
  63733. */
  63734. constructor(name: string);
  63735. /**
  63736. * Gets the current class name
  63737. * @returns the class name
  63738. */
  63739. getClassName(): string;
  63740. /**
  63741. * Gets the value input component
  63742. */
  63743. get value(): NodeMaterialConnectionPoint;
  63744. /**
  63745. * Gets the output component
  63746. */
  63747. get output(): NodeMaterialConnectionPoint;
  63748. protected _buildBlock(state: NodeMaterialBuildState): this;
  63749. }
  63750. }
  63751. declare module BABYLON {
  63752. /**
  63753. * Block used to get the value of the first parameter raised to the power of the second
  63754. */
  63755. export class PowBlock extends NodeMaterialBlock {
  63756. /**
  63757. * Creates a new PowBlock
  63758. * @param name defines the block name
  63759. */
  63760. constructor(name: string);
  63761. /**
  63762. * Gets the current class name
  63763. * @returns the class name
  63764. */
  63765. getClassName(): string;
  63766. /**
  63767. * Gets the value operand input component
  63768. */
  63769. get value(): NodeMaterialConnectionPoint;
  63770. /**
  63771. * Gets the power operand input component
  63772. */
  63773. get power(): NodeMaterialConnectionPoint;
  63774. /**
  63775. * Gets the output component
  63776. */
  63777. get output(): NodeMaterialConnectionPoint;
  63778. protected _buildBlock(state: NodeMaterialBuildState): this;
  63779. }
  63780. }
  63781. declare module BABYLON {
  63782. /**
  63783. * Block used to get a random number
  63784. */
  63785. export class RandomNumberBlock extends NodeMaterialBlock {
  63786. /**
  63787. * Creates a new RandomNumberBlock
  63788. * @param name defines the block name
  63789. */
  63790. constructor(name: string);
  63791. /**
  63792. * Gets the current class name
  63793. * @returns the class name
  63794. */
  63795. getClassName(): string;
  63796. /**
  63797. * Gets the seed input component
  63798. */
  63799. get seed(): NodeMaterialConnectionPoint;
  63800. /**
  63801. * Gets the output component
  63802. */
  63803. get output(): NodeMaterialConnectionPoint;
  63804. protected _buildBlock(state: NodeMaterialBuildState): this;
  63805. }
  63806. }
  63807. declare module BABYLON {
  63808. /**
  63809. * Block used to compute arc tangent of 2 values
  63810. */
  63811. export class ArcTan2Block extends NodeMaterialBlock {
  63812. /**
  63813. * Creates a new ArcTan2Block
  63814. * @param name defines the block name
  63815. */
  63816. constructor(name: string);
  63817. /**
  63818. * Gets the current class name
  63819. * @returns the class name
  63820. */
  63821. getClassName(): string;
  63822. /**
  63823. * Gets the x operand input component
  63824. */
  63825. get x(): NodeMaterialConnectionPoint;
  63826. /**
  63827. * Gets the y operand input component
  63828. */
  63829. get y(): NodeMaterialConnectionPoint;
  63830. /**
  63831. * Gets the output component
  63832. */
  63833. get output(): NodeMaterialConnectionPoint;
  63834. protected _buildBlock(state: NodeMaterialBuildState): this;
  63835. }
  63836. }
  63837. declare module BABYLON {
  63838. /**
  63839. * Block used to smooth step a value
  63840. */
  63841. export class SmoothStepBlock extends NodeMaterialBlock {
  63842. /**
  63843. * Creates a new SmoothStepBlock
  63844. * @param name defines the block name
  63845. */
  63846. constructor(name: string);
  63847. /**
  63848. * Gets the current class name
  63849. * @returns the class name
  63850. */
  63851. getClassName(): string;
  63852. /**
  63853. * Gets the value operand input component
  63854. */
  63855. get value(): NodeMaterialConnectionPoint;
  63856. /**
  63857. * Gets the first edge operand input component
  63858. */
  63859. get edge0(): NodeMaterialConnectionPoint;
  63860. /**
  63861. * Gets the second edge operand input component
  63862. */
  63863. get edge1(): NodeMaterialConnectionPoint;
  63864. /**
  63865. * Gets the output component
  63866. */
  63867. get output(): NodeMaterialConnectionPoint;
  63868. protected _buildBlock(state: NodeMaterialBuildState): this;
  63869. }
  63870. }
  63871. declare module BABYLON {
  63872. /**
  63873. * Block used to get the reciprocal (1 / x) of a value
  63874. */
  63875. export class ReciprocalBlock extends NodeMaterialBlock {
  63876. /**
  63877. * Creates a new ReciprocalBlock
  63878. * @param name defines the block name
  63879. */
  63880. constructor(name: string);
  63881. /**
  63882. * Gets the current class name
  63883. * @returns the class name
  63884. */
  63885. getClassName(): string;
  63886. /**
  63887. * Gets the input component
  63888. */
  63889. get input(): NodeMaterialConnectionPoint;
  63890. /**
  63891. * Gets the output component
  63892. */
  63893. get output(): NodeMaterialConnectionPoint;
  63894. protected _buildBlock(state: NodeMaterialBuildState): this;
  63895. }
  63896. }
  63897. declare module BABYLON {
  63898. /**
  63899. * Block used to replace a color by another one
  63900. */
  63901. export class ReplaceColorBlock extends NodeMaterialBlock {
  63902. /**
  63903. * Creates a new ReplaceColorBlock
  63904. * @param name defines the block name
  63905. */
  63906. constructor(name: string);
  63907. /**
  63908. * Gets the current class name
  63909. * @returns the class name
  63910. */
  63911. getClassName(): string;
  63912. /**
  63913. * Gets the value input component
  63914. */
  63915. get value(): NodeMaterialConnectionPoint;
  63916. /**
  63917. * Gets the reference input component
  63918. */
  63919. get reference(): NodeMaterialConnectionPoint;
  63920. /**
  63921. * Gets the distance input component
  63922. */
  63923. get distance(): NodeMaterialConnectionPoint;
  63924. /**
  63925. * Gets the replacement input component
  63926. */
  63927. get replacement(): NodeMaterialConnectionPoint;
  63928. /**
  63929. * Gets the output component
  63930. */
  63931. get output(): NodeMaterialConnectionPoint;
  63932. protected _buildBlock(state: NodeMaterialBuildState): this;
  63933. }
  63934. }
  63935. declare module BABYLON {
  63936. /**
  63937. * Block used to posterize a value
  63938. * @see https://en.wikipedia.org/wiki/Posterization
  63939. */
  63940. export class PosterizeBlock extends NodeMaterialBlock {
  63941. /**
  63942. * Creates a new PosterizeBlock
  63943. * @param name defines the block name
  63944. */
  63945. constructor(name: string);
  63946. /**
  63947. * Gets the current class name
  63948. * @returns the class name
  63949. */
  63950. getClassName(): string;
  63951. /**
  63952. * Gets the value input component
  63953. */
  63954. get value(): NodeMaterialConnectionPoint;
  63955. /**
  63956. * Gets the steps input component
  63957. */
  63958. get steps(): NodeMaterialConnectionPoint;
  63959. /**
  63960. * Gets the output component
  63961. */
  63962. get output(): NodeMaterialConnectionPoint;
  63963. protected _buildBlock(state: NodeMaterialBuildState): this;
  63964. }
  63965. }
  63966. declare module BABYLON {
  63967. /**
  63968. * Operations supported by the Wave block
  63969. */
  63970. export enum WaveBlockKind {
  63971. /** SawTooth */
  63972. SawTooth = 0,
  63973. /** Square */
  63974. Square = 1,
  63975. /** Triangle */
  63976. Triangle = 2
  63977. }
  63978. /**
  63979. * Block used to apply wave operation to floats
  63980. */
  63981. export class WaveBlock extends NodeMaterialBlock {
  63982. /**
  63983. * Gets or sets the kibnd of wave to be applied by the block
  63984. */
  63985. kind: WaveBlockKind;
  63986. /**
  63987. * Creates a new WaveBlock
  63988. * @param name defines the block name
  63989. */
  63990. constructor(name: string);
  63991. /**
  63992. * Gets the current class name
  63993. * @returns the class name
  63994. */
  63995. getClassName(): string;
  63996. /**
  63997. * Gets the input component
  63998. */
  63999. get input(): NodeMaterialConnectionPoint;
  64000. /**
  64001. * Gets the output component
  64002. */
  64003. get output(): NodeMaterialConnectionPoint;
  64004. protected _buildBlock(state: NodeMaterialBuildState): this;
  64005. serialize(): any;
  64006. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64007. }
  64008. }
  64009. declare module BABYLON {
  64010. /**
  64011. * Class used to store a color step for the GradientBlock
  64012. */
  64013. export class GradientBlockColorStep {
  64014. private _step;
  64015. /**
  64016. * Gets value indicating which step this color is associated with (between 0 and 1)
  64017. */
  64018. get step(): number;
  64019. /**
  64020. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64021. */
  64022. set step(val: number);
  64023. private _color;
  64024. /**
  64025. * Gets the color associated with this step
  64026. */
  64027. get color(): Color3;
  64028. /**
  64029. * Sets the color associated with this step
  64030. */
  64031. set color(val: Color3);
  64032. /**
  64033. * Creates a new GradientBlockColorStep
  64034. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64035. * @param color defines the color associated with this step
  64036. */
  64037. constructor(step: number, color: Color3);
  64038. }
  64039. /**
  64040. * Block used to return a color from a gradient based on an input value between 0 and 1
  64041. */
  64042. export class GradientBlock extends NodeMaterialBlock {
  64043. /**
  64044. * Gets or sets the list of color steps
  64045. */
  64046. colorSteps: GradientBlockColorStep[];
  64047. /** Gets an observable raised when the value is changed */
  64048. onValueChangedObservable: Observable<GradientBlock>;
  64049. /** calls observable when the value is changed*/
  64050. colorStepsUpdated(): void;
  64051. /**
  64052. * Creates a new GradientBlock
  64053. * @param name defines the block name
  64054. */
  64055. constructor(name: string);
  64056. /**
  64057. * Gets the current class name
  64058. * @returns the class name
  64059. */
  64060. getClassName(): string;
  64061. /**
  64062. * Gets the gradient input component
  64063. */
  64064. get gradient(): NodeMaterialConnectionPoint;
  64065. /**
  64066. * Gets the output component
  64067. */
  64068. get output(): NodeMaterialConnectionPoint;
  64069. private _writeColorConstant;
  64070. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64071. serialize(): any;
  64072. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64073. protected _dumpPropertiesCode(): string;
  64074. }
  64075. }
  64076. declare module BABYLON {
  64077. /**
  64078. * Block used to normalize lerp between 2 values
  64079. */
  64080. export class NLerpBlock extends NodeMaterialBlock {
  64081. /**
  64082. * Creates a new NLerpBlock
  64083. * @param name defines the block name
  64084. */
  64085. constructor(name: string);
  64086. /**
  64087. * Gets the current class name
  64088. * @returns the class name
  64089. */
  64090. getClassName(): string;
  64091. /**
  64092. * Gets the left operand input component
  64093. */
  64094. get left(): NodeMaterialConnectionPoint;
  64095. /**
  64096. * Gets the right operand input component
  64097. */
  64098. get right(): NodeMaterialConnectionPoint;
  64099. /**
  64100. * Gets the gradient operand input component
  64101. */
  64102. get gradient(): NodeMaterialConnectionPoint;
  64103. /**
  64104. * Gets the output component
  64105. */
  64106. get output(): NodeMaterialConnectionPoint;
  64107. protected _buildBlock(state: NodeMaterialBuildState): this;
  64108. }
  64109. }
  64110. declare module BABYLON {
  64111. /**
  64112. * block used to Generate a Worley Noise 3D Noise Pattern
  64113. */
  64114. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64115. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64116. manhattanDistance: boolean;
  64117. /**
  64118. * Creates a new WorleyNoise3DBlock
  64119. * @param name defines the block name
  64120. */
  64121. constructor(name: string);
  64122. /**
  64123. * Gets the current class name
  64124. * @returns the class name
  64125. */
  64126. getClassName(): string;
  64127. /**
  64128. * Gets the seed input component
  64129. */
  64130. get seed(): NodeMaterialConnectionPoint;
  64131. /**
  64132. * Gets the jitter input component
  64133. */
  64134. get jitter(): NodeMaterialConnectionPoint;
  64135. /**
  64136. * Gets the output component
  64137. */
  64138. get output(): NodeMaterialConnectionPoint;
  64139. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64140. /**
  64141. * Exposes the properties to the UI?
  64142. */
  64143. protected _dumpPropertiesCode(): string;
  64144. /**
  64145. * Exposes the properties to the Seralize?
  64146. */
  64147. serialize(): any;
  64148. /**
  64149. * Exposes the properties to the deseralize?
  64150. */
  64151. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64152. }
  64153. }
  64154. declare module BABYLON {
  64155. /**
  64156. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64157. */
  64158. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64159. /**
  64160. * Creates a new SimplexPerlin3DBlock
  64161. * @param name defines the block name
  64162. */
  64163. constructor(name: string);
  64164. /**
  64165. * Gets the current class name
  64166. * @returns the class name
  64167. */
  64168. getClassName(): string;
  64169. /**
  64170. * Gets the seed operand input component
  64171. */
  64172. get seed(): NodeMaterialConnectionPoint;
  64173. /**
  64174. * Gets the output component
  64175. */
  64176. get output(): NodeMaterialConnectionPoint;
  64177. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64178. }
  64179. }
  64180. declare module BABYLON {
  64181. /**
  64182. * Block used to blend normals
  64183. */
  64184. export class NormalBlendBlock extends NodeMaterialBlock {
  64185. /**
  64186. * Creates a new NormalBlendBlock
  64187. * @param name defines the block name
  64188. */
  64189. constructor(name: string);
  64190. /**
  64191. * Gets the current class name
  64192. * @returns the class name
  64193. */
  64194. getClassName(): string;
  64195. /**
  64196. * Gets the first input component
  64197. */
  64198. get normalMap0(): NodeMaterialConnectionPoint;
  64199. /**
  64200. * Gets the second input component
  64201. */
  64202. get normalMap1(): NodeMaterialConnectionPoint;
  64203. /**
  64204. * Gets the output component
  64205. */
  64206. get output(): NodeMaterialConnectionPoint;
  64207. protected _buildBlock(state: NodeMaterialBuildState): this;
  64208. }
  64209. }
  64210. declare module BABYLON {
  64211. /**
  64212. * Block used to rotate a 2d vector by a given angle
  64213. */
  64214. export class Rotate2dBlock extends NodeMaterialBlock {
  64215. /**
  64216. * Creates a new Rotate2dBlock
  64217. * @param name defines the block name
  64218. */
  64219. constructor(name: string);
  64220. /**
  64221. * Gets the current class name
  64222. * @returns the class name
  64223. */
  64224. getClassName(): string;
  64225. /**
  64226. * Gets the input vector
  64227. */
  64228. get input(): NodeMaterialConnectionPoint;
  64229. /**
  64230. * Gets the input angle
  64231. */
  64232. get angle(): NodeMaterialConnectionPoint;
  64233. /**
  64234. * Gets the output component
  64235. */
  64236. get output(): NodeMaterialConnectionPoint;
  64237. autoConfigure(material: NodeMaterial): void;
  64238. protected _buildBlock(state: NodeMaterialBuildState): this;
  64239. }
  64240. }
  64241. declare module BABYLON {
  64242. /**
  64243. * Block used to get the reflected vector from a direction and a normal
  64244. */
  64245. export class ReflectBlock extends NodeMaterialBlock {
  64246. /**
  64247. * Creates a new ReflectBlock
  64248. * @param name defines the block name
  64249. */
  64250. constructor(name: string);
  64251. /**
  64252. * Gets the current class name
  64253. * @returns the class name
  64254. */
  64255. getClassName(): string;
  64256. /**
  64257. * Gets the incident component
  64258. */
  64259. get incident(): NodeMaterialConnectionPoint;
  64260. /**
  64261. * Gets the normal component
  64262. */
  64263. get normal(): NodeMaterialConnectionPoint;
  64264. /**
  64265. * Gets the output component
  64266. */
  64267. get output(): NodeMaterialConnectionPoint;
  64268. protected _buildBlock(state: NodeMaterialBuildState): this;
  64269. }
  64270. }
  64271. declare module BABYLON {
  64272. /**
  64273. * Block used to get the refracted vector from a direction and a normal
  64274. */
  64275. export class RefractBlock extends NodeMaterialBlock {
  64276. /**
  64277. * Creates a new RefractBlock
  64278. * @param name defines the block name
  64279. */
  64280. constructor(name: string);
  64281. /**
  64282. * Gets the current class name
  64283. * @returns the class name
  64284. */
  64285. getClassName(): string;
  64286. /**
  64287. * Gets the incident component
  64288. */
  64289. get incident(): NodeMaterialConnectionPoint;
  64290. /**
  64291. * Gets the normal component
  64292. */
  64293. get normal(): NodeMaterialConnectionPoint;
  64294. /**
  64295. * Gets the index of refraction component
  64296. */
  64297. get ior(): NodeMaterialConnectionPoint;
  64298. /**
  64299. * Gets the output component
  64300. */
  64301. get output(): NodeMaterialConnectionPoint;
  64302. protected _buildBlock(state: NodeMaterialBuildState): this;
  64303. }
  64304. }
  64305. declare module BABYLON {
  64306. /**
  64307. * Block used to desaturate a color
  64308. */
  64309. export class DesaturateBlock extends NodeMaterialBlock {
  64310. /**
  64311. * Creates a new DesaturateBlock
  64312. * @param name defines the block name
  64313. */
  64314. constructor(name: string);
  64315. /**
  64316. * Gets the current class name
  64317. * @returns the class name
  64318. */
  64319. getClassName(): string;
  64320. /**
  64321. * Gets the color operand input component
  64322. */
  64323. get color(): NodeMaterialConnectionPoint;
  64324. /**
  64325. * Gets the level operand input component
  64326. */
  64327. get level(): NodeMaterialConnectionPoint;
  64328. /**
  64329. * Gets the output component
  64330. */
  64331. get output(): NodeMaterialConnectionPoint;
  64332. protected _buildBlock(state: NodeMaterialBuildState): this;
  64333. }
  64334. }
  64335. declare module BABYLON {
  64336. /**
  64337. * Block used to implement the ambient occlusion module of the PBR material
  64338. */
  64339. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64340. /**
  64341. * Create a new AmbientOcclusionBlock
  64342. * @param name defines the block name
  64343. */
  64344. constructor(name: string);
  64345. /**
  64346. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64347. */
  64348. useAmbientInGrayScale: boolean;
  64349. /**
  64350. * Initialize the block and prepare the context for build
  64351. * @param state defines the state that will be used for the build
  64352. */
  64353. initialize(state: NodeMaterialBuildState): void;
  64354. /**
  64355. * Gets the current class name
  64356. * @returns the class name
  64357. */
  64358. getClassName(): string;
  64359. /**
  64360. * Gets the texture input component
  64361. */
  64362. get texture(): NodeMaterialConnectionPoint;
  64363. /**
  64364. * Gets the texture intensity component
  64365. */
  64366. get intensity(): NodeMaterialConnectionPoint;
  64367. /**
  64368. * Gets the direct light intensity input component
  64369. */
  64370. get directLightIntensity(): NodeMaterialConnectionPoint;
  64371. /**
  64372. * Gets the ambient occlusion object output component
  64373. */
  64374. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64375. /**
  64376. * Gets the main code of the block (fragment side)
  64377. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64378. * @returns the shader code
  64379. */
  64380. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64381. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64382. protected _buildBlock(state: NodeMaterialBuildState): this;
  64383. protected _dumpPropertiesCode(): string;
  64384. serialize(): any;
  64385. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64386. }
  64387. }
  64388. declare module BABYLON {
  64389. /**
  64390. * Block used to implement the reflection module of the PBR material
  64391. */
  64392. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64393. /** @hidden */
  64394. _defineLODReflectionAlpha: string;
  64395. /** @hidden */
  64396. _defineLinearSpecularReflection: string;
  64397. private _vEnvironmentIrradianceName;
  64398. /** @hidden */
  64399. _vReflectionMicrosurfaceInfosName: string;
  64400. /** @hidden */
  64401. _vReflectionInfosName: string;
  64402. /** @hidden */
  64403. _vReflectionFilteringInfoName: string;
  64404. private _scene;
  64405. /**
  64406. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64407. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64408. * It's less burden on the user side in the editor part.
  64409. */
  64410. /** @hidden */
  64411. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64412. /** @hidden */
  64413. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64414. /** @hidden */
  64415. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64416. /**
  64417. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64418. * diffuse part of the IBL.
  64419. */
  64420. useSphericalHarmonics: boolean;
  64421. /**
  64422. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64423. */
  64424. forceIrradianceInFragment: boolean;
  64425. /**
  64426. * Create a new ReflectionBlock
  64427. * @param name defines the block name
  64428. */
  64429. constructor(name: string);
  64430. /**
  64431. * Gets the current class name
  64432. * @returns the class name
  64433. */
  64434. getClassName(): string;
  64435. /**
  64436. * Gets the position input component
  64437. */
  64438. get position(): NodeMaterialConnectionPoint;
  64439. /**
  64440. * Gets the world position input component
  64441. */
  64442. get worldPosition(): NodeMaterialConnectionPoint;
  64443. /**
  64444. * Gets the world normal input component
  64445. */
  64446. get worldNormal(): NodeMaterialConnectionPoint;
  64447. /**
  64448. * Gets the world input component
  64449. */
  64450. get world(): NodeMaterialConnectionPoint;
  64451. /**
  64452. * Gets the camera (or eye) position component
  64453. */
  64454. get cameraPosition(): NodeMaterialConnectionPoint;
  64455. /**
  64456. * Gets the view input component
  64457. */
  64458. get view(): NodeMaterialConnectionPoint;
  64459. /**
  64460. * Gets the color input component
  64461. */
  64462. get color(): NodeMaterialConnectionPoint;
  64463. /**
  64464. * Gets the reflection object output component
  64465. */
  64466. get reflection(): NodeMaterialConnectionPoint;
  64467. /**
  64468. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64469. */
  64470. get hasTexture(): boolean;
  64471. /**
  64472. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64473. */
  64474. get reflectionColor(): string;
  64475. protected _getTexture(): Nullable<BaseTexture>;
  64476. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64477. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64478. /**
  64479. * Gets the code to inject in the vertex shader
  64480. * @param state current state of the node material building
  64481. * @returns the shader code
  64482. */
  64483. handleVertexSide(state: NodeMaterialBuildState): string;
  64484. /**
  64485. * Gets the main code of the block (fragment side)
  64486. * @param state current state of the node material building
  64487. * @param normalVarName name of the existing variable corresponding to the normal
  64488. * @returns the shader code
  64489. */
  64490. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64491. protected _buildBlock(state: NodeMaterialBuildState): this;
  64492. protected _dumpPropertiesCode(): string;
  64493. serialize(): any;
  64494. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64495. }
  64496. }
  64497. declare module BABYLON {
  64498. /**
  64499. * Block used to implement the sheen module of the PBR material
  64500. */
  64501. export class SheenBlock extends NodeMaterialBlock {
  64502. /**
  64503. * Create a new SheenBlock
  64504. * @param name defines the block name
  64505. */
  64506. constructor(name: string);
  64507. /**
  64508. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64509. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64510. * making it easier to setup and tweak the effect
  64511. */
  64512. albedoScaling: boolean;
  64513. /**
  64514. * Defines if the sheen is linked to the sheen color.
  64515. */
  64516. linkSheenWithAlbedo: boolean;
  64517. /**
  64518. * Initialize the block and prepare the context for build
  64519. * @param state defines the state that will be used for the build
  64520. */
  64521. initialize(state: NodeMaterialBuildState): void;
  64522. /**
  64523. * Gets the current class name
  64524. * @returns the class name
  64525. */
  64526. getClassName(): string;
  64527. /**
  64528. * Gets the intensity input component
  64529. */
  64530. get intensity(): NodeMaterialConnectionPoint;
  64531. /**
  64532. * Gets the color input component
  64533. */
  64534. get color(): NodeMaterialConnectionPoint;
  64535. /**
  64536. * Gets the roughness input component
  64537. */
  64538. get roughness(): NodeMaterialConnectionPoint;
  64539. /**
  64540. * Gets the sheen object output component
  64541. */
  64542. get sheen(): NodeMaterialConnectionPoint;
  64543. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64544. /**
  64545. * Gets the main code of the block (fragment side)
  64546. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64547. * @returns the shader code
  64548. */
  64549. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64550. protected _buildBlock(state: NodeMaterialBuildState): this;
  64551. protected _dumpPropertiesCode(): string;
  64552. serialize(): any;
  64553. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64554. }
  64555. }
  64556. declare module BABYLON {
  64557. /**
  64558. * Block used to implement the reflectivity module of the PBR material
  64559. */
  64560. export class ReflectivityBlock extends NodeMaterialBlock {
  64561. private _metallicReflectanceColor;
  64562. private _metallicF0Factor;
  64563. /** @hidden */
  64564. _vMetallicReflectanceFactorsName: string;
  64565. /**
  64566. * The property below is set by the main PBR block prior to calling methods of this class.
  64567. */
  64568. /** @hidden */
  64569. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64570. /**
  64571. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64572. */
  64573. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64574. /**
  64575. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64576. */
  64577. useMetallnessFromMetallicTextureBlue: boolean;
  64578. /**
  64579. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64580. */
  64581. useRoughnessFromMetallicTextureAlpha: boolean;
  64582. /**
  64583. * Specifies if the metallic texture contains the roughness information in its green channel.
  64584. */
  64585. useRoughnessFromMetallicTextureGreen: boolean;
  64586. /**
  64587. * Create a new ReflectivityBlock
  64588. * @param name defines the block name
  64589. */
  64590. constructor(name: string);
  64591. /**
  64592. * Initialize the block and prepare the context for build
  64593. * @param state defines the state that will be used for the build
  64594. */
  64595. initialize(state: NodeMaterialBuildState): void;
  64596. /**
  64597. * Gets the current class name
  64598. * @returns the class name
  64599. */
  64600. getClassName(): string;
  64601. /**
  64602. * Gets the metallic input component
  64603. */
  64604. get metallic(): NodeMaterialConnectionPoint;
  64605. /**
  64606. * Gets the roughness input component
  64607. */
  64608. get roughness(): NodeMaterialConnectionPoint;
  64609. /**
  64610. * Gets the texture input component
  64611. */
  64612. get texture(): NodeMaterialConnectionPoint;
  64613. /**
  64614. * Gets the reflectivity object output component
  64615. */
  64616. get reflectivity(): NodeMaterialConnectionPoint;
  64617. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64618. /**
  64619. * Gets the main code of the block (fragment side)
  64620. * @param state current state of the node material building
  64621. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64622. * @returns the shader code
  64623. */
  64624. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64625. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64626. protected _buildBlock(state: NodeMaterialBuildState): this;
  64627. protected _dumpPropertiesCode(): string;
  64628. serialize(): any;
  64629. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64630. }
  64631. }
  64632. declare module BABYLON {
  64633. /**
  64634. * Block used to implement the anisotropy module of the PBR material
  64635. */
  64636. export class AnisotropyBlock extends NodeMaterialBlock {
  64637. /**
  64638. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64639. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64640. * It's less burden on the user side in the editor part.
  64641. */
  64642. /** @hidden */
  64643. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64644. /** @hidden */
  64645. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64646. /**
  64647. * Create a new AnisotropyBlock
  64648. * @param name defines the block name
  64649. */
  64650. constructor(name: string);
  64651. /**
  64652. * Initialize the block and prepare the context for build
  64653. * @param state defines the state that will be used for the build
  64654. */
  64655. initialize(state: NodeMaterialBuildState): void;
  64656. /**
  64657. * Gets the current class name
  64658. * @returns the class name
  64659. */
  64660. getClassName(): string;
  64661. /**
  64662. * Gets the intensity input component
  64663. */
  64664. get intensity(): NodeMaterialConnectionPoint;
  64665. /**
  64666. * Gets the direction input component
  64667. */
  64668. get direction(): NodeMaterialConnectionPoint;
  64669. /**
  64670. * Gets the texture input component
  64671. */
  64672. get texture(): NodeMaterialConnectionPoint;
  64673. /**
  64674. * Gets the uv input component
  64675. */
  64676. get uv(): NodeMaterialConnectionPoint;
  64677. /**
  64678. * Gets the worldTangent input component
  64679. */
  64680. get worldTangent(): NodeMaterialConnectionPoint;
  64681. /**
  64682. * Gets the anisotropy object output component
  64683. */
  64684. get anisotropy(): NodeMaterialConnectionPoint;
  64685. private _generateTBNSpace;
  64686. /**
  64687. * Gets the main code of the block (fragment side)
  64688. * @param state current state of the node material building
  64689. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64690. * @returns the shader code
  64691. */
  64692. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64693. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64694. protected _buildBlock(state: NodeMaterialBuildState): this;
  64695. }
  64696. }
  64697. declare module BABYLON {
  64698. /**
  64699. * Block used to implement the clear coat module of the PBR material
  64700. */
  64701. export class ClearCoatBlock extends NodeMaterialBlock {
  64702. private _scene;
  64703. /**
  64704. * Create a new ClearCoatBlock
  64705. * @param name defines the block name
  64706. */
  64707. constructor(name: string);
  64708. /**
  64709. * Initialize the block and prepare the context for build
  64710. * @param state defines the state that will be used for the build
  64711. */
  64712. initialize(state: NodeMaterialBuildState): void;
  64713. /**
  64714. * Gets the current class name
  64715. * @returns the class name
  64716. */
  64717. getClassName(): string;
  64718. /**
  64719. * Gets the intensity input component
  64720. */
  64721. get intensity(): NodeMaterialConnectionPoint;
  64722. /**
  64723. * Gets the roughness input component
  64724. */
  64725. get roughness(): NodeMaterialConnectionPoint;
  64726. /**
  64727. * Gets the ior input component
  64728. */
  64729. get ior(): NodeMaterialConnectionPoint;
  64730. /**
  64731. * Gets the texture input component
  64732. */
  64733. get texture(): NodeMaterialConnectionPoint;
  64734. /**
  64735. * Gets the bump texture input component
  64736. */
  64737. get bumpTexture(): NodeMaterialConnectionPoint;
  64738. /**
  64739. * Gets the uv input component
  64740. */
  64741. get uv(): NodeMaterialConnectionPoint;
  64742. /**
  64743. * Gets the tint color input component
  64744. */
  64745. get tintColor(): NodeMaterialConnectionPoint;
  64746. /**
  64747. * Gets the tint "at distance" input component
  64748. */
  64749. get tintAtDistance(): NodeMaterialConnectionPoint;
  64750. /**
  64751. * Gets the tint thickness input component
  64752. */
  64753. get tintThickness(): NodeMaterialConnectionPoint;
  64754. /**
  64755. * Gets the world tangent input component
  64756. */
  64757. get worldTangent(): NodeMaterialConnectionPoint;
  64758. /**
  64759. * Gets the clear coat object output component
  64760. */
  64761. get clearcoat(): NodeMaterialConnectionPoint;
  64762. autoConfigure(material: NodeMaterial): void;
  64763. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64764. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64765. private _generateTBNSpace;
  64766. /**
  64767. * Gets the main code of the block (fragment side)
  64768. * @param state current state of the node material building
  64769. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64770. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64771. * @param worldPosVarName name of the variable holding the world position
  64772. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64773. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64774. * @param worldNormalVarName name of the variable holding the world normal
  64775. * @returns the shader code
  64776. */
  64777. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64778. protected _buildBlock(state: NodeMaterialBuildState): this;
  64779. }
  64780. }
  64781. declare module BABYLON {
  64782. /**
  64783. * Block used to implement the sub surface module of the PBR material
  64784. */
  64785. export class SubSurfaceBlock extends NodeMaterialBlock {
  64786. /**
  64787. * Create a new SubSurfaceBlock
  64788. * @param name defines the block name
  64789. */
  64790. constructor(name: string);
  64791. /**
  64792. * Stores the intensity of the different subsurface effects in the thickness texture.
  64793. * * the green channel is the translucency intensity.
  64794. * * the blue channel is the scattering intensity.
  64795. * * the alpha channel is the refraction intensity.
  64796. */
  64797. useMaskFromThicknessTexture: boolean;
  64798. /**
  64799. * Initialize the block and prepare the context for build
  64800. * @param state defines the state that will be used for the build
  64801. */
  64802. initialize(state: NodeMaterialBuildState): void;
  64803. /**
  64804. * Gets the current class name
  64805. * @returns the class name
  64806. */
  64807. getClassName(): string;
  64808. /**
  64809. * Gets the min thickness input component
  64810. */
  64811. get minThickness(): NodeMaterialConnectionPoint;
  64812. /**
  64813. * Gets the max thickness input component
  64814. */
  64815. get maxThickness(): NodeMaterialConnectionPoint;
  64816. /**
  64817. * Gets the thickness texture component
  64818. */
  64819. get thicknessTexture(): NodeMaterialConnectionPoint;
  64820. /**
  64821. * Gets the tint color input component
  64822. */
  64823. get tintColor(): NodeMaterialConnectionPoint;
  64824. /**
  64825. * Gets the translucency intensity input component
  64826. */
  64827. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64828. /**
  64829. * Gets the translucency diffusion distance input component
  64830. */
  64831. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64832. /**
  64833. * Gets the refraction object parameters
  64834. */
  64835. get refraction(): NodeMaterialConnectionPoint;
  64836. /**
  64837. * Gets the sub surface object output component
  64838. */
  64839. get subsurface(): NodeMaterialConnectionPoint;
  64840. autoConfigure(material: NodeMaterial): void;
  64841. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64842. /**
  64843. * Gets the main code of the block (fragment side)
  64844. * @param state current state of the node material building
  64845. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64846. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64847. * @param worldPosVarName name of the variable holding the world position
  64848. * @returns the shader code
  64849. */
  64850. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64851. protected _buildBlock(state: NodeMaterialBuildState): this;
  64852. }
  64853. }
  64854. declare module BABYLON {
  64855. /**
  64856. * Block used to implement the PBR metallic/roughness model
  64857. */
  64858. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64859. /**
  64860. * Gets or sets the light associated with this block
  64861. */
  64862. light: Nullable<Light>;
  64863. private _lightId;
  64864. private _scene;
  64865. private _environmentBRDFTexture;
  64866. private _environmentBrdfSamplerName;
  64867. private _vNormalWName;
  64868. private _invertNormalName;
  64869. /**
  64870. * Create a new ReflectionBlock
  64871. * @param name defines the block name
  64872. */
  64873. constructor(name: string);
  64874. /**
  64875. * Intensity of the direct lights e.g. the four lights available in your scene.
  64876. * This impacts both the direct diffuse and specular highlights.
  64877. */
  64878. directIntensity: number;
  64879. /**
  64880. * Intensity of the environment e.g. how much the environment will light the object
  64881. * either through harmonics for rough material or through the refelction for shiny ones.
  64882. */
  64883. environmentIntensity: number;
  64884. /**
  64885. * This is a special control allowing the reduction of the specular highlights coming from the
  64886. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64887. */
  64888. specularIntensity: number;
  64889. /**
  64890. * Defines the falloff type used in this material.
  64891. * It by default is Physical.
  64892. */
  64893. lightFalloff: number;
  64894. /**
  64895. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64896. */
  64897. useAlphaFromAlbedoTexture: boolean;
  64898. /**
  64899. * Specifies that alpha test should be used
  64900. */
  64901. useAlphaTest: boolean;
  64902. /**
  64903. * Defines the alpha limits in alpha test mode.
  64904. */
  64905. alphaTestCutoff: number;
  64906. /**
  64907. * Specifies that alpha blending should be used
  64908. */
  64909. useAlphaBlending: boolean;
  64910. /**
  64911. * Defines if the alpha value should be determined via the rgb values.
  64912. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64913. */
  64914. opacityRGB: boolean;
  64915. /**
  64916. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64917. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64918. */
  64919. useRadianceOverAlpha: boolean;
  64920. /**
  64921. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64922. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64923. */
  64924. useSpecularOverAlpha: boolean;
  64925. /**
  64926. * Enables specular anti aliasing in the PBR shader.
  64927. * It will both interacts on the Geometry for analytical and IBL lighting.
  64928. * It also prefilter the roughness map based on the bump values.
  64929. */
  64930. enableSpecularAntiAliasing: boolean;
  64931. /**
  64932. * Enables realtime filtering on the texture.
  64933. */
  64934. realTimeFiltering: boolean;
  64935. /**
  64936. * Quality switch for realtime filtering
  64937. */
  64938. realTimeFilteringQuality: number;
  64939. /**
  64940. * Defines if the material uses energy conservation.
  64941. */
  64942. useEnergyConservation: boolean;
  64943. /**
  64944. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64945. * too much the area relying on ambient texture to define their ambient occlusion.
  64946. */
  64947. useRadianceOcclusion: boolean;
  64948. /**
  64949. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64950. * makes the reflect vector face the model (under horizon).
  64951. */
  64952. useHorizonOcclusion: boolean;
  64953. /**
  64954. * If set to true, no lighting calculations will be applied.
  64955. */
  64956. unlit: boolean;
  64957. /**
  64958. * Force normal to face away from face.
  64959. */
  64960. forceNormalForward: boolean;
  64961. /**
  64962. * Defines the material debug mode.
  64963. * It helps seeing only some components of the material while troubleshooting.
  64964. */
  64965. debugMode: number;
  64966. /**
  64967. * Specify from where on screen the debug mode should start.
  64968. * The value goes from -1 (full screen) to 1 (not visible)
  64969. * It helps with side by side comparison against the final render
  64970. * This defaults to 0
  64971. */
  64972. debugLimit: number;
  64973. /**
  64974. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64975. * You can use the factor to better multiply the final value.
  64976. */
  64977. debugFactor: number;
  64978. /**
  64979. * Initialize the block and prepare the context for build
  64980. * @param state defines the state that will be used for the build
  64981. */
  64982. initialize(state: NodeMaterialBuildState): void;
  64983. /**
  64984. * Gets the current class name
  64985. * @returns the class name
  64986. */
  64987. getClassName(): string;
  64988. /**
  64989. * Gets the world position input component
  64990. */
  64991. get worldPosition(): NodeMaterialConnectionPoint;
  64992. /**
  64993. * Gets the world normal input component
  64994. */
  64995. get worldNormal(): NodeMaterialConnectionPoint;
  64996. /**
  64997. * Gets the perturbed normal input component
  64998. */
  64999. get perturbedNormal(): NodeMaterialConnectionPoint;
  65000. /**
  65001. * Gets the camera position input component
  65002. */
  65003. get cameraPosition(): NodeMaterialConnectionPoint;
  65004. /**
  65005. * Gets the base color input component
  65006. */
  65007. get baseColor(): NodeMaterialConnectionPoint;
  65008. /**
  65009. * Gets the opacity texture input component
  65010. */
  65011. get opacityTexture(): NodeMaterialConnectionPoint;
  65012. /**
  65013. * Gets the ambient color input component
  65014. */
  65015. get ambientColor(): NodeMaterialConnectionPoint;
  65016. /**
  65017. * Gets the reflectivity object parameters
  65018. */
  65019. get reflectivity(): NodeMaterialConnectionPoint;
  65020. /**
  65021. * Gets the ambient occlusion object parameters
  65022. */
  65023. get ambientOcclusion(): NodeMaterialConnectionPoint;
  65024. /**
  65025. * Gets the reflection object parameters
  65026. */
  65027. get reflection(): NodeMaterialConnectionPoint;
  65028. /**
  65029. * Gets the sheen object parameters
  65030. */
  65031. get sheen(): NodeMaterialConnectionPoint;
  65032. /**
  65033. * Gets the clear coat object parameters
  65034. */
  65035. get clearcoat(): NodeMaterialConnectionPoint;
  65036. /**
  65037. * Gets the sub surface object parameters
  65038. */
  65039. get subsurface(): NodeMaterialConnectionPoint;
  65040. /**
  65041. * Gets the anisotropy object parameters
  65042. */
  65043. get anisotropy(): NodeMaterialConnectionPoint;
  65044. /**
  65045. * Gets the ambient output component
  65046. */
  65047. get ambient(): NodeMaterialConnectionPoint;
  65048. /**
  65049. * Gets the diffuse output component
  65050. */
  65051. get diffuse(): NodeMaterialConnectionPoint;
  65052. /**
  65053. * Gets the specular output component
  65054. */
  65055. get specular(): NodeMaterialConnectionPoint;
  65056. /**
  65057. * Gets the sheen output component
  65058. */
  65059. get sheenDir(): NodeMaterialConnectionPoint;
  65060. /**
  65061. * Gets the clear coat output component
  65062. */
  65063. get clearcoatDir(): NodeMaterialConnectionPoint;
  65064. /**
  65065. * Gets the indirect diffuse output component
  65066. */
  65067. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65068. /**
  65069. * Gets the indirect specular output component
  65070. */
  65071. get specularIndirect(): NodeMaterialConnectionPoint;
  65072. /**
  65073. * Gets the indirect sheen output component
  65074. */
  65075. get sheenIndirect(): NodeMaterialConnectionPoint;
  65076. /**
  65077. * Gets the indirect clear coat output component
  65078. */
  65079. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65080. /**
  65081. * Gets the refraction output component
  65082. */
  65083. get refraction(): NodeMaterialConnectionPoint;
  65084. /**
  65085. * Gets the global lighting output component
  65086. */
  65087. get lighting(): NodeMaterialConnectionPoint;
  65088. /**
  65089. * Gets the shadow output component
  65090. */
  65091. get shadow(): NodeMaterialConnectionPoint;
  65092. /**
  65093. * Gets the alpha output component
  65094. */
  65095. get alpha(): NodeMaterialConnectionPoint;
  65096. autoConfigure(material: NodeMaterial): void;
  65097. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65098. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65099. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65100. private _injectVertexCode;
  65101. /**
  65102. * Gets the code corresponding to the albedo/opacity module
  65103. * @returns the shader code
  65104. */
  65105. getAlbedoOpacityCode(): string;
  65106. protected _buildBlock(state: NodeMaterialBuildState): this;
  65107. protected _dumpPropertiesCode(): string;
  65108. serialize(): any;
  65109. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65110. }
  65111. }
  65112. declare module BABYLON {
  65113. /**
  65114. * Block used to compute value of one parameter modulo another
  65115. */
  65116. export class ModBlock extends NodeMaterialBlock {
  65117. /**
  65118. * Creates a new ModBlock
  65119. * @param name defines the block name
  65120. */
  65121. constructor(name: string);
  65122. /**
  65123. * Gets the current class name
  65124. * @returns the class name
  65125. */
  65126. getClassName(): string;
  65127. /**
  65128. * Gets the left operand input component
  65129. */
  65130. get left(): NodeMaterialConnectionPoint;
  65131. /**
  65132. * Gets the right operand input component
  65133. */
  65134. get right(): NodeMaterialConnectionPoint;
  65135. /**
  65136. * Gets the output component
  65137. */
  65138. get output(): NodeMaterialConnectionPoint;
  65139. protected _buildBlock(state: NodeMaterialBuildState): this;
  65140. }
  65141. }
  65142. declare module BABYLON {
  65143. /**
  65144. * Configuration for Draco compression
  65145. */
  65146. export interface IDracoCompressionConfiguration {
  65147. /**
  65148. * Configuration for the decoder.
  65149. */
  65150. decoder: {
  65151. /**
  65152. * The url to the WebAssembly module.
  65153. */
  65154. wasmUrl?: string;
  65155. /**
  65156. * The url to the WebAssembly binary.
  65157. */
  65158. wasmBinaryUrl?: string;
  65159. /**
  65160. * The url to the fallback JavaScript module.
  65161. */
  65162. fallbackUrl?: string;
  65163. };
  65164. }
  65165. /**
  65166. * Draco compression (https://google.github.io/draco/)
  65167. *
  65168. * This class wraps the Draco module.
  65169. *
  65170. * **Encoder**
  65171. *
  65172. * The encoder is not currently implemented.
  65173. *
  65174. * **Decoder**
  65175. *
  65176. * 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.
  65177. *
  65178. * To update the configuration, use the following code:
  65179. * ```javascript
  65180. * DracoCompression.Configuration = {
  65181. * decoder: {
  65182. * wasmUrl: "<url to the WebAssembly library>",
  65183. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65184. * fallbackUrl: "<url to the fallback JavaScript library>",
  65185. * }
  65186. * };
  65187. * ```
  65188. *
  65189. * 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.
  65190. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65191. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65192. *
  65193. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65194. * ```javascript
  65195. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65196. * ```
  65197. *
  65198. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65199. */
  65200. export class DracoCompression implements IDisposable {
  65201. private _workerPoolPromise?;
  65202. private _decoderModulePromise?;
  65203. /**
  65204. * The configuration. Defaults to the following urls:
  65205. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65206. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65207. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65208. */
  65209. static Configuration: IDracoCompressionConfiguration;
  65210. /**
  65211. * Returns true if the decoder configuration is available.
  65212. */
  65213. static get DecoderAvailable(): boolean;
  65214. /**
  65215. * Default number of workers to create when creating the draco compression object.
  65216. */
  65217. static DefaultNumWorkers: number;
  65218. private static GetDefaultNumWorkers;
  65219. private static _Default;
  65220. /**
  65221. * Default instance for the draco compression object.
  65222. */
  65223. static get Default(): DracoCompression;
  65224. /**
  65225. * Constructor
  65226. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65227. */
  65228. constructor(numWorkers?: number);
  65229. /**
  65230. * Stop all async operations and release resources.
  65231. */
  65232. dispose(): void;
  65233. /**
  65234. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65235. * @returns a promise that resolves when ready
  65236. */
  65237. whenReadyAsync(): Promise<void>;
  65238. /**
  65239. * Decode Draco compressed mesh data to vertex data.
  65240. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65241. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65242. * @returns A promise that resolves with the decoded vertex data
  65243. */
  65244. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65245. [kind: string]: number;
  65246. }): Promise<VertexData>;
  65247. }
  65248. }
  65249. declare module BABYLON {
  65250. /**
  65251. * Class for building Constructive Solid Geometry
  65252. */
  65253. export class CSG {
  65254. private polygons;
  65255. /**
  65256. * The world matrix
  65257. */
  65258. matrix: Matrix;
  65259. /**
  65260. * Stores the position
  65261. */
  65262. position: Vector3;
  65263. /**
  65264. * Stores the rotation
  65265. */
  65266. rotation: Vector3;
  65267. /**
  65268. * Stores the rotation quaternion
  65269. */
  65270. rotationQuaternion: Nullable<Quaternion>;
  65271. /**
  65272. * Stores the scaling vector
  65273. */
  65274. scaling: Vector3;
  65275. /**
  65276. * Convert the Mesh to CSG
  65277. * @param mesh The Mesh to convert to CSG
  65278. * @returns A new CSG from the Mesh
  65279. */
  65280. static FromMesh(mesh: Mesh): CSG;
  65281. /**
  65282. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65283. * @param polygons Polygons used to construct a CSG solid
  65284. */
  65285. private static FromPolygons;
  65286. /**
  65287. * Clones, or makes a deep copy, of the CSG
  65288. * @returns A new CSG
  65289. */
  65290. clone(): CSG;
  65291. /**
  65292. * Unions this CSG with another CSG
  65293. * @param csg The CSG to union against this CSG
  65294. * @returns The unioned CSG
  65295. */
  65296. union(csg: CSG): CSG;
  65297. /**
  65298. * Unions this CSG with another CSG in place
  65299. * @param csg The CSG to union against this CSG
  65300. */
  65301. unionInPlace(csg: CSG): void;
  65302. /**
  65303. * Subtracts this CSG with another CSG
  65304. * @param csg The CSG to subtract against this CSG
  65305. * @returns A new CSG
  65306. */
  65307. subtract(csg: CSG): CSG;
  65308. /**
  65309. * Subtracts this CSG with another CSG in place
  65310. * @param csg The CSG to subtact against this CSG
  65311. */
  65312. subtractInPlace(csg: CSG): void;
  65313. /**
  65314. * Intersect this CSG with another CSG
  65315. * @param csg The CSG to intersect against this CSG
  65316. * @returns A new CSG
  65317. */
  65318. intersect(csg: CSG): CSG;
  65319. /**
  65320. * Intersects this CSG with another CSG in place
  65321. * @param csg The CSG to intersect against this CSG
  65322. */
  65323. intersectInPlace(csg: CSG): void;
  65324. /**
  65325. * Return a new CSG solid with solid and empty space switched. This solid is
  65326. * not modified.
  65327. * @returns A new CSG solid with solid and empty space switched
  65328. */
  65329. inverse(): CSG;
  65330. /**
  65331. * Inverses the CSG in place
  65332. */
  65333. inverseInPlace(): void;
  65334. /**
  65335. * This is used to keep meshes transformations so they can be restored
  65336. * when we build back a Babylon Mesh
  65337. * NB : All CSG operations are performed in world coordinates
  65338. * @param csg The CSG to copy the transform attributes from
  65339. * @returns This CSG
  65340. */
  65341. copyTransformAttributes(csg: CSG): CSG;
  65342. /**
  65343. * Build Raw mesh from CSG
  65344. * Coordinates here are in world space
  65345. * @param name The name of the mesh geometry
  65346. * @param scene The Scene
  65347. * @param keepSubMeshes Specifies if the submeshes should be kept
  65348. * @returns A new Mesh
  65349. */
  65350. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65351. /**
  65352. * Build Mesh from CSG taking material and transforms into account
  65353. * @param name The name of the Mesh
  65354. * @param material The material of the Mesh
  65355. * @param scene The Scene
  65356. * @param keepSubMeshes Specifies if submeshes should be kept
  65357. * @returns The new Mesh
  65358. */
  65359. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65360. }
  65361. }
  65362. declare module BABYLON {
  65363. /**
  65364. * Class used to create a trail following a mesh
  65365. */
  65366. export class TrailMesh extends Mesh {
  65367. private _generator;
  65368. private _autoStart;
  65369. private _running;
  65370. private _diameter;
  65371. private _length;
  65372. private _sectionPolygonPointsCount;
  65373. private _sectionVectors;
  65374. private _sectionNormalVectors;
  65375. private _beforeRenderObserver;
  65376. /**
  65377. * @constructor
  65378. * @param name The value used by scene.getMeshByName() to do a lookup.
  65379. * @param generator The mesh or transform node to generate a trail.
  65380. * @param scene The scene to add this mesh to.
  65381. * @param diameter Diameter of trailing mesh. Default is 1.
  65382. * @param length Length of trailing mesh. Default is 60.
  65383. * @param autoStart Automatically start trailing mesh. Default true.
  65384. */
  65385. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65386. /**
  65387. * "TrailMesh"
  65388. * @returns "TrailMesh"
  65389. */
  65390. getClassName(): string;
  65391. private _createMesh;
  65392. /**
  65393. * Start trailing mesh.
  65394. */
  65395. start(): void;
  65396. /**
  65397. * Stop trailing mesh.
  65398. */
  65399. stop(): void;
  65400. /**
  65401. * Update trailing mesh geometry.
  65402. */
  65403. update(): void;
  65404. /**
  65405. * Returns a new TrailMesh object.
  65406. * @param name is a string, the name given to the new mesh
  65407. * @param newGenerator use new generator object for cloned trail mesh
  65408. * @returns a new mesh
  65409. */
  65410. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65411. /**
  65412. * Serializes this trail mesh
  65413. * @param serializationObject object to write serialization to
  65414. */
  65415. serialize(serializationObject: any): void;
  65416. /**
  65417. * Parses a serialized trail mesh
  65418. * @param parsedMesh the serialized mesh
  65419. * @param scene the scene to create the trail mesh in
  65420. * @returns the created trail mesh
  65421. */
  65422. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65423. }
  65424. }
  65425. declare module BABYLON {
  65426. /**
  65427. * Class containing static functions to help procedurally build meshes
  65428. */
  65429. export class TiledBoxBuilder {
  65430. /**
  65431. * Creates a box mesh
  65432. * 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)
  65433. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65435. * * 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
  65436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65437. * @param name defines the name of the mesh
  65438. * @param options defines the options used to create the mesh
  65439. * @param scene defines the hosting scene
  65440. * @returns the box mesh
  65441. */
  65442. static CreateTiledBox(name: string, options: {
  65443. pattern?: number;
  65444. width?: number;
  65445. height?: number;
  65446. depth?: number;
  65447. tileSize?: number;
  65448. tileWidth?: number;
  65449. tileHeight?: number;
  65450. alignHorizontal?: number;
  65451. alignVertical?: number;
  65452. faceUV?: Vector4[];
  65453. faceColors?: Color4[];
  65454. sideOrientation?: number;
  65455. updatable?: boolean;
  65456. }, scene?: Nullable<Scene>): Mesh;
  65457. }
  65458. }
  65459. declare module BABYLON {
  65460. /**
  65461. * Class containing static functions to help procedurally build meshes
  65462. */
  65463. export class TorusKnotBuilder {
  65464. /**
  65465. * Creates a torus knot mesh
  65466. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65467. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65468. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65469. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65471. * * 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
  65472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65473. * @param name defines the name of the mesh
  65474. * @param options defines the options used to create the mesh
  65475. * @param scene defines the hosting scene
  65476. * @returns the torus knot mesh
  65477. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65478. */
  65479. static CreateTorusKnot(name: string, options: {
  65480. radius?: number;
  65481. tube?: number;
  65482. radialSegments?: number;
  65483. tubularSegments?: number;
  65484. p?: number;
  65485. q?: number;
  65486. updatable?: boolean;
  65487. sideOrientation?: number;
  65488. frontUVs?: Vector4;
  65489. backUVs?: Vector4;
  65490. }, scene: any): Mesh;
  65491. }
  65492. }
  65493. declare module BABYLON {
  65494. /**
  65495. * Polygon
  65496. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65497. */
  65498. export class Polygon {
  65499. /**
  65500. * Creates a rectangle
  65501. * @param xmin bottom X coord
  65502. * @param ymin bottom Y coord
  65503. * @param xmax top X coord
  65504. * @param ymax top Y coord
  65505. * @returns points that make the resulting rectation
  65506. */
  65507. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65508. /**
  65509. * Creates a circle
  65510. * @param radius radius of circle
  65511. * @param cx scale in x
  65512. * @param cy scale in y
  65513. * @param numberOfSides number of sides that make up the circle
  65514. * @returns points that make the resulting circle
  65515. */
  65516. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65517. /**
  65518. * Creates a polygon from input string
  65519. * @param input Input polygon data
  65520. * @returns the parsed points
  65521. */
  65522. static Parse(input: string): Vector2[];
  65523. /**
  65524. * Starts building a polygon from x and y coordinates
  65525. * @param x x coordinate
  65526. * @param y y coordinate
  65527. * @returns the started path2
  65528. */
  65529. static StartingAt(x: number, y: number): Path2;
  65530. }
  65531. /**
  65532. * Builds a polygon
  65533. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65534. */
  65535. export class PolygonMeshBuilder {
  65536. private _points;
  65537. private _outlinepoints;
  65538. private _holes;
  65539. private _name;
  65540. private _scene;
  65541. private _epoints;
  65542. private _eholes;
  65543. private _addToepoint;
  65544. /**
  65545. * Babylon reference to the earcut plugin.
  65546. */
  65547. bjsEarcut: any;
  65548. /**
  65549. * Creates a PolygonMeshBuilder
  65550. * @param name name of the builder
  65551. * @param contours Path of the polygon
  65552. * @param scene scene to add to when creating the mesh
  65553. * @param earcutInjection can be used to inject your own earcut reference
  65554. */
  65555. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65556. /**
  65557. * Adds a whole within the polygon
  65558. * @param hole Array of points defining the hole
  65559. * @returns this
  65560. */
  65561. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65562. /**
  65563. * Creates the polygon
  65564. * @param updatable If the mesh should be updatable
  65565. * @param depth The depth of the mesh created
  65566. * @returns the created mesh
  65567. */
  65568. build(updatable?: boolean, depth?: number): Mesh;
  65569. /**
  65570. * Creates the polygon
  65571. * @param depth The depth of the mesh created
  65572. * @returns the created VertexData
  65573. */
  65574. buildVertexData(depth?: number): VertexData;
  65575. /**
  65576. * Adds a side to the polygon
  65577. * @param positions points that make the polygon
  65578. * @param normals normals of the polygon
  65579. * @param uvs uvs of the polygon
  65580. * @param indices indices of the polygon
  65581. * @param bounds bounds of the polygon
  65582. * @param points points of the polygon
  65583. * @param depth depth of the polygon
  65584. * @param flip flip of the polygon
  65585. */
  65586. private addSide;
  65587. }
  65588. }
  65589. declare module BABYLON {
  65590. /**
  65591. * Class containing static functions to help procedurally build meshes
  65592. */
  65593. export class PolygonBuilder {
  65594. /**
  65595. * Creates a polygon mesh
  65596. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65597. * * 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
  65598. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65600. * * 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)
  65601. * * Remember you can only change the shape positions, not their number when updating a polygon
  65602. * @param name defines the name of the mesh
  65603. * @param options defines the options used to create the mesh
  65604. * @param scene defines the hosting scene
  65605. * @param earcutInjection can be used to inject your own earcut reference
  65606. * @returns the polygon mesh
  65607. */
  65608. static CreatePolygon(name: string, options: {
  65609. shape: Vector3[];
  65610. holes?: Vector3[][];
  65611. depth?: number;
  65612. faceUV?: Vector4[];
  65613. faceColors?: Color4[];
  65614. updatable?: boolean;
  65615. sideOrientation?: number;
  65616. frontUVs?: Vector4;
  65617. backUVs?: Vector4;
  65618. wrap?: boolean;
  65619. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65620. /**
  65621. * Creates an extruded polygon mesh, with depth in the Y direction.
  65622. * * 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)
  65623. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65624. * @param name defines the name of the mesh
  65625. * @param options defines the options used to create the mesh
  65626. * @param scene defines the hosting scene
  65627. * @param earcutInjection can be used to inject your own earcut reference
  65628. * @returns the polygon mesh
  65629. */
  65630. static ExtrudePolygon(name: string, options: {
  65631. shape: Vector3[];
  65632. holes?: Vector3[][];
  65633. depth?: number;
  65634. faceUV?: Vector4[];
  65635. faceColors?: Color4[];
  65636. updatable?: boolean;
  65637. sideOrientation?: number;
  65638. frontUVs?: Vector4;
  65639. backUVs?: Vector4;
  65640. wrap?: boolean;
  65641. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65642. }
  65643. }
  65644. declare module BABYLON {
  65645. /**
  65646. * Class containing static functions to help procedurally build meshes
  65647. */
  65648. export class LatheBuilder {
  65649. /**
  65650. * Creates lathe mesh.
  65651. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65652. * * 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
  65653. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65654. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65655. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65656. * * 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
  65657. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65658. * * 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
  65659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65660. * * 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
  65661. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65663. * @param name defines the name of the mesh
  65664. * @param options defines the options used to create the mesh
  65665. * @param scene defines the hosting scene
  65666. * @returns the lathe mesh
  65667. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65668. */
  65669. static CreateLathe(name: string, options: {
  65670. shape: Vector3[];
  65671. radius?: number;
  65672. tessellation?: number;
  65673. clip?: number;
  65674. arc?: number;
  65675. closed?: boolean;
  65676. updatable?: boolean;
  65677. sideOrientation?: number;
  65678. frontUVs?: Vector4;
  65679. backUVs?: Vector4;
  65680. cap?: number;
  65681. invertUV?: boolean;
  65682. }, scene?: Nullable<Scene>): Mesh;
  65683. }
  65684. }
  65685. declare module BABYLON {
  65686. /**
  65687. * Class containing static functions to help procedurally build meshes
  65688. */
  65689. export class TiledPlaneBuilder {
  65690. /**
  65691. * Creates a tiled plane mesh
  65692. * * The parameter `pattern` will, depending on value, do nothing or
  65693. * * * flip (reflect about central vertical) alternate tiles across and up
  65694. * * * flip every tile on alternate rows
  65695. * * * rotate (180 degs) alternate tiles across and up
  65696. * * * rotate every tile on alternate rows
  65697. * * * flip and rotate alternate tiles across and up
  65698. * * * flip and rotate every tile on alternate rows
  65699. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65700. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65701. * * 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
  65702. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65703. * * 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)
  65704. * * 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)
  65705. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65706. * @param name defines the name of the mesh
  65707. * @param options defines the options used to create the mesh
  65708. * @param scene defines the hosting scene
  65709. * @returns the box mesh
  65710. */
  65711. static CreateTiledPlane(name: string, options: {
  65712. pattern?: number;
  65713. tileSize?: number;
  65714. tileWidth?: number;
  65715. tileHeight?: number;
  65716. size?: number;
  65717. width?: number;
  65718. height?: number;
  65719. alignHorizontal?: number;
  65720. alignVertical?: number;
  65721. sideOrientation?: number;
  65722. frontUVs?: Vector4;
  65723. backUVs?: Vector4;
  65724. updatable?: boolean;
  65725. }, scene?: Nullable<Scene>): Mesh;
  65726. }
  65727. }
  65728. declare module BABYLON {
  65729. /**
  65730. * Class containing static functions to help procedurally build meshes
  65731. */
  65732. export class TubeBuilder {
  65733. /**
  65734. * Creates a tube mesh.
  65735. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65736. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65737. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65738. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65739. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65740. * * 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)
  65741. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65742. * * 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
  65743. * * 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
  65744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65745. * * 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
  65746. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65748. * @param name defines the name of the mesh
  65749. * @param options defines the options used to create the mesh
  65750. * @param scene defines the hosting scene
  65751. * @returns the tube mesh
  65752. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65753. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65754. */
  65755. static CreateTube(name: string, options: {
  65756. path: Vector3[];
  65757. radius?: number;
  65758. tessellation?: number;
  65759. radiusFunction?: {
  65760. (i: number, distance: number): number;
  65761. };
  65762. cap?: number;
  65763. arc?: number;
  65764. updatable?: boolean;
  65765. sideOrientation?: number;
  65766. frontUVs?: Vector4;
  65767. backUVs?: Vector4;
  65768. instance?: Mesh;
  65769. invertUV?: boolean;
  65770. }, scene?: Nullable<Scene>): Mesh;
  65771. }
  65772. }
  65773. declare module BABYLON {
  65774. /**
  65775. * Class containing static functions to help procedurally build meshes
  65776. */
  65777. export class IcoSphereBuilder {
  65778. /**
  65779. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65780. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65781. * * 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`)
  65782. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65783. * * 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
  65784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65785. * * 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
  65786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65787. * @param name defines the name of the mesh
  65788. * @param options defines the options used to create the mesh
  65789. * @param scene defines the hosting scene
  65790. * @returns the icosahedron mesh
  65791. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65792. */
  65793. static CreateIcoSphere(name: string, options: {
  65794. radius?: number;
  65795. radiusX?: number;
  65796. radiusY?: number;
  65797. radiusZ?: number;
  65798. flat?: boolean;
  65799. subdivisions?: number;
  65800. sideOrientation?: number;
  65801. frontUVs?: Vector4;
  65802. backUVs?: Vector4;
  65803. updatable?: boolean;
  65804. }, scene?: Nullable<Scene>): Mesh;
  65805. }
  65806. }
  65807. declare module BABYLON {
  65808. /**
  65809. * Class containing static functions to help procedurally build meshes
  65810. */
  65811. export class DecalBuilder {
  65812. /**
  65813. * Creates a decal mesh.
  65814. * 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
  65815. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65816. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65817. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65818. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65819. * @param name defines the name of the mesh
  65820. * @param sourceMesh defines the mesh where the decal must be applied
  65821. * @param options defines the options used to create the mesh
  65822. * @param scene defines the hosting scene
  65823. * @returns the decal mesh
  65824. * @see https://doc.babylonjs.com/how_to/decals
  65825. */
  65826. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65827. position?: Vector3;
  65828. normal?: Vector3;
  65829. size?: Vector3;
  65830. angle?: number;
  65831. }): Mesh;
  65832. }
  65833. }
  65834. declare module BABYLON {
  65835. /**
  65836. * Class containing static functions to help procedurally build meshes
  65837. */
  65838. export class MeshBuilder {
  65839. /**
  65840. * Creates a box mesh
  65841. * * The parameter `size` sets the size (float) of each box side (default 1)
  65842. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65843. * * 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)
  65844. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65846. * * 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
  65847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65848. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65849. * @param name defines the name of the mesh
  65850. * @param options defines the options used to create the mesh
  65851. * @param scene defines the hosting scene
  65852. * @returns the box mesh
  65853. */
  65854. static CreateBox(name: string, options: {
  65855. size?: number;
  65856. width?: number;
  65857. height?: number;
  65858. depth?: number;
  65859. faceUV?: Vector4[];
  65860. faceColors?: Color4[];
  65861. sideOrientation?: number;
  65862. frontUVs?: Vector4;
  65863. backUVs?: Vector4;
  65864. wrap?: boolean;
  65865. topBaseAt?: number;
  65866. bottomBaseAt?: number;
  65867. updatable?: boolean;
  65868. }, scene?: Nullable<Scene>): Mesh;
  65869. /**
  65870. * Creates a tiled box mesh
  65871. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65873. * @param name defines the name of the mesh
  65874. * @param options defines the options used to create the mesh
  65875. * @param scene defines the hosting scene
  65876. * @returns the tiled box mesh
  65877. */
  65878. static CreateTiledBox(name: string, options: {
  65879. pattern?: number;
  65880. size?: number;
  65881. width?: number;
  65882. height?: number;
  65883. depth: number;
  65884. tileSize?: number;
  65885. tileWidth?: number;
  65886. tileHeight?: number;
  65887. faceUV?: Vector4[];
  65888. faceColors?: Color4[];
  65889. alignHorizontal?: number;
  65890. alignVertical?: number;
  65891. sideOrientation?: number;
  65892. updatable?: boolean;
  65893. }, scene?: Nullable<Scene>): Mesh;
  65894. /**
  65895. * Creates a sphere mesh
  65896. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65897. * * 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`)
  65898. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65899. * * 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
  65900. * * 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)
  65901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65902. * * 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
  65903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65904. * @param name defines the name of the mesh
  65905. * @param options defines the options used to create the mesh
  65906. * @param scene defines the hosting scene
  65907. * @returns the sphere mesh
  65908. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65909. */
  65910. static CreateSphere(name: string, options: {
  65911. segments?: number;
  65912. diameter?: number;
  65913. diameterX?: number;
  65914. diameterY?: number;
  65915. diameterZ?: number;
  65916. arc?: number;
  65917. slice?: number;
  65918. sideOrientation?: number;
  65919. frontUVs?: Vector4;
  65920. backUVs?: Vector4;
  65921. updatable?: boolean;
  65922. }, scene?: Nullable<Scene>): Mesh;
  65923. /**
  65924. * Creates a plane polygonal mesh. By default, this is a disc
  65925. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65926. * * 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
  65927. * * 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
  65928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65929. * * 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
  65930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65931. * @param name defines the name of the mesh
  65932. * @param options defines the options used to create the mesh
  65933. * @param scene defines the hosting scene
  65934. * @returns the plane polygonal mesh
  65935. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65936. */
  65937. static CreateDisc(name: string, options: {
  65938. radius?: number;
  65939. tessellation?: number;
  65940. arc?: number;
  65941. updatable?: boolean;
  65942. sideOrientation?: number;
  65943. frontUVs?: Vector4;
  65944. backUVs?: Vector4;
  65945. }, scene?: Nullable<Scene>): Mesh;
  65946. /**
  65947. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65948. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65949. * * 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`)
  65950. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65951. * * 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
  65952. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65953. * * 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
  65954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65955. * @param name defines the name of the mesh
  65956. * @param options defines the options used to create the mesh
  65957. * @param scene defines the hosting scene
  65958. * @returns the icosahedron mesh
  65959. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65960. */
  65961. static CreateIcoSphere(name: string, options: {
  65962. radius?: number;
  65963. radiusX?: number;
  65964. radiusY?: number;
  65965. radiusZ?: number;
  65966. flat?: boolean;
  65967. subdivisions?: number;
  65968. sideOrientation?: number;
  65969. frontUVs?: Vector4;
  65970. backUVs?: Vector4;
  65971. updatable?: boolean;
  65972. }, scene?: Nullable<Scene>): Mesh;
  65973. /**
  65974. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65975. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65976. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65977. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65978. * * 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
  65979. * * 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
  65980. * * 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
  65981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65982. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65983. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65984. * * 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
  65985. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65986. * * 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
  65987. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65989. * @param name defines the name of the mesh
  65990. * @param options defines the options used to create the mesh
  65991. * @param scene defines the hosting scene
  65992. * @returns the ribbon mesh
  65993. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65994. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65995. */
  65996. static CreateRibbon(name: string, options: {
  65997. pathArray: Vector3[][];
  65998. closeArray?: boolean;
  65999. closePath?: boolean;
  66000. offset?: number;
  66001. updatable?: boolean;
  66002. sideOrientation?: number;
  66003. frontUVs?: Vector4;
  66004. backUVs?: Vector4;
  66005. instance?: Mesh;
  66006. invertUV?: boolean;
  66007. uvs?: Vector2[];
  66008. colors?: Color4[];
  66009. }, scene?: Nullable<Scene>): Mesh;
  66010. /**
  66011. * Creates a cylinder or a cone mesh
  66012. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66013. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66014. * * 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.
  66015. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66016. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66017. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66018. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66019. * * 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).
  66020. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66021. * * 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).
  66022. * * 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
  66023. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66024. * * 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
  66025. * * 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.
  66026. * * If `enclose` is false, a ring surface is one element.
  66027. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66028. * * 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
  66029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66030. * * 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
  66031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66032. * @param name defines the name of the mesh
  66033. * @param options defines the options used to create the mesh
  66034. * @param scene defines the hosting scene
  66035. * @returns the cylinder mesh
  66036. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66037. */
  66038. static CreateCylinder(name: string, options: {
  66039. height?: number;
  66040. diameterTop?: number;
  66041. diameterBottom?: number;
  66042. diameter?: number;
  66043. tessellation?: number;
  66044. subdivisions?: number;
  66045. arc?: number;
  66046. faceColors?: Color4[];
  66047. faceUV?: Vector4[];
  66048. updatable?: boolean;
  66049. hasRings?: boolean;
  66050. enclose?: boolean;
  66051. cap?: number;
  66052. sideOrientation?: number;
  66053. frontUVs?: Vector4;
  66054. backUVs?: Vector4;
  66055. }, scene?: Nullable<Scene>): Mesh;
  66056. /**
  66057. * Creates a torus mesh
  66058. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66059. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66060. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66062. * * 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
  66063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66064. * @param name defines the name of the mesh
  66065. * @param options defines the options used to create the mesh
  66066. * @param scene defines the hosting scene
  66067. * @returns the torus mesh
  66068. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66069. */
  66070. static CreateTorus(name: string, options: {
  66071. diameter?: number;
  66072. thickness?: number;
  66073. tessellation?: number;
  66074. updatable?: boolean;
  66075. sideOrientation?: number;
  66076. frontUVs?: Vector4;
  66077. backUVs?: Vector4;
  66078. }, scene?: Nullable<Scene>): Mesh;
  66079. /**
  66080. * Creates a torus knot mesh
  66081. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66082. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66083. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66084. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66085. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66086. * * 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
  66087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66088. * @param name defines the name of the mesh
  66089. * @param options defines the options used to create the mesh
  66090. * @param scene defines the hosting scene
  66091. * @returns the torus knot mesh
  66092. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66093. */
  66094. static CreateTorusKnot(name: string, options: {
  66095. radius?: number;
  66096. tube?: number;
  66097. radialSegments?: number;
  66098. tubularSegments?: number;
  66099. p?: number;
  66100. q?: number;
  66101. updatable?: boolean;
  66102. sideOrientation?: number;
  66103. frontUVs?: Vector4;
  66104. backUVs?: Vector4;
  66105. }, scene?: Nullable<Scene>): Mesh;
  66106. /**
  66107. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66108. * * 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
  66109. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66110. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66111. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66112. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66113. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66114. * * 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
  66115. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66117. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66118. * @param name defines the name of the new line system
  66119. * @param options defines the options used to create the line system
  66120. * @param scene defines the hosting scene
  66121. * @returns a new line system mesh
  66122. */
  66123. static CreateLineSystem(name: string, options: {
  66124. lines: Vector3[][];
  66125. updatable?: boolean;
  66126. instance?: Nullable<LinesMesh>;
  66127. colors?: Nullable<Color4[][]>;
  66128. useVertexAlpha?: boolean;
  66129. }, scene: Nullable<Scene>): LinesMesh;
  66130. /**
  66131. * Creates a line mesh
  66132. * 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
  66133. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66134. * * The parameter `points` is an array successive Vector3
  66135. * * 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
  66136. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66137. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66138. * * When updating an instance, remember that only point positions can change, not the number of points
  66139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66140. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66141. * @param name defines the name of the new line system
  66142. * @param options defines the options used to create the line system
  66143. * @param scene defines the hosting scene
  66144. * @returns a new line mesh
  66145. */
  66146. static CreateLines(name: string, options: {
  66147. points: Vector3[];
  66148. updatable?: boolean;
  66149. instance?: Nullable<LinesMesh>;
  66150. colors?: Color4[];
  66151. useVertexAlpha?: boolean;
  66152. }, scene?: Nullable<Scene>): LinesMesh;
  66153. /**
  66154. * Creates a dashed line mesh
  66155. * * 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
  66156. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66157. * * The parameter `points` is an array successive Vector3
  66158. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66159. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66160. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66161. * * 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
  66162. * * When updating an instance, remember that only point positions can change, not the number of points
  66163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66164. * @param name defines the name of the mesh
  66165. * @param options defines the options used to create the mesh
  66166. * @param scene defines the hosting scene
  66167. * @returns the dashed line mesh
  66168. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66169. */
  66170. static CreateDashedLines(name: string, options: {
  66171. points: Vector3[];
  66172. dashSize?: number;
  66173. gapSize?: number;
  66174. dashNb?: number;
  66175. updatable?: boolean;
  66176. instance?: LinesMesh;
  66177. }, scene?: Nullable<Scene>): LinesMesh;
  66178. /**
  66179. * 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.
  66180. * * 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.
  66181. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66182. * * 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.
  66183. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66184. * * 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
  66185. * * 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
  66186. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66188. * * 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
  66189. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66191. * @param name defines the name of the mesh
  66192. * @param options defines the options used to create the mesh
  66193. * @param scene defines the hosting scene
  66194. * @returns the extruded shape mesh
  66195. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66196. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66197. */
  66198. static ExtrudeShape(name: string, options: {
  66199. shape: Vector3[];
  66200. path: Vector3[];
  66201. scale?: number;
  66202. rotation?: number;
  66203. cap?: number;
  66204. updatable?: boolean;
  66205. sideOrientation?: number;
  66206. frontUVs?: Vector4;
  66207. backUVs?: Vector4;
  66208. instance?: Mesh;
  66209. invertUV?: boolean;
  66210. }, scene?: Nullable<Scene>): Mesh;
  66211. /**
  66212. * Creates an custom extruded shape mesh.
  66213. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66214. * * 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.
  66215. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66216. * * 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
  66217. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66218. * * 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
  66219. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66220. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66221. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66222. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  66223. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  66224. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66227. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66229. * @param name defines the name of the mesh
  66230. * @param options defines the options used to create the mesh
  66231. * @param scene defines the hosting scene
  66232. * @returns the custom extruded shape mesh
  66233. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66234. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66235. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66236. */
  66237. static ExtrudeShapeCustom(name: string, options: {
  66238. shape: Vector3[];
  66239. path: Vector3[];
  66240. scaleFunction?: any;
  66241. rotationFunction?: any;
  66242. ribbonCloseArray?: boolean;
  66243. ribbonClosePath?: boolean;
  66244. cap?: number;
  66245. updatable?: boolean;
  66246. sideOrientation?: number;
  66247. frontUVs?: Vector4;
  66248. backUVs?: Vector4;
  66249. instance?: Mesh;
  66250. invertUV?: boolean;
  66251. }, scene?: Nullable<Scene>): Mesh;
  66252. /**
  66253. * Creates lathe mesh.
  66254. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66255. * * 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
  66256. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66257. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66258. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66259. * * 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
  66260. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66261. * * 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
  66262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66263. * * 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
  66264. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66266. * @param name defines the name of the mesh
  66267. * @param options defines the options used to create the mesh
  66268. * @param scene defines the hosting scene
  66269. * @returns the lathe mesh
  66270. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66271. */
  66272. static CreateLathe(name: string, options: {
  66273. shape: Vector3[];
  66274. radius?: number;
  66275. tessellation?: number;
  66276. clip?: number;
  66277. arc?: number;
  66278. closed?: boolean;
  66279. updatable?: boolean;
  66280. sideOrientation?: number;
  66281. frontUVs?: Vector4;
  66282. backUVs?: Vector4;
  66283. cap?: number;
  66284. invertUV?: boolean;
  66285. }, scene?: Nullable<Scene>): Mesh;
  66286. /**
  66287. * Creates a tiled plane mesh
  66288. * * You can set a limited pattern arrangement with the tiles
  66289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66290. * * 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
  66291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66292. * @param name defines the name of the mesh
  66293. * @param options defines the options used to create the mesh
  66294. * @param scene defines the hosting scene
  66295. * @returns the plane mesh
  66296. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66297. */
  66298. static CreateTiledPlane(name: string, options: {
  66299. pattern?: number;
  66300. tileSize?: number;
  66301. tileWidth?: number;
  66302. tileHeight?: number;
  66303. size?: number;
  66304. width?: number;
  66305. height?: number;
  66306. alignHorizontal?: number;
  66307. alignVertical?: number;
  66308. sideOrientation?: number;
  66309. frontUVs?: Vector4;
  66310. backUVs?: Vector4;
  66311. updatable?: boolean;
  66312. }, scene?: Nullable<Scene>): Mesh;
  66313. /**
  66314. * Creates a plane mesh
  66315. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66316. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66317. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66319. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66321. * @param name defines the name of the mesh
  66322. * @param options defines the options used to create the mesh
  66323. * @param scene defines the hosting scene
  66324. * @returns the plane mesh
  66325. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66326. */
  66327. static CreatePlane(name: string, options: {
  66328. size?: number;
  66329. width?: number;
  66330. height?: number;
  66331. sideOrientation?: number;
  66332. frontUVs?: Vector4;
  66333. backUVs?: Vector4;
  66334. updatable?: boolean;
  66335. sourcePlane?: Plane;
  66336. }, scene?: Nullable<Scene>): Mesh;
  66337. /**
  66338. * Creates a ground mesh
  66339. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66340. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66342. * @param name defines the name of the mesh
  66343. * @param options defines the options used to create the mesh
  66344. * @param scene defines the hosting scene
  66345. * @returns the ground mesh
  66346. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66347. */
  66348. static CreateGround(name: string, options: {
  66349. width?: number;
  66350. height?: number;
  66351. subdivisions?: number;
  66352. subdivisionsX?: number;
  66353. subdivisionsY?: number;
  66354. updatable?: boolean;
  66355. }, scene?: Nullable<Scene>): Mesh;
  66356. /**
  66357. * Creates a tiled ground mesh
  66358. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66359. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66360. * * 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
  66361. * * 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
  66362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66363. * @param name defines the name of the mesh
  66364. * @param options defines the options used to create the mesh
  66365. * @param scene defines the hosting scene
  66366. * @returns the tiled ground mesh
  66367. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66368. */
  66369. static CreateTiledGround(name: string, options: {
  66370. xmin: number;
  66371. zmin: number;
  66372. xmax: number;
  66373. zmax: number;
  66374. subdivisions?: {
  66375. w: number;
  66376. h: number;
  66377. };
  66378. precision?: {
  66379. w: number;
  66380. h: number;
  66381. };
  66382. updatable?: boolean;
  66383. }, scene?: Nullable<Scene>): Mesh;
  66384. /**
  66385. * Creates a ground mesh from a height map
  66386. * * The parameter `url` sets the URL of the height map image resource.
  66387. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66388. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66389. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66390. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66391. * * 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.
  66392. * * 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).
  66393. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66395. * @param name defines the name of the mesh
  66396. * @param url defines the url to the height map
  66397. * @param options defines the options used to create the mesh
  66398. * @param scene defines the hosting scene
  66399. * @returns the ground mesh
  66400. * @see https://doc.babylonjs.com/babylon101/height_map
  66401. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66402. */
  66403. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66404. width?: number;
  66405. height?: number;
  66406. subdivisions?: number;
  66407. minHeight?: number;
  66408. maxHeight?: number;
  66409. colorFilter?: Color3;
  66410. alphaFilter?: number;
  66411. updatable?: boolean;
  66412. onReady?: (mesh: GroundMesh) => void;
  66413. }, scene?: Nullable<Scene>): GroundMesh;
  66414. /**
  66415. * Creates a polygon mesh
  66416. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66417. * * 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
  66418. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66420. * * 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)
  66421. * * Remember you can only change the shape positions, not their number when updating a polygon
  66422. * @param name defines the name of the mesh
  66423. * @param options defines the options used to create the mesh
  66424. * @param scene defines the hosting scene
  66425. * @param earcutInjection can be used to inject your own earcut reference
  66426. * @returns the polygon mesh
  66427. */
  66428. static CreatePolygon(name: string, options: {
  66429. shape: Vector3[];
  66430. holes?: Vector3[][];
  66431. depth?: number;
  66432. faceUV?: Vector4[];
  66433. faceColors?: Color4[];
  66434. updatable?: boolean;
  66435. sideOrientation?: number;
  66436. frontUVs?: Vector4;
  66437. backUVs?: Vector4;
  66438. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66439. /**
  66440. * Creates an extruded polygon mesh, with depth in the Y direction.
  66441. * * 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)
  66442. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66443. * @param name defines the name of the mesh
  66444. * @param options defines the options used to create the mesh
  66445. * @param scene defines the hosting scene
  66446. * @param earcutInjection can be used to inject your own earcut reference
  66447. * @returns the polygon mesh
  66448. */
  66449. static ExtrudePolygon(name: string, options: {
  66450. shape: Vector3[];
  66451. holes?: Vector3[][];
  66452. depth?: number;
  66453. faceUV?: Vector4[];
  66454. faceColors?: Color4[];
  66455. updatable?: boolean;
  66456. sideOrientation?: number;
  66457. frontUVs?: Vector4;
  66458. backUVs?: Vector4;
  66459. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66460. /**
  66461. * Creates a tube mesh.
  66462. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66463. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66464. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66465. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66466. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66467. * * 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)
  66468. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66469. * * 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
  66470. * * 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
  66471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66472. * * 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
  66473. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66475. * @param name defines the name of the mesh
  66476. * @param options defines the options used to create the mesh
  66477. * @param scene defines the hosting scene
  66478. * @returns the tube mesh
  66479. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66480. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66481. */
  66482. static CreateTube(name: string, options: {
  66483. path: Vector3[];
  66484. radius?: number;
  66485. tessellation?: number;
  66486. radiusFunction?: {
  66487. (i: number, distance: number): number;
  66488. };
  66489. cap?: number;
  66490. arc?: number;
  66491. updatable?: boolean;
  66492. sideOrientation?: number;
  66493. frontUVs?: Vector4;
  66494. backUVs?: Vector4;
  66495. instance?: Mesh;
  66496. invertUV?: boolean;
  66497. }, scene?: Nullable<Scene>): Mesh;
  66498. /**
  66499. * Creates a polyhedron mesh
  66500. * * 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
  66501. * * The parameter `size` (positive float, default 1) sets the polygon size
  66502. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66503. * * 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`
  66504. * * 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
  66505. * * 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)`)
  66506. * * 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
  66507. * * 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
  66508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66509. * * 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
  66510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66511. * @param name defines the name of the mesh
  66512. * @param options defines the options used to create the mesh
  66513. * @param scene defines the hosting scene
  66514. * @returns the polyhedron mesh
  66515. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66516. */
  66517. static CreatePolyhedron(name: string, options: {
  66518. type?: number;
  66519. size?: number;
  66520. sizeX?: number;
  66521. sizeY?: number;
  66522. sizeZ?: number;
  66523. custom?: any;
  66524. faceUV?: Vector4[];
  66525. faceColors?: Color4[];
  66526. flat?: boolean;
  66527. updatable?: boolean;
  66528. sideOrientation?: number;
  66529. frontUVs?: Vector4;
  66530. backUVs?: Vector4;
  66531. }, scene?: Nullable<Scene>): Mesh;
  66532. /**
  66533. * Creates a decal mesh.
  66534. * 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
  66535. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66536. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66537. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66538. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66539. * @param name defines the name of the mesh
  66540. * @param sourceMesh defines the mesh where the decal must be applied
  66541. * @param options defines the options used to create the mesh
  66542. * @param scene defines the hosting scene
  66543. * @returns the decal mesh
  66544. * @see https://doc.babylonjs.com/how_to/decals
  66545. */
  66546. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66547. position?: Vector3;
  66548. normal?: Vector3;
  66549. size?: Vector3;
  66550. angle?: number;
  66551. }): Mesh;
  66552. /**
  66553. * Creates a Capsule Mesh
  66554. * @param name defines the name of the mesh.
  66555. * @param options the constructors options used to shape the mesh.
  66556. * @param scene defines the scene the mesh is scoped to.
  66557. * @returns the capsule mesh
  66558. * @see https://doc.babylonjs.com/how_to/capsule_shape
  66559. */
  66560. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  66561. }
  66562. }
  66563. declare module BABYLON {
  66564. /**
  66565. * A simplifier interface for future simplification implementations
  66566. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66567. */
  66568. export interface ISimplifier {
  66569. /**
  66570. * Simplification of a given mesh according to the given settings.
  66571. * Since this requires computation, it is assumed that the function runs async.
  66572. * @param settings The settings of the simplification, including quality and distance
  66573. * @param successCallback A callback that will be called after the mesh was simplified.
  66574. * @param errorCallback in case of an error, this callback will be called. optional.
  66575. */
  66576. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66577. }
  66578. /**
  66579. * Expected simplification settings.
  66580. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66581. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66582. */
  66583. export interface ISimplificationSettings {
  66584. /**
  66585. * Gets or sets the expected quality
  66586. */
  66587. quality: number;
  66588. /**
  66589. * Gets or sets the distance when this optimized version should be used
  66590. */
  66591. distance: number;
  66592. /**
  66593. * Gets an already optimized mesh
  66594. */
  66595. optimizeMesh?: boolean;
  66596. }
  66597. /**
  66598. * Class used to specify simplification options
  66599. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66600. */
  66601. export class SimplificationSettings implements ISimplificationSettings {
  66602. /** expected quality */
  66603. quality: number;
  66604. /** distance when this optimized version should be used */
  66605. distance: number;
  66606. /** already optimized mesh */
  66607. optimizeMesh?: boolean | undefined;
  66608. /**
  66609. * Creates a SimplificationSettings
  66610. * @param quality expected quality
  66611. * @param distance distance when this optimized version should be used
  66612. * @param optimizeMesh already optimized mesh
  66613. */
  66614. constructor(
  66615. /** expected quality */
  66616. quality: number,
  66617. /** distance when this optimized version should be used */
  66618. distance: number,
  66619. /** already optimized mesh */
  66620. optimizeMesh?: boolean | undefined);
  66621. }
  66622. /**
  66623. * Interface used to define a simplification task
  66624. */
  66625. export interface ISimplificationTask {
  66626. /**
  66627. * Array of settings
  66628. */
  66629. settings: Array<ISimplificationSettings>;
  66630. /**
  66631. * Simplification type
  66632. */
  66633. simplificationType: SimplificationType;
  66634. /**
  66635. * Mesh to simplify
  66636. */
  66637. mesh: Mesh;
  66638. /**
  66639. * Callback called on success
  66640. */
  66641. successCallback?: () => void;
  66642. /**
  66643. * Defines if parallel processing can be used
  66644. */
  66645. parallelProcessing: boolean;
  66646. }
  66647. /**
  66648. * Queue used to order the simplification tasks
  66649. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66650. */
  66651. export class SimplificationQueue {
  66652. private _simplificationArray;
  66653. /**
  66654. * Gets a boolean indicating that the process is still running
  66655. */
  66656. running: boolean;
  66657. /**
  66658. * Creates a new queue
  66659. */
  66660. constructor();
  66661. /**
  66662. * Adds a new simplification task
  66663. * @param task defines a task to add
  66664. */
  66665. addTask(task: ISimplificationTask): void;
  66666. /**
  66667. * Execute next task
  66668. */
  66669. executeNext(): void;
  66670. /**
  66671. * Execute a simplification task
  66672. * @param task defines the task to run
  66673. */
  66674. runSimplification(task: ISimplificationTask): void;
  66675. private getSimplifier;
  66676. }
  66677. /**
  66678. * The implemented types of simplification
  66679. * At the moment only Quadratic Error Decimation is implemented
  66680. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66681. */
  66682. export enum SimplificationType {
  66683. /** Quadratic error decimation */
  66684. QUADRATIC = 0
  66685. }
  66686. /**
  66687. * An implementation of the Quadratic Error simplification algorithm.
  66688. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66689. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66690. * @author RaananW
  66691. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66692. */
  66693. export class QuadraticErrorSimplification implements ISimplifier {
  66694. private _mesh;
  66695. private triangles;
  66696. private vertices;
  66697. private references;
  66698. private _reconstructedMesh;
  66699. /** Gets or sets the number pf sync interations */
  66700. syncIterations: number;
  66701. /** Gets or sets the aggressiveness of the simplifier */
  66702. aggressiveness: number;
  66703. /** Gets or sets the number of allowed iterations for decimation */
  66704. decimationIterations: number;
  66705. /** Gets or sets the espilon to use for bounding box computation */
  66706. boundingBoxEpsilon: number;
  66707. /**
  66708. * Creates a new QuadraticErrorSimplification
  66709. * @param _mesh defines the target mesh
  66710. */
  66711. constructor(_mesh: Mesh);
  66712. /**
  66713. * Simplification of a given mesh according to the given settings.
  66714. * Since this requires computation, it is assumed that the function runs async.
  66715. * @param settings The settings of the simplification, including quality and distance
  66716. * @param successCallback A callback that will be called after the mesh was simplified.
  66717. */
  66718. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66719. private runDecimation;
  66720. private initWithMesh;
  66721. private init;
  66722. private reconstructMesh;
  66723. private initDecimatedMesh;
  66724. private isFlipped;
  66725. private updateTriangles;
  66726. private identifyBorder;
  66727. private updateMesh;
  66728. private vertexError;
  66729. private calculateError;
  66730. }
  66731. }
  66732. declare module BABYLON {
  66733. interface Scene {
  66734. /** @hidden (Backing field) */
  66735. _simplificationQueue: SimplificationQueue;
  66736. /**
  66737. * Gets or sets the simplification queue attached to the scene
  66738. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66739. */
  66740. simplificationQueue: SimplificationQueue;
  66741. }
  66742. interface Mesh {
  66743. /**
  66744. * Simplify the mesh according to the given array of settings.
  66745. * Function will return immediately and will simplify async
  66746. * @param settings a collection of simplification settings
  66747. * @param parallelProcessing should all levels calculate parallel or one after the other
  66748. * @param simplificationType the type of simplification to run
  66749. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66750. * @returns the current mesh
  66751. */
  66752. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66753. }
  66754. /**
  66755. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66756. * created in a scene
  66757. */
  66758. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66759. /**
  66760. * The component name helpfull to identify the component in the list of scene components.
  66761. */
  66762. readonly name: string;
  66763. /**
  66764. * The scene the component belongs to.
  66765. */
  66766. scene: Scene;
  66767. /**
  66768. * Creates a new instance of the component for the given scene
  66769. * @param scene Defines the scene to register the component in
  66770. */
  66771. constructor(scene: Scene);
  66772. /**
  66773. * Registers the component in a given scene
  66774. */
  66775. register(): void;
  66776. /**
  66777. * Rebuilds the elements related to this component in case of
  66778. * context lost for instance.
  66779. */
  66780. rebuild(): void;
  66781. /**
  66782. * Disposes the component and the associated ressources
  66783. */
  66784. dispose(): void;
  66785. private _beforeCameraUpdate;
  66786. }
  66787. }
  66788. declare module BABYLON {
  66789. interface Mesh {
  66790. /**
  66791. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66792. */
  66793. thinInstanceEnablePicking: boolean;
  66794. /**
  66795. * Creates a new thin instance
  66796. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66797. * @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
  66798. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66799. */
  66800. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66801. /**
  66802. * Adds the transformation (matrix) of the current mesh as a thin instance
  66803. * @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
  66804. * @returns the thin instance index number
  66805. */
  66806. thinInstanceAddSelf(refresh: boolean): number;
  66807. /**
  66808. * Registers a custom attribute to be used with thin instances
  66809. * @param kind name of the attribute
  66810. * @param stride size in floats of the attribute
  66811. */
  66812. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66813. /**
  66814. * Sets the matrix of a thin instance
  66815. * @param index index of the thin instance
  66816. * @param matrix matrix to set
  66817. * @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
  66818. */
  66819. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66820. /**
  66821. * Sets the value of a custom attribute for a thin instance
  66822. * @param kind name of the attribute
  66823. * @param index index of the thin instance
  66824. * @param value value to set
  66825. * @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
  66826. */
  66827. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66828. /**
  66829. * 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.
  66830. */
  66831. thinInstanceCount: number;
  66832. /**
  66833. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66834. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66835. * @param buffer buffer to set
  66836. * @param stride size in floats of each value of the buffer
  66837. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66838. */
  66839. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66840. /**
  66841. * Gets the list of world matrices
  66842. * @return an array containing all the world matrices from the thin instances
  66843. */
  66844. thinInstanceGetWorldMatrices(): Matrix[];
  66845. /**
  66846. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66847. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66848. */
  66849. thinInstanceBufferUpdated(kind: string): void;
  66850. /**
  66851. * Applies a partial update to a buffer directly on the GPU
  66852. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  66853. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66854. * @param data the data to set in the GPU buffer
  66855. * @param offset the offset in the GPU buffer where to update the data
  66856. */
  66857. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  66858. /**
  66859. * Refreshes the bounding info, taking into account all the thin instances defined
  66860. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66861. */
  66862. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66863. /** @hidden */
  66864. _thinInstanceInitializeUserStorage(): void;
  66865. /** @hidden */
  66866. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66867. /** @hidden */
  66868. _userThinInstanceBuffersStorage: {
  66869. data: {
  66870. [key: string]: Float32Array;
  66871. };
  66872. sizes: {
  66873. [key: string]: number;
  66874. };
  66875. vertexBuffers: {
  66876. [key: string]: Nullable<VertexBuffer>;
  66877. };
  66878. strides: {
  66879. [key: string]: number;
  66880. };
  66881. };
  66882. }
  66883. }
  66884. declare module BABYLON {
  66885. /**
  66886. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66887. */
  66888. export interface INavigationEnginePlugin {
  66889. /**
  66890. * plugin name
  66891. */
  66892. name: string;
  66893. /**
  66894. * Creates a navigation mesh
  66895. * @param meshes array of all the geometry used to compute the navigatio mesh
  66896. * @param parameters bunch of parameters used to filter geometry
  66897. */
  66898. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66899. /**
  66900. * Create a navigation mesh debug mesh
  66901. * @param scene is where the mesh will be added
  66902. * @returns debug display mesh
  66903. */
  66904. createDebugNavMesh(scene: Scene): Mesh;
  66905. /**
  66906. * Get a navigation mesh constrained position, closest to the parameter position
  66907. * @param position world position
  66908. * @returns the closest point to position constrained by the navigation mesh
  66909. */
  66910. getClosestPoint(position: Vector3): Vector3;
  66911. /**
  66912. * Get a navigation mesh constrained position, closest to the parameter position
  66913. * @param position world position
  66914. * @param result output the closest point to position constrained by the navigation mesh
  66915. */
  66916. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66917. /**
  66918. * Get a navigation mesh constrained position, within a particular radius
  66919. * @param position world position
  66920. * @param maxRadius the maximum distance to the constrained world position
  66921. * @returns the closest point to position constrained by the navigation mesh
  66922. */
  66923. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66924. /**
  66925. * Get a navigation mesh constrained position, within a particular radius
  66926. * @param position world position
  66927. * @param maxRadius the maximum distance to the constrained world position
  66928. * @param result output the closest point to position constrained by the navigation mesh
  66929. */
  66930. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66931. /**
  66932. * Compute the final position from a segment made of destination-position
  66933. * @param position world position
  66934. * @param destination world position
  66935. * @returns the resulting point along the navmesh
  66936. */
  66937. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66938. /**
  66939. * Compute the final position from a segment made of destination-position
  66940. * @param position world position
  66941. * @param destination world position
  66942. * @param result output the resulting point along the navmesh
  66943. */
  66944. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66945. /**
  66946. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66947. * @param start world position
  66948. * @param end world position
  66949. * @returns array containing world position composing the path
  66950. */
  66951. computePath(start: Vector3, end: Vector3): Vector3[];
  66952. /**
  66953. * If this plugin is supported
  66954. * @returns true if plugin is supported
  66955. */
  66956. isSupported(): boolean;
  66957. /**
  66958. * Create a new Crowd so you can add agents
  66959. * @param maxAgents the maximum agent count in the crowd
  66960. * @param maxAgentRadius the maximum radius an agent can have
  66961. * @param scene to attach the crowd to
  66962. * @returns the crowd you can add agents to
  66963. */
  66964. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66965. /**
  66966. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66967. * The queries will try to find a solution within those bounds
  66968. * default is (1,1,1)
  66969. * @param extent x,y,z value that define the extent around the queries point of reference
  66970. */
  66971. setDefaultQueryExtent(extent: Vector3): void;
  66972. /**
  66973. * Get the Bounding box extent specified by setDefaultQueryExtent
  66974. * @returns the box extent values
  66975. */
  66976. getDefaultQueryExtent(): Vector3;
  66977. /**
  66978. * build the navmesh from a previously saved state using getNavmeshData
  66979. * @param data the Uint8Array returned by getNavmeshData
  66980. */
  66981. buildFromNavmeshData(data: Uint8Array): void;
  66982. /**
  66983. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66984. * @returns data the Uint8Array that can be saved and reused
  66985. */
  66986. getNavmeshData(): Uint8Array;
  66987. /**
  66988. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66989. * @param result output the box extent values
  66990. */
  66991. getDefaultQueryExtentToRef(result: Vector3): void;
  66992. /**
  66993. * Release all resources
  66994. */
  66995. dispose(): void;
  66996. }
  66997. /**
  66998. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66999. */
  67000. export interface ICrowd {
  67001. /**
  67002. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67003. * You can attach anything to that node. The node position is updated in the scene update tick.
  67004. * @param pos world position that will be constrained by the navigation mesh
  67005. * @param parameters agent parameters
  67006. * @param transform hooked to the agent that will be update by the scene
  67007. * @returns agent index
  67008. */
  67009. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67010. /**
  67011. * Returns the agent position in world space
  67012. * @param index agent index returned by addAgent
  67013. * @returns world space position
  67014. */
  67015. getAgentPosition(index: number): Vector3;
  67016. /**
  67017. * Gets the agent position result in world space
  67018. * @param index agent index returned by addAgent
  67019. * @param result output world space position
  67020. */
  67021. getAgentPositionToRef(index: number, result: Vector3): void;
  67022. /**
  67023. * Gets the agent velocity in world space
  67024. * @param index agent index returned by addAgent
  67025. * @returns world space velocity
  67026. */
  67027. getAgentVelocity(index: number): Vector3;
  67028. /**
  67029. * Gets the agent velocity result in world space
  67030. * @param index agent index returned by addAgent
  67031. * @param result output world space velocity
  67032. */
  67033. getAgentVelocityToRef(index: number, result: Vector3): void;
  67034. /**
  67035. * remove a particular agent previously created
  67036. * @param index agent index returned by addAgent
  67037. */
  67038. removeAgent(index: number): void;
  67039. /**
  67040. * get the list of all agents attached to this crowd
  67041. * @returns list of agent indices
  67042. */
  67043. getAgents(): number[];
  67044. /**
  67045. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67046. * @param deltaTime in seconds
  67047. */
  67048. update(deltaTime: number): void;
  67049. /**
  67050. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67051. * @param index agent index returned by addAgent
  67052. * @param destination targeted world position
  67053. */
  67054. agentGoto(index: number, destination: Vector3): void;
  67055. /**
  67056. * Teleport the agent to a new position
  67057. * @param index agent index returned by addAgent
  67058. * @param destination targeted world position
  67059. */
  67060. agentTeleport(index: number, destination: Vector3): void;
  67061. /**
  67062. * Update agent parameters
  67063. * @param index agent index returned by addAgent
  67064. * @param parameters agent parameters
  67065. */
  67066. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67067. /**
  67068. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67069. * The queries will try to find a solution within those bounds
  67070. * default is (1,1,1)
  67071. * @param extent x,y,z value that define the extent around the queries point of reference
  67072. */
  67073. setDefaultQueryExtent(extent: Vector3): void;
  67074. /**
  67075. * Get the Bounding box extent specified by setDefaultQueryExtent
  67076. * @returns the box extent values
  67077. */
  67078. getDefaultQueryExtent(): Vector3;
  67079. /**
  67080. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67081. * @param result output the box extent values
  67082. */
  67083. getDefaultQueryExtentToRef(result: Vector3): void;
  67084. /**
  67085. * Release all resources
  67086. */
  67087. dispose(): void;
  67088. }
  67089. /**
  67090. * Configures an agent
  67091. */
  67092. export interface IAgentParameters {
  67093. /**
  67094. * Agent radius. [Limit: >= 0]
  67095. */
  67096. radius: number;
  67097. /**
  67098. * Agent height. [Limit: > 0]
  67099. */
  67100. height: number;
  67101. /**
  67102. * Maximum allowed acceleration. [Limit: >= 0]
  67103. */
  67104. maxAcceleration: number;
  67105. /**
  67106. * Maximum allowed speed. [Limit: >= 0]
  67107. */
  67108. maxSpeed: number;
  67109. /**
  67110. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67111. */
  67112. collisionQueryRange: number;
  67113. /**
  67114. * The path visibility optimization range. [Limit: > 0]
  67115. */
  67116. pathOptimizationRange: number;
  67117. /**
  67118. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67119. */
  67120. separationWeight: number;
  67121. }
  67122. /**
  67123. * Configures the navigation mesh creation
  67124. */
  67125. export interface INavMeshParameters {
  67126. /**
  67127. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67128. */
  67129. cs: number;
  67130. /**
  67131. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67132. */
  67133. ch: number;
  67134. /**
  67135. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67136. */
  67137. walkableSlopeAngle: number;
  67138. /**
  67139. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67140. * be considered walkable. [Limit: >= 3] [Units: vx]
  67141. */
  67142. walkableHeight: number;
  67143. /**
  67144. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67145. */
  67146. walkableClimb: number;
  67147. /**
  67148. * The distance to erode/shrink the walkable area of the heightfield away from
  67149. * obstructions. [Limit: >=0] [Units: vx]
  67150. */
  67151. walkableRadius: number;
  67152. /**
  67153. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67154. */
  67155. maxEdgeLen: number;
  67156. /**
  67157. * The maximum distance a simplfied contour's border edges should deviate
  67158. * the original raw contour. [Limit: >=0] [Units: vx]
  67159. */
  67160. maxSimplificationError: number;
  67161. /**
  67162. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67163. */
  67164. minRegionArea: number;
  67165. /**
  67166. * Any regions with a span count smaller than this value will, if possible,
  67167. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67168. */
  67169. mergeRegionArea: number;
  67170. /**
  67171. * The maximum number of vertices allowed for polygons generated during the
  67172. * contour to polygon conversion process. [Limit: >= 3]
  67173. */
  67174. maxVertsPerPoly: number;
  67175. /**
  67176. * Sets the sampling distance to use when generating the detail mesh.
  67177. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67178. */
  67179. detailSampleDist: number;
  67180. /**
  67181. * The maximum distance the detail mesh surface should deviate from heightfield
  67182. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67183. */
  67184. detailSampleMaxError: number;
  67185. }
  67186. }
  67187. declare module BABYLON {
  67188. /**
  67189. * RecastJS navigation plugin
  67190. */
  67191. export class RecastJSPlugin implements INavigationEnginePlugin {
  67192. /**
  67193. * Reference to the Recast library
  67194. */
  67195. bjsRECAST: any;
  67196. /**
  67197. * plugin name
  67198. */
  67199. name: string;
  67200. /**
  67201. * the first navmesh created. We might extend this to support multiple navmeshes
  67202. */
  67203. navMesh: any;
  67204. /**
  67205. * Initializes the recastJS plugin
  67206. * @param recastInjection can be used to inject your own recast reference
  67207. */
  67208. constructor(recastInjection?: any);
  67209. /**
  67210. * Creates a navigation mesh
  67211. * @param meshes array of all the geometry used to compute the navigatio mesh
  67212. * @param parameters bunch of parameters used to filter geometry
  67213. */
  67214. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67215. /**
  67216. * Create a navigation mesh debug mesh
  67217. * @param scene is where the mesh will be added
  67218. * @returns debug display mesh
  67219. */
  67220. createDebugNavMesh(scene: Scene): Mesh;
  67221. /**
  67222. * Get a navigation mesh constrained position, closest to the parameter position
  67223. * @param position world position
  67224. * @returns the closest point to position constrained by the navigation mesh
  67225. */
  67226. getClosestPoint(position: Vector3): Vector3;
  67227. /**
  67228. * Get a navigation mesh constrained position, closest to the parameter position
  67229. * @param position world position
  67230. * @param result output the closest point to position constrained by the navigation mesh
  67231. */
  67232. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67233. /**
  67234. * Get a navigation mesh constrained position, within a particular radius
  67235. * @param position world position
  67236. * @param maxRadius the maximum distance to the constrained world position
  67237. * @returns the closest point to position constrained by the navigation mesh
  67238. */
  67239. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67240. /**
  67241. * Get a navigation mesh constrained position, within a particular radius
  67242. * @param position world position
  67243. * @param maxRadius the maximum distance to the constrained world position
  67244. * @param result output the closest point to position constrained by the navigation mesh
  67245. */
  67246. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67247. /**
  67248. * Compute the final position from a segment made of destination-position
  67249. * @param position world position
  67250. * @param destination world position
  67251. * @returns the resulting point along the navmesh
  67252. */
  67253. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67254. /**
  67255. * Compute the final position from a segment made of destination-position
  67256. * @param position world position
  67257. * @param destination world position
  67258. * @param result output the resulting point along the navmesh
  67259. */
  67260. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67261. /**
  67262. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67263. * @param start world position
  67264. * @param end world position
  67265. * @returns array containing world position composing the path
  67266. */
  67267. computePath(start: Vector3, end: Vector3): Vector3[];
  67268. /**
  67269. * Create a new Crowd so you can add agents
  67270. * @param maxAgents the maximum agent count in the crowd
  67271. * @param maxAgentRadius the maximum radius an agent can have
  67272. * @param scene to attach the crowd to
  67273. * @returns the crowd you can add agents to
  67274. */
  67275. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67276. /**
  67277. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67278. * The queries will try to find a solution within those bounds
  67279. * default is (1,1,1)
  67280. * @param extent x,y,z value that define the extent around the queries point of reference
  67281. */
  67282. setDefaultQueryExtent(extent: Vector3): void;
  67283. /**
  67284. * Get the Bounding box extent specified by setDefaultQueryExtent
  67285. * @returns the box extent values
  67286. */
  67287. getDefaultQueryExtent(): Vector3;
  67288. /**
  67289. * build the navmesh from a previously saved state using getNavmeshData
  67290. * @param data the Uint8Array returned by getNavmeshData
  67291. */
  67292. buildFromNavmeshData(data: Uint8Array): void;
  67293. /**
  67294. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67295. * @returns data the Uint8Array that can be saved and reused
  67296. */
  67297. getNavmeshData(): Uint8Array;
  67298. /**
  67299. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67300. * @param result output the box extent values
  67301. */
  67302. getDefaultQueryExtentToRef(result: Vector3): void;
  67303. /**
  67304. * Disposes
  67305. */
  67306. dispose(): void;
  67307. /**
  67308. * If this plugin is supported
  67309. * @returns true if plugin is supported
  67310. */
  67311. isSupported(): boolean;
  67312. }
  67313. /**
  67314. * Recast detour crowd implementation
  67315. */
  67316. export class RecastJSCrowd implements ICrowd {
  67317. /**
  67318. * Recast/detour plugin
  67319. */
  67320. bjsRECASTPlugin: RecastJSPlugin;
  67321. /**
  67322. * Link to the detour crowd
  67323. */
  67324. recastCrowd: any;
  67325. /**
  67326. * One transform per agent
  67327. */
  67328. transforms: TransformNode[];
  67329. /**
  67330. * All agents created
  67331. */
  67332. agents: number[];
  67333. /**
  67334. * Link to the scene is kept to unregister the crowd from the scene
  67335. */
  67336. private _scene;
  67337. /**
  67338. * Observer for crowd updates
  67339. */
  67340. private _onBeforeAnimationsObserver;
  67341. /**
  67342. * Constructor
  67343. * @param plugin recastJS plugin
  67344. * @param maxAgents the maximum agent count in the crowd
  67345. * @param maxAgentRadius the maximum radius an agent can have
  67346. * @param scene to attach the crowd to
  67347. * @returns the crowd you can add agents to
  67348. */
  67349. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67350. /**
  67351. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67352. * You can attach anything to that node. The node position is updated in the scene update tick.
  67353. * @param pos world position that will be constrained by the navigation mesh
  67354. * @param parameters agent parameters
  67355. * @param transform hooked to the agent that will be update by the scene
  67356. * @returns agent index
  67357. */
  67358. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67359. /**
  67360. * Returns the agent position in world space
  67361. * @param index agent index returned by addAgent
  67362. * @returns world space position
  67363. */
  67364. getAgentPosition(index: number): Vector3;
  67365. /**
  67366. * Returns the agent position result in world space
  67367. * @param index agent index returned by addAgent
  67368. * @param result output world space position
  67369. */
  67370. getAgentPositionToRef(index: number, result: Vector3): void;
  67371. /**
  67372. * Returns the agent velocity in world space
  67373. * @param index agent index returned by addAgent
  67374. * @returns world space velocity
  67375. */
  67376. getAgentVelocity(index: number): Vector3;
  67377. /**
  67378. * Returns the agent velocity result in world space
  67379. * @param index agent index returned by addAgent
  67380. * @param result output world space velocity
  67381. */
  67382. getAgentVelocityToRef(index: number, result: Vector3): void;
  67383. /**
  67384. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67385. * @param index agent index returned by addAgent
  67386. * @param destination targeted world position
  67387. */
  67388. agentGoto(index: number, destination: Vector3): void;
  67389. /**
  67390. * Teleport the agent to a new position
  67391. * @param index agent index returned by addAgent
  67392. * @param destination targeted world position
  67393. */
  67394. agentTeleport(index: number, destination: Vector3): void;
  67395. /**
  67396. * Update agent parameters
  67397. * @param index agent index returned by addAgent
  67398. * @param parameters agent parameters
  67399. */
  67400. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67401. /**
  67402. * remove a particular agent previously created
  67403. * @param index agent index returned by addAgent
  67404. */
  67405. removeAgent(index: number): void;
  67406. /**
  67407. * get the list of all agents attached to this crowd
  67408. * @returns list of agent indices
  67409. */
  67410. getAgents(): number[];
  67411. /**
  67412. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67413. * @param deltaTime in seconds
  67414. */
  67415. update(deltaTime: number): void;
  67416. /**
  67417. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67418. * The queries will try to find a solution within those bounds
  67419. * default is (1,1,1)
  67420. * @param extent x,y,z value that define the extent around the queries point of reference
  67421. */
  67422. setDefaultQueryExtent(extent: Vector3): void;
  67423. /**
  67424. * Get the Bounding box extent specified by setDefaultQueryExtent
  67425. * @returns the box extent values
  67426. */
  67427. getDefaultQueryExtent(): Vector3;
  67428. /**
  67429. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67430. * @param result output the box extent values
  67431. */
  67432. getDefaultQueryExtentToRef(result: Vector3): void;
  67433. /**
  67434. * Release all resources
  67435. */
  67436. dispose(): void;
  67437. }
  67438. }
  67439. declare module BABYLON {
  67440. /**
  67441. * Class used to enable access to IndexedDB
  67442. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67443. */
  67444. export class Database implements IOfflineProvider {
  67445. private _callbackManifestChecked;
  67446. private _currentSceneUrl;
  67447. private _db;
  67448. private _enableSceneOffline;
  67449. private _enableTexturesOffline;
  67450. private _manifestVersionFound;
  67451. private _mustUpdateRessources;
  67452. private _hasReachedQuota;
  67453. private _isSupported;
  67454. private _idbFactory;
  67455. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67456. private static IsUASupportingBlobStorage;
  67457. /**
  67458. * Gets a boolean indicating if Database storate is enabled (off by default)
  67459. */
  67460. static IDBStorageEnabled: boolean;
  67461. /**
  67462. * Gets a boolean indicating if scene must be saved in the database
  67463. */
  67464. get enableSceneOffline(): boolean;
  67465. /**
  67466. * Gets a boolean indicating if textures must be saved in the database
  67467. */
  67468. get enableTexturesOffline(): boolean;
  67469. /**
  67470. * Creates a new Database
  67471. * @param urlToScene defines the url to load the scene
  67472. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67473. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67474. */
  67475. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67476. private static _ParseURL;
  67477. private static _ReturnFullUrlLocation;
  67478. private _checkManifestFile;
  67479. /**
  67480. * Open the database and make it available
  67481. * @param successCallback defines the callback to call on success
  67482. * @param errorCallback defines the callback to call on error
  67483. */
  67484. open(successCallback: () => void, errorCallback: () => void): void;
  67485. /**
  67486. * Loads an image from the database
  67487. * @param url defines the url to load from
  67488. * @param image defines the target DOM image
  67489. */
  67490. loadImage(url: string, image: HTMLImageElement): void;
  67491. private _loadImageFromDBAsync;
  67492. private _saveImageIntoDBAsync;
  67493. private _checkVersionFromDB;
  67494. private _loadVersionFromDBAsync;
  67495. private _saveVersionIntoDBAsync;
  67496. /**
  67497. * Loads a file from database
  67498. * @param url defines the URL to load from
  67499. * @param sceneLoaded defines a callback to call on success
  67500. * @param progressCallBack defines a callback to call when progress changed
  67501. * @param errorCallback defines a callback to call on error
  67502. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67503. */
  67504. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67505. private _loadFileAsync;
  67506. private _saveFileAsync;
  67507. /**
  67508. * Validates if xhr data is correct
  67509. * @param xhr defines the request to validate
  67510. * @param dataType defines the expected data type
  67511. * @returns true if data is correct
  67512. */
  67513. private static _ValidateXHRData;
  67514. }
  67515. }
  67516. declare module BABYLON {
  67517. /** @hidden */
  67518. export var gpuUpdateParticlesPixelShader: {
  67519. name: string;
  67520. shader: string;
  67521. };
  67522. }
  67523. declare module BABYLON {
  67524. /** @hidden */
  67525. export var gpuUpdateParticlesVertexShader: {
  67526. name: string;
  67527. shader: string;
  67528. };
  67529. }
  67530. declare module BABYLON {
  67531. /** @hidden */
  67532. export var clipPlaneFragmentDeclaration2: {
  67533. name: string;
  67534. shader: string;
  67535. };
  67536. }
  67537. declare module BABYLON {
  67538. /** @hidden */
  67539. export var gpuRenderParticlesPixelShader: {
  67540. name: string;
  67541. shader: string;
  67542. };
  67543. }
  67544. declare module BABYLON {
  67545. /** @hidden */
  67546. export var clipPlaneVertexDeclaration2: {
  67547. name: string;
  67548. shader: string;
  67549. };
  67550. }
  67551. declare module BABYLON {
  67552. /** @hidden */
  67553. export var gpuRenderParticlesVertexShader: {
  67554. name: string;
  67555. shader: string;
  67556. };
  67557. }
  67558. declare module BABYLON {
  67559. /**
  67560. * This represents a GPU particle system in Babylon
  67561. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67562. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67563. */
  67564. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67565. /**
  67566. * The layer mask we are rendering the particles through.
  67567. */
  67568. layerMask: number;
  67569. private _capacity;
  67570. private _activeCount;
  67571. private _currentActiveCount;
  67572. private _accumulatedCount;
  67573. private _renderEffect;
  67574. private _updateEffect;
  67575. private _buffer0;
  67576. private _buffer1;
  67577. private _spriteBuffer;
  67578. private _updateVAO;
  67579. private _renderVAO;
  67580. private _targetIndex;
  67581. private _sourceBuffer;
  67582. private _targetBuffer;
  67583. private _currentRenderId;
  67584. private _started;
  67585. private _stopped;
  67586. private _timeDelta;
  67587. private _randomTexture;
  67588. private _randomTexture2;
  67589. private _attributesStrideSize;
  67590. private _updateEffectOptions;
  67591. private _randomTextureSize;
  67592. private _actualFrame;
  67593. private _customEffect;
  67594. private readonly _rawTextureWidth;
  67595. /**
  67596. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67597. */
  67598. static get IsSupported(): boolean;
  67599. /**
  67600. * An event triggered when the system is disposed.
  67601. */
  67602. onDisposeObservable: Observable<IParticleSystem>;
  67603. /**
  67604. * Gets the maximum number of particles active at the same time.
  67605. * @returns The max number of active particles.
  67606. */
  67607. getCapacity(): number;
  67608. /**
  67609. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67610. * to override the particles.
  67611. */
  67612. forceDepthWrite: boolean;
  67613. /**
  67614. * Gets or set the number of active particles
  67615. */
  67616. get activeParticleCount(): number;
  67617. set activeParticleCount(value: number);
  67618. private _preWarmDone;
  67619. /**
  67620. * Specifies if the particles are updated in emitter local space or world space.
  67621. */
  67622. isLocal: boolean;
  67623. /** Gets or sets a matrix to use to compute projection */
  67624. defaultProjectionMatrix: Matrix;
  67625. /**
  67626. * Is this system ready to be used/rendered
  67627. * @return true if the system is ready
  67628. */
  67629. isReady(): boolean;
  67630. /**
  67631. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67632. * @returns True if it has been started, otherwise false.
  67633. */
  67634. isStarted(): boolean;
  67635. /**
  67636. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67637. * @returns True if it has been stopped, otherwise false.
  67638. */
  67639. isStopped(): boolean;
  67640. /**
  67641. * Gets a boolean indicating that the system is stopping
  67642. * @returns true if the system is currently stopping
  67643. */
  67644. isStopping(): boolean;
  67645. /**
  67646. * Gets the number of particles active at the same time.
  67647. * @returns The number of active particles.
  67648. */
  67649. getActiveCount(): number;
  67650. /**
  67651. * Starts the particle system and begins to emit
  67652. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67653. */
  67654. start(delay?: number): void;
  67655. /**
  67656. * Stops the particle system.
  67657. */
  67658. stop(): void;
  67659. /**
  67660. * Remove all active particles
  67661. */
  67662. reset(): void;
  67663. /**
  67664. * Returns the string "GPUParticleSystem"
  67665. * @returns a string containing the class name
  67666. */
  67667. getClassName(): string;
  67668. /**
  67669. * Gets the custom effect used to render the particles
  67670. * @param blendMode Blend mode for which the effect should be retrieved
  67671. * @returns The effect
  67672. */
  67673. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67674. /**
  67675. * Sets the custom effect used to render the particles
  67676. * @param effect The effect to set
  67677. * @param blendMode Blend mode for which the effect should be set
  67678. */
  67679. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67680. /** @hidden */
  67681. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67682. /**
  67683. * Observable that will be called just before the particles are drawn
  67684. */
  67685. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67686. /**
  67687. * Gets the name of the particle vertex shader
  67688. */
  67689. get vertexShaderName(): string;
  67690. private _colorGradientsTexture;
  67691. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67692. /**
  67693. * Adds a new color gradient
  67694. * @param gradient defines the gradient to use (between 0 and 1)
  67695. * @param color1 defines the color to affect to the specified gradient
  67696. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67697. * @returns the current particle system
  67698. */
  67699. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67700. private _refreshColorGradient;
  67701. /** Force the system to rebuild all gradients that need to be resync */
  67702. forceRefreshGradients(): void;
  67703. /**
  67704. * Remove a specific color gradient
  67705. * @param gradient defines the gradient to remove
  67706. * @returns the current particle system
  67707. */
  67708. removeColorGradient(gradient: number): GPUParticleSystem;
  67709. private _angularSpeedGradientsTexture;
  67710. private _sizeGradientsTexture;
  67711. private _velocityGradientsTexture;
  67712. private _limitVelocityGradientsTexture;
  67713. private _dragGradientsTexture;
  67714. private _addFactorGradient;
  67715. /**
  67716. * Adds a new size gradient
  67717. * @param gradient defines the gradient to use (between 0 and 1)
  67718. * @param factor defines the size factor to affect to the specified gradient
  67719. * @returns the current particle system
  67720. */
  67721. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67722. /**
  67723. * Remove a specific size gradient
  67724. * @param gradient defines the gradient to remove
  67725. * @returns the current particle system
  67726. */
  67727. removeSizeGradient(gradient: number): GPUParticleSystem;
  67728. private _refreshFactorGradient;
  67729. /**
  67730. * Adds a new angular speed gradient
  67731. * @param gradient defines the gradient to use (between 0 and 1)
  67732. * @param factor defines the angular speed to affect to the specified gradient
  67733. * @returns the current particle system
  67734. */
  67735. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67736. /**
  67737. * Remove a specific angular speed gradient
  67738. * @param gradient defines the gradient to remove
  67739. * @returns the current particle system
  67740. */
  67741. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67742. /**
  67743. * Adds a new velocity gradient
  67744. * @param gradient defines the gradient to use (between 0 and 1)
  67745. * @param factor defines the velocity to affect to the specified gradient
  67746. * @returns the current particle system
  67747. */
  67748. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67749. /**
  67750. * Remove a specific velocity gradient
  67751. * @param gradient defines the gradient to remove
  67752. * @returns the current particle system
  67753. */
  67754. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67755. /**
  67756. * Adds a new limit velocity gradient
  67757. * @param gradient defines the gradient to use (between 0 and 1)
  67758. * @param factor defines the limit velocity value to affect to the specified gradient
  67759. * @returns the current particle system
  67760. */
  67761. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67762. /**
  67763. * Remove a specific limit velocity gradient
  67764. * @param gradient defines the gradient to remove
  67765. * @returns the current particle system
  67766. */
  67767. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67768. /**
  67769. * Adds a new drag gradient
  67770. * @param gradient defines the gradient to use (between 0 and 1)
  67771. * @param factor defines the drag value to affect to the specified gradient
  67772. * @returns the current particle system
  67773. */
  67774. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67775. /**
  67776. * Remove a specific drag gradient
  67777. * @param gradient defines the gradient to remove
  67778. * @returns the current particle system
  67779. */
  67780. removeDragGradient(gradient: number): GPUParticleSystem;
  67781. /**
  67782. * Not supported by GPUParticleSystem
  67783. * @param gradient defines the gradient to use (between 0 and 1)
  67784. * @param factor defines the emit rate value to affect to the specified gradient
  67785. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67786. * @returns the current particle system
  67787. */
  67788. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67789. /**
  67790. * Not supported by GPUParticleSystem
  67791. * @param gradient defines the gradient to remove
  67792. * @returns the current particle system
  67793. */
  67794. removeEmitRateGradient(gradient: number): IParticleSystem;
  67795. /**
  67796. * Not supported by GPUParticleSystem
  67797. * @param gradient defines the gradient to use (between 0 and 1)
  67798. * @param factor defines the start size value to affect to the specified gradient
  67799. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67800. * @returns the current particle system
  67801. */
  67802. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67803. /**
  67804. * Not supported by GPUParticleSystem
  67805. * @param gradient defines the gradient to remove
  67806. * @returns the current particle system
  67807. */
  67808. removeStartSizeGradient(gradient: number): IParticleSystem;
  67809. /**
  67810. * Not supported by GPUParticleSystem
  67811. * @param gradient defines the gradient to use (between 0 and 1)
  67812. * @param min defines the color remap minimal range
  67813. * @param max defines the color remap maximal range
  67814. * @returns the current particle system
  67815. */
  67816. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67817. /**
  67818. * Not supported by GPUParticleSystem
  67819. * @param gradient defines the gradient to remove
  67820. * @returns the current particle system
  67821. */
  67822. removeColorRemapGradient(): IParticleSystem;
  67823. /**
  67824. * Not supported by GPUParticleSystem
  67825. * @param gradient defines the gradient to use (between 0 and 1)
  67826. * @param min defines the alpha remap minimal range
  67827. * @param max defines the alpha remap maximal range
  67828. * @returns the current particle system
  67829. */
  67830. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67831. /**
  67832. * Not supported by GPUParticleSystem
  67833. * @param gradient defines the gradient to remove
  67834. * @returns the current particle system
  67835. */
  67836. removeAlphaRemapGradient(): IParticleSystem;
  67837. /**
  67838. * Not supported by GPUParticleSystem
  67839. * @param gradient defines the gradient to use (between 0 and 1)
  67840. * @param color defines the color to affect to the specified gradient
  67841. * @returns the current particle system
  67842. */
  67843. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67844. /**
  67845. * Not supported by GPUParticleSystem
  67846. * @param gradient defines the gradient to remove
  67847. * @returns the current particle system
  67848. */
  67849. removeRampGradient(): IParticleSystem;
  67850. /**
  67851. * Not supported by GPUParticleSystem
  67852. * @returns the list of ramp gradients
  67853. */
  67854. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67855. /**
  67856. * Not supported by GPUParticleSystem
  67857. * Gets or sets a boolean indicating that ramp gradients must be used
  67858. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67859. */
  67860. get useRampGradients(): boolean;
  67861. set useRampGradients(value: boolean);
  67862. /**
  67863. * Not supported by GPUParticleSystem
  67864. * @param gradient defines the gradient to use (between 0 and 1)
  67865. * @param factor defines the life time factor to affect to the specified gradient
  67866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67867. * @returns the current particle system
  67868. */
  67869. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67870. /**
  67871. * Not supported by GPUParticleSystem
  67872. * @param gradient defines the gradient to remove
  67873. * @returns the current particle system
  67874. */
  67875. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67876. /**
  67877. * Instantiates a GPU particle system.
  67878. * 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.
  67879. * @param name The name of the particle system
  67880. * @param options The options used to create the system
  67881. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67882. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67883. * @param customEffect a custom effect used to change the way particles are rendered by default
  67884. */
  67885. constructor(name: string, options: Partial<{
  67886. capacity: number;
  67887. randomTextureSize: number;
  67888. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67889. protected _reset(): void;
  67890. private _createUpdateVAO;
  67891. private _createRenderVAO;
  67892. private _initialize;
  67893. /** @hidden */
  67894. _recreateUpdateEffect(): void;
  67895. private _getEffect;
  67896. /**
  67897. * Fill the defines array according to the current settings of the particle system
  67898. * @param defines Array to be updated
  67899. * @param blendMode blend mode to take into account when updating the array
  67900. */
  67901. fillDefines(defines: Array<string>, blendMode?: number): void;
  67902. /**
  67903. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67904. * @param uniforms Uniforms array to fill
  67905. * @param attributes Attributes array to fill
  67906. * @param samplers Samplers array to fill
  67907. */
  67908. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67909. /** @hidden */
  67910. _recreateRenderEffect(): Effect;
  67911. /**
  67912. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67913. * @param preWarm defines if we are in the pre-warmimg phase
  67914. */
  67915. animate(preWarm?: boolean): void;
  67916. private _createFactorGradientTexture;
  67917. private _createSizeGradientTexture;
  67918. private _createAngularSpeedGradientTexture;
  67919. private _createVelocityGradientTexture;
  67920. private _createLimitVelocityGradientTexture;
  67921. private _createDragGradientTexture;
  67922. private _createColorGradientTexture;
  67923. /**
  67924. * Renders the particle system in its current state
  67925. * @param preWarm defines if the system should only update the particles but not render them
  67926. * @returns the current number of particles
  67927. */
  67928. render(preWarm?: boolean): number;
  67929. /**
  67930. * Rebuilds the particle system
  67931. */
  67932. rebuild(): void;
  67933. private _releaseBuffers;
  67934. private _releaseVAOs;
  67935. /**
  67936. * Disposes the particle system and free the associated resources
  67937. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67938. */
  67939. dispose(disposeTexture?: boolean): void;
  67940. /**
  67941. * Clones the particle system.
  67942. * @param name The name of the cloned object
  67943. * @param newEmitter The new emitter to use
  67944. * @returns the cloned particle system
  67945. */
  67946. clone(name: string, newEmitter: any): GPUParticleSystem;
  67947. /**
  67948. * Serializes the particle system to a JSON object
  67949. * @param serializeTexture defines if the texture must be serialized as well
  67950. * @returns the JSON object
  67951. */
  67952. serialize(serializeTexture?: boolean): any;
  67953. /**
  67954. * Parses a JSON object to create a GPU particle system.
  67955. * @param parsedParticleSystem The JSON object to parse
  67956. * @param sceneOrEngine The scene or the engine to create the particle system in
  67957. * @param rootUrl The root url to use to load external dependencies like texture
  67958. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67959. * @returns the parsed GPU particle system
  67960. */
  67961. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67962. }
  67963. }
  67964. declare module BABYLON {
  67965. /**
  67966. * Represents a set of particle systems working together to create a specific effect
  67967. */
  67968. export class ParticleSystemSet implements IDisposable {
  67969. /**
  67970. * Gets or sets base Assets URL
  67971. */
  67972. static BaseAssetsUrl: string;
  67973. private _emitterCreationOptions;
  67974. private _emitterNode;
  67975. /**
  67976. * Gets the particle system list
  67977. */
  67978. systems: IParticleSystem[];
  67979. /**
  67980. * Gets the emitter node used with this set
  67981. */
  67982. get emitterNode(): Nullable<TransformNode>;
  67983. /**
  67984. * Creates a new emitter mesh as a sphere
  67985. * @param options defines the options used to create the sphere
  67986. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67987. * @param scene defines the hosting scene
  67988. */
  67989. setEmitterAsSphere(options: {
  67990. diameter: number;
  67991. segments: number;
  67992. color: Color3;
  67993. }, renderingGroupId: number, scene: Scene): void;
  67994. /**
  67995. * Starts all particle systems of the set
  67996. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67997. */
  67998. start(emitter?: AbstractMesh): void;
  67999. /**
  68000. * Release all associated resources
  68001. */
  68002. dispose(): void;
  68003. /**
  68004. * Serialize the set into a JSON compatible object
  68005. * @param serializeTexture defines if the texture must be serialized as well
  68006. * @returns a JSON compatible representation of the set
  68007. */
  68008. serialize(serializeTexture?: boolean): any;
  68009. /**
  68010. * Parse a new ParticleSystemSet from a serialized source
  68011. * @param data defines a JSON compatible representation of the set
  68012. * @param scene defines the hosting scene
  68013. * @param gpu defines if we want GPU particles or CPU particles
  68014. * @returns a new ParticleSystemSet
  68015. */
  68016. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68017. }
  68018. }
  68019. declare module BABYLON {
  68020. /**
  68021. * This class is made for on one-liner static method to help creating particle system set.
  68022. */
  68023. export class ParticleHelper {
  68024. /**
  68025. * Gets or sets base Assets URL
  68026. */
  68027. static BaseAssetsUrl: string;
  68028. /** Define the Url to load snippets */
  68029. static SnippetUrl: string;
  68030. /**
  68031. * Create a default particle system that you can tweak
  68032. * @param emitter defines the emitter to use
  68033. * @param capacity defines the system capacity (default is 500 particles)
  68034. * @param scene defines the hosting scene
  68035. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68036. * @returns the new Particle system
  68037. */
  68038. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68039. /**
  68040. * This is the main static method (one-liner) of this helper to create different particle systems
  68041. * @param type This string represents the type to the particle system to create
  68042. * @param scene The scene where the particle system should live
  68043. * @param gpu If the system will use gpu
  68044. * @returns the ParticleSystemSet created
  68045. */
  68046. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68047. /**
  68048. * Static function used to export a particle system to a ParticleSystemSet variable.
  68049. * Please note that the emitter shape is not exported
  68050. * @param systems defines the particle systems to export
  68051. * @returns the created particle system set
  68052. */
  68053. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68054. /**
  68055. * Creates a particle system from a snippet saved in a remote file
  68056. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68057. * @param url defines the url to load from
  68058. * @param scene defines the hosting scene
  68059. * @param gpu If the system will use gpu
  68060. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68061. * @returns a promise that will resolve to the new particle system
  68062. */
  68063. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68064. /**
  68065. * Creates a particle system from a snippet saved by the particle system editor
  68066. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  68067. * @param scene defines the hosting scene
  68068. * @param gpu If the system will use gpu
  68069. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68070. * @returns a promise that will resolve to the new particle system
  68071. */
  68072. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68073. }
  68074. }
  68075. declare module BABYLON {
  68076. interface Engine {
  68077. /**
  68078. * Create an effect to use with particle systems.
  68079. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68080. * the particle system for which you want to create a custom effect in the last parameter
  68081. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68082. * @param uniformsNames defines a list of attribute names
  68083. * @param samplers defines an array of string used to represent textures
  68084. * @param defines defines the string containing the defines to use to compile the shaders
  68085. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68086. * @param onCompiled defines a function to call when the effect creation is successful
  68087. * @param onError defines a function to call when the effect creation has failed
  68088. * @param particleSystem the particle system you want to create the effect for
  68089. * @returns the new Effect
  68090. */
  68091. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68092. }
  68093. interface Mesh {
  68094. /**
  68095. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68096. * @returns an array of IParticleSystem
  68097. */
  68098. getEmittedParticleSystems(): IParticleSystem[];
  68099. /**
  68100. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68101. * @returns an array of IParticleSystem
  68102. */
  68103. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68104. }
  68105. }
  68106. declare module BABYLON {
  68107. /** Defines the 4 color options */
  68108. export enum PointColor {
  68109. /** color value */
  68110. Color = 2,
  68111. /** uv value */
  68112. UV = 1,
  68113. /** random value */
  68114. Random = 0,
  68115. /** stated value */
  68116. Stated = 3
  68117. }
  68118. /**
  68119. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68120. * 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.
  68121. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68122. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68123. *
  68124. * Full documentation here : TO BE ENTERED
  68125. */
  68126. export class PointsCloudSystem implements IDisposable {
  68127. /**
  68128. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68129. * Example : var p = SPS.particles[i];
  68130. */
  68131. particles: CloudPoint[];
  68132. /**
  68133. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68134. */
  68135. nbParticles: number;
  68136. /**
  68137. * This a counter for your own usage. It's not set by any SPS functions.
  68138. */
  68139. counter: number;
  68140. /**
  68141. * The PCS name. This name is also given to the underlying mesh.
  68142. */
  68143. name: string;
  68144. /**
  68145. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68146. */
  68147. mesh: Mesh;
  68148. /**
  68149. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68150. * Please read :
  68151. */
  68152. vars: any;
  68153. /**
  68154. * @hidden
  68155. */
  68156. _size: number;
  68157. private _scene;
  68158. private _promises;
  68159. private _positions;
  68160. private _indices;
  68161. private _normals;
  68162. private _colors;
  68163. private _uvs;
  68164. private _indices32;
  68165. private _positions32;
  68166. private _colors32;
  68167. private _uvs32;
  68168. private _updatable;
  68169. private _isVisibilityBoxLocked;
  68170. private _alwaysVisible;
  68171. private _groups;
  68172. private _groupCounter;
  68173. private _computeParticleColor;
  68174. private _computeParticleTexture;
  68175. private _computeParticleRotation;
  68176. private _computeBoundingBox;
  68177. private _isReady;
  68178. /**
  68179. * Creates a PCS (Points Cloud System) object
  68180. * @param name (String) is the PCS name, this will be the underlying mesh name
  68181. * @param pointSize (number) is the size for each point
  68182. * @param scene (Scene) is the scene in which the PCS is added
  68183. * @param options defines the options of the PCS e.g.
  68184. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68185. */
  68186. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68187. updatable?: boolean;
  68188. });
  68189. /**
  68190. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68191. * If no points were added to the PCS, the returned mesh is just a single point.
  68192. * @returns a promise for the created mesh
  68193. */
  68194. buildMeshAsync(): Promise<Mesh>;
  68195. /**
  68196. * @hidden
  68197. */
  68198. private _buildMesh;
  68199. private _addParticle;
  68200. private _randomUnitVector;
  68201. private _getColorIndicesForCoord;
  68202. private _setPointsColorOrUV;
  68203. private _colorFromTexture;
  68204. private _calculateDensity;
  68205. /**
  68206. * Adds points to the PCS in random positions within a unit sphere
  68207. * @param nb (positive integer) the number of particles to be created from this model
  68208. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68209. * @returns the number of groups in the system
  68210. */
  68211. addPoints(nb: number, pointFunction?: any): number;
  68212. /**
  68213. * Adds points to the PCS from the surface of the model shape
  68214. * @param mesh is any Mesh object that will be used as a surface model for the points
  68215. * @param nb (positive integer) the number of particles to be created from this model
  68216. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68217. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68218. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68219. * @returns the number of groups in the system
  68220. */
  68221. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68222. /**
  68223. * Adds points to the PCS inside the model shape
  68224. * @param mesh is any Mesh object that will be used as a surface model for the points
  68225. * @param nb (positive integer) the number of particles to be created from this model
  68226. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68227. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68228. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68229. * @returns the number of groups in the system
  68230. */
  68231. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68232. /**
  68233. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68234. * This method calls `updateParticle()` for each particle of the SPS.
  68235. * For an animated SPS, it is usually called within the render loop.
  68236. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68237. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68238. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68239. * @returns the PCS.
  68240. */
  68241. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68242. /**
  68243. * Disposes the PCS.
  68244. */
  68245. dispose(): void;
  68246. /**
  68247. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68248. * doc :
  68249. * @returns the PCS.
  68250. */
  68251. refreshVisibleSize(): PointsCloudSystem;
  68252. /**
  68253. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68254. * @param size the size (float) of the visibility box
  68255. * note : this doesn't lock the PCS mesh bounding box.
  68256. * doc :
  68257. */
  68258. setVisibilityBox(size: number): void;
  68259. /**
  68260. * Gets whether the PCS is always visible or not
  68261. * doc :
  68262. */
  68263. get isAlwaysVisible(): boolean;
  68264. /**
  68265. * Sets the PCS as always visible or not
  68266. * doc :
  68267. */
  68268. set isAlwaysVisible(val: boolean);
  68269. /**
  68270. * Tells to `setParticles()` to compute the particle rotations or not
  68271. * Default value : false. The PCS is faster when it's set to false
  68272. * Note : particle rotations are only applied to parent particles
  68273. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68274. */
  68275. set computeParticleRotation(val: boolean);
  68276. /**
  68277. * Tells to `setParticles()` to compute the particle colors or not.
  68278. * Default value : true. The PCS is faster when it's set to false.
  68279. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68280. */
  68281. set computeParticleColor(val: boolean);
  68282. set computeParticleTexture(val: boolean);
  68283. /**
  68284. * Gets if `setParticles()` computes the particle colors or not.
  68285. * Default value : false. The PCS is faster when it's set to false.
  68286. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68287. */
  68288. get computeParticleColor(): boolean;
  68289. /**
  68290. * Gets if `setParticles()` computes the particle textures or not.
  68291. * Default value : false. The PCS is faster when it's set to false.
  68292. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68293. */
  68294. get computeParticleTexture(): boolean;
  68295. /**
  68296. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68297. */
  68298. set computeBoundingBox(val: boolean);
  68299. /**
  68300. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68301. */
  68302. get computeBoundingBox(): boolean;
  68303. /**
  68304. * This function does nothing. It may be overwritten to set all the particle first values.
  68305. * The PCS doesn't call this function, you may have to call it by your own.
  68306. * doc :
  68307. */
  68308. initParticles(): void;
  68309. /**
  68310. * This function does nothing. It may be overwritten to recycle a particle
  68311. * The PCS doesn't call this function, you can to call it
  68312. * doc :
  68313. * @param particle The particle to recycle
  68314. * @returns the recycled particle
  68315. */
  68316. recycleParticle(particle: CloudPoint): CloudPoint;
  68317. /**
  68318. * Updates a particle : this function should be overwritten by the user.
  68319. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68320. * doc :
  68321. * @example : just set a particle position or velocity and recycle conditions
  68322. * @param particle The particle to update
  68323. * @returns the updated particle
  68324. */
  68325. updateParticle(particle: CloudPoint): CloudPoint;
  68326. /**
  68327. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68328. * This does nothing and may be overwritten by the user.
  68329. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68330. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68331. * @param update the boolean update value actually passed to setParticles()
  68332. */
  68333. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68334. /**
  68335. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68336. * This will be passed three parameters.
  68337. * This does nothing and may be overwritten by the user.
  68338. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68339. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68340. * @param update the boolean update value actually passed to setParticles()
  68341. */
  68342. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68343. }
  68344. }
  68345. declare module BABYLON {
  68346. /**
  68347. * Represents one particle of a points cloud system.
  68348. */
  68349. export class CloudPoint {
  68350. /**
  68351. * particle global index
  68352. */
  68353. idx: number;
  68354. /**
  68355. * The color of the particle
  68356. */
  68357. color: Nullable<Color4>;
  68358. /**
  68359. * The world space position of the particle.
  68360. */
  68361. position: Vector3;
  68362. /**
  68363. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68364. */
  68365. rotation: Vector3;
  68366. /**
  68367. * The world space rotation quaternion of the particle.
  68368. */
  68369. rotationQuaternion: Nullable<Quaternion>;
  68370. /**
  68371. * The uv of the particle.
  68372. */
  68373. uv: Nullable<Vector2>;
  68374. /**
  68375. * The current speed of the particle.
  68376. */
  68377. velocity: Vector3;
  68378. /**
  68379. * The pivot point in the particle local space.
  68380. */
  68381. pivot: Vector3;
  68382. /**
  68383. * Must the particle be translated from its pivot point in its local space ?
  68384. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68385. * Default : false
  68386. */
  68387. translateFromPivot: boolean;
  68388. /**
  68389. * Index of this particle in the global "positions" array (Internal use)
  68390. * @hidden
  68391. */
  68392. _pos: number;
  68393. /**
  68394. * @hidden Index of this particle in the global "indices" array (Internal use)
  68395. */
  68396. _ind: number;
  68397. /**
  68398. * Group this particle belongs to
  68399. */
  68400. _group: PointsGroup;
  68401. /**
  68402. * Group id of this particle
  68403. */
  68404. groupId: number;
  68405. /**
  68406. * Index of the particle in its group id (Internal use)
  68407. */
  68408. idxInGroup: number;
  68409. /**
  68410. * @hidden Particle BoundingInfo object (Internal use)
  68411. */
  68412. _boundingInfo: BoundingInfo;
  68413. /**
  68414. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68415. */
  68416. _pcs: PointsCloudSystem;
  68417. /**
  68418. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68419. */
  68420. _stillInvisible: boolean;
  68421. /**
  68422. * @hidden Last computed particle rotation matrix
  68423. */
  68424. _rotationMatrix: number[];
  68425. /**
  68426. * Parent particle Id, if any.
  68427. * Default null.
  68428. */
  68429. parentId: Nullable<number>;
  68430. /**
  68431. * @hidden Internal global position in the PCS.
  68432. */
  68433. _globalPosition: Vector3;
  68434. /**
  68435. * Creates a Point Cloud object.
  68436. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68437. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68438. * @param group (PointsGroup) is the group the particle belongs to
  68439. * @param groupId (integer) is the group identifier in the PCS.
  68440. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68441. * @param pcs defines the PCS it is associated to
  68442. */
  68443. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68444. /**
  68445. * get point size
  68446. */
  68447. get size(): Vector3;
  68448. /**
  68449. * Set point size
  68450. */
  68451. set size(scale: Vector3);
  68452. /**
  68453. * Legacy support, changed quaternion to rotationQuaternion
  68454. */
  68455. get quaternion(): Nullable<Quaternion>;
  68456. /**
  68457. * Legacy support, changed quaternion to rotationQuaternion
  68458. */
  68459. set quaternion(q: Nullable<Quaternion>);
  68460. /**
  68461. * Returns a boolean. True if the particle intersects a mesh, else false
  68462. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68463. * @param target is the object (point or mesh) what the intersection is computed against
  68464. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68465. * @returns true if it intersects
  68466. */
  68467. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68468. /**
  68469. * get the rotation matrix of the particle
  68470. * @hidden
  68471. */
  68472. getRotationMatrix(m: Matrix): void;
  68473. }
  68474. /**
  68475. * Represents a group of points in a points cloud system
  68476. * * PCS internal tool, don't use it manually.
  68477. */
  68478. export class PointsGroup {
  68479. /**
  68480. * The group id
  68481. * @hidden
  68482. */
  68483. groupID: number;
  68484. /**
  68485. * image data for group (internal use)
  68486. * @hidden
  68487. */
  68488. _groupImageData: Nullable<ArrayBufferView>;
  68489. /**
  68490. * Image Width (internal use)
  68491. * @hidden
  68492. */
  68493. _groupImgWidth: number;
  68494. /**
  68495. * Image Height (internal use)
  68496. * @hidden
  68497. */
  68498. _groupImgHeight: number;
  68499. /**
  68500. * Custom position function (internal use)
  68501. * @hidden
  68502. */
  68503. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68504. /**
  68505. * density per facet for surface points
  68506. * @hidden
  68507. */
  68508. _groupDensity: number[];
  68509. /**
  68510. * Only when points are colored by texture carries pointer to texture list array
  68511. * @hidden
  68512. */
  68513. _textureNb: number;
  68514. /**
  68515. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68516. * PCS internal tool, don't use it manually.
  68517. * @hidden
  68518. */
  68519. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68520. }
  68521. }
  68522. declare module BABYLON {
  68523. interface Scene {
  68524. /** @hidden (Backing field) */
  68525. _physicsEngine: Nullable<IPhysicsEngine>;
  68526. /** @hidden */
  68527. _physicsTimeAccumulator: number;
  68528. /**
  68529. * Gets the current physics engine
  68530. * @returns a IPhysicsEngine or null if none attached
  68531. */
  68532. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68533. /**
  68534. * Enables physics to the current scene
  68535. * @param gravity defines the scene's gravity for the physics engine
  68536. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68537. * @return a boolean indicating if the physics engine was initialized
  68538. */
  68539. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68540. /**
  68541. * Disables and disposes the physics engine associated with the scene
  68542. */
  68543. disablePhysicsEngine(): void;
  68544. /**
  68545. * Gets a boolean indicating if there is an active physics engine
  68546. * @returns a boolean indicating if there is an active physics engine
  68547. */
  68548. isPhysicsEnabled(): boolean;
  68549. /**
  68550. * Deletes a physics compound impostor
  68551. * @param compound defines the compound to delete
  68552. */
  68553. deleteCompoundImpostor(compound: any): void;
  68554. /**
  68555. * An event triggered when physic simulation is about to be run
  68556. */
  68557. onBeforePhysicsObservable: Observable<Scene>;
  68558. /**
  68559. * An event triggered when physic simulation has been done
  68560. */
  68561. onAfterPhysicsObservable: Observable<Scene>;
  68562. }
  68563. interface AbstractMesh {
  68564. /** @hidden */
  68565. _physicsImpostor: Nullable<PhysicsImpostor>;
  68566. /**
  68567. * Gets or sets impostor used for physic simulation
  68568. * @see https://doc.babylonjs.com/features/physics_engine
  68569. */
  68570. physicsImpostor: Nullable<PhysicsImpostor>;
  68571. /**
  68572. * Gets the current physics impostor
  68573. * @see https://doc.babylonjs.com/features/physics_engine
  68574. * @returns a physics impostor or null
  68575. */
  68576. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68577. /** Apply a physic impulse to the mesh
  68578. * @param force defines the force to apply
  68579. * @param contactPoint defines where to apply the force
  68580. * @returns the current mesh
  68581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68582. */
  68583. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68584. /**
  68585. * Creates a physic joint between two meshes
  68586. * @param otherMesh defines the other mesh to use
  68587. * @param pivot1 defines the pivot to use on this mesh
  68588. * @param pivot2 defines the pivot to use on the other mesh
  68589. * @param options defines additional options (can be plugin dependent)
  68590. * @returns the current mesh
  68591. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68592. */
  68593. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68594. /** @hidden */
  68595. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68596. }
  68597. /**
  68598. * Defines the physics engine scene component responsible to manage a physics engine
  68599. */
  68600. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68601. /**
  68602. * The component name helpful to identify the component in the list of scene components.
  68603. */
  68604. readonly name: string;
  68605. /**
  68606. * The scene the component belongs to.
  68607. */
  68608. scene: Scene;
  68609. /**
  68610. * Creates a new instance of the component for the given scene
  68611. * @param scene Defines the scene to register the component in
  68612. */
  68613. constructor(scene: Scene);
  68614. /**
  68615. * Registers the component in a given scene
  68616. */
  68617. register(): void;
  68618. /**
  68619. * Rebuilds the elements related to this component in case of
  68620. * context lost for instance.
  68621. */
  68622. rebuild(): void;
  68623. /**
  68624. * Disposes the component and the associated ressources
  68625. */
  68626. dispose(): void;
  68627. }
  68628. }
  68629. declare module BABYLON {
  68630. /**
  68631. * A helper for physics simulations
  68632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68633. */
  68634. export class PhysicsHelper {
  68635. private _scene;
  68636. private _physicsEngine;
  68637. /**
  68638. * Initializes the Physics helper
  68639. * @param scene Babylon.js scene
  68640. */
  68641. constructor(scene: Scene);
  68642. /**
  68643. * Applies a radial explosion impulse
  68644. * @param origin the origin of the explosion
  68645. * @param radiusOrEventOptions the radius or the options of radial explosion
  68646. * @param strength the explosion strength
  68647. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68648. * @returns A physics radial explosion event, or null
  68649. */
  68650. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68651. /**
  68652. * Applies a radial explosion force
  68653. * @param origin the origin of the explosion
  68654. * @param radiusOrEventOptions the radius or the options of radial explosion
  68655. * @param strength the explosion strength
  68656. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68657. * @returns A physics radial explosion event, or null
  68658. */
  68659. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68660. /**
  68661. * Creates a gravitational field
  68662. * @param origin the origin of the explosion
  68663. * @param radiusOrEventOptions the radius or the options of radial explosion
  68664. * @param strength the explosion strength
  68665. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68666. * @returns A physics gravitational field event, or null
  68667. */
  68668. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68669. /**
  68670. * Creates a physics updraft event
  68671. * @param origin the origin of the updraft
  68672. * @param radiusOrEventOptions the radius or the options of the updraft
  68673. * @param strength the strength of the updraft
  68674. * @param height the height of the updraft
  68675. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68676. * @returns A physics updraft event, or null
  68677. */
  68678. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68679. /**
  68680. * Creates a physics vortex event
  68681. * @param origin the of the vortex
  68682. * @param radiusOrEventOptions the radius or the options of the vortex
  68683. * @param strength the strength of the vortex
  68684. * @param height the height of the vortex
  68685. * @returns a Physics vortex event, or null
  68686. * A physics vortex event or null
  68687. */
  68688. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68689. }
  68690. /**
  68691. * Represents a physics radial explosion event
  68692. */
  68693. class PhysicsRadialExplosionEvent {
  68694. private _scene;
  68695. private _options;
  68696. private _sphere;
  68697. private _dataFetched;
  68698. /**
  68699. * Initializes a radial explosioin event
  68700. * @param _scene BabylonJS scene
  68701. * @param _options The options for the vortex event
  68702. */
  68703. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68704. /**
  68705. * Returns the data related to the radial explosion event (sphere).
  68706. * @returns The radial explosion event data
  68707. */
  68708. getData(): PhysicsRadialExplosionEventData;
  68709. /**
  68710. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68711. * @param impostor A physics imposter
  68712. * @param origin the origin of the explosion
  68713. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68714. */
  68715. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68716. /**
  68717. * Triggers affecterd impostors callbacks
  68718. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68719. */
  68720. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68721. /**
  68722. * Disposes the sphere.
  68723. * @param force Specifies if the sphere should be disposed by force
  68724. */
  68725. dispose(force?: boolean): void;
  68726. /*** Helpers ***/
  68727. private _prepareSphere;
  68728. private _intersectsWithSphere;
  68729. }
  68730. /**
  68731. * Represents a gravitational field event
  68732. */
  68733. class PhysicsGravitationalFieldEvent {
  68734. private _physicsHelper;
  68735. private _scene;
  68736. private _origin;
  68737. private _options;
  68738. private _tickCallback;
  68739. private _sphere;
  68740. private _dataFetched;
  68741. /**
  68742. * Initializes the physics gravitational field event
  68743. * @param _physicsHelper A physics helper
  68744. * @param _scene BabylonJS scene
  68745. * @param _origin The origin position of the gravitational field event
  68746. * @param _options The options for the vortex event
  68747. */
  68748. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68749. /**
  68750. * Returns the data related to the gravitational field event (sphere).
  68751. * @returns A gravitational field event
  68752. */
  68753. getData(): PhysicsGravitationalFieldEventData;
  68754. /**
  68755. * Enables the gravitational field.
  68756. */
  68757. enable(): void;
  68758. /**
  68759. * Disables the gravitational field.
  68760. */
  68761. disable(): void;
  68762. /**
  68763. * Disposes the sphere.
  68764. * @param force The force to dispose from the gravitational field event
  68765. */
  68766. dispose(force?: boolean): void;
  68767. private _tick;
  68768. }
  68769. /**
  68770. * Represents a physics updraft event
  68771. */
  68772. class PhysicsUpdraftEvent {
  68773. private _scene;
  68774. private _origin;
  68775. private _options;
  68776. private _physicsEngine;
  68777. private _originTop;
  68778. private _originDirection;
  68779. private _tickCallback;
  68780. private _cylinder;
  68781. private _cylinderPosition;
  68782. private _dataFetched;
  68783. /**
  68784. * Initializes the physics updraft event
  68785. * @param _scene BabylonJS scene
  68786. * @param _origin The origin position of the updraft
  68787. * @param _options The options for the updraft event
  68788. */
  68789. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68790. /**
  68791. * Returns the data related to the updraft event (cylinder).
  68792. * @returns A physics updraft event
  68793. */
  68794. getData(): PhysicsUpdraftEventData;
  68795. /**
  68796. * Enables the updraft.
  68797. */
  68798. enable(): void;
  68799. /**
  68800. * Disables the updraft.
  68801. */
  68802. disable(): void;
  68803. /**
  68804. * Disposes the cylinder.
  68805. * @param force Specifies if the updraft should be disposed by force
  68806. */
  68807. dispose(force?: boolean): void;
  68808. private getImpostorHitData;
  68809. private _tick;
  68810. /*** Helpers ***/
  68811. private _prepareCylinder;
  68812. private _intersectsWithCylinder;
  68813. }
  68814. /**
  68815. * Represents a physics vortex event
  68816. */
  68817. class PhysicsVortexEvent {
  68818. private _scene;
  68819. private _origin;
  68820. private _options;
  68821. private _physicsEngine;
  68822. private _originTop;
  68823. private _tickCallback;
  68824. private _cylinder;
  68825. private _cylinderPosition;
  68826. private _dataFetched;
  68827. /**
  68828. * Initializes the physics vortex event
  68829. * @param _scene The BabylonJS scene
  68830. * @param _origin The origin position of the vortex
  68831. * @param _options The options for the vortex event
  68832. */
  68833. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68834. /**
  68835. * Returns the data related to the vortex event (cylinder).
  68836. * @returns The physics vortex event data
  68837. */
  68838. getData(): PhysicsVortexEventData;
  68839. /**
  68840. * Enables the vortex.
  68841. */
  68842. enable(): void;
  68843. /**
  68844. * Disables the cortex.
  68845. */
  68846. disable(): void;
  68847. /**
  68848. * Disposes the sphere.
  68849. * @param force
  68850. */
  68851. dispose(force?: boolean): void;
  68852. private getImpostorHitData;
  68853. private _tick;
  68854. /*** Helpers ***/
  68855. private _prepareCylinder;
  68856. private _intersectsWithCylinder;
  68857. }
  68858. /**
  68859. * Options fot the radial explosion event
  68860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68861. */
  68862. export class PhysicsRadialExplosionEventOptions {
  68863. /**
  68864. * The radius of the sphere for the radial explosion.
  68865. */
  68866. radius: number;
  68867. /**
  68868. * The strenth of the explosion.
  68869. */
  68870. strength: number;
  68871. /**
  68872. * The strenght of the force in correspondence to the distance of the affected object
  68873. */
  68874. falloff: PhysicsRadialImpulseFalloff;
  68875. /**
  68876. * Sphere options for the radial explosion.
  68877. */
  68878. sphere: {
  68879. segments: number;
  68880. diameter: number;
  68881. };
  68882. /**
  68883. * Sphere options for the radial explosion.
  68884. */
  68885. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68886. }
  68887. /**
  68888. * Options fot the updraft event
  68889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68890. */
  68891. export class PhysicsUpdraftEventOptions {
  68892. /**
  68893. * The radius of the cylinder for the vortex
  68894. */
  68895. radius: number;
  68896. /**
  68897. * The strenth of the updraft.
  68898. */
  68899. strength: number;
  68900. /**
  68901. * The height of the cylinder for the updraft.
  68902. */
  68903. height: number;
  68904. /**
  68905. * The mode for the the updraft.
  68906. */
  68907. updraftMode: PhysicsUpdraftMode;
  68908. }
  68909. /**
  68910. * Options fot the vortex event
  68911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68912. */
  68913. export class PhysicsVortexEventOptions {
  68914. /**
  68915. * The radius of the cylinder for the vortex
  68916. */
  68917. radius: number;
  68918. /**
  68919. * The strenth of the vortex.
  68920. */
  68921. strength: number;
  68922. /**
  68923. * The height of the cylinder for the vortex.
  68924. */
  68925. height: number;
  68926. /**
  68927. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68928. */
  68929. centripetalForceThreshold: number;
  68930. /**
  68931. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68932. */
  68933. centripetalForceMultiplier: number;
  68934. /**
  68935. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68936. */
  68937. centrifugalForceMultiplier: number;
  68938. /**
  68939. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68940. */
  68941. updraftForceMultiplier: number;
  68942. }
  68943. /**
  68944. * The strenght of the force in correspondence to the distance of the affected object
  68945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68946. */
  68947. export enum PhysicsRadialImpulseFalloff {
  68948. /** Defines that impulse is constant in strength across it's whole radius */
  68949. Constant = 0,
  68950. /** Defines that impulse gets weaker if it's further from the origin */
  68951. Linear = 1
  68952. }
  68953. /**
  68954. * The strength of the force in correspondence to the distance of the affected object
  68955. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68956. */
  68957. export enum PhysicsUpdraftMode {
  68958. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68959. Center = 0,
  68960. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68961. Perpendicular = 1
  68962. }
  68963. /**
  68964. * Interface for a physics hit data
  68965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68966. */
  68967. export interface PhysicsHitData {
  68968. /**
  68969. * The force applied at the contact point
  68970. */
  68971. force: Vector3;
  68972. /**
  68973. * The contact point
  68974. */
  68975. contactPoint: Vector3;
  68976. /**
  68977. * The distance from the origin to the contact point
  68978. */
  68979. distanceFromOrigin: number;
  68980. }
  68981. /**
  68982. * Interface for radial explosion event data
  68983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68984. */
  68985. export interface PhysicsRadialExplosionEventData {
  68986. /**
  68987. * A sphere used for the radial explosion event
  68988. */
  68989. sphere: Mesh;
  68990. }
  68991. /**
  68992. * Interface for gravitational field event data
  68993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68994. */
  68995. export interface PhysicsGravitationalFieldEventData {
  68996. /**
  68997. * A sphere mesh used for the gravitational field event
  68998. */
  68999. sphere: Mesh;
  69000. }
  69001. /**
  69002. * Interface for updraft event data
  69003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69004. */
  69005. export interface PhysicsUpdraftEventData {
  69006. /**
  69007. * A cylinder used for the updraft event
  69008. */
  69009. cylinder: Mesh;
  69010. }
  69011. /**
  69012. * Interface for vortex event data
  69013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69014. */
  69015. export interface PhysicsVortexEventData {
  69016. /**
  69017. * A cylinder used for the vortex event
  69018. */
  69019. cylinder: Mesh;
  69020. }
  69021. /**
  69022. * Interface for an affected physics impostor
  69023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69024. */
  69025. export interface PhysicsAffectedImpostorWithData {
  69026. /**
  69027. * The impostor affected by the effect
  69028. */
  69029. impostor: PhysicsImpostor;
  69030. /**
  69031. * The data about the hit/horce from the explosion
  69032. */
  69033. hitData: PhysicsHitData;
  69034. }
  69035. }
  69036. declare module BABYLON {
  69037. /** @hidden */
  69038. export var blackAndWhitePixelShader: {
  69039. name: string;
  69040. shader: string;
  69041. };
  69042. }
  69043. declare module BABYLON {
  69044. /**
  69045. * Post process used to render in black and white
  69046. */
  69047. export class BlackAndWhitePostProcess extends PostProcess {
  69048. /**
  69049. * Linear about to convert he result to black and white (default: 1)
  69050. */
  69051. degree: number;
  69052. /**
  69053. * Gets a string identifying the name of the class
  69054. * @returns "BlackAndWhitePostProcess" string
  69055. */
  69056. getClassName(): string;
  69057. /**
  69058. * Creates a black and white post process
  69059. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69060. * @param name The name of the effect.
  69061. * @param options The required width/height ratio to downsize to before computing the render pass.
  69062. * @param camera The camera to apply the render pass to.
  69063. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69064. * @param engine The engine which the post process will be applied. (default: current engine)
  69065. * @param reusable If the post process can be reused on the same frame. (default: false)
  69066. */
  69067. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69068. /** @hidden */
  69069. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69070. }
  69071. }
  69072. declare module BABYLON {
  69073. /**
  69074. * This represents a set of one or more post processes in Babylon.
  69075. * A post process can be used to apply a shader to a texture after it is rendered.
  69076. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69077. */
  69078. export class PostProcessRenderEffect {
  69079. private _postProcesses;
  69080. private _getPostProcesses;
  69081. private _singleInstance;
  69082. private _cameras;
  69083. private _indicesForCamera;
  69084. /**
  69085. * Name of the effect
  69086. * @hidden
  69087. */
  69088. _name: string;
  69089. /**
  69090. * Instantiates a post process render effect.
  69091. * A post process can be used to apply a shader to a texture after it is rendered.
  69092. * @param engine The engine the effect is tied to
  69093. * @param name The name of the effect
  69094. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69095. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69096. */
  69097. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69098. /**
  69099. * Checks if all the post processes in the effect are supported.
  69100. */
  69101. get isSupported(): boolean;
  69102. /**
  69103. * Updates the current state of the effect
  69104. * @hidden
  69105. */
  69106. _update(): void;
  69107. /**
  69108. * Attaches the effect on cameras
  69109. * @param cameras The camera to attach to.
  69110. * @hidden
  69111. */
  69112. _attachCameras(cameras: Camera): void;
  69113. /**
  69114. * Attaches the effect on cameras
  69115. * @param cameras The camera to attach to.
  69116. * @hidden
  69117. */
  69118. _attachCameras(cameras: Camera[]): void;
  69119. /**
  69120. * Detaches the effect on cameras
  69121. * @param cameras The camera to detatch from.
  69122. * @hidden
  69123. */
  69124. _detachCameras(cameras: Camera): void;
  69125. /**
  69126. * Detatches the effect on cameras
  69127. * @param cameras The camera to detatch from.
  69128. * @hidden
  69129. */
  69130. _detachCameras(cameras: Camera[]): void;
  69131. /**
  69132. * Enables the effect on given cameras
  69133. * @param cameras The camera to enable.
  69134. * @hidden
  69135. */
  69136. _enable(cameras: Camera): void;
  69137. /**
  69138. * Enables the effect on given cameras
  69139. * @param cameras The camera to enable.
  69140. * @hidden
  69141. */
  69142. _enable(cameras: Nullable<Camera[]>): void;
  69143. /**
  69144. * Disables the effect on the given cameras
  69145. * @param cameras The camera to disable.
  69146. * @hidden
  69147. */
  69148. _disable(cameras: Camera): void;
  69149. /**
  69150. * Disables the effect on the given cameras
  69151. * @param cameras The camera to disable.
  69152. * @hidden
  69153. */
  69154. _disable(cameras: Nullable<Camera[]>): void;
  69155. /**
  69156. * Gets a list of the post processes contained in the effect.
  69157. * @param camera The camera to get the post processes on.
  69158. * @returns The list of the post processes in the effect.
  69159. */
  69160. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69161. }
  69162. }
  69163. declare module BABYLON {
  69164. /** @hidden */
  69165. export var extractHighlightsPixelShader: {
  69166. name: string;
  69167. shader: string;
  69168. };
  69169. }
  69170. declare module BABYLON {
  69171. /**
  69172. * 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.
  69173. */
  69174. export class ExtractHighlightsPostProcess extends PostProcess {
  69175. /**
  69176. * The luminance threshold, pixels below this value will be set to black.
  69177. */
  69178. threshold: number;
  69179. /** @hidden */
  69180. _exposure: number;
  69181. /**
  69182. * Post process which has the input texture to be used when performing highlight extraction
  69183. * @hidden
  69184. */
  69185. _inputPostProcess: Nullable<PostProcess>;
  69186. /**
  69187. * Gets a string identifying the name of the class
  69188. * @returns "ExtractHighlightsPostProcess" string
  69189. */
  69190. getClassName(): string;
  69191. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69192. }
  69193. }
  69194. declare module BABYLON {
  69195. /** @hidden */
  69196. export var bloomMergePixelShader: {
  69197. name: string;
  69198. shader: string;
  69199. };
  69200. }
  69201. declare module BABYLON {
  69202. /**
  69203. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69204. */
  69205. export class BloomMergePostProcess extends PostProcess {
  69206. /** Weight of the bloom to be added to the original input. */
  69207. weight: number;
  69208. /**
  69209. * Gets a string identifying the name of the class
  69210. * @returns "BloomMergePostProcess" string
  69211. */
  69212. getClassName(): string;
  69213. /**
  69214. * Creates a new instance of @see BloomMergePostProcess
  69215. * @param name The name of the effect.
  69216. * @param originalFromInput Post process which's input will be used for the merge.
  69217. * @param blurred Blurred highlights post process which's output will be used.
  69218. * @param weight Weight of the bloom to be added to the original input.
  69219. * @param options The required width/height ratio to downsize to before computing the render pass.
  69220. * @param camera The camera to apply the render pass to.
  69221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69222. * @param engine The engine which the post process will be applied. (default: current engine)
  69223. * @param reusable If the post process can be reused on the same frame. (default: false)
  69224. * @param textureType Type of textures used when performing the post process. (default: 0)
  69225. * @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)
  69226. */
  69227. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69228. /** Weight of the bloom to be added to the original input. */
  69229. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69230. }
  69231. }
  69232. declare module BABYLON {
  69233. /**
  69234. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69235. */
  69236. export class BloomEffect extends PostProcessRenderEffect {
  69237. private bloomScale;
  69238. /**
  69239. * @hidden Internal
  69240. */
  69241. _effects: Array<PostProcess>;
  69242. /**
  69243. * @hidden Internal
  69244. */
  69245. _downscale: ExtractHighlightsPostProcess;
  69246. private _blurX;
  69247. private _blurY;
  69248. private _merge;
  69249. /**
  69250. * The luminance threshold to find bright areas of the image to bloom.
  69251. */
  69252. get threshold(): number;
  69253. set threshold(value: number);
  69254. /**
  69255. * The strength of the bloom.
  69256. */
  69257. get weight(): number;
  69258. set weight(value: number);
  69259. /**
  69260. * Specifies the size of the bloom blur kernel, relative to the final output size
  69261. */
  69262. get kernel(): number;
  69263. set kernel(value: number);
  69264. /**
  69265. * Creates a new instance of @see BloomEffect
  69266. * @param scene The scene the effect belongs to.
  69267. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69268. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69269. * @param bloomWeight The the strength of bloom.
  69270. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69271. * @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)
  69272. */
  69273. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69274. /**
  69275. * Disposes each of the internal effects for a given camera.
  69276. * @param camera The camera to dispose the effect on.
  69277. */
  69278. disposeEffects(camera: Camera): void;
  69279. /**
  69280. * @hidden Internal
  69281. */
  69282. _updateEffects(): void;
  69283. /**
  69284. * Internal
  69285. * @returns if all the contained post processes are ready.
  69286. * @hidden
  69287. */
  69288. _isReady(): boolean;
  69289. }
  69290. }
  69291. declare module BABYLON {
  69292. /** @hidden */
  69293. export var chromaticAberrationPixelShader: {
  69294. name: string;
  69295. shader: string;
  69296. };
  69297. }
  69298. declare module BABYLON {
  69299. /**
  69300. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69301. */
  69302. export class ChromaticAberrationPostProcess extends PostProcess {
  69303. /**
  69304. * The amount of seperation of rgb channels (default: 30)
  69305. */
  69306. aberrationAmount: number;
  69307. /**
  69308. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69309. */
  69310. radialIntensity: number;
  69311. /**
  69312. * 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))
  69313. */
  69314. direction: Vector2;
  69315. /**
  69316. * 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))
  69317. */
  69318. centerPosition: Vector2;
  69319. /** The width of the screen to apply the effect on */
  69320. screenWidth: number;
  69321. /** The height of the screen to apply the effect on */
  69322. screenHeight: number;
  69323. /**
  69324. * Gets a string identifying the name of the class
  69325. * @returns "ChromaticAberrationPostProcess" string
  69326. */
  69327. getClassName(): string;
  69328. /**
  69329. * Creates a new instance ChromaticAberrationPostProcess
  69330. * @param name The name of the effect.
  69331. * @param screenWidth The width of the screen to apply the effect on.
  69332. * @param screenHeight The height of the screen to apply the effect on.
  69333. * @param options The required width/height ratio to downsize to before computing the render pass.
  69334. * @param camera The camera to apply the render pass to.
  69335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69336. * @param engine The engine which the post process will be applied. (default: current engine)
  69337. * @param reusable If the post process can be reused on the same frame. (default: false)
  69338. * @param textureType Type of textures used when performing the post process. (default: 0)
  69339. * @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)
  69340. */
  69341. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69342. /** @hidden */
  69343. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69344. }
  69345. }
  69346. declare module BABYLON {
  69347. /** @hidden */
  69348. export var circleOfConfusionPixelShader: {
  69349. name: string;
  69350. shader: string;
  69351. };
  69352. }
  69353. declare module BABYLON {
  69354. /**
  69355. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69356. */
  69357. export class CircleOfConfusionPostProcess extends PostProcess {
  69358. /**
  69359. * 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.
  69360. */
  69361. lensSize: number;
  69362. /**
  69363. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69364. */
  69365. fStop: number;
  69366. /**
  69367. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69368. */
  69369. focusDistance: number;
  69370. /**
  69371. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69372. */
  69373. focalLength: number;
  69374. /**
  69375. * Gets a string identifying the name of the class
  69376. * @returns "CircleOfConfusionPostProcess" string
  69377. */
  69378. getClassName(): string;
  69379. private _depthTexture;
  69380. /**
  69381. * Creates a new instance CircleOfConfusionPostProcess
  69382. * @param name The name of the effect.
  69383. * @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.
  69384. * @param options The required width/height ratio to downsize to before computing the render pass.
  69385. * @param camera The camera to apply the render pass to.
  69386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69387. * @param engine The engine which the post process will be applied. (default: current engine)
  69388. * @param reusable If the post process can be reused on the same frame. (default: false)
  69389. * @param textureType Type of textures used when performing the post process. (default: 0)
  69390. * @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)
  69391. */
  69392. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69393. /**
  69394. * 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.
  69395. */
  69396. set depthTexture(value: RenderTargetTexture);
  69397. }
  69398. }
  69399. declare module BABYLON {
  69400. /** @hidden */
  69401. export var colorCorrectionPixelShader: {
  69402. name: string;
  69403. shader: string;
  69404. };
  69405. }
  69406. declare module BABYLON {
  69407. /**
  69408. *
  69409. * This post-process allows the modification of rendered colors by using
  69410. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69411. *
  69412. * The object needs to be provided an url to a texture containing the color
  69413. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69414. * Use an image editing software to tweak the LUT to match your needs.
  69415. *
  69416. * For an example of a color LUT, see here:
  69417. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69418. * For explanations on color grading, see here:
  69419. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69420. *
  69421. */
  69422. export class ColorCorrectionPostProcess extends PostProcess {
  69423. private _colorTableTexture;
  69424. /**
  69425. * Gets the color table url used to create the LUT texture
  69426. */
  69427. colorTableUrl: string;
  69428. /**
  69429. * Gets a string identifying the name of the class
  69430. * @returns "ColorCorrectionPostProcess" string
  69431. */
  69432. getClassName(): string;
  69433. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69434. /** @hidden */
  69435. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69436. }
  69437. }
  69438. declare module BABYLON {
  69439. /** @hidden */
  69440. export var convolutionPixelShader: {
  69441. name: string;
  69442. shader: string;
  69443. };
  69444. }
  69445. declare module BABYLON {
  69446. /**
  69447. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69448. * input texture to perform effects such as edge detection or sharpening
  69449. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69450. */
  69451. export class ConvolutionPostProcess extends PostProcess {
  69452. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69453. kernel: number[];
  69454. /**
  69455. * Gets a string identifying the name of the class
  69456. * @returns "ConvolutionPostProcess" string
  69457. */
  69458. getClassName(): string;
  69459. /**
  69460. * Creates a new instance ConvolutionPostProcess
  69461. * @param name The name of the effect.
  69462. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69463. * @param options The required width/height ratio to downsize to before computing the render pass.
  69464. * @param camera The camera to apply the render pass to.
  69465. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69466. * @param engine The engine which the post process will be applied. (default: current engine)
  69467. * @param reusable If the post process can be reused on the same frame. (default: false)
  69468. * @param textureType Type of textures used when performing the post process. (default: 0)
  69469. */
  69470. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69471. /** @hidden */
  69472. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69473. /**
  69474. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69475. */
  69476. static EdgeDetect0Kernel: number[];
  69477. /**
  69478. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69479. */
  69480. static EdgeDetect1Kernel: number[];
  69481. /**
  69482. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69483. */
  69484. static EdgeDetect2Kernel: number[];
  69485. /**
  69486. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69487. */
  69488. static SharpenKernel: number[];
  69489. /**
  69490. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69491. */
  69492. static EmbossKernel: number[];
  69493. /**
  69494. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69495. */
  69496. static GaussianKernel: number[];
  69497. }
  69498. }
  69499. declare module BABYLON {
  69500. /**
  69501. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69502. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69503. * based on samples that have a large difference in distance than the center pixel.
  69504. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69505. */
  69506. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69507. /**
  69508. * The direction the blur should be applied
  69509. */
  69510. direction: Vector2;
  69511. /**
  69512. * Gets a string identifying the name of the class
  69513. * @returns "DepthOfFieldBlurPostProcess" string
  69514. */
  69515. getClassName(): string;
  69516. /**
  69517. * Creates a new instance CircleOfConfusionPostProcess
  69518. * @param name The name of the effect.
  69519. * @param scene The scene the effect belongs to.
  69520. * @param direction The direction the blur should be applied.
  69521. * @param kernel The size of the kernel used to blur.
  69522. * @param options The required width/height ratio to downsize to before computing the render pass.
  69523. * @param camera The camera to apply the render pass to.
  69524. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69525. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69526. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69527. * @param engine The engine which the post process will be applied. (default: current engine)
  69528. * @param reusable If the post process can be reused on the same frame. (default: false)
  69529. * @param textureType Type of textures used when performing the post process. (default: 0)
  69530. * @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)
  69531. */
  69532. 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);
  69533. }
  69534. }
  69535. declare module BABYLON {
  69536. /** @hidden */
  69537. export var depthOfFieldMergePixelShader: {
  69538. name: string;
  69539. shader: string;
  69540. };
  69541. }
  69542. declare module BABYLON {
  69543. /**
  69544. * Options to be set when merging outputs from the default pipeline.
  69545. */
  69546. export class DepthOfFieldMergePostProcessOptions {
  69547. /**
  69548. * The original image to merge on top of
  69549. */
  69550. originalFromInput: PostProcess;
  69551. /**
  69552. * Parameters to perform the merge of the depth of field effect
  69553. */
  69554. depthOfField?: {
  69555. circleOfConfusion: PostProcess;
  69556. blurSteps: Array<PostProcess>;
  69557. };
  69558. /**
  69559. * Parameters to perform the merge of bloom effect
  69560. */
  69561. bloom?: {
  69562. blurred: PostProcess;
  69563. weight: number;
  69564. };
  69565. }
  69566. /**
  69567. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69568. */
  69569. export class DepthOfFieldMergePostProcess extends PostProcess {
  69570. private blurSteps;
  69571. /**
  69572. * Gets a string identifying the name of the class
  69573. * @returns "DepthOfFieldMergePostProcess" string
  69574. */
  69575. getClassName(): string;
  69576. /**
  69577. * Creates a new instance of DepthOfFieldMergePostProcess
  69578. * @param name The name of the effect.
  69579. * @param originalFromInput Post process which's input will be used for the merge.
  69580. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69581. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69582. * @param options The required width/height ratio to downsize to before computing the render pass.
  69583. * @param camera The camera to apply the render pass to.
  69584. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69585. * @param engine The engine which the post process will be applied. (default: current engine)
  69586. * @param reusable If the post process can be reused on the same frame. (default: false)
  69587. * @param textureType Type of textures used when performing the post process. (default: 0)
  69588. * @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)
  69589. */
  69590. 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);
  69591. /**
  69592. * Updates the effect with the current post process compile time values and recompiles the shader.
  69593. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69594. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69595. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69596. * @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
  69597. * @param onCompiled Called when the shader has been compiled.
  69598. * @param onError Called if there is an error when compiling a shader.
  69599. */
  69600. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69601. }
  69602. }
  69603. declare module BABYLON {
  69604. /**
  69605. * Specifies the level of max blur that should be applied when using the depth of field effect
  69606. */
  69607. export enum DepthOfFieldEffectBlurLevel {
  69608. /**
  69609. * Subtle blur
  69610. */
  69611. Low = 0,
  69612. /**
  69613. * Medium blur
  69614. */
  69615. Medium = 1,
  69616. /**
  69617. * Large blur
  69618. */
  69619. High = 2
  69620. }
  69621. /**
  69622. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69623. */
  69624. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69625. private _circleOfConfusion;
  69626. /**
  69627. * @hidden Internal, blurs from high to low
  69628. */
  69629. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69630. private _depthOfFieldBlurY;
  69631. private _dofMerge;
  69632. /**
  69633. * @hidden Internal post processes in depth of field effect
  69634. */
  69635. _effects: Array<PostProcess>;
  69636. /**
  69637. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69638. */
  69639. set focalLength(value: number);
  69640. get focalLength(): number;
  69641. /**
  69642. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69643. */
  69644. set fStop(value: number);
  69645. get fStop(): number;
  69646. /**
  69647. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69648. */
  69649. set focusDistance(value: number);
  69650. get focusDistance(): number;
  69651. /**
  69652. * 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.
  69653. */
  69654. set lensSize(value: number);
  69655. get lensSize(): number;
  69656. /**
  69657. * Creates a new instance DepthOfFieldEffect
  69658. * @param scene The scene the effect belongs to.
  69659. * @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.
  69660. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69661. * @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)
  69662. */
  69663. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69664. /**
  69665. * Get the current class name of the current effet
  69666. * @returns "DepthOfFieldEffect"
  69667. */
  69668. getClassName(): string;
  69669. /**
  69670. * 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.
  69671. */
  69672. set depthTexture(value: RenderTargetTexture);
  69673. /**
  69674. * Disposes each of the internal effects for a given camera.
  69675. * @param camera The camera to dispose the effect on.
  69676. */
  69677. disposeEffects(camera: Camera): void;
  69678. /**
  69679. * @hidden Internal
  69680. */
  69681. _updateEffects(): void;
  69682. /**
  69683. * Internal
  69684. * @returns if all the contained post processes are ready.
  69685. * @hidden
  69686. */
  69687. _isReady(): boolean;
  69688. }
  69689. }
  69690. declare module BABYLON {
  69691. /** @hidden */
  69692. export var displayPassPixelShader: {
  69693. name: string;
  69694. shader: string;
  69695. };
  69696. }
  69697. declare module BABYLON {
  69698. /**
  69699. * DisplayPassPostProcess which produces an output the same as it's input
  69700. */
  69701. export class DisplayPassPostProcess extends PostProcess {
  69702. /**
  69703. * Gets a string identifying the name of the class
  69704. * @returns "DisplayPassPostProcess" string
  69705. */
  69706. getClassName(): string;
  69707. /**
  69708. * Creates the DisplayPassPostProcess
  69709. * @param name The name of the effect.
  69710. * @param options The required width/height ratio to downsize to before computing the render pass.
  69711. * @param camera The camera to apply the render pass to.
  69712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69713. * @param engine The engine which the post process will be applied. (default: current engine)
  69714. * @param reusable If the post process can be reused on the same frame. (default: false)
  69715. */
  69716. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69717. /** @hidden */
  69718. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69719. }
  69720. }
  69721. declare module BABYLON {
  69722. /** @hidden */
  69723. export var filterPixelShader: {
  69724. name: string;
  69725. shader: string;
  69726. };
  69727. }
  69728. declare module BABYLON {
  69729. /**
  69730. * Applies a kernel filter to the image
  69731. */
  69732. export class FilterPostProcess extends PostProcess {
  69733. /** The matrix to be applied to the image */
  69734. kernelMatrix: Matrix;
  69735. /**
  69736. * Gets a string identifying the name of the class
  69737. * @returns "FilterPostProcess" string
  69738. */
  69739. getClassName(): string;
  69740. /**
  69741. *
  69742. * @param name The name of the effect.
  69743. * @param kernelMatrix The matrix to be applied to the image
  69744. * @param options The required width/height ratio to downsize to before computing the render pass.
  69745. * @param camera The camera to apply the render pass to.
  69746. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69747. * @param engine The engine which the post process will be applied. (default: current engine)
  69748. * @param reusable If the post process can be reused on the same frame. (default: false)
  69749. */
  69750. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69751. /** @hidden */
  69752. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69753. }
  69754. }
  69755. declare module BABYLON {
  69756. /** @hidden */
  69757. export var fxaaPixelShader: {
  69758. name: string;
  69759. shader: string;
  69760. };
  69761. }
  69762. declare module BABYLON {
  69763. /** @hidden */
  69764. export var fxaaVertexShader: {
  69765. name: string;
  69766. shader: string;
  69767. };
  69768. }
  69769. declare module BABYLON {
  69770. /**
  69771. * Fxaa post process
  69772. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69773. */
  69774. export class FxaaPostProcess extends PostProcess {
  69775. /**
  69776. * Gets a string identifying the name of the class
  69777. * @returns "FxaaPostProcess" string
  69778. */
  69779. getClassName(): string;
  69780. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69781. private _getDefines;
  69782. /** @hidden */
  69783. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69784. }
  69785. }
  69786. declare module BABYLON {
  69787. /** @hidden */
  69788. export var grainPixelShader: {
  69789. name: string;
  69790. shader: string;
  69791. };
  69792. }
  69793. declare module BABYLON {
  69794. /**
  69795. * The GrainPostProcess adds noise to the image at mid luminance levels
  69796. */
  69797. export class GrainPostProcess extends PostProcess {
  69798. /**
  69799. * The intensity of the grain added (default: 30)
  69800. */
  69801. intensity: number;
  69802. /**
  69803. * If the grain should be randomized on every frame
  69804. */
  69805. animated: boolean;
  69806. /**
  69807. * Gets a string identifying the name of the class
  69808. * @returns "GrainPostProcess" string
  69809. */
  69810. getClassName(): string;
  69811. /**
  69812. * Creates a new instance of @see GrainPostProcess
  69813. * @param name The name of the effect.
  69814. * @param options The required width/height ratio to downsize to before computing the render pass.
  69815. * @param camera The camera to apply the render pass to.
  69816. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69817. * @param engine The engine which the post process will be applied. (default: current engine)
  69818. * @param reusable If the post process can be reused on the same frame. (default: false)
  69819. * @param textureType Type of textures used when performing the post process. (default: 0)
  69820. * @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)
  69821. */
  69822. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69823. /** @hidden */
  69824. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  69825. }
  69826. }
  69827. declare module BABYLON {
  69828. /** @hidden */
  69829. export var highlightsPixelShader: {
  69830. name: string;
  69831. shader: string;
  69832. };
  69833. }
  69834. declare module BABYLON {
  69835. /**
  69836. * Extracts highlights from the image
  69837. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69838. */
  69839. export class HighlightsPostProcess extends PostProcess {
  69840. /**
  69841. * Gets a string identifying the name of the class
  69842. * @returns "HighlightsPostProcess" string
  69843. */
  69844. getClassName(): string;
  69845. /**
  69846. * Extracts highlights from the image
  69847. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69848. * @param name The name of the effect.
  69849. * @param options The required width/height ratio to downsize to before computing the render pass.
  69850. * @param camera The camera to apply the render pass to.
  69851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69852. * @param engine The engine which the post process will be applied. (default: current engine)
  69853. * @param reusable If the post process can be reused on the same frame. (default: false)
  69854. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69855. */
  69856. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69857. }
  69858. }
  69859. declare module BABYLON {
  69860. /** @hidden */
  69861. export var mrtFragmentDeclaration: {
  69862. name: string;
  69863. shader: string;
  69864. };
  69865. }
  69866. declare module BABYLON {
  69867. /** @hidden */
  69868. export var geometryPixelShader: {
  69869. name: string;
  69870. shader: string;
  69871. };
  69872. }
  69873. declare module BABYLON {
  69874. /** @hidden */
  69875. export var geometryVertexShader: {
  69876. name: string;
  69877. shader: string;
  69878. };
  69879. }
  69880. declare module BABYLON {
  69881. /** @hidden */
  69882. interface ISavedTransformationMatrix {
  69883. world: Matrix;
  69884. viewProjection: Matrix;
  69885. }
  69886. /**
  69887. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69888. */
  69889. export class GeometryBufferRenderer {
  69890. /**
  69891. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69892. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69893. */
  69894. static readonly POSITION_TEXTURE_TYPE: number;
  69895. /**
  69896. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69897. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69898. */
  69899. static readonly VELOCITY_TEXTURE_TYPE: number;
  69900. /**
  69901. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69902. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69903. */
  69904. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69905. /**
  69906. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69907. * in order to compute objects velocities when enableVelocity is set to "true"
  69908. * @hidden
  69909. */
  69910. _previousTransformationMatrices: {
  69911. [index: number]: ISavedTransformationMatrix;
  69912. };
  69913. /**
  69914. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69915. * in order to compute objects velocities when enableVelocity is set to "true"
  69916. * @hidden
  69917. */
  69918. _previousBonesTransformationMatrices: {
  69919. [index: number]: Float32Array;
  69920. };
  69921. /**
  69922. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69923. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69924. */
  69925. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69926. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69927. renderTransparentMeshes: boolean;
  69928. private _scene;
  69929. private _resizeObserver;
  69930. private _multiRenderTarget;
  69931. private _ratio;
  69932. private _enablePosition;
  69933. private _enableVelocity;
  69934. private _enableReflectivity;
  69935. private _positionIndex;
  69936. private _velocityIndex;
  69937. private _reflectivityIndex;
  69938. protected _effect: Effect;
  69939. protected _cachedDefines: string;
  69940. /**
  69941. * Set the render list (meshes to be rendered) used in the G buffer.
  69942. */
  69943. set renderList(meshes: Mesh[]);
  69944. /**
  69945. * Gets wether or not G buffer are supported by the running hardware.
  69946. * This requires draw buffer supports
  69947. */
  69948. get isSupported(): boolean;
  69949. /**
  69950. * Returns the index of the given texture type in the G-Buffer textures array
  69951. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69952. * @returns the index of the given texture type in the G-Buffer textures array
  69953. */
  69954. getTextureIndex(textureType: number): number;
  69955. /**
  69956. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69957. */
  69958. get enablePosition(): boolean;
  69959. /**
  69960. * Sets whether or not objects positions are enabled for the G buffer.
  69961. */
  69962. set enablePosition(enable: boolean);
  69963. /**
  69964. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69965. */
  69966. get enableVelocity(): boolean;
  69967. /**
  69968. * Sets wether or not objects velocities are enabled for the G buffer.
  69969. */
  69970. set enableVelocity(enable: boolean);
  69971. /**
  69972. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69973. */
  69974. get enableReflectivity(): boolean;
  69975. /**
  69976. * Sets wether or not objects roughness are enabled for the G buffer.
  69977. */
  69978. set enableReflectivity(enable: boolean);
  69979. /**
  69980. * Gets the scene associated with the buffer.
  69981. */
  69982. get scene(): Scene;
  69983. /**
  69984. * Gets the ratio used by the buffer during its creation.
  69985. * How big is the buffer related to the main canvas.
  69986. */
  69987. get ratio(): number;
  69988. /** @hidden */
  69989. static _SceneComponentInitialization: (scene: Scene) => void;
  69990. /**
  69991. * Creates a new G Buffer for the scene
  69992. * @param scene The scene the buffer belongs to
  69993. * @param ratio How big is the buffer related to the main canvas.
  69994. */
  69995. constructor(scene: Scene, ratio?: number);
  69996. /**
  69997. * Checks wether everything is ready to render a submesh to the G buffer.
  69998. * @param subMesh the submesh to check readiness for
  69999. * @param useInstances is the mesh drawn using instance or not
  70000. * @returns true if ready otherwise false
  70001. */
  70002. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70003. /**
  70004. * Gets the current underlying G Buffer.
  70005. * @returns the buffer
  70006. */
  70007. getGBuffer(): MultiRenderTarget;
  70008. /**
  70009. * Gets the number of samples used to render the buffer (anti aliasing).
  70010. */
  70011. get samples(): number;
  70012. /**
  70013. * Sets the number of samples used to render the buffer (anti aliasing).
  70014. */
  70015. set samples(value: number);
  70016. /**
  70017. * Disposes the renderer and frees up associated resources.
  70018. */
  70019. dispose(): void;
  70020. protected _createRenderTargets(): void;
  70021. private _copyBonesTransformationMatrices;
  70022. }
  70023. }
  70024. declare module BABYLON {
  70025. interface Scene {
  70026. /** @hidden (Backing field) */
  70027. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70028. /**
  70029. * Gets or Sets the current geometry buffer associated to the scene.
  70030. */
  70031. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70032. /**
  70033. * Enables a GeometryBufferRender and associates it with the scene
  70034. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70035. * @returns the GeometryBufferRenderer
  70036. */
  70037. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70038. /**
  70039. * Disables the GeometryBufferRender associated with the scene
  70040. */
  70041. disableGeometryBufferRenderer(): void;
  70042. }
  70043. /**
  70044. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70045. * in several rendering techniques.
  70046. */
  70047. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70048. /**
  70049. * The component name helpful to identify the component in the list of scene components.
  70050. */
  70051. readonly name: string;
  70052. /**
  70053. * The scene the component belongs to.
  70054. */
  70055. scene: Scene;
  70056. /**
  70057. * Creates a new instance of the component for the given scene
  70058. * @param scene Defines the scene to register the component in
  70059. */
  70060. constructor(scene: Scene);
  70061. /**
  70062. * Registers the component in a given scene
  70063. */
  70064. register(): void;
  70065. /**
  70066. * Rebuilds the elements related to this component in case of
  70067. * context lost for instance.
  70068. */
  70069. rebuild(): void;
  70070. /**
  70071. * Disposes the component and the associated ressources
  70072. */
  70073. dispose(): void;
  70074. private _gatherRenderTargets;
  70075. }
  70076. }
  70077. declare module BABYLON {
  70078. /** @hidden */
  70079. export var motionBlurPixelShader: {
  70080. name: string;
  70081. shader: string;
  70082. };
  70083. }
  70084. declare module BABYLON {
  70085. /**
  70086. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70087. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70088. * As an example, all you have to do is to create the post-process:
  70089. * var mb = new BABYLON.MotionBlurPostProcess(
  70090. * 'mb', // The name of the effect.
  70091. * scene, // The scene containing the objects to blur according to their velocity.
  70092. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70093. * camera // The camera to apply the render pass to.
  70094. * );
  70095. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70096. */
  70097. export class MotionBlurPostProcess extends PostProcess {
  70098. /**
  70099. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70100. */
  70101. motionStrength: number;
  70102. /**
  70103. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70104. */
  70105. get motionBlurSamples(): number;
  70106. /**
  70107. * Sets the number of iterations to be used for motion blur quality
  70108. */
  70109. set motionBlurSamples(samples: number);
  70110. private _motionBlurSamples;
  70111. private _geometryBufferRenderer;
  70112. /**
  70113. * Gets a string identifying the name of the class
  70114. * @returns "MotionBlurPostProcess" string
  70115. */
  70116. getClassName(): string;
  70117. /**
  70118. * Creates a new instance MotionBlurPostProcess
  70119. * @param name The name of the effect.
  70120. * @param scene The scene containing the objects to blur according to their velocity.
  70121. * @param options The required width/height ratio to downsize to before computing the render pass.
  70122. * @param camera The camera to apply the render pass to.
  70123. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70124. * @param engine The engine which the post process will be applied. (default: current engine)
  70125. * @param reusable If the post process can be reused on the same frame. (default: false)
  70126. * @param textureType Type of textures used when performing the post process. (default: 0)
  70127. * @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)
  70128. */
  70129. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70130. /**
  70131. * Excludes the given skinned mesh from computing bones velocities.
  70132. * 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.
  70133. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70134. */
  70135. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70136. /**
  70137. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70138. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70139. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70140. */
  70141. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70142. /**
  70143. * Disposes the post process.
  70144. * @param camera The camera to dispose the post process on.
  70145. */
  70146. dispose(camera?: Camera): void;
  70147. /** @hidden */
  70148. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70149. }
  70150. }
  70151. declare module BABYLON {
  70152. /** @hidden */
  70153. export var refractionPixelShader: {
  70154. name: string;
  70155. shader: string;
  70156. };
  70157. }
  70158. declare module BABYLON {
  70159. /**
  70160. * Post process which applies a refractin texture
  70161. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70162. */
  70163. export class RefractionPostProcess extends PostProcess {
  70164. private _refTexture;
  70165. private _ownRefractionTexture;
  70166. /** the base color of the refraction (used to taint the rendering) */
  70167. color: Color3;
  70168. /** simulated refraction depth */
  70169. depth: number;
  70170. /** the coefficient of the base color (0 to remove base color tainting) */
  70171. colorLevel: number;
  70172. /** Gets the url used to load the refraction texture */
  70173. refractionTextureUrl: string;
  70174. /**
  70175. * Gets or sets the refraction texture
  70176. * Please note that you are responsible for disposing the texture if you set it manually
  70177. */
  70178. get refractionTexture(): Texture;
  70179. set refractionTexture(value: Texture);
  70180. /**
  70181. * Gets a string identifying the name of the class
  70182. * @returns "RefractionPostProcess" string
  70183. */
  70184. getClassName(): string;
  70185. /**
  70186. * Initializes the RefractionPostProcess
  70187. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70188. * @param name The name of the effect.
  70189. * @param refractionTextureUrl Url of the refraction texture to use
  70190. * @param color the base color of the refraction (used to taint the rendering)
  70191. * @param depth simulated refraction depth
  70192. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70193. * @param camera The camera to apply the render pass to.
  70194. * @param options The required width/height ratio to downsize to before computing the render pass.
  70195. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70196. * @param engine The engine which the post process will be applied. (default: current engine)
  70197. * @param reusable If the post process can be reused on the same frame. (default: false)
  70198. */
  70199. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70200. /**
  70201. * Disposes of the post process
  70202. * @param camera Camera to dispose post process on
  70203. */
  70204. dispose(camera: Camera): void;
  70205. /** @hidden */
  70206. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70207. }
  70208. }
  70209. declare module BABYLON {
  70210. /** @hidden */
  70211. export var sharpenPixelShader: {
  70212. name: string;
  70213. shader: string;
  70214. };
  70215. }
  70216. declare module BABYLON {
  70217. /**
  70218. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70219. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70220. */
  70221. export class SharpenPostProcess extends PostProcess {
  70222. /**
  70223. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70224. */
  70225. colorAmount: number;
  70226. /**
  70227. * How much sharpness should be applied (default: 0.3)
  70228. */
  70229. edgeAmount: number;
  70230. /**
  70231. * Gets a string identifying the name of the class
  70232. * @returns "SharpenPostProcess" string
  70233. */
  70234. getClassName(): string;
  70235. /**
  70236. * Creates a new instance ConvolutionPostProcess
  70237. * @param name The name of the effect.
  70238. * @param options The required width/height ratio to downsize to before computing the render pass.
  70239. * @param camera The camera to apply the render pass to.
  70240. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70241. * @param engine The engine which the post process will be applied. (default: current engine)
  70242. * @param reusable If the post process can be reused on the same frame. (default: false)
  70243. * @param textureType Type of textures used when performing the post process. (default: 0)
  70244. * @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)
  70245. */
  70246. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70247. /** @hidden */
  70248. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70249. }
  70250. }
  70251. declare module BABYLON {
  70252. /**
  70253. * PostProcessRenderPipeline
  70254. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70255. */
  70256. export class PostProcessRenderPipeline {
  70257. private engine;
  70258. private _renderEffects;
  70259. private _renderEffectsForIsolatedPass;
  70260. /**
  70261. * List of inspectable custom properties (used by the Inspector)
  70262. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70263. */
  70264. inspectableCustomProperties: IInspectable[];
  70265. /**
  70266. * @hidden
  70267. */
  70268. protected _cameras: Camera[];
  70269. /** @hidden */
  70270. _name: string;
  70271. /**
  70272. * Gets pipeline name
  70273. */
  70274. get name(): string;
  70275. /** Gets the list of attached cameras */
  70276. get cameras(): Camera[];
  70277. /**
  70278. * Initializes a PostProcessRenderPipeline
  70279. * @param engine engine to add the pipeline to
  70280. * @param name name of the pipeline
  70281. */
  70282. constructor(engine: Engine, name: string);
  70283. /**
  70284. * Gets the class name
  70285. * @returns "PostProcessRenderPipeline"
  70286. */
  70287. getClassName(): string;
  70288. /**
  70289. * If all the render effects in the pipeline are supported
  70290. */
  70291. get isSupported(): boolean;
  70292. /**
  70293. * Adds an effect to the pipeline
  70294. * @param renderEffect the effect to add
  70295. */
  70296. addEffect(renderEffect: PostProcessRenderEffect): void;
  70297. /** @hidden */
  70298. _rebuild(): void;
  70299. /** @hidden */
  70300. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70301. /** @hidden */
  70302. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70303. /** @hidden */
  70304. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70305. /** @hidden */
  70306. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70307. /** @hidden */
  70308. _attachCameras(cameras: Camera, unique: boolean): void;
  70309. /** @hidden */
  70310. _attachCameras(cameras: Camera[], unique: boolean): void;
  70311. /** @hidden */
  70312. _detachCameras(cameras: Camera): void;
  70313. /** @hidden */
  70314. _detachCameras(cameras: Nullable<Camera[]>): void;
  70315. /** @hidden */
  70316. _update(): void;
  70317. /** @hidden */
  70318. _reset(): void;
  70319. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70320. /**
  70321. * Sets the required values to the prepass renderer.
  70322. * @param prePassRenderer defines the prepass renderer to setup.
  70323. * @returns true if the pre pass is needed.
  70324. */
  70325. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70326. /**
  70327. * Disposes of the pipeline
  70328. */
  70329. dispose(): void;
  70330. }
  70331. }
  70332. declare module BABYLON {
  70333. /**
  70334. * PostProcessRenderPipelineManager class
  70335. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70336. */
  70337. export class PostProcessRenderPipelineManager {
  70338. private _renderPipelines;
  70339. /**
  70340. * Initializes a PostProcessRenderPipelineManager
  70341. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70342. */
  70343. constructor();
  70344. /**
  70345. * Gets the list of supported render pipelines
  70346. */
  70347. get supportedPipelines(): PostProcessRenderPipeline[];
  70348. /**
  70349. * Adds a pipeline to the manager
  70350. * @param renderPipeline The pipeline to add
  70351. */
  70352. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70353. /**
  70354. * Attaches a camera to the pipeline
  70355. * @param renderPipelineName The name of the pipeline to attach to
  70356. * @param cameras the camera to attach
  70357. * @param unique if the camera can be attached multiple times to the pipeline
  70358. */
  70359. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70360. /**
  70361. * Detaches a camera from the pipeline
  70362. * @param renderPipelineName The name of the pipeline to detach from
  70363. * @param cameras the camera to detach
  70364. */
  70365. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70366. /**
  70367. * Enables an effect by name on a pipeline
  70368. * @param renderPipelineName the name of the pipeline to enable the effect in
  70369. * @param renderEffectName the name of the effect to enable
  70370. * @param cameras the cameras that the effect should be enabled on
  70371. */
  70372. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70373. /**
  70374. * Disables an effect by name on a pipeline
  70375. * @param renderPipelineName the name of the pipeline to disable the effect in
  70376. * @param renderEffectName the name of the effect to disable
  70377. * @param cameras the cameras that the effect should be disabled on
  70378. */
  70379. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70380. /**
  70381. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70382. */
  70383. update(): void;
  70384. /** @hidden */
  70385. _rebuild(): void;
  70386. /**
  70387. * Disposes of the manager and pipelines
  70388. */
  70389. dispose(): void;
  70390. }
  70391. }
  70392. declare module BABYLON {
  70393. interface Scene {
  70394. /** @hidden (Backing field) */
  70395. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70396. /**
  70397. * Gets the postprocess render pipeline manager
  70398. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70399. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70400. */
  70401. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70402. }
  70403. /**
  70404. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70405. */
  70406. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70407. /**
  70408. * The component name helpfull to identify the component in the list of scene components.
  70409. */
  70410. readonly name: string;
  70411. /**
  70412. * The scene the component belongs to.
  70413. */
  70414. scene: Scene;
  70415. /**
  70416. * Creates a new instance of the component for the given scene
  70417. * @param scene Defines the scene to register the component in
  70418. */
  70419. constructor(scene: Scene);
  70420. /**
  70421. * Registers the component in a given scene
  70422. */
  70423. register(): void;
  70424. /**
  70425. * Rebuilds the elements related to this component in case of
  70426. * context lost for instance.
  70427. */
  70428. rebuild(): void;
  70429. /**
  70430. * Disposes the component and the associated ressources
  70431. */
  70432. dispose(): void;
  70433. private _gatherRenderTargets;
  70434. }
  70435. }
  70436. declare module BABYLON {
  70437. /**
  70438. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70439. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70440. */
  70441. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70442. private _scene;
  70443. private _camerasToBeAttached;
  70444. /**
  70445. * ID of the sharpen post process,
  70446. */
  70447. private readonly SharpenPostProcessId;
  70448. /**
  70449. * @ignore
  70450. * ID of the image processing post process;
  70451. */
  70452. readonly ImageProcessingPostProcessId: string;
  70453. /**
  70454. * @ignore
  70455. * ID of the Fast Approximate Anti-Aliasing post process;
  70456. */
  70457. readonly FxaaPostProcessId: string;
  70458. /**
  70459. * ID of the chromatic aberration post process,
  70460. */
  70461. private readonly ChromaticAberrationPostProcessId;
  70462. /**
  70463. * ID of the grain post process
  70464. */
  70465. private readonly GrainPostProcessId;
  70466. /**
  70467. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70468. */
  70469. sharpen: SharpenPostProcess;
  70470. private _sharpenEffect;
  70471. private bloom;
  70472. /**
  70473. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70474. */
  70475. depthOfField: DepthOfFieldEffect;
  70476. /**
  70477. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70478. */
  70479. fxaa: FxaaPostProcess;
  70480. /**
  70481. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70482. */
  70483. imageProcessing: ImageProcessingPostProcess;
  70484. /**
  70485. * Chromatic aberration post process which will shift rgb colors in the image
  70486. */
  70487. chromaticAberration: ChromaticAberrationPostProcess;
  70488. private _chromaticAberrationEffect;
  70489. /**
  70490. * Grain post process which add noise to the image
  70491. */
  70492. grain: GrainPostProcess;
  70493. private _grainEffect;
  70494. /**
  70495. * Glow post process which adds a glow to emissive areas of the image
  70496. */
  70497. private _glowLayer;
  70498. /**
  70499. * Animations which can be used to tweak settings over a period of time
  70500. */
  70501. animations: Animation[];
  70502. private _imageProcessingConfigurationObserver;
  70503. private _sharpenEnabled;
  70504. private _bloomEnabled;
  70505. private _depthOfFieldEnabled;
  70506. private _depthOfFieldBlurLevel;
  70507. private _fxaaEnabled;
  70508. private _imageProcessingEnabled;
  70509. private _defaultPipelineTextureType;
  70510. private _bloomScale;
  70511. private _chromaticAberrationEnabled;
  70512. private _grainEnabled;
  70513. private _buildAllowed;
  70514. /**
  70515. * Gets active scene
  70516. */
  70517. get scene(): Scene;
  70518. /**
  70519. * Enable or disable the sharpen process from the pipeline
  70520. */
  70521. set sharpenEnabled(enabled: boolean);
  70522. get sharpenEnabled(): boolean;
  70523. private _resizeObserver;
  70524. private _hardwareScaleLevel;
  70525. private _bloomKernel;
  70526. /**
  70527. * Specifies the size of the bloom blur kernel, relative to the final output size
  70528. */
  70529. get bloomKernel(): number;
  70530. set bloomKernel(value: number);
  70531. /**
  70532. * Specifies the weight of the bloom in the final rendering
  70533. */
  70534. private _bloomWeight;
  70535. /**
  70536. * Specifies the luma threshold for the area that will be blurred by the bloom
  70537. */
  70538. private _bloomThreshold;
  70539. private _hdr;
  70540. /**
  70541. * The strength of the bloom.
  70542. */
  70543. set bloomWeight(value: number);
  70544. get bloomWeight(): number;
  70545. /**
  70546. * The strength of the bloom.
  70547. */
  70548. set bloomThreshold(value: number);
  70549. get bloomThreshold(): number;
  70550. /**
  70551. * The scale of the bloom, lower value will provide better performance.
  70552. */
  70553. set bloomScale(value: number);
  70554. get bloomScale(): number;
  70555. /**
  70556. * Enable or disable the bloom from the pipeline
  70557. */
  70558. set bloomEnabled(enabled: boolean);
  70559. get bloomEnabled(): boolean;
  70560. private _rebuildBloom;
  70561. /**
  70562. * If the depth of field is enabled.
  70563. */
  70564. get depthOfFieldEnabled(): boolean;
  70565. set depthOfFieldEnabled(enabled: boolean);
  70566. /**
  70567. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70568. */
  70569. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70570. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70571. /**
  70572. * If the anti aliasing is enabled.
  70573. */
  70574. set fxaaEnabled(enabled: boolean);
  70575. get fxaaEnabled(): boolean;
  70576. private _samples;
  70577. /**
  70578. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70579. */
  70580. set samples(sampleCount: number);
  70581. get samples(): number;
  70582. /**
  70583. * If image processing is enabled.
  70584. */
  70585. set imageProcessingEnabled(enabled: boolean);
  70586. get imageProcessingEnabled(): boolean;
  70587. /**
  70588. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70589. */
  70590. set glowLayerEnabled(enabled: boolean);
  70591. get glowLayerEnabled(): boolean;
  70592. /**
  70593. * Gets the glow layer (or null if not defined)
  70594. */
  70595. get glowLayer(): Nullable<GlowLayer>;
  70596. /**
  70597. * Enable or disable the chromaticAberration process from the pipeline
  70598. */
  70599. set chromaticAberrationEnabled(enabled: boolean);
  70600. get chromaticAberrationEnabled(): boolean;
  70601. /**
  70602. * Enable or disable the grain process from the pipeline
  70603. */
  70604. set grainEnabled(enabled: boolean);
  70605. get grainEnabled(): boolean;
  70606. /**
  70607. * @constructor
  70608. * @param name - The rendering pipeline name (default: "")
  70609. * @param hdr - If high dynamic range textures should be used (default: true)
  70610. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70611. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70612. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70613. */
  70614. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70615. /**
  70616. * Get the class name
  70617. * @returns "DefaultRenderingPipeline"
  70618. */
  70619. getClassName(): string;
  70620. /**
  70621. * Force the compilation of the entire pipeline.
  70622. */
  70623. prepare(): void;
  70624. private _hasCleared;
  70625. private _prevPostProcess;
  70626. private _prevPrevPostProcess;
  70627. private _setAutoClearAndTextureSharing;
  70628. private _depthOfFieldSceneObserver;
  70629. private _buildPipeline;
  70630. private _disposePostProcesses;
  70631. /**
  70632. * Adds a camera to the pipeline
  70633. * @param camera the camera to be added
  70634. */
  70635. addCamera(camera: Camera): void;
  70636. /**
  70637. * Removes a camera from the pipeline
  70638. * @param camera the camera to remove
  70639. */
  70640. removeCamera(camera: Camera): void;
  70641. /**
  70642. * Dispose of the pipeline and stop all post processes
  70643. */
  70644. dispose(): void;
  70645. /**
  70646. * Serialize the rendering pipeline (Used when exporting)
  70647. * @returns the serialized object
  70648. */
  70649. serialize(): any;
  70650. /**
  70651. * Parse the serialized pipeline
  70652. * @param source Source pipeline.
  70653. * @param scene The scene to load the pipeline to.
  70654. * @param rootUrl The URL of the serialized pipeline.
  70655. * @returns An instantiated pipeline from the serialized object.
  70656. */
  70657. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70658. }
  70659. }
  70660. declare module BABYLON {
  70661. /** @hidden */
  70662. export var lensHighlightsPixelShader: {
  70663. name: string;
  70664. shader: string;
  70665. };
  70666. }
  70667. declare module BABYLON {
  70668. /** @hidden */
  70669. export var depthOfFieldPixelShader: {
  70670. name: string;
  70671. shader: string;
  70672. };
  70673. }
  70674. declare module BABYLON {
  70675. /**
  70676. * BABYLON.JS Chromatic Aberration GLSL Shader
  70677. * Author: Olivier Guyot
  70678. * Separates very slightly R, G and B colors on the edges of the screen
  70679. * Inspired by Francois Tarlier & Martins Upitis
  70680. */
  70681. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70682. /**
  70683. * @ignore
  70684. * The chromatic aberration PostProcess id in the pipeline
  70685. */
  70686. LensChromaticAberrationEffect: string;
  70687. /**
  70688. * @ignore
  70689. * The highlights enhancing PostProcess id in the pipeline
  70690. */
  70691. HighlightsEnhancingEffect: string;
  70692. /**
  70693. * @ignore
  70694. * The depth-of-field PostProcess id in the pipeline
  70695. */
  70696. LensDepthOfFieldEffect: string;
  70697. private _scene;
  70698. private _depthTexture;
  70699. private _grainTexture;
  70700. private _chromaticAberrationPostProcess;
  70701. private _highlightsPostProcess;
  70702. private _depthOfFieldPostProcess;
  70703. private _edgeBlur;
  70704. private _grainAmount;
  70705. private _chromaticAberration;
  70706. private _distortion;
  70707. private _highlightsGain;
  70708. private _highlightsThreshold;
  70709. private _dofDistance;
  70710. private _dofAperture;
  70711. private _dofDarken;
  70712. private _dofPentagon;
  70713. private _blurNoise;
  70714. /**
  70715. * @constructor
  70716. *
  70717. * Effect parameters are as follow:
  70718. * {
  70719. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70720. * edge_blur: number; // from 0 to x (1 for realism)
  70721. * distortion: number; // from 0 to x (1 for realism)
  70722. * grain_amount: number; // from 0 to 1
  70723. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70724. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70725. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70726. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70727. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70728. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70729. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70730. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70731. * }
  70732. * Note: if an effect parameter is unset, effect is disabled
  70733. *
  70734. * @param name The rendering pipeline name
  70735. * @param parameters - An object containing all parameters (see above)
  70736. * @param scene The scene linked to this pipeline
  70737. * @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)
  70738. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70739. */
  70740. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70741. /**
  70742. * Get the class name
  70743. * @returns "LensRenderingPipeline"
  70744. */
  70745. getClassName(): string;
  70746. /**
  70747. * Gets associated scene
  70748. */
  70749. get scene(): Scene;
  70750. /**
  70751. * Gets or sets the edge blur
  70752. */
  70753. get edgeBlur(): number;
  70754. set edgeBlur(value: number);
  70755. /**
  70756. * Gets or sets the grain amount
  70757. */
  70758. get grainAmount(): number;
  70759. set grainAmount(value: number);
  70760. /**
  70761. * Gets or sets the chromatic aberration amount
  70762. */
  70763. get chromaticAberration(): number;
  70764. set chromaticAberration(value: number);
  70765. /**
  70766. * Gets or sets the depth of field aperture
  70767. */
  70768. get dofAperture(): number;
  70769. set dofAperture(value: number);
  70770. /**
  70771. * Gets or sets the edge distortion
  70772. */
  70773. get edgeDistortion(): number;
  70774. set edgeDistortion(value: number);
  70775. /**
  70776. * Gets or sets the depth of field distortion
  70777. */
  70778. get dofDistortion(): number;
  70779. set dofDistortion(value: number);
  70780. /**
  70781. * Gets or sets the darken out of focus amount
  70782. */
  70783. get darkenOutOfFocus(): number;
  70784. set darkenOutOfFocus(value: number);
  70785. /**
  70786. * Gets or sets a boolean indicating if blur noise is enabled
  70787. */
  70788. get blurNoise(): boolean;
  70789. set blurNoise(value: boolean);
  70790. /**
  70791. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70792. */
  70793. get pentagonBokeh(): boolean;
  70794. set pentagonBokeh(value: boolean);
  70795. /**
  70796. * Gets or sets the highlight grain amount
  70797. */
  70798. get highlightsGain(): number;
  70799. set highlightsGain(value: number);
  70800. /**
  70801. * Gets or sets the highlight threshold
  70802. */
  70803. get highlightsThreshold(): number;
  70804. set highlightsThreshold(value: number);
  70805. /**
  70806. * Sets the amount of blur at the edges
  70807. * @param amount blur amount
  70808. */
  70809. setEdgeBlur(amount: number): void;
  70810. /**
  70811. * Sets edge blur to 0
  70812. */
  70813. disableEdgeBlur(): void;
  70814. /**
  70815. * Sets the amout of grain
  70816. * @param amount Amount of grain
  70817. */
  70818. setGrainAmount(amount: number): void;
  70819. /**
  70820. * Set grain amount to 0
  70821. */
  70822. disableGrain(): void;
  70823. /**
  70824. * Sets the chromatic aberration amount
  70825. * @param amount amount of chromatic aberration
  70826. */
  70827. setChromaticAberration(amount: number): void;
  70828. /**
  70829. * Sets chromatic aberration amount to 0
  70830. */
  70831. disableChromaticAberration(): void;
  70832. /**
  70833. * Sets the EdgeDistortion amount
  70834. * @param amount amount of EdgeDistortion
  70835. */
  70836. setEdgeDistortion(amount: number): void;
  70837. /**
  70838. * Sets edge distortion to 0
  70839. */
  70840. disableEdgeDistortion(): void;
  70841. /**
  70842. * Sets the FocusDistance amount
  70843. * @param amount amount of FocusDistance
  70844. */
  70845. setFocusDistance(amount: number): void;
  70846. /**
  70847. * Disables depth of field
  70848. */
  70849. disableDepthOfField(): void;
  70850. /**
  70851. * Sets the Aperture amount
  70852. * @param amount amount of Aperture
  70853. */
  70854. setAperture(amount: number): void;
  70855. /**
  70856. * Sets the DarkenOutOfFocus amount
  70857. * @param amount amount of DarkenOutOfFocus
  70858. */
  70859. setDarkenOutOfFocus(amount: number): void;
  70860. private _pentagonBokehIsEnabled;
  70861. /**
  70862. * Creates a pentagon bokeh effect
  70863. */
  70864. enablePentagonBokeh(): void;
  70865. /**
  70866. * Disables the pentagon bokeh effect
  70867. */
  70868. disablePentagonBokeh(): void;
  70869. /**
  70870. * Enables noise blur
  70871. */
  70872. enableNoiseBlur(): void;
  70873. /**
  70874. * Disables noise blur
  70875. */
  70876. disableNoiseBlur(): void;
  70877. /**
  70878. * Sets the HighlightsGain amount
  70879. * @param amount amount of HighlightsGain
  70880. */
  70881. setHighlightsGain(amount: number): void;
  70882. /**
  70883. * Sets the HighlightsThreshold amount
  70884. * @param amount amount of HighlightsThreshold
  70885. */
  70886. setHighlightsThreshold(amount: number): void;
  70887. /**
  70888. * Disables highlights
  70889. */
  70890. disableHighlights(): void;
  70891. /**
  70892. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70893. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70894. */
  70895. dispose(disableDepthRender?: boolean): void;
  70896. private _createChromaticAberrationPostProcess;
  70897. private _createHighlightsPostProcess;
  70898. private _createDepthOfFieldPostProcess;
  70899. private _createGrainTexture;
  70900. }
  70901. }
  70902. declare module BABYLON {
  70903. /** @hidden */
  70904. export var ssao2PixelShader: {
  70905. name: string;
  70906. shader: string;
  70907. };
  70908. }
  70909. declare module BABYLON {
  70910. /** @hidden */
  70911. export var ssaoCombinePixelShader: {
  70912. name: string;
  70913. shader: string;
  70914. };
  70915. }
  70916. declare module BABYLON {
  70917. /**
  70918. * Render pipeline to produce ssao effect
  70919. */
  70920. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70921. /**
  70922. * @ignore
  70923. * The PassPostProcess id in the pipeline that contains the original scene color
  70924. */
  70925. SSAOOriginalSceneColorEffect: string;
  70926. /**
  70927. * @ignore
  70928. * The SSAO PostProcess id in the pipeline
  70929. */
  70930. SSAORenderEffect: string;
  70931. /**
  70932. * @ignore
  70933. * The horizontal blur PostProcess id in the pipeline
  70934. */
  70935. SSAOBlurHRenderEffect: string;
  70936. /**
  70937. * @ignore
  70938. * The vertical blur PostProcess id in the pipeline
  70939. */
  70940. SSAOBlurVRenderEffect: string;
  70941. /**
  70942. * @ignore
  70943. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70944. */
  70945. SSAOCombineRenderEffect: string;
  70946. /**
  70947. * The output strength of the SSAO post-process. Default value is 1.0.
  70948. */
  70949. totalStrength: number;
  70950. /**
  70951. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70952. */
  70953. maxZ: number;
  70954. /**
  70955. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70956. */
  70957. minZAspect: number;
  70958. private _samples;
  70959. /**
  70960. * Number of samples used for the SSAO calculations. Default value is 8
  70961. */
  70962. set samples(n: number);
  70963. get samples(): number;
  70964. private _textureSamples;
  70965. /**
  70966. * Number of samples to use for antialiasing
  70967. */
  70968. set textureSamples(n: number);
  70969. get textureSamples(): number;
  70970. /**
  70971. * Force rendering the geometry through geometry buffer
  70972. */
  70973. private _forceGeometryBuffer;
  70974. /**
  70975. * Ratio object used for SSAO ratio and blur ratio
  70976. */
  70977. private _ratio;
  70978. /**
  70979. * Dynamically generated sphere sampler.
  70980. */
  70981. private _sampleSphere;
  70982. /**
  70983. * Blur filter offsets
  70984. */
  70985. private _samplerOffsets;
  70986. private _expensiveBlur;
  70987. /**
  70988. * If bilateral blur should be used
  70989. */
  70990. set expensiveBlur(b: boolean);
  70991. get expensiveBlur(): boolean;
  70992. /**
  70993. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70994. */
  70995. radius: number;
  70996. /**
  70997. * The base color of the SSAO post-process
  70998. * The final result is "base + ssao" between [0, 1]
  70999. */
  71000. base: number;
  71001. /**
  71002. * Support test.
  71003. */
  71004. static get IsSupported(): boolean;
  71005. private _scene;
  71006. private _randomTexture;
  71007. private _originalColorPostProcess;
  71008. private _ssaoPostProcess;
  71009. private _blurHPostProcess;
  71010. private _blurVPostProcess;
  71011. private _ssaoCombinePostProcess;
  71012. private _prePassRenderer;
  71013. /**
  71014. * Gets active scene
  71015. */
  71016. get scene(): Scene;
  71017. /**
  71018. * @constructor
  71019. * @param name The rendering pipeline name
  71020. * @param scene The scene linked to this pipeline
  71021. * @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 }
  71022. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71023. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71024. */
  71025. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71026. /**
  71027. * Get the class name
  71028. * @returns "SSAO2RenderingPipeline"
  71029. */
  71030. getClassName(): string;
  71031. /**
  71032. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71033. */
  71034. dispose(disableGeometryBufferRenderer?: boolean): void;
  71035. private _createBlurPostProcess;
  71036. /** @hidden */
  71037. _rebuild(): void;
  71038. private _bits;
  71039. private _radicalInverse_VdC;
  71040. private _hammersley;
  71041. private _hemisphereSample_uniform;
  71042. private _generateHemisphere;
  71043. private _getDefinesForSSAO;
  71044. private _createSSAOPostProcess;
  71045. private _createSSAOCombinePostProcess;
  71046. private _createRandomTexture;
  71047. /**
  71048. * Serialize the rendering pipeline (Used when exporting)
  71049. * @returns the serialized object
  71050. */
  71051. serialize(): any;
  71052. /**
  71053. * Parse the serialized pipeline
  71054. * @param source Source pipeline.
  71055. * @param scene The scene to load the pipeline to.
  71056. * @param rootUrl The URL of the serialized pipeline.
  71057. * @returns An instantiated pipeline from the serialized object.
  71058. */
  71059. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71060. /**
  71061. * Sets the required values to the prepass renderer.
  71062. * @param prePassRenderer defines the prepass renderer to setup
  71063. * @returns true if the pre pass is needed.
  71064. */
  71065. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71066. }
  71067. }
  71068. declare module BABYLON {
  71069. /** @hidden */
  71070. export var ssaoPixelShader: {
  71071. name: string;
  71072. shader: string;
  71073. };
  71074. }
  71075. declare module BABYLON {
  71076. /**
  71077. * Render pipeline to produce ssao effect
  71078. */
  71079. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71080. /**
  71081. * @ignore
  71082. * The PassPostProcess id in the pipeline that contains the original scene color
  71083. */
  71084. SSAOOriginalSceneColorEffect: string;
  71085. /**
  71086. * @ignore
  71087. * The SSAO PostProcess id in the pipeline
  71088. */
  71089. SSAORenderEffect: string;
  71090. /**
  71091. * @ignore
  71092. * The horizontal blur PostProcess id in the pipeline
  71093. */
  71094. SSAOBlurHRenderEffect: string;
  71095. /**
  71096. * @ignore
  71097. * The vertical blur PostProcess id in the pipeline
  71098. */
  71099. SSAOBlurVRenderEffect: string;
  71100. /**
  71101. * @ignore
  71102. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71103. */
  71104. SSAOCombineRenderEffect: string;
  71105. /**
  71106. * The output strength of the SSAO post-process. Default value is 1.0.
  71107. */
  71108. totalStrength: number;
  71109. /**
  71110. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71111. */
  71112. radius: number;
  71113. /**
  71114. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71115. * Must not be equal to fallOff and superior to fallOff.
  71116. * Default value is 0.0075
  71117. */
  71118. area: number;
  71119. /**
  71120. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71121. * Must not be equal to area and inferior to area.
  71122. * Default value is 0.000001
  71123. */
  71124. fallOff: number;
  71125. /**
  71126. * The base color of the SSAO post-process
  71127. * The final result is "base + ssao" between [0, 1]
  71128. */
  71129. base: number;
  71130. private _scene;
  71131. private _depthTexture;
  71132. private _randomTexture;
  71133. private _originalColorPostProcess;
  71134. private _ssaoPostProcess;
  71135. private _blurHPostProcess;
  71136. private _blurVPostProcess;
  71137. private _ssaoCombinePostProcess;
  71138. private _firstUpdate;
  71139. /**
  71140. * Gets active scene
  71141. */
  71142. get scene(): Scene;
  71143. /**
  71144. * @constructor
  71145. * @param name - The rendering pipeline name
  71146. * @param scene - The scene linked to this pipeline
  71147. * @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 }
  71148. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71149. */
  71150. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71151. /**
  71152. * Get the class name
  71153. * @returns "SSAORenderingPipeline"
  71154. */
  71155. getClassName(): string;
  71156. /**
  71157. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71158. */
  71159. dispose(disableDepthRender?: boolean): void;
  71160. private _createBlurPostProcess;
  71161. /** @hidden */
  71162. _rebuild(): void;
  71163. private _createSSAOPostProcess;
  71164. private _createSSAOCombinePostProcess;
  71165. private _createRandomTexture;
  71166. }
  71167. }
  71168. declare module BABYLON {
  71169. /** @hidden */
  71170. export var screenSpaceReflectionPixelShader: {
  71171. name: string;
  71172. shader: string;
  71173. };
  71174. }
  71175. declare module BABYLON {
  71176. /**
  71177. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71178. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71179. */
  71180. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71181. /**
  71182. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71183. */
  71184. threshold: number;
  71185. /**
  71186. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71187. */
  71188. strength: number;
  71189. /**
  71190. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71191. */
  71192. reflectionSpecularFalloffExponent: number;
  71193. /**
  71194. * 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]
  71195. */
  71196. step: number;
  71197. /**
  71198. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71199. */
  71200. roughnessFactor: number;
  71201. private _geometryBufferRenderer;
  71202. private _enableSmoothReflections;
  71203. private _reflectionSamples;
  71204. private _smoothSteps;
  71205. /**
  71206. * Gets a string identifying the name of the class
  71207. * @returns "ScreenSpaceReflectionPostProcess" string
  71208. */
  71209. getClassName(): string;
  71210. /**
  71211. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71212. * @param name The name of the effect.
  71213. * @param scene The scene containing the objects to calculate reflections.
  71214. * @param options The required width/height ratio to downsize to before computing the render pass.
  71215. * @param camera The camera to apply the render pass to.
  71216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71217. * @param engine The engine which the post process will be applied. (default: current engine)
  71218. * @param reusable If the post process can be reused on the same frame. (default: false)
  71219. * @param textureType Type of textures used when performing the post process. (default: 0)
  71220. * @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)
  71221. */
  71222. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71223. /**
  71224. * Gets wether or not smoothing reflections is enabled.
  71225. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71226. */
  71227. get enableSmoothReflections(): boolean;
  71228. /**
  71229. * Sets wether or not smoothing reflections is enabled.
  71230. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71231. */
  71232. set enableSmoothReflections(enabled: boolean);
  71233. /**
  71234. * Gets the number of samples taken while computing reflections. More samples count is high,
  71235. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71236. */
  71237. get reflectionSamples(): number;
  71238. /**
  71239. * Sets the number of samples taken while computing reflections. More samples count is high,
  71240. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71241. */
  71242. set reflectionSamples(samples: number);
  71243. /**
  71244. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71245. * more the post-process will require GPU power and can generate a drop in FPS.
  71246. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71247. */
  71248. get smoothSteps(): number;
  71249. set smoothSteps(steps: number);
  71250. private _updateEffectDefines;
  71251. /** @hidden */
  71252. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71253. }
  71254. }
  71255. declare module BABYLON {
  71256. /** @hidden */
  71257. export var standardPixelShader: {
  71258. name: string;
  71259. shader: string;
  71260. };
  71261. }
  71262. declare module BABYLON {
  71263. /**
  71264. * Standard rendering pipeline
  71265. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71266. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71267. */
  71268. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71269. /**
  71270. * Public members
  71271. */
  71272. /**
  71273. * Post-process which contains the original scene color before the pipeline applies all the effects
  71274. */
  71275. originalPostProcess: Nullable<PostProcess>;
  71276. /**
  71277. * Post-process used to down scale an image x4
  71278. */
  71279. downSampleX4PostProcess: Nullable<PostProcess>;
  71280. /**
  71281. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71282. */
  71283. brightPassPostProcess: Nullable<PostProcess>;
  71284. /**
  71285. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71286. */
  71287. blurHPostProcesses: PostProcess[];
  71288. /**
  71289. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71290. */
  71291. blurVPostProcesses: PostProcess[];
  71292. /**
  71293. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71294. */
  71295. textureAdderPostProcess: Nullable<PostProcess>;
  71296. /**
  71297. * Post-process used to create volumetric lighting effect
  71298. */
  71299. volumetricLightPostProcess: Nullable<PostProcess>;
  71300. /**
  71301. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71302. */
  71303. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71304. /**
  71305. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71306. */
  71307. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71308. /**
  71309. * Post-process used to merge the volumetric light effect and the real scene color
  71310. */
  71311. volumetricLightMergePostProces: Nullable<PostProcess>;
  71312. /**
  71313. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71314. */
  71315. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71316. /**
  71317. * Base post-process used to calculate the average luminance of the final image for HDR
  71318. */
  71319. luminancePostProcess: Nullable<PostProcess>;
  71320. /**
  71321. * Post-processes used to create down sample post-processes in order to get
  71322. * the average luminance of the final image for HDR
  71323. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71324. */
  71325. luminanceDownSamplePostProcesses: PostProcess[];
  71326. /**
  71327. * Post-process used to create a HDR effect (light adaptation)
  71328. */
  71329. hdrPostProcess: Nullable<PostProcess>;
  71330. /**
  71331. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71332. */
  71333. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71334. /**
  71335. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71336. */
  71337. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71338. /**
  71339. * Post-process used to merge the final HDR post-process and the real scene color
  71340. */
  71341. hdrFinalPostProcess: Nullable<PostProcess>;
  71342. /**
  71343. * Post-process used to create a lens flare effect
  71344. */
  71345. lensFlarePostProcess: Nullable<PostProcess>;
  71346. /**
  71347. * Post-process that merges the result of the lens flare post-process and the real scene color
  71348. */
  71349. lensFlareComposePostProcess: Nullable<PostProcess>;
  71350. /**
  71351. * Post-process used to create a motion blur effect
  71352. */
  71353. motionBlurPostProcess: Nullable<PostProcess>;
  71354. /**
  71355. * Post-process used to create a depth of field effect
  71356. */
  71357. depthOfFieldPostProcess: Nullable<PostProcess>;
  71358. /**
  71359. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71360. */
  71361. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71362. /**
  71363. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71364. */
  71365. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71366. /**
  71367. * Represents the brightness threshold in order to configure the illuminated surfaces
  71368. */
  71369. brightThreshold: number;
  71370. /**
  71371. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71372. */
  71373. blurWidth: number;
  71374. /**
  71375. * Sets if the blur for highlighted surfaces must be only horizontal
  71376. */
  71377. horizontalBlur: boolean;
  71378. /**
  71379. * Gets the overall exposure used by the pipeline
  71380. */
  71381. get exposure(): number;
  71382. /**
  71383. * Sets the overall exposure used by the pipeline
  71384. */
  71385. set exposure(value: number);
  71386. /**
  71387. * Texture used typically to simulate "dirty" on camera lens
  71388. */
  71389. lensTexture: Nullable<Texture>;
  71390. /**
  71391. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71392. */
  71393. volumetricLightCoefficient: number;
  71394. /**
  71395. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71396. */
  71397. volumetricLightPower: number;
  71398. /**
  71399. * Used the set the blur intensity to smooth the volumetric lights
  71400. */
  71401. volumetricLightBlurScale: number;
  71402. /**
  71403. * Light (spot or directional) used to generate the volumetric lights rays
  71404. * The source light must have a shadow generate so the pipeline can get its
  71405. * depth map
  71406. */
  71407. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71408. /**
  71409. * For eye adaptation, represents the minimum luminance the eye can see
  71410. */
  71411. hdrMinimumLuminance: number;
  71412. /**
  71413. * For eye adaptation, represents the decrease luminance speed
  71414. */
  71415. hdrDecreaseRate: number;
  71416. /**
  71417. * For eye adaptation, represents the increase luminance speed
  71418. */
  71419. hdrIncreaseRate: number;
  71420. /**
  71421. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71422. */
  71423. get hdrAutoExposure(): boolean;
  71424. /**
  71425. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71426. */
  71427. set hdrAutoExposure(value: boolean);
  71428. /**
  71429. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71430. */
  71431. lensColorTexture: Nullable<Texture>;
  71432. /**
  71433. * The overall strengh for the lens flare effect
  71434. */
  71435. lensFlareStrength: number;
  71436. /**
  71437. * Dispersion coefficient for lens flare ghosts
  71438. */
  71439. lensFlareGhostDispersal: number;
  71440. /**
  71441. * Main lens flare halo width
  71442. */
  71443. lensFlareHaloWidth: number;
  71444. /**
  71445. * Based on the lens distortion effect, defines how much the lens flare result
  71446. * is distorted
  71447. */
  71448. lensFlareDistortionStrength: number;
  71449. /**
  71450. * Configures the blur intensity used for for lens flare (halo)
  71451. */
  71452. lensFlareBlurWidth: number;
  71453. /**
  71454. * Lens star texture must be used to simulate rays on the flares and is available
  71455. * in the documentation
  71456. */
  71457. lensStarTexture: Nullable<Texture>;
  71458. /**
  71459. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71460. * flare effect by taking account of the dirt texture
  71461. */
  71462. lensFlareDirtTexture: Nullable<Texture>;
  71463. /**
  71464. * Represents the focal length for the depth of field effect
  71465. */
  71466. depthOfFieldDistance: number;
  71467. /**
  71468. * Represents the blur intensity for the blurred part of the depth of field effect
  71469. */
  71470. depthOfFieldBlurWidth: number;
  71471. /**
  71472. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71473. */
  71474. get motionStrength(): number;
  71475. /**
  71476. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71477. */
  71478. set motionStrength(strength: number);
  71479. /**
  71480. * Gets wether or not the motion blur post-process is object based or screen based.
  71481. */
  71482. get objectBasedMotionBlur(): boolean;
  71483. /**
  71484. * Sets wether or not the motion blur post-process should be object based or screen based
  71485. */
  71486. set objectBasedMotionBlur(value: boolean);
  71487. /**
  71488. * List of animations for the pipeline (IAnimatable implementation)
  71489. */
  71490. animations: Animation[];
  71491. /**
  71492. * Private members
  71493. */
  71494. private _scene;
  71495. private _currentDepthOfFieldSource;
  71496. private _basePostProcess;
  71497. private _fixedExposure;
  71498. private _currentExposure;
  71499. private _hdrAutoExposure;
  71500. private _hdrCurrentLuminance;
  71501. private _motionStrength;
  71502. private _isObjectBasedMotionBlur;
  71503. private _floatTextureType;
  71504. private _camerasToBeAttached;
  71505. private _ratio;
  71506. private _bloomEnabled;
  71507. private _depthOfFieldEnabled;
  71508. private _vlsEnabled;
  71509. private _lensFlareEnabled;
  71510. private _hdrEnabled;
  71511. private _motionBlurEnabled;
  71512. private _fxaaEnabled;
  71513. private _screenSpaceReflectionsEnabled;
  71514. private _motionBlurSamples;
  71515. private _volumetricLightStepsCount;
  71516. private _samples;
  71517. /**
  71518. * @ignore
  71519. * Specifies if the bloom pipeline is enabled
  71520. */
  71521. get BloomEnabled(): boolean;
  71522. set BloomEnabled(enabled: boolean);
  71523. /**
  71524. * @ignore
  71525. * Specifies if the depth of field pipeline is enabed
  71526. */
  71527. get DepthOfFieldEnabled(): boolean;
  71528. set DepthOfFieldEnabled(enabled: boolean);
  71529. /**
  71530. * @ignore
  71531. * Specifies if the lens flare pipeline is enabed
  71532. */
  71533. get LensFlareEnabled(): boolean;
  71534. set LensFlareEnabled(enabled: boolean);
  71535. /**
  71536. * @ignore
  71537. * Specifies if the HDR pipeline is enabled
  71538. */
  71539. get HDREnabled(): boolean;
  71540. set HDREnabled(enabled: boolean);
  71541. /**
  71542. * @ignore
  71543. * Specifies if the volumetric lights scattering effect is enabled
  71544. */
  71545. get VLSEnabled(): boolean;
  71546. set VLSEnabled(enabled: boolean);
  71547. /**
  71548. * @ignore
  71549. * Specifies if the motion blur effect is enabled
  71550. */
  71551. get MotionBlurEnabled(): boolean;
  71552. set MotionBlurEnabled(enabled: boolean);
  71553. /**
  71554. * Specifies if anti-aliasing is enabled
  71555. */
  71556. get fxaaEnabled(): boolean;
  71557. set fxaaEnabled(enabled: boolean);
  71558. /**
  71559. * Specifies if screen space reflections are enabled.
  71560. */
  71561. get screenSpaceReflectionsEnabled(): boolean;
  71562. set screenSpaceReflectionsEnabled(enabled: boolean);
  71563. /**
  71564. * Specifies the number of steps used to calculate the volumetric lights
  71565. * Typically in interval [50, 200]
  71566. */
  71567. get volumetricLightStepsCount(): number;
  71568. set volumetricLightStepsCount(count: number);
  71569. /**
  71570. * Specifies the number of samples used for the motion blur effect
  71571. * Typically in interval [16, 64]
  71572. */
  71573. get motionBlurSamples(): number;
  71574. set motionBlurSamples(samples: number);
  71575. /**
  71576. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71577. */
  71578. get samples(): number;
  71579. set samples(sampleCount: number);
  71580. /**
  71581. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71582. * @constructor
  71583. * @param name The rendering pipeline name
  71584. * @param scene The scene linked to this pipeline
  71585. * @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)
  71586. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71587. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71588. */
  71589. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71590. private _buildPipeline;
  71591. private _createDownSampleX4PostProcess;
  71592. private _createBrightPassPostProcess;
  71593. private _createBlurPostProcesses;
  71594. private _createTextureAdderPostProcess;
  71595. private _createVolumetricLightPostProcess;
  71596. private _createLuminancePostProcesses;
  71597. private _createHdrPostProcess;
  71598. private _createLensFlarePostProcess;
  71599. private _createDepthOfFieldPostProcess;
  71600. private _createMotionBlurPostProcess;
  71601. private _getDepthTexture;
  71602. private _disposePostProcesses;
  71603. /**
  71604. * Dispose of the pipeline and stop all post processes
  71605. */
  71606. dispose(): void;
  71607. /**
  71608. * Serialize the rendering pipeline (Used when exporting)
  71609. * @returns the serialized object
  71610. */
  71611. serialize(): any;
  71612. /**
  71613. * Parse the serialized pipeline
  71614. * @param source Source pipeline.
  71615. * @param scene The scene to load the pipeline to.
  71616. * @param rootUrl The URL of the serialized pipeline.
  71617. * @returns An instantiated pipeline from the serialized object.
  71618. */
  71619. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71620. /**
  71621. * Luminance steps
  71622. */
  71623. static LuminanceSteps: number;
  71624. }
  71625. }
  71626. declare module BABYLON {
  71627. /** @hidden */
  71628. export var stereoscopicInterlacePixelShader: {
  71629. name: string;
  71630. shader: string;
  71631. };
  71632. }
  71633. declare module BABYLON {
  71634. /**
  71635. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71636. */
  71637. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71638. private _stepSize;
  71639. private _passedProcess;
  71640. /**
  71641. * Gets a string identifying the name of the class
  71642. * @returns "StereoscopicInterlacePostProcessI" string
  71643. */
  71644. getClassName(): string;
  71645. /**
  71646. * Initializes a StereoscopicInterlacePostProcessI
  71647. * @param name The name of the effect.
  71648. * @param rigCameras The rig cameras to be appled to the post process
  71649. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71650. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71652. * @param engine The engine which the post process will be applied. (default: current engine)
  71653. * @param reusable If the post process can be reused on the same frame. (default: false)
  71654. */
  71655. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71656. }
  71657. /**
  71658. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71659. */
  71660. export class StereoscopicInterlacePostProcess extends PostProcess {
  71661. private _stepSize;
  71662. private _passedProcess;
  71663. /**
  71664. * Gets a string identifying the name of the class
  71665. * @returns "StereoscopicInterlacePostProcess" string
  71666. */
  71667. getClassName(): string;
  71668. /**
  71669. * Initializes a StereoscopicInterlacePostProcess
  71670. * @param name The name of the effect.
  71671. * @param rigCameras The rig cameras to be appled to the post process
  71672. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71673. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71674. * @param engine The engine which the post process will be applied. (default: current engine)
  71675. * @param reusable If the post process can be reused on the same frame. (default: false)
  71676. */
  71677. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71678. }
  71679. }
  71680. declare module BABYLON {
  71681. /** @hidden */
  71682. export var tonemapPixelShader: {
  71683. name: string;
  71684. shader: string;
  71685. };
  71686. }
  71687. declare module BABYLON {
  71688. /** Defines operator used for tonemapping */
  71689. export enum TonemappingOperator {
  71690. /** Hable */
  71691. Hable = 0,
  71692. /** Reinhard */
  71693. Reinhard = 1,
  71694. /** HejiDawson */
  71695. HejiDawson = 2,
  71696. /** Photographic */
  71697. Photographic = 3
  71698. }
  71699. /**
  71700. * Defines a post process to apply tone mapping
  71701. */
  71702. export class TonemapPostProcess extends PostProcess {
  71703. private _operator;
  71704. /** Defines the required exposure adjustement */
  71705. exposureAdjustment: number;
  71706. /**
  71707. * Gets a string identifying the name of the class
  71708. * @returns "TonemapPostProcess" string
  71709. */
  71710. getClassName(): string;
  71711. /**
  71712. * Creates a new TonemapPostProcess
  71713. * @param name defines the name of the postprocess
  71714. * @param _operator defines the operator to use
  71715. * @param exposureAdjustment defines the required exposure adjustement
  71716. * @param camera defines the camera to use (can be null)
  71717. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71718. * @param engine defines the hosting engine (can be ignore if camera is set)
  71719. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71720. */
  71721. constructor(name: string, _operator: TonemappingOperator,
  71722. /** Defines the required exposure adjustement */
  71723. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71724. }
  71725. }
  71726. declare module BABYLON {
  71727. /** @hidden */
  71728. export var volumetricLightScatteringPixelShader: {
  71729. name: string;
  71730. shader: string;
  71731. };
  71732. }
  71733. declare module BABYLON {
  71734. /** @hidden */
  71735. export var volumetricLightScatteringPassVertexShader: {
  71736. name: string;
  71737. shader: string;
  71738. };
  71739. }
  71740. declare module BABYLON {
  71741. /** @hidden */
  71742. export var volumetricLightScatteringPassPixelShader: {
  71743. name: string;
  71744. shader: string;
  71745. };
  71746. }
  71747. declare module BABYLON {
  71748. /**
  71749. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71750. */
  71751. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71752. private _volumetricLightScatteringPass;
  71753. private _volumetricLightScatteringRTT;
  71754. private _viewPort;
  71755. private _screenCoordinates;
  71756. private _cachedDefines;
  71757. /**
  71758. * If not undefined, the mesh position is computed from the attached node position
  71759. */
  71760. attachedNode: {
  71761. position: Vector3;
  71762. };
  71763. /**
  71764. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71765. */
  71766. customMeshPosition: Vector3;
  71767. /**
  71768. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71769. */
  71770. useCustomMeshPosition: boolean;
  71771. /**
  71772. * If the post-process should inverse the light scattering direction
  71773. */
  71774. invert: boolean;
  71775. /**
  71776. * The internal mesh used by the post-process
  71777. */
  71778. mesh: Mesh;
  71779. /**
  71780. * @hidden
  71781. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71782. */
  71783. get useDiffuseColor(): boolean;
  71784. set useDiffuseColor(useDiffuseColor: boolean);
  71785. /**
  71786. * Array containing the excluded meshes not rendered in the internal pass
  71787. */
  71788. excludedMeshes: AbstractMesh[];
  71789. /**
  71790. * Controls the overall intensity of the post-process
  71791. */
  71792. exposure: number;
  71793. /**
  71794. * Dissipates each sample's contribution in range [0, 1]
  71795. */
  71796. decay: number;
  71797. /**
  71798. * Controls the overall intensity of each sample
  71799. */
  71800. weight: number;
  71801. /**
  71802. * Controls the density of each sample
  71803. */
  71804. density: number;
  71805. /**
  71806. * @constructor
  71807. * @param name The post-process name
  71808. * @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)
  71809. * @param camera The camera that the post-process will be attached to
  71810. * @param mesh The mesh used to create the light scattering
  71811. * @param samples The post-process quality, default 100
  71812. * @param samplingModeThe post-process filtering mode
  71813. * @param engine The babylon engine
  71814. * @param reusable If the post-process is reusable
  71815. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71816. */
  71817. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71818. /**
  71819. * Returns the string "VolumetricLightScatteringPostProcess"
  71820. * @returns "VolumetricLightScatteringPostProcess"
  71821. */
  71822. getClassName(): string;
  71823. private _isReady;
  71824. /**
  71825. * Sets the new light position for light scattering effect
  71826. * @param position The new custom light position
  71827. */
  71828. setCustomMeshPosition(position: Vector3): void;
  71829. /**
  71830. * Returns the light position for light scattering effect
  71831. * @return Vector3 The custom light position
  71832. */
  71833. getCustomMeshPosition(): Vector3;
  71834. /**
  71835. * Disposes the internal assets and detaches the post-process from the camera
  71836. */
  71837. dispose(camera: Camera): void;
  71838. /**
  71839. * Returns the render target texture used by the post-process
  71840. * @return the render target texture used by the post-process
  71841. */
  71842. getPass(): RenderTargetTexture;
  71843. private _meshExcluded;
  71844. private _createPass;
  71845. private _updateMeshScreenCoordinates;
  71846. /**
  71847. * Creates a default mesh for the Volumeric Light Scattering post-process
  71848. * @param name The mesh name
  71849. * @param scene The scene where to create the mesh
  71850. * @return the default mesh
  71851. */
  71852. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71853. }
  71854. }
  71855. declare module BABYLON {
  71856. /** @hidden */
  71857. export var screenSpaceCurvaturePixelShader: {
  71858. name: string;
  71859. shader: string;
  71860. };
  71861. }
  71862. declare module BABYLON {
  71863. /**
  71864. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71865. */
  71866. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71867. /**
  71868. * Defines how much ridge the curvature effect displays.
  71869. */
  71870. ridge: number;
  71871. /**
  71872. * Defines how much valley the curvature effect displays.
  71873. */
  71874. valley: number;
  71875. private _geometryBufferRenderer;
  71876. /**
  71877. * Gets a string identifying the name of the class
  71878. * @returns "ScreenSpaceCurvaturePostProcess" string
  71879. */
  71880. getClassName(): string;
  71881. /**
  71882. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71883. * @param name The name of the effect.
  71884. * @param scene The scene containing the objects to blur according to their velocity.
  71885. * @param options The required width/height ratio to downsize to before computing the render pass.
  71886. * @param camera The camera to apply the render pass to.
  71887. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71888. * @param engine The engine which the post process will be applied. (default: current engine)
  71889. * @param reusable If the post process can be reused on the same frame. (default: false)
  71890. * @param textureType Type of textures used when performing the post process. (default: 0)
  71891. * @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)
  71892. */
  71893. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71894. /**
  71895. * Support test.
  71896. */
  71897. static get IsSupported(): boolean;
  71898. /** @hidden */
  71899. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  71900. }
  71901. }
  71902. declare module BABYLON {
  71903. interface Scene {
  71904. /** @hidden (Backing field) */
  71905. _boundingBoxRenderer: BoundingBoxRenderer;
  71906. /** @hidden (Backing field) */
  71907. _forceShowBoundingBoxes: boolean;
  71908. /**
  71909. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71910. */
  71911. forceShowBoundingBoxes: boolean;
  71912. /**
  71913. * Gets the bounding box renderer associated with the scene
  71914. * @returns a BoundingBoxRenderer
  71915. */
  71916. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71917. }
  71918. interface AbstractMesh {
  71919. /** @hidden (Backing field) */
  71920. _showBoundingBox: boolean;
  71921. /**
  71922. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71923. */
  71924. showBoundingBox: boolean;
  71925. }
  71926. /**
  71927. * Component responsible of rendering the bounding box of the meshes in a scene.
  71928. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71929. */
  71930. export class BoundingBoxRenderer implements ISceneComponent {
  71931. /**
  71932. * The component name helpfull to identify the component in the list of scene components.
  71933. */
  71934. readonly name: string;
  71935. /**
  71936. * The scene the component belongs to.
  71937. */
  71938. scene: Scene;
  71939. /**
  71940. * Color of the bounding box lines placed in front of an object
  71941. */
  71942. frontColor: Color3;
  71943. /**
  71944. * Color of the bounding box lines placed behind an object
  71945. */
  71946. backColor: Color3;
  71947. /**
  71948. * Defines if the renderer should show the back lines or not
  71949. */
  71950. showBackLines: boolean;
  71951. /**
  71952. * Observable raised before rendering a bounding box
  71953. */
  71954. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71955. /**
  71956. * Observable raised after rendering a bounding box
  71957. */
  71958. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71959. /**
  71960. * @hidden
  71961. */
  71962. renderList: SmartArray<BoundingBox>;
  71963. private _colorShader;
  71964. private _vertexBuffers;
  71965. private _indexBuffer;
  71966. private _fillIndexBuffer;
  71967. private _fillIndexData;
  71968. /**
  71969. * Instantiates a new bounding box renderer in a scene.
  71970. * @param scene the scene the renderer renders in
  71971. */
  71972. constructor(scene: Scene);
  71973. /**
  71974. * Registers the component in a given scene
  71975. */
  71976. register(): void;
  71977. private _evaluateSubMesh;
  71978. private _activeMesh;
  71979. private _prepareRessources;
  71980. private _createIndexBuffer;
  71981. /**
  71982. * Rebuilds the elements related to this component in case of
  71983. * context lost for instance.
  71984. */
  71985. rebuild(): void;
  71986. /**
  71987. * @hidden
  71988. */
  71989. reset(): void;
  71990. /**
  71991. * Render the bounding boxes of a specific rendering group
  71992. * @param renderingGroupId defines the rendering group to render
  71993. */
  71994. render(renderingGroupId: number): void;
  71995. /**
  71996. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71997. * @param mesh Define the mesh to render the occlusion bounding box for
  71998. */
  71999. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72000. /**
  72001. * Dispose and release the resources attached to this renderer.
  72002. */
  72003. dispose(): void;
  72004. }
  72005. }
  72006. declare module BABYLON {
  72007. interface Scene {
  72008. /** @hidden (Backing field) */
  72009. _depthRenderer: {
  72010. [id: string]: DepthRenderer;
  72011. };
  72012. /**
  72013. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72014. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72015. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72016. * @returns the created depth renderer
  72017. */
  72018. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  72019. /**
  72020. * Disables a depth renderer for a given camera
  72021. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72022. */
  72023. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72024. }
  72025. /**
  72026. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72027. * in several rendering techniques.
  72028. */
  72029. export class DepthRendererSceneComponent implements ISceneComponent {
  72030. /**
  72031. * The component name helpfull to identify the component in the list of scene components.
  72032. */
  72033. readonly name: string;
  72034. /**
  72035. * The scene the component belongs to.
  72036. */
  72037. scene: Scene;
  72038. /**
  72039. * Creates a new instance of the component for the given scene
  72040. * @param scene Defines the scene to register the component in
  72041. */
  72042. constructor(scene: Scene);
  72043. /**
  72044. * Registers the component in a given scene
  72045. */
  72046. register(): void;
  72047. /**
  72048. * Rebuilds the elements related to this component in case of
  72049. * context lost for instance.
  72050. */
  72051. rebuild(): void;
  72052. /**
  72053. * Disposes the component and the associated ressources
  72054. */
  72055. dispose(): void;
  72056. private _gatherRenderTargets;
  72057. private _gatherActiveCameraRenderTargets;
  72058. }
  72059. }
  72060. declare module BABYLON {
  72061. interface AbstractScene {
  72062. /** @hidden (Backing field) */
  72063. _prePassRenderer: Nullable<PrePassRenderer>;
  72064. /**
  72065. * Gets or Sets the current prepass renderer associated to the scene.
  72066. */
  72067. prePassRenderer: Nullable<PrePassRenderer>;
  72068. /**
  72069. * Enables the prepass and associates it with the scene
  72070. * @returns the PrePassRenderer
  72071. */
  72072. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72073. /**
  72074. * Disables the prepass associated with the scene
  72075. */
  72076. disablePrePassRenderer(): void;
  72077. }
  72078. /**
  72079. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72080. * in several rendering techniques.
  72081. */
  72082. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  72083. /**
  72084. * The component name helpful to identify the component in the list of scene components.
  72085. */
  72086. readonly name: string;
  72087. /**
  72088. * The scene the component belongs to.
  72089. */
  72090. scene: Scene;
  72091. /**
  72092. * Creates a new instance of the component for the given scene
  72093. * @param scene Defines the scene to register the component in
  72094. */
  72095. constructor(scene: Scene);
  72096. /**
  72097. * Registers the component in a given scene
  72098. */
  72099. register(): void;
  72100. private _beforeCameraDraw;
  72101. private _afterCameraDraw;
  72102. private _beforeClearStage;
  72103. /**
  72104. * Serializes the component data to the specified json object
  72105. * @param serializationObject The object to serialize to
  72106. */
  72107. serialize(serializationObject: any): void;
  72108. /**
  72109. * Adds all the elements from the container to the scene
  72110. * @param container the container holding the elements
  72111. */
  72112. addFromContainer(container: AbstractScene): void;
  72113. /**
  72114. * Removes all the elements in the container from the scene
  72115. * @param container contains the elements to remove
  72116. * @param dispose if the removed element should be disposed (default: false)
  72117. */
  72118. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72119. /**
  72120. * Rebuilds the elements related to this component in case of
  72121. * context lost for instance.
  72122. */
  72123. rebuild(): void;
  72124. /**
  72125. * Disposes the component and the associated ressources
  72126. */
  72127. dispose(): void;
  72128. }
  72129. }
  72130. declare module BABYLON {
  72131. /** @hidden */
  72132. export var outlinePixelShader: {
  72133. name: string;
  72134. shader: string;
  72135. };
  72136. }
  72137. declare module BABYLON {
  72138. /** @hidden */
  72139. export var outlineVertexShader: {
  72140. name: string;
  72141. shader: string;
  72142. };
  72143. }
  72144. declare module BABYLON {
  72145. interface Scene {
  72146. /** @hidden */
  72147. _outlineRenderer: OutlineRenderer;
  72148. /**
  72149. * Gets the outline renderer associated with the scene
  72150. * @returns a OutlineRenderer
  72151. */
  72152. getOutlineRenderer(): OutlineRenderer;
  72153. }
  72154. interface AbstractMesh {
  72155. /** @hidden (Backing field) */
  72156. _renderOutline: boolean;
  72157. /**
  72158. * Gets or sets a boolean indicating if the outline must be rendered as well
  72159. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72160. */
  72161. renderOutline: boolean;
  72162. /** @hidden (Backing field) */
  72163. _renderOverlay: boolean;
  72164. /**
  72165. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72166. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72167. */
  72168. renderOverlay: boolean;
  72169. }
  72170. /**
  72171. * This class is responsible to draw bothe outline/overlay of meshes.
  72172. * It should not be used directly but through the available method on mesh.
  72173. */
  72174. export class OutlineRenderer implements ISceneComponent {
  72175. /**
  72176. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72177. */
  72178. private static _StencilReference;
  72179. /**
  72180. * The name of the component. Each component must have a unique name.
  72181. */
  72182. name: string;
  72183. /**
  72184. * The scene the component belongs to.
  72185. */
  72186. scene: Scene;
  72187. /**
  72188. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72189. */
  72190. zOffset: number;
  72191. private _engine;
  72192. private _effect;
  72193. private _cachedDefines;
  72194. private _savedDepthWrite;
  72195. /**
  72196. * Instantiates a new outline renderer. (There could be only one per scene).
  72197. * @param scene Defines the scene it belongs to
  72198. */
  72199. constructor(scene: Scene);
  72200. /**
  72201. * Register the component to one instance of a scene.
  72202. */
  72203. register(): void;
  72204. /**
  72205. * Rebuilds the elements related to this component in case of
  72206. * context lost for instance.
  72207. */
  72208. rebuild(): void;
  72209. /**
  72210. * Disposes the component and the associated ressources.
  72211. */
  72212. dispose(): void;
  72213. /**
  72214. * Renders the outline in the canvas.
  72215. * @param subMesh Defines the sumesh to render
  72216. * @param batch Defines the batch of meshes in case of instances
  72217. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72218. */
  72219. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72220. /**
  72221. * Returns whether or not the outline renderer is ready for a given submesh.
  72222. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72223. * @param subMesh Defines the submesh to check readyness for
  72224. * @param useInstances Defines wheter wee are trying to render instances or not
  72225. * @returns true if ready otherwise false
  72226. */
  72227. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72228. private _beforeRenderingMesh;
  72229. private _afterRenderingMesh;
  72230. }
  72231. }
  72232. declare module BABYLON {
  72233. /**
  72234. * Defines the basic options interface of a Sprite Frame Source Size.
  72235. */
  72236. export interface ISpriteJSONSpriteSourceSize {
  72237. /**
  72238. * number of the original width of the Frame
  72239. */
  72240. w: number;
  72241. /**
  72242. * number of the original height of the Frame
  72243. */
  72244. h: number;
  72245. }
  72246. /**
  72247. * Defines the basic options interface of a Sprite Frame Data.
  72248. */
  72249. export interface ISpriteJSONSpriteFrameData {
  72250. /**
  72251. * number of the x offset of the Frame
  72252. */
  72253. x: number;
  72254. /**
  72255. * number of the y offset of the Frame
  72256. */
  72257. y: number;
  72258. /**
  72259. * number of the width of the Frame
  72260. */
  72261. w: number;
  72262. /**
  72263. * number of the height of the Frame
  72264. */
  72265. h: number;
  72266. }
  72267. /**
  72268. * Defines the basic options interface of a JSON Sprite.
  72269. */
  72270. export interface ISpriteJSONSprite {
  72271. /**
  72272. * string name of the Frame
  72273. */
  72274. filename: string;
  72275. /**
  72276. * ISpriteJSONSpriteFrame basic object of the frame data
  72277. */
  72278. frame: ISpriteJSONSpriteFrameData;
  72279. /**
  72280. * boolean to flag is the frame was rotated.
  72281. */
  72282. rotated: boolean;
  72283. /**
  72284. * boolean to flag is the frame was trimmed.
  72285. */
  72286. trimmed: boolean;
  72287. /**
  72288. * ISpriteJSONSpriteFrame basic object of the source data
  72289. */
  72290. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72291. /**
  72292. * ISpriteJSONSpriteFrame basic object of the source data
  72293. */
  72294. sourceSize: ISpriteJSONSpriteSourceSize;
  72295. }
  72296. /**
  72297. * Defines the basic options interface of a JSON atlas.
  72298. */
  72299. export interface ISpriteJSONAtlas {
  72300. /**
  72301. * Array of objects that contain the frame data.
  72302. */
  72303. frames: Array<ISpriteJSONSprite>;
  72304. /**
  72305. * object basic object containing the sprite meta data.
  72306. */
  72307. meta?: object;
  72308. }
  72309. }
  72310. declare module BABYLON {
  72311. /** @hidden */
  72312. export var spriteMapPixelShader: {
  72313. name: string;
  72314. shader: string;
  72315. };
  72316. }
  72317. declare module BABYLON {
  72318. /** @hidden */
  72319. export var spriteMapVertexShader: {
  72320. name: string;
  72321. shader: string;
  72322. };
  72323. }
  72324. declare module BABYLON {
  72325. /**
  72326. * Defines the basic options interface of a SpriteMap
  72327. */
  72328. export interface ISpriteMapOptions {
  72329. /**
  72330. * Vector2 of the number of cells in the grid.
  72331. */
  72332. stageSize?: Vector2;
  72333. /**
  72334. * Vector2 of the size of the output plane in World Units.
  72335. */
  72336. outputSize?: Vector2;
  72337. /**
  72338. * Vector3 of the position of the output plane in World Units.
  72339. */
  72340. outputPosition?: Vector3;
  72341. /**
  72342. * Vector3 of the rotation of the output plane.
  72343. */
  72344. outputRotation?: Vector3;
  72345. /**
  72346. * number of layers that the system will reserve in resources.
  72347. */
  72348. layerCount?: number;
  72349. /**
  72350. * number of max animation frames a single cell will reserve in resources.
  72351. */
  72352. maxAnimationFrames?: number;
  72353. /**
  72354. * number cell index of the base tile when the system compiles.
  72355. */
  72356. baseTile?: number;
  72357. /**
  72358. * boolean flip the sprite after its been repositioned by the framing data.
  72359. */
  72360. flipU?: boolean;
  72361. /**
  72362. * Vector3 scalar of the global RGB values of the SpriteMap.
  72363. */
  72364. colorMultiply?: Vector3;
  72365. }
  72366. /**
  72367. * Defines the IDisposable interface in order to be cleanable from resources.
  72368. */
  72369. export interface ISpriteMap extends IDisposable {
  72370. /**
  72371. * String name of the SpriteMap.
  72372. */
  72373. name: string;
  72374. /**
  72375. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72376. */
  72377. atlasJSON: ISpriteJSONAtlas;
  72378. /**
  72379. * Texture of the SpriteMap.
  72380. */
  72381. spriteSheet: Texture;
  72382. /**
  72383. * The parameters to initialize the SpriteMap with.
  72384. */
  72385. options: ISpriteMapOptions;
  72386. }
  72387. /**
  72388. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72389. */
  72390. export class SpriteMap implements ISpriteMap {
  72391. /** The Name of the spriteMap */
  72392. name: string;
  72393. /** The JSON file with the frame and meta data */
  72394. atlasJSON: ISpriteJSONAtlas;
  72395. /** The systems Sprite Sheet Texture */
  72396. spriteSheet: Texture;
  72397. /** Arguments passed with the Constructor */
  72398. options: ISpriteMapOptions;
  72399. /** Public Sprite Storage array, parsed from atlasJSON */
  72400. sprites: Array<ISpriteJSONSprite>;
  72401. /** Returns the Number of Sprites in the System */
  72402. get spriteCount(): number;
  72403. /** Returns the Position of Output Plane*/
  72404. get position(): Vector3;
  72405. /** Returns the Position of Output Plane*/
  72406. set position(v: Vector3);
  72407. /** Returns the Rotation of Output Plane*/
  72408. get rotation(): Vector3;
  72409. /** Returns the Rotation of Output Plane*/
  72410. set rotation(v: Vector3);
  72411. /** Sets the AnimationMap*/
  72412. get animationMap(): RawTexture;
  72413. /** Sets the AnimationMap*/
  72414. set animationMap(v: RawTexture);
  72415. /** Scene that the SpriteMap was created in */
  72416. private _scene;
  72417. /** Texture Buffer of Float32 that holds tile frame data*/
  72418. private _frameMap;
  72419. /** Texture Buffers of Float32 that holds tileMap data*/
  72420. private _tileMaps;
  72421. /** Texture Buffer of Float32 that holds Animation Data*/
  72422. private _animationMap;
  72423. /** Custom ShaderMaterial Central to the System*/
  72424. private _material;
  72425. /** Custom ShaderMaterial Central to the System*/
  72426. private _output;
  72427. /** Systems Time Ticker*/
  72428. private _time;
  72429. /**
  72430. * Creates a new SpriteMap
  72431. * @param name defines the SpriteMaps Name
  72432. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72433. * @param spriteSheet is the Texture that the Sprites are on.
  72434. * @param options a basic deployment configuration
  72435. * @param scene The Scene that the map is deployed on
  72436. */
  72437. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72438. /**
  72439. * Returns tileID location
  72440. * @returns Vector2 the cell position ID
  72441. */
  72442. getTileID(): Vector2;
  72443. /**
  72444. * Gets the UV location of the mouse over the SpriteMap.
  72445. * @returns Vector2 the UV position of the mouse interaction
  72446. */
  72447. getMousePosition(): Vector2;
  72448. /**
  72449. * Creates the "frame" texture Buffer
  72450. * -------------------------------------
  72451. * Structure of frames
  72452. * "filename": "Falling-Water-2.png",
  72453. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72454. * "rotated": true,
  72455. * "trimmed": true,
  72456. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72457. * "sourceSize": {"w":32,"h":32}
  72458. * @returns RawTexture of the frameMap
  72459. */
  72460. private _createFrameBuffer;
  72461. /**
  72462. * Creates the tileMap texture Buffer
  72463. * @param buffer normally and array of numbers, or a false to generate from scratch
  72464. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72465. * @returns RawTexture of the tileMap
  72466. */
  72467. private _createTileBuffer;
  72468. /**
  72469. * Modifies the data of the tileMaps
  72470. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72471. * @param pos is the iVector2 Coordinates of the Tile
  72472. * @param tile The SpriteIndex of the new Tile
  72473. */
  72474. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72475. /**
  72476. * Creates the animationMap texture Buffer
  72477. * @param buffer normally and array of numbers, or a false to generate from scratch
  72478. * @returns RawTexture of the animationMap
  72479. */
  72480. private _createTileAnimationBuffer;
  72481. /**
  72482. * Modifies the data of the animationMap
  72483. * @param cellID is the Index of the Sprite
  72484. * @param _frame is the target Animation frame
  72485. * @param toCell is the Target Index of the next frame of the animation
  72486. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72487. * @param speed is a global scalar of the time variable on the map.
  72488. */
  72489. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72490. /**
  72491. * Exports the .tilemaps file
  72492. */
  72493. saveTileMaps(): void;
  72494. /**
  72495. * Imports the .tilemaps file
  72496. * @param url of the .tilemaps file
  72497. */
  72498. loadTileMaps(url: string): void;
  72499. /**
  72500. * Release associated resources
  72501. */
  72502. dispose(): void;
  72503. }
  72504. }
  72505. declare module BABYLON {
  72506. /**
  72507. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72508. * @see https://doc.babylonjs.com/babylon101/sprites
  72509. */
  72510. export class SpritePackedManager extends SpriteManager {
  72511. /** defines the packed manager's name */
  72512. name: string;
  72513. /**
  72514. * Creates a new sprite manager from a packed sprite sheet
  72515. * @param name defines the manager's name
  72516. * @param imgUrl defines the sprite sheet url
  72517. * @param capacity defines the maximum allowed number of sprites
  72518. * @param scene defines the hosting scene
  72519. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72520. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72521. * @param samplingMode defines the smapling mode to use with spritesheet
  72522. * @param fromPacked set to true; do not alter
  72523. */
  72524. constructor(
  72525. /** defines the packed manager's name */
  72526. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72527. }
  72528. }
  72529. declare module BABYLON {
  72530. /**
  72531. * Defines the list of states available for a task inside a AssetsManager
  72532. */
  72533. export enum AssetTaskState {
  72534. /**
  72535. * Initialization
  72536. */
  72537. INIT = 0,
  72538. /**
  72539. * Running
  72540. */
  72541. RUNNING = 1,
  72542. /**
  72543. * Done
  72544. */
  72545. DONE = 2,
  72546. /**
  72547. * Error
  72548. */
  72549. ERROR = 3
  72550. }
  72551. /**
  72552. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72553. */
  72554. export abstract class AbstractAssetTask {
  72555. /**
  72556. * Task name
  72557. */ name: string;
  72558. /**
  72559. * Callback called when the task is successful
  72560. */
  72561. onSuccess: (task: any) => void;
  72562. /**
  72563. * Callback called when the task is not successful
  72564. */
  72565. onError: (task: any, message?: string, exception?: any) => void;
  72566. /**
  72567. * Creates a new AssetsManager
  72568. * @param name defines the name of the task
  72569. */
  72570. constructor(
  72571. /**
  72572. * Task name
  72573. */ name: string);
  72574. private _isCompleted;
  72575. private _taskState;
  72576. private _errorObject;
  72577. /**
  72578. * Get if the task is completed
  72579. */
  72580. get isCompleted(): boolean;
  72581. /**
  72582. * Gets the current state of the task
  72583. */
  72584. get taskState(): AssetTaskState;
  72585. /**
  72586. * Gets the current error object (if task is in error)
  72587. */
  72588. get errorObject(): {
  72589. message?: string;
  72590. exception?: any;
  72591. };
  72592. /**
  72593. * Internal only
  72594. * @hidden
  72595. */
  72596. _setErrorObject(message?: string, exception?: any): void;
  72597. /**
  72598. * Execute the current task
  72599. * @param scene defines the scene where you want your assets to be loaded
  72600. * @param onSuccess is a callback called when the task is successfully executed
  72601. * @param onError is a callback called if an error occurs
  72602. */
  72603. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72604. /**
  72605. * Execute the current task
  72606. * @param scene defines the scene where you want your assets to be loaded
  72607. * @param onSuccess is a callback called when the task is successfully executed
  72608. * @param onError is a callback called if an error occurs
  72609. */
  72610. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72611. /**
  72612. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72613. * This can be used with failed tasks that have the reason for failure fixed.
  72614. */
  72615. reset(): void;
  72616. private onErrorCallback;
  72617. private onDoneCallback;
  72618. }
  72619. /**
  72620. * Define the interface used by progress events raised during assets loading
  72621. */
  72622. export interface IAssetsProgressEvent {
  72623. /**
  72624. * Defines the number of remaining tasks to process
  72625. */
  72626. remainingCount: number;
  72627. /**
  72628. * Defines the total number of tasks
  72629. */
  72630. totalCount: number;
  72631. /**
  72632. * Defines the task that was just processed
  72633. */
  72634. task: AbstractAssetTask;
  72635. }
  72636. /**
  72637. * Class used to share progress information about assets loading
  72638. */
  72639. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72640. /**
  72641. * Defines the number of remaining tasks to process
  72642. */
  72643. remainingCount: number;
  72644. /**
  72645. * Defines the total number of tasks
  72646. */
  72647. totalCount: number;
  72648. /**
  72649. * Defines the task that was just processed
  72650. */
  72651. task: AbstractAssetTask;
  72652. /**
  72653. * Creates a AssetsProgressEvent
  72654. * @param remainingCount defines the number of remaining tasks to process
  72655. * @param totalCount defines the total number of tasks
  72656. * @param task defines the task that was just processed
  72657. */
  72658. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72659. }
  72660. /**
  72661. * Define a task used by AssetsManager to load assets into a container
  72662. */
  72663. export class ContainerAssetTask extends AbstractAssetTask {
  72664. /**
  72665. * Defines the name of the task
  72666. */
  72667. name: string;
  72668. /**
  72669. * Defines the list of mesh's names you want to load
  72670. */
  72671. meshesNames: any;
  72672. /**
  72673. * Defines the root url to use as a base to load your meshes and associated resources
  72674. */
  72675. rootUrl: string;
  72676. /**
  72677. * Defines the filename or File of the scene to load from
  72678. */
  72679. sceneFilename: string | File;
  72680. /**
  72681. * Get the loaded asset container
  72682. */
  72683. loadedContainer: AssetContainer;
  72684. /**
  72685. * Gets the list of loaded meshes
  72686. */
  72687. loadedMeshes: Array<AbstractMesh>;
  72688. /**
  72689. * Gets the list of loaded particle systems
  72690. */
  72691. loadedParticleSystems: Array<IParticleSystem>;
  72692. /**
  72693. * Gets the list of loaded skeletons
  72694. */
  72695. loadedSkeletons: Array<Skeleton>;
  72696. /**
  72697. * Gets the list of loaded animation groups
  72698. */
  72699. loadedAnimationGroups: Array<AnimationGroup>;
  72700. /**
  72701. * Callback called when the task is successful
  72702. */
  72703. onSuccess: (task: ContainerAssetTask) => void;
  72704. /**
  72705. * Callback called when the task is successful
  72706. */
  72707. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72708. /**
  72709. * Creates a new ContainerAssetTask
  72710. * @param name defines the name of the task
  72711. * @param meshesNames defines the list of mesh's names you want to load
  72712. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72713. * @param sceneFilename defines the filename or File of the scene to load from
  72714. */
  72715. constructor(
  72716. /**
  72717. * Defines the name of the task
  72718. */
  72719. name: string,
  72720. /**
  72721. * Defines the list of mesh's names you want to load
  72722. */
  72723. meshesNames: any,
  72724. /**
  72725. * Defines the root url to use as a base to load your meshes and associated resources
  72726. */
  72727. rootUrl: string,
  72728. /**
  72729. * Defines the filename or File of the scene to load from
  72730. */
  72731. sceneFilename: string | File);
  72732. /**
  72733. * Execute the current task
  72734. * @param scene defines the scene where you want your assets to be loaded
  72735. * @param onSuccess is a callback called when the task is successfully executed
  72736. * @param onError is a callback called if an error occurs
  72737. */
  72738. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72739. }
  72740. /**
  72741. * Define a task used by AssetsManager to load meshes
  72742. */
  72743. export class MeshAssetTask extends AbstractAssetTask {
  72744. /**
  72745. * Defines the name of the task
  72746. */
  72747. name: string;
  72748. /**
  72749. * Defines the list of mesh's names you want to load
  72750. */
  72751. meshesNames: any;
  72752. /**
  72753. * Defines the root url to use as a base to load your meshes and associated resources
  72754. */
  72755. rootUrl: string;
  72756. /**
  72757. * Defines the filename or File of the scene to load from
  72758. */
  72759. sceneFilename: string | File;
  72760. /**
  72761. * Gets the list of loaded meshes
  72762. */
  72763. loadedMeshes: Array<AbstractMesh>;
  72764. /**
  72765. * Gets the list of loaded particle systems
  72766. */
  72767. loadedParticleSystems: Array<IParticleSystem>;
  72768. /**
  72769. * Gets the list of loaded skeletons
  72770. */
  72771. loadedSkeletons: Array<Skeleton>;
  72772. /**
  72773. * Gets the list of loaded animation groups
  72774. */
  72775. loadedAnimationGroups: Array<AnimationGroup>;
  72776. /**
  72777. * Callback called when the task is successful
  72778. */
  72779. onSuccess: (task: MeshAssetTask) => void;
  72780. /**
  72781. * Callback called when the task is successful
  72782. */
  72783. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  72784. /**
  72785. * Creates a new MeshAssetTask
  72786. * @param name defines the name of the task
  72787. * @param meshesNames defines the list of mesh's names you want to load
  72788. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72789. * @param sceneFilename defines the filename or File of the scene to load from
  72790. */
  72791. constructor(
  72792. /**
  72793. * Defines the name of the task
  72794. */
  72795. name: string,
  72796. /**
  72797. * Defines the list of mesh's names you want to load
  72798. */
  72799. meshesNames: any,
  72800. /**
  72801. * Defines the root url to use as a base to load your meshes and associated resources
  72802. */
  72803. rootUrl: string,
  72804. /**
  72805. * Defines the filename or File of the scene to load from
  72806. */
  72807. sceneFilename: string | File);
  72808. /**
  72809. * Execute the current task
  72810. * @param scene defines the scene where you want your assets to be loaded
  72811. * @param onSuccess is a callback called when the task is successfully executed
  72812. * @param onError is a callback called if an error occurs
  72813. */
  72814. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72815. }
  72816. /**
  72817. * Define a task used by AssetsManager to load text content
  72818. */
  72819. export class TextFileAssetTask extends AbstractAssetTask {
  72820. /**
  72821. * Defines the name of the task
  72822. */
  72823. name: string;
  72824. /**
  72825. * Defines the location of the file to load
  72826. */
  72827. url: string;
  72828. /**
  72829. * Gets the loaded text string
  72830. */
  72831. text: string;
  72832. /**
  72833. * Callback called when the task is successful
  72834. */
  72835. onSuccess: (task: TextFileAssetTask) => void;
  72836. /**
  72837. * Callback called when the task is successful
  72838. */
  72839. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72840. /**
  72841. * Creates a new TextFileAssetTask object
  72842. * @param name defines the name of the task
  72843. * @param url defines the location of the file to load
  72844. */
  72845. constructor(
  72846. /**
  72847. * Defines the name of the task
  72848. */
  72849. name: string,
  72850. /**
  72851. * Defines the location of the file to load
  72852. */
  72853. url: string);
  72854. /**
  72855. * Execute the current task
  72856. * @param scene defines the scene where you want your assets to be loaded
  72857. * @param onSuccess is a callback called when the task is successfully executed
  72858. * @param onError is a callback called if an error occurs
  72859. */
  72860. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72861. }
  72862. /**
  72863. * Define a task used by AssetsManager to load binary data
  72864. */
  72865. export class BinaryFileAssetTask extends AbstractAssetTask {
  72866. /**
  72867. * Defines the name of the task
  72868. */
  72869. name: string;
  72870. /**
  72871. * Defines the location of the file to load
  72872. */
  72873. url: string;
  72874. /**
  72875. * Gets the lodaded data (as an array buffer)
  72876. */
  72877. data: ArrayBuffer;
  72878. /**
  72879. * Callback called when the task is successful
  72880. */
  72881. onSuccess: (task: BinaryFileAssetTask) => void;
  72882. /**
  72883. * Callback called when the task is successful
  72884. */
  72885. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72886. /**
  72887. * Creates a new BinaryFileAssetTask object
  72888. * @param name defines the name of the new task
  72889. * @param url defines the location of the file to load
  72890. */
  72891. constructor(
  72892. /**
  72893. * Defines the name of the task
  72894. */
  72895. name: string,
  72896. /**
  72897. * Defines the location of the file to load
  72898. */
  72899. url: string);
  72900. /**
  72901. * Execute the current task
  72902. * @param scene defines the scene where you want your assets to be loaded
  72903. * @param onSuccess is a callback called when the task is successfully executed
  72904. * @param onError is a callback called if an error occurs
  72905. */
  72906. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72907. }
  72908. /**
  72909. * Define a task used by AssetsManager to load images
  72910. */
  72911. export class ImageAssetTask extends AbstractAssetTask {
  72912. /**
  72913. * Defines the name of the task
  72914. */
  72915. name: string;
  72916. /**
  72917. * Defines the location of the image to load
  72918. */
  72919. url: string;
  72920. /**
  72921. * Gets the loaded images
  72922. */
  72923. image: HTMLImageElement;
  72924. /**
  72925. * Callback called when the task is successful
  72926. */
  72927. onSuccess: (task: ImageAssetTask) => void;
  72928. /**
  72929. * Callback called when the task is successful
  72930. */
  72931. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72932. /**
  72933. * Creates a new ImageAssetTask
  72934. * @param name defines the name of the task
  72935. * @param url defines the location of the image to load
  72936. */
  72937. constructor(
  72938. /**
  72939. * Defines the name of the task
  72940. */
  72941. name: string,
  72942. /**
  72943. * Defines the location of the image to load
  72944. */
  72945. url: string);
  72946. /**
  72947. * Execute the current task
  72948. * @param scene defines the scene where you want your assets to be loaded
  72949. * @param onSuccess is a callback called when the task is successfully executed
  72950. * @param onError is a callback called if an error occurs
  72951. */
  72952. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72953. }
  72954. /**
  72955. * Defines the interface used by texture loading tasks
  72956. */
  72957. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72958. /**
  72959. * Gets the loaded texture
  72960. */
  72961. texture: TEX;
  72962. }
  72963. /**
  72964. * Define a task used by AssetsManager to load 2D textures
  72965. */
  72966. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72967. /**
  72968. * Defines the name of the task
  72969. */
  72970. name: string;
  72971. /**
  72972. * Defines the location of the file to load
  72973. */
  72974. url: string;
  72975. /**
  72976. * Defines if mipmap should not be generated (default is false)
  72977. */
  72978. noMipmap?: boolean | undefined;
  72979. /**
  72980. * Defines if texture must be inverted on Y axis (default is true)
  72981. */
  72982. invertY: boolean;
  72983. /**
  72984. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72985. */
  72986. samplingMode: number;
  72987. /**
  72988. * Gets the loaded texture
  72989. */
  72990. texture: Texture;
  72991. /**
  72992. * Callback called when the task is successful
  72993. */
  72994. onSuccess: (task: TextureAssetTask) => void;
  72995. /**
  72996. * Callback called when the task is successful
  72997. */
  72998. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72999. /**
  73000. * Creates a new TextureAssetTask object
  73001. * @param name defines the name of the task
  73002. * @param url defines the location of the file to load
  73003. * @param noMipmap defines if mipmap should not be generated (default is false)
  73004. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73005. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73006. */
  73007. constructor(
  73008. /**
  73009. * Defines the name of the task
  73010. */
  73011. name: string,
  73012. /**
  73013. * Defines the location of the file to load
  73014. */
  73015. url: string,
  73016. /**
  73017. * Defines if mipmap should not be generated (default is false)
  73018. */
  73019. noMipmap?: boolean | undefined,
  73020. /**
  73021. * Defines if texture must be inverted on Y axis (default is true)
  73022. */
  73023. invertY?: boolean,
  73024. /**
  73025. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73026. */
  73027. samplingMode?: number);
  73028. /**
  73029. * Execute the current task
  73030. * @param scene defines the scene where you want your assets to be loaded
  73031. * @param onSuccess is a callback called when the task is successfully executed
  73032. * @param onError is a callback called if an error occurs
  73033. */
  73034. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73035. }
  73036. /**
  73037. * Define a task used by AssetsManager to load cube textures
  73038. */
  73039. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73040. /**
  73041. * Defines the name of the task
  73042. */
  73043. name: string;
  73044. /**
  73045. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73046. */
  73047. url: string;
  73048. /**
  73049. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73050. */
  73051. extensions?: string[] | undefined;
  73052. /**
  73053. * Defines if mipmaps should not be generated (default is false)
  73054. */
  73055. noMipmap?: boolean | undefined;
  73056. /**
  73057. * Defines the explicit list of files (undefined by default)
  73058. */
  73059. files?: string[] | undefined;
  73060. /**
  73061. * Gets the loaded texture
  73062. */
  73063. texture: CubeTexture;
  73064. /**
  73065. * Callback called when the task is successful
  73066. */
  73067. onSuccess: (task: CubeTextureAssetTask) => void;
  73068. /**
  73069. * Callback called when the task is successful
  73070. */
  73071. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73072. /**
  73073. * Creates a new CubeTextureAssetTask
  73074. * @param name defines the name of the task
  73075. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73076. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73077. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73078. * @param files defines the explicit list of files (undefined by default)
  73079. */
  73080. constructor(
  73081. /**
  73082. * Defines the name of the task
  73083. */
  73084. name: string,
  73085. /**
  73086. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73087. */
  73088. url: string,
  73089. /**
  73090. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73091. */
  73092. extensions?: string[] | undefined,
  73093. /**
  73094. * Defines if mipmaps should not be generated (default is false)
  73095. */
  73096. noMipmap?: boolean | undefined,
  73097. /**
  73098. * Defines the explicit list of files (undefined by default)
  73099. */
  73100. files?: string[] | undefined);
  73101. /**
  73102. * Execute the current task
  73103. * @param scene defines the scene where you want your assets to be loaded
  73104. * @param onSuccess is a callback called when the task is successfully executed
  73105. * @param onError is a callback called if an error occurs
  73106. */
  73107. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73108. }
  73109. /**
  73110. * Define a task used by AssetsManager to load HDR cube textures
  73111. */
  73112. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73113. /**
  73114. * Defines the name of the task
  73115. */
  73116. name: string;
  73117. /**
  73118. * Defines the location of the file to load
  73119. */
  73120. url: string;
  73121. /**
  73122. * Defines the desired size (the more it increases the longer the generation will be)
  73123. */
  73124. size: number;
  73125. /**
  73126. * Defines if mipmaps should not be generated (default is false)
  73127. */
  73128. noMipmap: boolean;
  73129. /**
  73130. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73131. */
  73132. generateHarmonics: boolean;
  73133. /**
  73134. * 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)
  73135. */
  73136. gammaSpace: boolean;
  73137. /**
  73138. * Internal Use Only
  73139. */
  73140. reserved: boolean;
  73141. /**
  73142. * Gets the loaded texture
  73143. */
  73144. texture: HDRCubeTexture;
  73145. /**
  73146. * Callback called when the task is successful
  73147. */
  73148. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73149. /**
  73150. * Callback called when the task is successful
  73151. */
  73152. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73153. /**
  73154. * Creates a new HDRCubeTextureAssetTask object
  73155. * @param name defines the name of the task
  73156. * @param url defines the location of the file to load
  73157. * @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.
  73158. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73159. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73160. * @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)
  73161. * @param reserved Internal use only
  73162. */
  73163. constructor(
  73164. /**
  73165. * Defines the name of the task
  73166. */
  73167. name: string,
  73168. /**
  73169. * Defines the location of the file to load
  73170. */
  73171. url: string,
  73172. /**
  73173. * Defines the desired size (the more it increases the longer the generation will be)
  73174. */
  73175. size: number,
  73176. /**
  73177. * Defines if mipmaps should not be generated (default is false)
  73178. */
  73179. noMipmap?: boolean,
  73180. /**
  73181. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73182. */
  73183. generateHarmonics?: boolean,
  73184. /**
  73185. * 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)
  73186. */
  73187. gammaSpace?: boolean,
  73188. /**
  73189. * Internal Use Only
  73190. */
  73191. reserved?: boolean);
  73192. /**
  73193. * Execute the current task
  73194. * @param scene defines the scene where you want your assets to be loaded
  73195. * @param onSuccess is a callback called when the task is successfully executed
  73196. * @param onError is a callback called if an error occurs
  73197. */
  73198. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73199. }
  73200. /**
  73201. * Define a task used by AssetsManager to load Equirectangular cube textures
  73202. */
  73203. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73204. /**
  73205. * Defines the name of the task
  73206. */
  73207. name: string;
  73208. /**
  73209. * Defines the location of the file to load
  73210. */
  73211. url: string;
  73212. /**
  73213. * Defines the desired size (the more it increases the longer the generation will be)
  73214. */
  73215. size: number;
  73216. /**
  73217. * Defines if mipmaps should not be generated (default is false)
  73218. */
  73219. noMipmap: boolean;
  73220. /**
  73221. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73222. * but the standard material would require them in Gamma space) (default is true)
  73223. */
  73224. gammaSpace: boolean;
  73225. /**
  73226. * Gets the loaded texture
  73227. */
  73228. texture: EquiRectangularCubeTexture;
  73229. /**
  73230. * Callback called when the task is successful
  73231. */
  73232. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73233. /**
  73234. * Callback called when the task is successful
  73235. */
  73236. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73237. /**
  73238. * Creates a new EquiRectangularCubeTextureAssetTask object
  73239. * @param name defines the name of the task
  73240. * @param url defines the location of the file to load
  73241. * @param size defines the desired size (the more it increases the longer the generation will be)
  73242. * If the size is omitted this implies you are using a preprocessed cubemap.
  73243. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73244. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73245. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73246. * (default is true)
  73247. */
  73248. constructor(
  73249. /**
  73250. * Defines the name of the task
  73251. */
  73252. name: string,
  73253. /**
  73254. * Defines the location of the file to load
  73255. */
  73256. url: string,
  73257. /**
  73258. * Defines the desired size (the more it increases the longer the generation will be)
  73259. */
  73260. size: number,
  73261. /**
  73262. * Defines if mipmaps should not be generated (default is false)
  73263. */
  73264. noMipmap?: boolean,
  73265. /**
  73266. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73267. * but the standard material would require them in Gamma space) (default is true)
  73268. */
  73269. gammaSpace?: boolean);
  73270. /**
  73271. * Execute the current task
  73272. * @param scene defines the scene where you want your assets to be loaded
  73273. * @param onSuccess is a callback called when the task is successfully executed
  73274. * @param onError is a callback called if an error occurs
  73275. */
  73276. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73277. }
  73278. /**
  73279. * This class can be used to easily import assets into a scene
  73280. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73281. */
  73282. export class AssetsManager {
  73283. private _scene;
  73284. private _isLoading;
  73285. protected _tasks: AbstractAssetTask[];
  73286. protected _waitingTasksCount: number;
  73287. protected _totalTasksCount: number;
  73288. /**
  73289. * Callback called when all tasks are processed
  73290. */
  73291. onFinish: (tasks: AbstractAssetTask[]) => void;
  73292. /**
  73293. * Callback called when a task is successful
  73294. */
  73295. onTaskSuccess: (task: AbstractAssetTask) => void;
  73296. /**
  73297. * Callback called when a task had an error
  73298. */
  73299. onTaskError: (task: AbstractAssetTask) => void;
  73300. /**
  73301. * Callback called when a task is done (whatever the result is)
  73302. */
  73303. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73304. /**
  73305. * Observable called when all tasks are processed
  73306. */
  73307. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73308. /**
  73309. * Observable called when a task had an error
  73310. */
  73311. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73312. /**
  73313. * Observable called when all tasks were executed
  73314. */
  73315. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73316. /**
  73317. * Observable called when a task is done (whatever the result is)
  73318. */
  73319. onProgressObservable: Observable<IAssetsProgressEvent>;
  73320. /**
  73321. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73322. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73323. */
  73324. useDefaultLoadingScreen: boolean;
  73325. /**
  73326. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73327. * when all assets have been downloaded.
  73328. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73329. */
  73330. autoHideLoadingUI: boolean;
  73331. /**
  73332. * Creates a new AssetsManager
  73333. * @param scene defines the scene to work on
  73334. */
  73335. constructor(scene: Scene);
  73336. /**
  73337. * Add a ContainerAssetTask to the list of active tasks
  73338. * @param taskName defines the name of the new task
  73339. * @param meshesNames defines the name of meshes to load
  73340. * @param rootUrl defines the root url to use to locate files
  73341. * @param sceneFilename defines the filename of the scene file
  73342. * @returns a new ContainerAssetTask object
  73343. */
  73344. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73345. /**
  73346. * Add a MeshAssetTask to the list of active tasks
  73347. * @param taskName defines the name of the new task
  73348. * @param meshesNames defines the name of meshes to load
  73349. * @param rootUrl defines the root url to use to locate files
  73350. * @param sceneFilename defines the filename of the scene file
  73351. * @returns a new MeshAssetTask object
  73352. */
  73353. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73354. /**
  73355. * Add a TextFileAssetTask to the list of active tasks
  73356. * @param taskName defines the name of the new task
  73357. * @param url defines the url of the file to load
  73358. * @returns a new TextFileAssetTask object
  73359. */
  73360. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73361. /**
  73362. * Add a BinaryFileAssetTask to the list of active tasks
  73363. * @param taskName defines the name of the new task
  73364. * @param url defines the url of the file to load
  73365. * @returns a new BinaryFileAssetTask object
  73366. */
  73367. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73368. /**
  73369. * Add a ImageAssetTask to the list of active tasks
  73370. * @param taskName defines the name of the new task
  73371. * @param url defines the url of the file to load
  73372. * @returns a new ImageAssetTask object
  73373. */
  73374. addImageTask(taskName: string, url: string): ImageAssetTask;
  73375. /**
  73376. * Add a TextureAssetTask to the list of active tasks
  73377. * @param taskName defines the name of the new task
  73378. * @param url defines the url of the file to load
  73379. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73380. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73381. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73382. * @returns a new TextureAssetTask object
  73383. */
  73384. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73385. /**
  73386. * Add a CubeTextureAssetTask to the list of active tasks
  73387. * @param taskName defines the name of the new task
  73388. * @param url defines the url of the file to load
  73389. * @param extensions defines the extension to use to load the cube map (can be null)
  73390. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73391. * @param files defines the list of files to load (can be null)
  73392. * @returns a new CubeTextureAssetTask object
  73393. */
  73394. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73395. /**
  73396. *
  73397. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73398. * @param taskName defines the name of the new task
  73399. * @param url defines the url of the file to load
  73400. * @param size defines the size you want for the cubemap (can be null)
  73401. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73402. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73403. * @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)
  73404. * @param reserved Internal use only
  73405. * @returns a new HDRCubeTextureAssetTask object
  73406. */
  73407. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73408. /**
  73409. *
  73410. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73411. * @param taskName defines the name of the new task
  73412. * @param url defines the url of the file to load
  73413. * @param size defines the size you want for the cubemap (can be null)
  73414. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73415. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73416. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73417. * @returns a new EquiRectangularCubeTextureAssetTask object
  73418. */
  73419. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73420. /**
  73421. * Remove a task from the assets manager.
  73422. * @param task the task to remove
  73423. */
  73424. removeTask(task: AbstractAssetTask): void;
  73425. private _decreaseWaitingTasksCount;
  73426. private _runTask;
  73427. /**
  73428. * Reset the AssetsManager and remove all tasks
  73429. * @return the current instance of the AssetsManager
  73430. */
  73431. reset(): AssetsManager;
  73432. /**
  73433. * Start the loading process
  73434. * @return the current instance of the AssetsManager
  73435. */
  73436. load(): AssetsManager;
  73437. /**
  73438. * Start the loading process as an async operation
  73439. * @return a promise returning the list of failed tasks
  73440. */
  73441. loadAsync(): Promise<void>;
  73442. }
  73443. }
  73444. declare module BABYLON {
  73445. /**
  73446. * Wrapper class for promise with external resolve and reject.
  73447. */
  73448. export class Deferred<T> {
  73449. /**
  73450. * The promise associated with this deferred object.
  73451. */
  73452. readonly promise: Promise<T>;
  73453. private _resolve;
  73454. private _reject;
  73455. /**
  73456. * The resolve method of the promise associated with this deferred object.
  73457. */
  73458. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73459. /**
  73460. * The reject method of the promise associated with this deferred object.
  73461. */
  73462. get reject(): (reason?: any) => void;
  73463. /**
  73464. * Constructor for this deferred object.
  73465. */
  73466. constructor();
  73467. }
  73468. }
  73469. declare module BABYLON {
  73470. /**
  73471. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73472. */
  73473. export class MeshExploder {
  73474. private _centerMesh;
  73475. private _meshes;
  73476. private _meshesOrigins;
  73477. private _toCenterVectors;
  73478. private _scaledDirection;
  73479. private _newPosition;
  73480. private _centerPosition;
  73481. /**
  73482. * Explodes meshes from a center mesh.
  73483. * @param meshes The meshes to explode.
  73484. * @param centerMesh The mesh to be center of explosion.
  73485. */
  73486. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73487. private _setCenterMesh;
  73488. /**
  73489. * Get class name
  73490. * @returns "MeshExploder"
  73491. */
  73492. getClassName(): string;
  73493. /**
  73494. * "Exploded meshes"
  73495. * @returns Array of meshes with the centerMesh at index 0.
  73496. */
  73497. getMeshes(): Array<Mesh>;
  73498. /**
  73499. * Explodes meshes giving a specific direction
  73500. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73501. */
  73502. explode(direction?: number): void;
  73503. }
  73504. }
  73505. declare module BABYLON {
  73506. /**
  73507. * Class used to help managing file picking and drag'n'drop
  73508. */
  73509. export class FilesInput {
  73510. /**
  73511. * List of files ready to be loaded
  73512. */
  73513. static get FilesToLoad(): {
  73514. [key: string]: File;
  73515. };
  73516. /**
  73517. * Callback called when a file is processed
  73518. */
  73519. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73520. private _engine;
  73521. private _currentScene;
  73522. private _sceneLoadedCallback;
  73523. private _progressCallback;
  73524. private _additionalRenderLoopLogicCallback;
  73525. private _textureLoadingCallback;
  73526. private _startingProcessingFilesCallback;
  73527. private _onReloadCallback;
  73528. private _errorCallback;
  73529. private _elementToMonitor;
  73530. private _sceneFileToLoad;
  73531. private _filesToLoad;
  73532. /**
  73533. * Creates a new FilesInput
  73534. * @param engine defines the rendering engine
  73535. * @param scene defines the hosting scene
  73536. * @param sceneLoadedCallback callback called when scene is loaded
  73537. * @param progressCallback callback called to track progress
  73538. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73539. * @param textureLoadingCallback callback called when a texture is loading
  73540. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73541. * @param onReloadCallback callback called when a reload is requested
  73542. * @param errorCallback callback call if an error occurs
  73543. */
  73544. 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>);
  73545. private _dragEnterHandler;
  73546. private _dragOverHandler;
  73547. private _dropHandler;
  73548. /**
  73549. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73550. * @param elementToMonitor defines the DOM element to track
  73551. */
  73552. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73553. /** Gets the current list of files to load */
  73554. get filesToLoad(): File[];
  73555. /**
  73556. * Release all associated resources
  73557. */
  73558. dispose(): void;
  73559. private renderFunction;
  73560. private drag;
  73561. private drop;
  73562. private _traverseFolder;
  73563. private _processFiles;
  73564. /**
  73565. * Load files from a drop event
  73566. * @param event defines the drop event to use as source
  73567. */
  73568. loadFiles(event: any): void;
  73569. private _processReload;
  73570. /**
  73571. * Reload the current scene from the loaded files
  73572. */
  73573. reload(): void;
  73574. }
  73575. }
  73576. declare module BABYLON {
  73577. /**
  73578. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73579. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73580. */
  73581. export class SceneOptimization {
  73582. /**
  73583. * Defines the priority of this optimization (0 by default which means first in the list)
  73584. */
  73585. priority: number;
  73586. /**
  73587. * Gets a string describing the action executed by the current optimization
  73588. * @returns description string
  73589. */
  73590. getDescription(): string;
  73591. /**
  73592. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73593. * @param scene defines the current scene where to apply this optimization
  73594. * @param optimizer defines the current optimizer
  73595. * @returns true if everything that can be done was applied
  73596. */
  73597. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73598. /**
  73599. * Creates the SceneOptimization object
  73600. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73601. * @param desc defines the description associated with the optimization
  73602. */
  73603. constructor(
  73604. /**
  73605. * Defines the priority of this optimization (0 by default which means first in the list)
  73606. */
  73607. priority?: number);
  73608. }
  73609. /**
  73610. * Defines an optimization used to reduce the size of render target textures
  73611. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73612. */
  73613. export class TextureOptimization extends SceneOptimization {
  73614. /**
  73615. * Defines the priority of this optimization (0 by default which means first in the list)
  73616. */
  73617. priority: number;
  73618. /**
  73619. * 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
  73620. */
  73621. maximumSize: number;
  73622. /**
  73623. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73624. */
  73625. step: number;
  73626. /**
  73627. * Gets a string describing the action executed by the current optimization
  73628. * @returns description string
  73629. */
  73630. getDescription(): string;
  73631. /**
  73632. * Creates the TextureOptimization object
  73633. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73634. * @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
  73635. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73636. */
  73637. constructor(
  73638. /**
  73639. * Defines the priority of this optimization (0 by default which means first in the list)
  73640. */
  73641. priority?: number,
  73642. /**
  73643. * 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
  73644. */
  73645. maximumSize?: number,
  73646. /**
  73647. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73648. */
  73649. step?: number);
  73650. /**
  73651. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73652. * @param scene defines the current scene where to apply this optimization
  73653. * @param optimizer defines the current optimizer
  73654. * @returns true if everything that can be done was applied
  73655. */
  73656. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73657. }
  73658. /**
  73659. * Defines an optimization used to increase or decrease the rendering resolution
  73660. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73661. */
  73662. export class HardwareScalingOptimization extends SceneOptimization {
  73663. /**
  73664. * Defines the priority of this optimization (0 by default which means first in the list)
  73665. */
  73666. priority: number;
  73667. /**
  73668. * Defines the maximum scale to use (2 by default)
  73669. */
  73670. maximumScale: number;
  73671. /**
  73672. * Defines the step to use between two passes (0.5 by default)
  73673. */
  73674. step: number;
  73675. private _currentScale;
  73676. private _directionOffset;
  73677. /**
  73678. * Gets a string describing the action executed by the current optimization
  73679. * @return description string
  73680. */
  73681. getDescription(): string;
  73682. /**
  73683. * Creates the HardwareScalingOptimization object
  73684. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73685. * @param maximumScale defines the maximum scale to use (2 by default)
  73686. * @param step defines the step to use between two passes (0.5 by default)
  73687. */
  73688. constructor(
  73689. /**
  73690. * Defines the priority of this optimization (0 by default which means first in the list)
  73691. */
  73692. priority?: number,
  73693. /**
  73694. * Defines the maximum scale to use (2 by default)
  73695. */
  73696. maximumScale?: number,
  73697. /**
  73698. * Defines the step to use between two passes (0.5 by default)
  73699. */
  73700. step?: number);
  73701. /**
  73702. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73703. * @param scene defines the current scene where to apply this optimization
  73704. * @param optimizer defines the current optimizer
  73705. * @returns true if everything that can be done was applied
  73706. */
  73707. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73708. }
  73709. /**
  73710. * Defines an optimization used to remove shadows
  73711. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73712. */
  73713. export class ShadowsOptimization extends SceneOptimization {
  73714. /**
  73715. * Gets a string describing the action executed by the current optimization
  73716. * @return description string
  73717. */
  73718. getDescription(): string;
  73719. /**
  73720. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73721. * @param scene defines the current scene where to apply this optimization
  73722. * @param optimizer defines the current optimizer
  73723. * @returns true if everything that can be done was applied
  73724. */
  73725. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73726. }
  73727. /**
  73728. * Defines an optimization used to turn post-processes off
  73729. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73730. */
  73731. export class PostProcessesOptimization extends SceneOptimization {
  73732. /**
  73733. * Gets a string describing the action executed by the current optimization
  73734. * @return description string
  73735. */
  73736. getDescription(): string;
  73737. /**
  73738. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73739. * @param scene defines the current scene where to apply this optimization
  73740. * @param optimizer defines the current optimizer
  73741. * @returns true if everything that can be done was applied
  73742. */
  73743. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73744. }
  73745. /**
  73746. * Defines an optimization used to turn lens flares off
  73747. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73748. */
  73749. export class LensFlaresOptimization extends SceneOptimization {
  73750. /**
  73751. * Gets a string describing the action executed by the current optimization
  73752. * @return description string
  73753. */
  73754. getDescription(): string;
  73755. /**
  73756. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73757. * @param scene defines the current scene where to apply this optimization
  73758. * @param optimizer defines the current optimizer
  73759. * @returns true if everything that can be done was applied
  73760. */
  73761. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73762. }
  73763. /**
  73764. * Defines an optimization based on user defined callback.
  73765. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73766. */
  73767. export class CustomOptimization extends SceneOptimization {
  73768. /**
  73769. * Callback called to apply the custom optimization.
  73770. */
  73771. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  73772. /**
  73773. * Callback called to get custom description
  73774. */
  73775. onGetDescription: () => string;
  73776. /**
  73777. * Gets a string describing the action executed by the current optimization
  73778. * @returns description string
  73779. */
  73780. getDescription(): string;
  73781. /**
  73782. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73783. * @param scene defines the current scene where to apply this optimization
  73784. * @param optimizer defines the current optimizer
  73785. * @returns true if everything that can be done was applied
  73786. */
  73787. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73788. }
  73789. /**
  73790. * Defines an optimization used to turn particles off
  73791. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73792. */
  73793. export class ParticlesOptimization extends SceneOptimization {
  73794. /**
  73795. * Gets a string describing the action executed by the current optimization
  73796. * @return description string
  73797. */
  73798. getDescription(): string;
  73799. /**
  73800. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73801. * @param scene defines the current scene where to apply this optimization
  73802. * @param optimizer defines the current optimizer
  73803. * @returns true if everything that can be done was applied
  73804. */
  73805. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73806. }
  73807. /**
  73808. * Defines an optimization used to turn render targets off
  73809. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73810. */
  73811. export class RenderTargetsOptimization extends SceneOptimization {
  73812. /**
  73813. * Gets a string describing the action executed by the current optimization
  73814. * @return description string
  73815. */
  73816. getDescription(): string;
  73817. /**
  73818. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73819. * @param scene defines the current scene where to apply this optimization
  73820. * @param optimizer defines the current optimizer
  73821. * @returns true if everything that can be done was applied
  73822. */
  73823. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73824. }
  73825. /**
  73826. * Defines an optimization used to merge meshes with compatible materials
  73827. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73828. */
  73829. export class MergeMeshesOptimization extends SceneOptimization {
  73830. private static _UpdateSelectionTree;
  73831. /**
  73832. * Gets or sets a boolean which defines if optimization octree has to be updated
  73833. */
  73834. static get UpdateSelectionTree(): boolean;
  73835. /**
  73836. * Gets or sets a boolean which defines if optimization octree has to be updated
  73837. */
  73838. static set UpdateSelectionTree(value: boolean);
  73839. /**
  73840. * Gets a string describing the action executed by the current optimization
  73841. * @return description string
  73842. */
  73843. getDescription(): string;
  73844. private _canBeMerged;
  73845. /**
  73846. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73847. * @param scene defines the current scene where to apply this optimization
  73848. * @param optimizer defines the current optimizer
  73849. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73850. * @returns true if everything that can be done was applied
  73851. */
  73852. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73853. }
  73854. /**
  73855. * Defines a list of options used by SceneOptimizer
  73856. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73857. */
  73858. export class SceneOptimizerOptions {
  73859. /**
  73860. * Defines the target frame rate to reach (60 by default)
  73861. */
  73862. targetFrameRate: number;
  73863. /**
  73864. * Defines the interval between two checkes (2000ms by default)
  73865. */
  73866. trackerDuration: number;
  73867. /**
  73868. * Gets the list of optimizations to apply
  73869. */
  73870. optimizations: SceneOptimization[];
  73871. /**
  73872. * Creates a new list of options used by SceneOptimizer
  73873. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73874. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73875. */
  73876. constructor(
  73877. /**
  73878. * Defines the target frame rate to reach (60 by default)
  73879. */
  73880. targetFrameRate?: number,
  73881. /**
  73882. * Defines the interval between two checkes (2000ms by default)
  73883. */
  73884. trackerDuration?: number);
  73885. /**
  73886. * Add a new optimization
  73887. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73888. * @returns the current SceneOptimizerOptions
  73889. */
  73890. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73891. /**
  73892. * Add a new custom optimization
  73893. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73894. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73895. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73896. * @returns the current SceneOptimizerOptions
  73897. */
  73898. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73899. /**
  73900. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73901. * @param targetFrameRate defines the target frame rate (60 by default)
  73902. * @returns a SceneOptimizerOptions object
  73903. */
  73904. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73905. /**
  73906. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73907. * @param targetFrameRate defines the target frame rate (60 by default)
  73908. * @returns a SceneOptimizerOptions object
  73909. */
  73910. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73911. /**
  73912. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73913. * @param targetFrameRate defines the target frame rate (60 by default)
  73914. * @returns a SceneOptimizerOptions object
  73915. */
  73916. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73917. }
  73918. /**
  73919. * Class used to run optimizations in order to reach a target frame rate
  73920. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73921. */
  73922. export class SceneOptimizer implements IDisposable {
  73923. private _isRunning;
  73924. private _options;
  73925. private _scene;
  73926. private _currentPriorityLevel;
  73927. private _targetFrameRate;
  73928. private _trackerDuration;
  73929. private _currentFrameRate;
  73930. private _sceneDisposeObserver;
  73931. private _improvementMode;
  73932. /**
  73933. * Defines an observable called when the optimizer reaches the target frame rate
  73934. */
  73935. onSuccessObservable: Observable<SceneOptimizer>;
  73936. /**
  73937. * Defines an observable called when the optimizer enables an optimization
  73938. */
  73939. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73940. /**
  73941. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73942. */
  73943. onFailureObservable: Observable<SceneOptimizer>;
  73944. /**
  73945. * Gets a boolean indicating if the optimizer is in improvement mode
  73946. */
  73947. get isInImprovementMode(): boolean;
  73948. /**
  73949. * Gets the current priority level (0 at start)
  73950. */
  73951. get currentPriorityLevel(): number;
  73952. /**
  73953. * Gets the current frame rate checked by the SceneOptimizer
  73954. */
  73955. get currentFrameRate(): number;
  73956. /**
  73957. * Gets or sets the current target frame rate (60 by default)
  73958. */
  73959. get targetFrameRate(): number;
  73960. /**
  73961. * Gets or sets the current target frame rate (60 by default)
  73962. */
  73963. set targetFrameRate(value: number);
  73964. /**
  73965. * Gets or sets the current interval between two checks (every 2000ms by default)
  73966. */
  73967. get trackerDuration(): number;
  73968. /**
  73969. * Gets or sets the current interval between two checks (every 2000ms by default)
  73970. */
  73971. set trackerDuration(value: number);
  73972. /**
  73973. * Gets the list of active optimizations
  73974. */
  73975. get optimizations(): SceneOptimization[];
  73976. /**
  73977. * Creates a new SceneOptimizer
  73978. * @param scene defines the scene to work on
  73979. * @param options defines the options to use with the SceneOptimizer
  73980. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73981. * @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)
  73982. */
  73983. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73984. /**
  73985. * Stops the current optimizer
  73986. */
  73987. stop(): void;
  73988. /**
  73989. * Reset the optimizer to initial step (current priority level = 0)
  73990. */
  73991. reset(): void;
  73992. /**
  73993. * Start the optimizer. By default it will try to reach a specific framerate
  73994. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73995. */
  73996. start(): void;
  73997. private _checkCurrentState;
  73998. /**
  73999. * Release all resources
  74000. */
  74001. dispose(): void;
  74002. /**
  74003. * Helper function to create a SceneOptimizer with one single line of code
  74004. * @param scene defines the scene to work on
  74005. * @param options defines the options to use with the SceneOptimizer
  74006. * @param onSuccess defines a callback to call on success
  74007. * @param onFailure defines a callback to call on failure
  74008. * @returns the new SceneOptimizer object
  74009. */
  74010. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74011. }
  74012. }
  74013. declare module BABYLON {
  74014. /**
  74015. * Class used to serialize a scene into a string
  74016. */
  74017. export class SceneSerializer {
  74018. /**
  74019. * Clear cache used by a previous serialization
  74020. */
  74021. static ClearCache(): void;
  74022. /**
  74023. * Serialize a scene into a JSON compatible object
  74024. * @param scene defines the scene to serialize
  74025. * @returns a JSON compatible object
  74026. */
  74027. static Serialize(scene: Scene): any;
  74028. /**
  74029. * Serialize a mesh into a JSON compatible object
  74030. * @param toSerialize defines the mesh to serialize
  74031. * @param withParents defines if parents must be serialized as well
  74032. * @param withChildren defines if children must be serialized as well
  74033. * @returns a JSON compatible object
  74034. */
  74035. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74036. }
  74037. }
  74038. declare module BABYLON {
  74039. /**
  74040. * Class used to host texture specific utilities
  74041. */
  74042. export class TextureTools {
  74043. /**
  74044. * Uses the GPU to create a copy texture rescaled at a given size
  74045. * @param texture Texture to copy from
  74046. * @param width defines the desired width
  74047. * @param height defines the desired height
  74048. * @param useBilinearMode defines if bilinear mode has to be used
  74049. * @return the generated texture
  74050. */
  74051. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74052. }
  74053. }
  74054. declare module BABYLON {
  74055. /**
  74056. * This represents the different options available for the video capture.
  74057. */
  74058. export interface VideoRecorderOptions {
  74059. /** Defines the mime type of the video. */
  74060. mimeType: string;
  74061. /** Defines the FPS the video should be recorded at. */
  74062. fps: number;
  74063. /** Defines the chunk size for the recording data. */
  74064. recordChunckSize: number;
  74065. /** The audio tracks to attach to the recording. */
  74066. audioTracks?: MediaStreamTrack[];
  74067. }
  74068. /**
  74069. * This can help with recording videos from BabylonJS.
  74070. * This is based on the available WebRTC functionalities of the browser.
  74071. *
  74072. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74073. */
  74074. export class VideoRecorder {
  74075. private static readonly _defaultOptions;
  74076. /**
  74077. * Returns whether or not the VideoRecorder is available in your browser.
  74078. * @param engine Defines the Babylon Engine.
  74079. * @returns true if supported otherwise false.
  74080. */
  74081. static IsSupported(engine: Engine): boolean;
  74082. private readonly _options;
  74083. private _canvas;
  74084. private _mediaRecorder;
  74085. private _recordedChunks;
  74086. private _fileName;
  74087. private _resolve;
  74088. private _reject;
  74089. /**
  74090. * True when a recording is already in progress.
  74091. */
  74092. get isRecording(): boolean;
  74093. /**
  74094. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74095. * @param engine Defines the BabylonJS Engine you wish to record.
  74096. * @param options Defines options that can be used to customize the capture.
  74097. */
  74098. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74099. /**
  74100. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74101. */
  74102. stopRecording(): void;
  74103. /**
  74104. * Starts recording the canvas for a max duration specified in parameters.
  74105. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74106. * If null no automatic download will start and you can rely on the promise to get the data back.
  74107. * @param maxDuration Defines the maximum recording time in seconds.
  74108. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74109. * @return A promise callback at the end of the recording with the video data in Blob.
  74110. */
  74111. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74112. /**
  74113. * Releases internal resources used during the recording.
  74114. */
  74115. dispose(): void;
  74116. private _handleDataAvailable;
  74117. private _handleError;
  74118. private _handleStop;
  74119. }
  74120. }
  74121. declare module BABYLON {
  74122. /**
  74123. * Class containing a set of static utilities functions for screenshots
  74124. */
  74125. export class ScreenshotTools {
  74126. /**
  74127. * Captures a screenshot of the current rendering
  74128. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74129. * @param engine defines the rendering engine
  74130. * @param camera defines the source camera
  74131. * @param size This parameter can be set to a single number or to an object with the
  74132. * following (optional) properties: precision, width, height. If a single number is passed,
  74133. * it will be used for both width and height. If an object is passed, the screenshot size
  74134. * will be derived from the parameters. The precision property is a multiplier allowing
  74135. * rendering at a higher or lower resolution
  74136. * @param successCallback defines the callback receives a single parameter which contains the
  74137. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74138. * src parameter of an <img> to display it
  74139. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74140. * Check your browser for supported MIME types
  74141. */
  74142. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74143. /**
  74144. * Captures a screenshot of the current rendering
  74145. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74146. * @param engine defines the rendering engine
  74147. * @param camera defines the source camera
  74148. * @param size This parameter can be set to a single number or to an object with the
  74149. * following (optional) properties: precision, width, height. If a single number is passed,
  74150. * it will be used for both width and height. If an object is passed, the screenshot size
  74151. * will be derived from the parameters. The precision property is a multiplier allowing
  74152. * rendering at a higher or lower resolution
  74153. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74154. * Check your browser for supported MIME types
  74155. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74156. * to the src parameter of an <img> to display it
  74157. */
  74158. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74159. /**
  74160. * Generates an image screenshot from the specified camera.
  74161. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74162. * @param engine The engine to use for rendering
  74163. * @param camera The camera to use for rendering
  74164. * @param size This parameter can be set to a single number or to an object with the
  74165. * following (optional) properties: precision, width, height. If a single number is passed,
  74166. * it will be used for both width and height. If an object is passed, the screenshot size
  74167. * will be derived from the parameters. The precision property is a multiplier allowing
  74168. * rendering at a higher or lower resolution
  74169. * @param successCallback The callback receives a single parameter which contains the
  74170. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74171. * src parameter of an <img> to display it
  74172. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74173. * Check your browser for supported MIME types
  74174. * @param samples Texture samples (default: 1)
  74175. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74176. * @param fileName A name for for the downloaded file.
  74177. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74178. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74179. */
  74180. 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;
  74181. /**
  74182. * Generates an image screenshot from the specified camera.
  74183. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74184. * @param engine The engine to use for rendering
  74185. * @param camera The camera to use for rendering
  74186. * @param size This parameter can be set to a single number or to an object with the
  74187. * following (optional) properties: precision, width, height. If a single number is passed,
  74188. * it will be used for both width and height. If an object is passed, the screenshot size
  74189. * will be derived from the parameters. The precision property is a multiplier allowing
  74190. * rendering at a higher or lower resolution
  74191. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74192. * Check your browser for supported MIME types
  74193. * @param samples Texture samples (default: 1)
  74194. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74195. * @param fileName A name for for the downloaded file.
  74196. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74197. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74198. * to the src parameter of an <img> to display it
  74199. */
  74200. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74201. /**
  74202. * Gets height and width for screenshot size
  74203. * @private
  74204. */
  74205. private static _getScreenshotSize;
  74206. }
  74207. }
  74208. declare module BABYLON {
  74209. /**
  74210. * Interface for a data buffer
  74211. */
  74212. export interface IDataBuffer {
  74213. /**
  74214. * Reads bytes from the data buffer.
  74215. * @param byteOffset The byte offset to read
  74216. * @param byteLength The byte length to read
  74217. * @returns A promise that resolves when the bytes are read
  74218. */
  74219. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74220. /**
  74221. * The byte length of the buffer.
  74222. */
  74223. readonly byteLength: number;
  74224. }
  74225. /**
  74226. * Utility class for reading from a data buffer
  74227. */
  74228. export class DataReader {
  74229. /**
  74230. * The data buffer associated with this data reader.
  74231. */
  74232. readonly buffer: IDataBuffer;
  74233. /**
  74234. * The current byte offset from the beginning of the data buffer.
  74235. */
  74236. byteOffset: number;
  74237. private _dataView;
  74238. private _dataByteOffset;
  74239. /**
  74240. * Constructor
  74241. * @param buffer The buffer to read
  74242. */
  74243. constructor(buffer: IDataBuffer);
  74244. /**
  74245. * Loads the given byte length.
  74246. * @param byteLength The byte length to load
  74247. * @returns A promise that resolves when the load is complete
  74248. */
  74249. loadAsync(byteLength: number): Promise<void>;
  74250. /**
  74251. * Read a unsigned 32-bit integer from the currently loaded data range.
  74252. * @returns The 32-bit integer read
  74253. */
  74254. readUint32(): number;
  74255. /**
  74256. * Read a byte array from the currently loaded data range.
  74257. * @param byteLength The byte length to read
  74258. * @returns The byte array read
  74259. */
  74260. readUint8Array(byteLength: number): Uint8Array;
  74261. /**
  74262. * Read a string from the currently loaded data range.
  74263. * @param byteLength The byte length to read
  74264. * @returns The string read
  74265. */
  74266. readString(byteLength: number): string;
  74267. /**
  74268. * Skips the given byte length the currently loaded data range.
  74269. * @param byteLength The byte length to skip
  74270. */
  74271. skipBytes(byteLength: number): void;
  74272. }
  74273. }
  74274. declare module BABYLON {
  74275. /**
  74276. * Class for storing data to local storage if available or in-memory storage otherwise
  74277. */
  74278. export class DataStorage {
  74279. private static _Storage;
  74280. private static _GetStorage;
  74281. /**
  74282. * Reads a string from the data storage
  74283. * @param key The key to read
  74284. * @param defaultValue The value if the key doesn't exist
  74285. * @returns The string value
  74286. */
  74287. static ReadString(key: string, defaultValue: string): string;
  74288. /**
  74289. * Writes a string to the data storage
  74290. * @param key The key to write
  74291. * @param value The value to write
  74292. */
  74293. static WriteString(key: string, value: string): void;
  74294. /**
  74295. * Reads a boolean from the data storage
  74296. * @param key The key to read
  74297. * @param defaultValue The value if the key doesn't exist
  74298. * @returns The boolean value
  74299. */
  74300. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74301. /**
  74302. * Writes a boolean to the data storage
  74303. * @param key The key to write
  74304. * @param value The value to write
  74305. */
  74306. static WriteBoolean(key: string, value: boolean): void;
  74307. /**
  74308. * Reads a number from the data storage
  74309. * @param key The key to read
  74310. * @param defaultValue The value if the key doesn't exist
  74311. * @returns The number value
  74312. */
  74313. static ReadNumber(key: string, defaultValue: number): number;
  74314. /**
  74315. * Writes a number to the data storage
  74316. * @param key The key to write
  74317. * @param value The value to write
  74318. */
  74319. static WriteNumber(key: string, value: number): void;
  74320. }
  74321. }
  74322. declare module BABYLON {
  74323. /**
  74324. * Class used to record delta files between 2 scene states
  74325. */
  74326. export class SceneRecorder {
  74327. private _trackedScene;
  74328. private _savedJSON;
  74329. /**
  74330. * Track a given scene. This means the current scene state will be considered the original state
  74331. * @param scene defines the scene to track
  74332. */
  74333. track(scene: Scene): void;
  74334. /**
  74335. * Get the delta between current state and original state
  74336. * @returns a string containing the delta
  74337. */
  74338. getDelta(): any;
  74339. private _compareArray;
  74340. private _compareObjects;
  74341. private _compareCollections;
  74342. private static GetShadowGeneratorById;
  74343. /**
  74344. * Apply a given delta to a given scene
  74345. * @param deltaJSON defines the JSON containing the delta
  74346. * @param scene defines the scene to apply the delta to
  74347. */
  74348. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74349. private static _ApplyPropertiesToEntity;
  74350. private static _ApplyDeltaForEntity;
  74351. }
  74352. }
  74353. declare module BABYLON {
  74354. /**
  74355. * An interface for all Hit test features
  74356. */
  74357. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74358. /**
  74359. * Triggered when new babylon (transformed) hit test results are available
  74360. */
  74361. onHitTestResultObservable: Observable<T[]>;
  74362. }
  74363. /**
  74364. * Options used for hit testing
  74365. */
  74366. export interface IWebXRLegacyHitTestOptions {
  74367. /**
  74368. * Only test when user interacted with the scene. Default - hit test every frame
  74369. */
  74370. testOnPointerDownOnly?: boolean;
  74371. /**
  74372. * The node to use to transform the local results to world coordinates
  74373. */
  74374. worldParentNode?: TransformNode;
  74375. }
  74376. /**
  74377. * Interface defining the babylon result of raycasting/hit-test
  74378. */
  74379. export interface IWebXRLegacyHitResult {
  74380. /**
  74381. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74382. */
  74383. transformationMatrix: Matrix;
  74384. /**
  74385. * The native hit test result
  74386. */
  74387. xrHitResult: XRHitResult | XRHitTestResult;
  74388. }
  74389. /**
  74390. * The currently-working hit-test module.
  74391. * Hit test (or Ray-casting) is used to interact with the real world.
  74392. * For further information read here - https://github.com/immersive-web/hit-test
  74393. */
  74394. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74395. /**
  74396. * options to use when constructing this feature
  74397. */
  74398. readonly options: IWebXRLegacyHitTestOptions;
  74399. private _direction;
  74400. private _mat;
  74401. private _onSelectEnabled;
  74402. private _origin;
  74403. /**
  74404. * The module's name
  74405. */
  74406. static readonly Name: string;
  74407. /**
  74408. * The (Babylon) version of this module.
  74409. * This is an integer representing the implementation version.
  74410. * This number does not correspond to the WebXR specs version
  74411. */
  74412. static readonly Version: number;
  74413. /**
  74414. * Populated with the last native XR Hit Results
  74415. */
  74416. lastNativeXRHitResults: XRHitResult[];
  74417. /**
  74418. * Triggered when new babylon (transformed) hit test results are available
  74419. */
  74420. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74421. /**
  74422. * Creates a new instance of the (legacy version) hit test feature
  74423. * @param _xrSessionManager an instance of WebXRSessionManager
  74424. * @param options options to use when constructing this feature
  74425. */
  74426. constructor(_xrSessionManager: WebXRSessionManager,
  74427. /**
  74428. * options to use when constructing this feature
  74429. */
  74430. options?: IWebXRLegacyHitTestOptions);
  74431. /**
  74432. * execute a hit test with an XR Ray
  74433. *
  74434. * @param xrSession a native xrSession that will execute this hit test
  74435. * @param xrRay the ray (position and direction) to use for ray-casting
  74436. * @param referenceSpace native XR reference space to use for the hit-test
  74437. * @param filter filter function that will filter the results
  74438. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74439. */
  74440. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74441. /**
  74442. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74443. * @param event the (select) event to use to select with
  74444. * @param referenceSpace the reference space to use for this hit test
  74445. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74446. */
  74447. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74448. /**
  74449. * attach this feature
  74450. * Will usually be called by the features manager
  74451. *
  74452. * @returns true if successful.
  74453. */
  74454. attach(): boolean;
  74455. /**
  74456. * detach this feature.
  74457. * Will usually be called by the features manager
  74458. *
  74459. * @returns true if successful.
  74460. */
  74461. detach(): boolean;
  74462. /**
  74463. * Dispose this feature and all of the resources attached
  74464. */
  74465. dispose(): void;
  74466. protected _onXRFrame(frame: XRFrame): void;
  74467. private _onHitTestResults;
  74468. private _onSelect;
  74469. }
  74470. }
  74471. declare module BABYLON {
  74472. /**
  74473. * Options used for hit testing (version 2)
  74474. */
  74475. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74476. /**
  74477. * Do not create a permanent hit test. Will usually be used when only
  74478. * transient inputs are needed.
  74479. */
  74480. disablePermanentHitTest?: boolean;
  74481. /**
  74482. * Enable transient (for example touch-based) hit test inspections
  74483. */
  74484. enableTransientHitTest?: boolean;
  74485. /**
  74486. * Offset ray for the permanent hit test
  74487. */
  74488. offsetRay?: Vector3;
  74489. /**
  74490. * Offset ray for the transient hit test
  74491. */
  74492. transientOffsetRay?: Vector3;
  74493. /**
  74494. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74495. */
  74496. useReferenceSpace?: boolean;
  74497. /**
  74498. * Override the default entity type(s) of the hit-test result
  74499. */
  74500. entityTypes?: XRHitTestTrackableType[];
  74501. }
  74502. /**
  74503. * Interface defining the babylon result of hit-test
  74504. */
  74505. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74506. /**
  74507. * The input source that generated this hit test (if transient)
  74508. */
  74509. inputSource?: XRInputSource;
  74510. /**
  74511. * Is this a transient hit test
  74512. */
  74513. isTransient?: boolean;
  74514. /**
  74515. * Position of the hit test result
  74516. */
  74517. position: Vector3;
  74518. /**
  74519. * Rotation of the hit test result
  74520. */
  74521. rotationQuaternion: Quaternion;
  74522. /**
  74523. * The native hit test result
  74524. */
  74525. xrHitResult: XRHitTestResult;
  74526. }
  74527. /**
  74528. * The currently-working hit-test module.
  74529. * Hit test (or Ray-casting) is used to interact with the real world.
  74530. * For further information read here - https://github.com/immersive-web/hit-test
  74531. *
  74532. * Tested on chrome (mobile) 80.
  74533. */
  74534. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74535. /**
  74536. * options to use when constructing this feature
  74537. */
  74538. readonly options: IWebXRHitTestOptions;
  74539. private _tmpMat;
  74540. private _tmpPos;
  74541. private _tmpQuat;
  74542. private _transientXrHitTestSource;
  74543. private _xrHitTestSource;
  74544. private initHitTestSource;
  74545. /**
  74546. * The module's name
  74547. */
  74548. static readonly Name: string;
  74549. /**
  74550. * The (Babylon) version of this module.
  74551. * This is an integer representing the implementation version.
  74552. * This number does not correspond to the WebXR specs version
  74553. */
  74554. static readonly Version: number;
  74555. /**
  74556. * When set to true, each hit test will have its own position/rotation objects
  74557. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74558. * the developers will clone them or copy them as they see fit.
  74559. */
  74560. autoCloneTransformation: boolean;
  74561. /**
  74562. * Triggered when new babylon (transformed) hit test results are available
  74563. * Note - this will be called when results come back from the device. It can be an empty array!!
  74564. */
  74565. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74566. /**
  74567. * Use this to temporarily pause hit test checks.
  74568. */
  74569. paused: boolean;
  74570. /**
  74571. * Creates a new instance of the hit test feature
  74572. * @param _xrSessionManager an instance of WebXRSessionManager
  74573. * @param options options to use when constructing this feature
  74574. */
  74575. constructor(_xrSessionManager: WebXRSessionManager,
  74576. /**
  74577. * options to use when constructing this feature
  74578. */
  74579. options?: IWebXRHitTestOptions);
  74580. /**
  74581. * attach this feature
  74582. * Will usually be called by the features manager
  74583. *
  74584. * @returns true if successful.
  74585. */
  74586. attach(): boolean;
  74587. /**
  74588. * detach this feature.
  74589. * Will usually be called by the features manager
  74590. *
  74591. * @returns true if successful.
  74592. */
  74593. detach(): boolean;
  74594. /**
  74595. * Dispose this feature and all of the resources attached
  74596. */
  74597. dispose(): void;
  74598. protected _onXRFrame(frame: XRFrame): void;
  74599. private _processWebXRHitTestResult;
  74600. }
  74601. }
  74602. declare module BABYLON {
  74603. /**
  74604. * Configuration options of the anchor system
  74605. */
  74606. export interface IWebXRAnchorSystemOptions {
  74607. /**
  74608. * a node that will be used to convert local to world coordinates
  74609. */
  74610. worldParentNode?: TransformNode;
  74611. /**
  74612. * If set to true a reference of the created anchors will be kept until the next session starts
  74613. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  74614. */
  74615. doNotRemoveAnchorsOnSessionEnded?: boolean;
  74616. }
  74617. /**
  74618. * A babylon container for an XR Anchor
  74619. */
  74620. export interface IWebXRAnchor {
  74621. /**
  74622. * A babylon-assigned ID for this anchor
  74623. */
  74624. id: number;
  74625. /**
  74626. * Transformation matrix to apply to an object attached to this anchor
  74627. */
  74628. transformationMatrix: Matrix;
  74629. /**
  74630. * The native anchor object
  74631. */
  74632. xrAnchor: XRAnchor;
  74633. /**
  74634. * if defined, this object will be constantly updated by the anchor's position and rotation
  74635. */
  74636. attachedNode?: TransformNode;
  74637. }
  74638. /**
  74639. * An implementation of the anchor system for WebXR.
  74640. * For further information see https://github.com/immersive-web/anchors/
  74641. */
  74642. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74643. private _options;
  74644. private _lastFrameDetected;
  74645. private _trackedAnchors;
  74646. private _referenceSpaceForFrameAnchors;
  74647. private _futureAnchors;
  74648. /**
  74649. * The module's name
  74650. */
  74651. static readonly Name: string;
  74652. /**
  74653. * The (Babylon) version of this module.
  74654. * This is an integer representing the implementation version.
  74655. * This number does not correspond to the WebXR specs version
  74656. */
  74657. static readonly Version: number;
  74658. /**
  74659. * Observers registered here will be executed when a new anchor was added to the session
  74660. */
  74661. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  74662. /**
  74663. * Observers registered here will be executed when an anchor was removed from the session
  74664. */
  74665. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  74666. /**
  74667. * Observers registered here will be executed when an existing anchor updates
  74668. * This can execute N times every frame
  74669. */
  74670. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  74671. /**
  74672. * Set the reference space to use for anchor creation, when not using a hit test.
  74673. * Will default to the session's reference space if not defined
  74674. */
  74675. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  74676. /**
  74677. * constructs a new anchor system
  74678. * @param _xrSessionManager an instance of WebXRSessionManager
  74679. * @param _options configuration object for this feature
  74680. */
  74681. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  74682. private _tmpVector;
  74683. private _tmpQuaternion;
  74684. private _populateTmpTransformation;
  74685. /**
  74686. * Create a new anchor point using a hit test result at a specific point in the scene
  74687. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74688. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74689. *
  74690. * @param hitTestResult The hit test result to use for this anchor creation
  74691. * @param position an optional position offset for this anchor
  74692. * @param rotationQuaternion an optional rotation offset for this anchor
  74693. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74694. */
  74695. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  74696. /**
  74697. * Add a new anchor at a specific position and rotation
  74698. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  74699. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  74700. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74701. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74702. *
  74703. * @param position the position in which to add an anchor
  74704. * @param rotationQuaternion an optional rotation for the anchor transformation
  74705. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  74706. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74707. */
  74708. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  74709. /**
  74710. * detach this feature.
  74711. * Will usually be called by the features manager
  74712. *
  74713. * @returns true if successful.
  74714. */
  74715. detach(): boolean;
  74716. /**
  74717. * Dispose this feature and all of the resources attached
  74718. */
  74719. dispose(): void;
  74720. protected _onXRFrame(frame: XRFrame): void;
  74721. /**
  74722. * avoiding using Array.find for global support.
  74723. * @param xrAnchor the plane to find in the array
  74724. */
  74725. private _findIndexInAnchorArray;
  74726. private _updateAnchorWithXRFrame;
  74727. private _createAnchorAtTransformation;
  74728. }
  74729. }
  74730. declare module BABYLON {
  74731. /**
  74732. * Options used in the plane detector module
  74733. */
  74734. export interface IWebXRPlaneDetectorOptions {
  74735. /**
  74736. * The node to use to transform the local results to world coordinates
  74737. */
  74738. worldParentNode?: TransformNode;
  74739. /**
  74740. * If set to true a reference of the created planes will be kept until the next session starts
  74741. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  74742. */
  74743. doNotRemovePlanesOnSessionEnded?: boolean;
  74744. }
  74745. /**
  74746. * A babylon interface for a WebXR plane.
  74747. * A Plane is actually a polygon, built from N points in space
  74748. *
  74749. * Supported in chrome 79, not supported in canary 81 ATM
  74750. */
  74751. export interface IWebXRPlane {
  74752. /**
  74753. * a babylon-assigned ID for this polygon
  74754. */
  74755. id: number;
  74756. /**
  74757. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74758. */
  74759. polygonDefinition: Array<Vector3>;
  74760. /**
  74761. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74762. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74763. */
  74764. transformationMatrix: Matrix;
  74765. /**
  74766. * the native xr-plane object
  74767. */
  74768. xrPlane: XRPlane;
  74769. }
  74770. /**
  74771. * The plane detector is used to detect planes in the real world when in AR
  74772. * For more information see https://github.com/immersive-web/real-world-geometry/
  74773. */
  74774. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74775. private _options;
  74776. private _detectedPlanes;
  74777. private _enabled;
  74778. private _lastFrameDetected;
  74779. /**
  74780. * The module's name
  74781. */
  74782. static readonly Name: string;
  74783. /**
  74784. * The (Babylon) version of this module.
  74785. * This is an integer representing the implementation version.
  74786. * This number does not correspond to the WebXR specs version
  74787. */
  74788. static readonly Version: number;
  74789. /**
  74790. * Observers registered here will be executed when a new plane was added to the session
  74791. */
  74792. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74793. /**
  74794. * Observers registered here will be executed when a plane is no longer detected in the session
  74795. */
  74796. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74797. /**
  74798. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74799. * This can execute N times every frame
  74800. */
  74801. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74802. /**
  74803. * construct a new Plane Detector
  74804. * @param _xrSessionManager an instance of xr Session manager
  74805. * @param _options configuration to use when constructing this feature
  74806. */
  74807. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74808. /**
  74809. * detach this feature.
  74810. * Will usually be called by the features manager
  74811. *
  74812. * @returns true if successful.
  74813. */
  74814. detach(): boolean;
  74815. /**
  74816. * Dispose this feature and all of the resources attached
  74817. */
  74818. dispose(): void;
  74819. protected _onXRFrame(frame: XRFrame): void;
  74820. private _init;
  74821. private _updatePlaneWithXRPlane;
  74822. /**
  74823. * avoiding using Array.find for global support.
  74824. * @param xrPlane the plane to find in the array
  74825. */
  74826. private findIndexInPlaneArray;
  74827. }
  74828. }
  74829. declare module BABYLON {
  74830. /**
  74831. * Options interface for the background remover plugin
  74832. */
  74833. export interface IWebXRBackgroundRemoverOptions {
  74834. /**
  74835. * Further background meshes to disable when entering AR
  74836. */
  74837. backgroundMeshes?: AbstractMesh[];
  74838. /**
  74839. * flags to configure the removal of the environment helper.
  74840. * If not set, the entire background will be removed. If set, flags should be set as well.
  74841. */
  74842. environmentHelperRemovalFlags?: {
  74843. /**
  74844. * Should the skybox be removed (default false)
  74845. */
  74846. skyBox?: boolean;
  74847. /**
  74848. * Should the ground be removed (default false)
  74849. */
  74850. ground?: boolean;
  74851. };
  74852. /**
  74853. * don't disable the environment helper
  74854. */
  74855. ignoreEnvironmentHelper?: boolean;
  74856. }
  74857. /**
  74858. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74859. */
  74860. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74861. /**
  74862. * read-only options to be used in this module
  74863. */
  74864. readonly options: IWebXRBackgroundRemoverOptions;
  74865. /**
  74866. * The module's name
  74867. */
  74868. static readonly Name: string;
  74869. /**
  74870. * The (Babylon) version of this module.
  74871. * This is an integer representing the implementation version.
  74872. * This number does not correspond to the WebXR specs version
  74873. */
  74874. static readonly Version: number;
  74875. /**
  74876. * registered observers will be triggered when the background state changes
  74877. */
  74878. onBackgroundStateChangedObservable: Observable<boolean>;
  74879. /**
  74880. * constructs a new background remover module
  74881. * @param _xrSessionManager the session manager for this module
  74882. * @param options read-only options to be used in this module
  74883. */
  74884. constructor(_xrSessionManager: WebXRSessionManager,
  74885. /**
  74886. * read-only options to be used in this module
  74887. */
  74888. options?: IWebXRBackgroundRemoverOptions);
  74889. /**
  74890. * attach this feature
  74891. * Will usually be called by the features manager
  74892. *
  74893. * @returns true if successful.
  74894. */
  74895. attach(): boolean;
  74896. /**
  74897. * detach this feature.
  74898. * Will usually be called by the features manager
  74899. *
  74900. * @returns true if successful.
  74901. */
  74902. detach(): boolean;
  74903. /**
  74904. * Dispose this feature and all of the resources attached
  74905. */
  74906. dispose(): void;
  74907. protected _onXRFrame(_xrFrame: XRFrame): void;
  74908. private _setBackgroundState;
  74909. }
  74910. }
  74911. declare module BABYLON {
  74912. /**
  74913. * Options for the controller physics feature
  74914. */
  74915. export class IWebXRControllerPhysicsOptions {
  74916. /**
  74917. * Should the headset get its own impostor
  74918. */
  74919. enableHeadsetImpostor?: boolean;
  74920. /**
  74921. * Optional parameters for the headset impostor
  74922. */
  74923. headsetImpostorParams?: {
  74924. /**
  74925. * The type of impostor to create. Default is sphere
  74926. */
  74927. impostorType: number;
  74928. /**
  74929. * the size of the impostor. Defaults to 10cm
  74930. */
  74931. impostorSize?: number | {
  74932. width: number;
  74933. height: number;
  74934. depth: number;
  74935. };
  74936. /**
  74937. * Friction definitions
  74938. */
  74939. friction?: number;
  74940. /**
  74941. * Restitution
  74942. */
  74943. restitution?: number;
  74944. };
  74945. /**
  74946. * The physics properties of the future impostors
  74947. */
  74948. physicsProperties?: {
  74949. /**
  74950. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74951. * Note that this requires a physics engine that supports mesh impostors!
  74952. */
  74953. useControllerMesh?: boolean;
  74954. /**
  74955. * The type of impostor to create. Default is sphere
  74956. */
  74957. impostorType?: number;
  74958. /**
  74959. * the size of the impostor. Defaults to 10cm
  74960. */
  74961. impostorSize?: number | {
  74962. width: number;
  74963. height: number;
  74964. depth: number;
  74965. };
  74966. /**
  74967. * Friction definitions
  74968. */
  74969. friction?: number;
  74970. /**
  74971. * Restitution
  74972. */
  74973. restitution?: number;
  74974. };
  74975. /**
  74976. * the xr input to use with this pointer selection
  74977. */
  74978. xrInput: WebXRInput;
  74979. }
  74980. /**
  74981. * Add physics impostor to your webxr controllers,
  74982. * including naive calculation of their linear and angular velocity
  74983. */
  74984. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74985. private readonly _options;
  74986. private _attachController;
  74987. private _controllers;
  74988. private _debugMode;
  74989. private _delta;
  74990. private _headsetImpostor?;
  74991. private _headsetMesh?;
  74992. private _lastTimestamp;
  74993. private _tmpQuaternion;
  74994. private _tmpVector;
  74995. /**
  74996. * The module's name
  74997. */
  74998. static readonly Name: string;
  74999. /**
  75000. * The (Babylon) version of this module.
  75001. * This is an integer representing the implementation version.
  75002. * This number does not correspond to the webxr specs version
  75003. */
  75004. static readonly Version: number;
  75005. /**
  75006. * Construct a new Controller Physics Feature
  75007. * @param _xrSessionManager the corresponding xr session manager
  75008. * @param _options options to create this feature with
  75009. */
  75010. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75011. /**
  75012. * @hidden
  75013. * enable debugging - will show console outputs and the impostor mesh
  75014. */
  75015. _enablePhysicsDebug(): void;
  75016. /**
  75017. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75018. * @param xrController the controller to add
  75019. */
  75020. addController(xrController: WebXRInputSource): void;
  75021. /**
  75022. * attach this feature
  75023. * Will usually be called by the features manager
  75024. *
  75025. * @returns true if successful.
  75026. */
  75027. attach(): boolean;
  75028. /**
  75029. * detach this feature.
  75030. * Will usually be called by the features manager
  75031. *
  75032. * @returns true if successful.
  75033. */
  75034. detach(): boolean;
  75035. /**
  75036. * Get the headset impostor, if enabled
  75037. * @returns the impostor
  75038. */
  75039. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75040. /**
  75041. * Get the physics impostor of a specific controller.
  75042. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75043. * @param controller the controller or the controller id of which to get the impostor
  75044. * @returns the impostor or null
  75045. */
  75046. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75047. /**
  75048. * Update the physics properties provided in the constructor
  75049. * @param newProperties the new properties object
  75050. */
  75051. setPhysicsProperties(newProperties: {
  75052. impostorType?: number;
  75053. impostorSize?: number | {
  75054. width: number;
  75055. height: number;
  75056. depth: number;
  75057. };
  75058. friction?: number;
  75059. restitution?: number;
  75060. }): void;
  75061. protected _onXRFrame(_xrFrame: any): void;
  75062. private _detachController;
  75063. }
  75064. }
  75065. declare module BABYLON {
  75066. /**
  75067. * A babylon interface for a "WebXR" feature point.
  75068. * Represents the position and confidence value of a given feature point.
  75069. */
  75070. export interface IWebXRFeaturePoint {
  75071. /**
  75072. * Represents the position of the feature point in world space.
  75073. */
  75074. position: Vector3;
  75075. /**
  75076. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75077. */
  75078. confidenceValue: number;
  75079. }
  75080. /**
  75081. * The feature point system is used to detect feature points from real world geometry.
  75082. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75083. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75084. */
  75085. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75086. private _enabled;
  75087. private _featurePointCloud;
  75088. /**
  75089. * The module's name
  75090. */
  75091. static readonly Name: string;
  75092. /**
  75093. * The (Babylon) version of this module.
  75094. * This is an integer representing the implementation version.
  75095. * This number does not correspond to the WebXR specs version
  75096. */
  75097. static readonly Version: number;
  75098. /**
  75099. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75100. * Will notify the observers about which feature points have been added.
  75101. */
  75102. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75103. /**
  75104. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75105. * Will notify the observers about which feature points have been updated.
  75106. */
  75107. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75108. /**
  75109. * The current feature point cloud maintained across frames.
  75110. */
  75111. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75112. /**
  75113. * construct the feature point system
  75114. * @param _xrSessionManager an instance of xr Session manager
  75115. */
  75116. constructor(_xrSessionManager: WebXRSessionManager);
  75117. /**
  75118. * Detach this feature.
  75119. * Will usually be called by the features manager
  75120. *
  75121. * @returns true if successful.
  75122. */
  75123. detach(): boolean;
  75124. /**
  75125. * Dispose this feature and all of the resources attached
  75126. */
  75127. dispose(): void;
  75128. /**
  75129. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75130. */
  75131. protected _onXRFrame(frame: XRFrame): void;
  75132. /**
  75133. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75134. */
  75135. private _init;
  75136. }
  75137. }
  75138. declare module BABYLON {
  75139. /**
  75140. * Configuration interface for the hand tracking feature
  75141. */
  75142. export interface IWebXRHandTrackingOptions {
  75143. /**
  75144. * The xrInput that will be used as source for new hands
  75145. */
  75146. xrInput: WebXRInput;
  75147. /**
  75148. * Configuration object for the joint meshes
  75149. */
  75150. jointMeshes?: {
  75151. /**
  75152. * Should the meshes created be invisible (defaults to false)
  75153. */
  75154. invisible?: boolean;
  75155. /**
  75156. * A source mesh to be used to create instances. Defaults to a sphere.
  75157. * This mesh will be the source for all other (25) meshes.
  75158. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75159. */
  75160. sourceMesh?: Mesh;
  75161. /**
  75162. * Should the source mesh stay visible. Defaults to false
  75163. */
  75164. keepOriginalVisible?: boolean;
  75165. /**
  75166. * Scale factor for all instances (defaults to 2)
  75167. */
  75168. scaleFactor?: number;
  75169. /**
  75170. * Should each instance have its own physics impostor
  75171. */
  75172. enablePhysics?: boolean;
  75173. /**
  75174. * If enabled, override default physics properties
  75175. */
  75176. physicsProps?: {
  75177. friction?: number;
  75178. restitution?: number;
  75179. impostorType?: number;
  75180. };
  75181. /**
  75182. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  75183. */
  75184. handMesh?: AbstractMesh;
  75185. };
  75186. }
  75187. /**
  75188. * Parts of the hands divided to writs and finger names
  75189. */
  75190. export const enum HandPart {
  75191. /**
  75192. * HandPart - Wrist
  75193. */
  75194. WRIST = "wrist",
  75195. /**
  75196. * HandPart - The THumb
  75197. */
  75198. THUMB = "thumb",
  75199. /**
  75200. * HandPart - Index finger
  75201. */
  75202. INDEX = "index",
  75203. /**
  75204. * HandPart - Middle finger
  75205. */
  75206. MIDDLE = "middle",
  75207. /**
  75208. * HandPart - Ring finger
  75209. */
  75210. RING = "ring",
  75211. /**
  75212. * HandPart - Little finger
  75213. */
  75214. LITTLE = "little"
  75215. }
  75216. /**
  75217. * Representing a single hand (with its corresponding native XRHand object)
  75218. */
  75219. export class WebXRHand implements IDisposable {
  75220. /** the controller to which the hand correlates */
  75221. readonly xrController: WebXRInputSource;
  75222. /** the meshes to be used to track the hand joints */
  75223. readonly trackedMeshes: AbstractMesh[];
  75224. /**
  75225. * Hand-parts definition (key is HandPart)
  75226. */
  75227. handPartsDefinition: {
  75228. [key: string]: number[];
  75229. };
  75230. /**
  75231. * Populate the HandPartsDefinition object.
  75232. * This is called as a side effect since certain browsers don't have XRHand defined.
  75233. */
  75234. private generateHandPartsDefinition;
  75235. /**
  75236. * Construct a new hand object
  75237. * @param xrController the controller to which the hand correlates
  75238. * @param trackedMeshes the meshes to be used to track the hand joints
  75239. */
  75240. constructor(
  75241. /** the controller to which the hand correlates */
  75242. xrController: WebXRInputSource,
  75243. /** the meshes to be used to track the hand joints */
  75244. trackedMeshes: AbstractMesh[]);
  75245. /**
  75246. * Update this hand from the latest xr frame
  75247. * @param xrFrame xrFrame to update from
  75248. * @param referenceSpace The current viewer reference space
  75249. * @param scaleFactor optional scale factor for the meshes
  75250. */
  75251. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75252. /**
  75253. * Get meshes of part of the hand
  75254. * @param part the part of hand to get
  75255. * @returns An array of meshes that correlate to the hand part requested
  75256. */
  75257. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75258. /**
  75259. * Dispose this Hand object
  75260. */
  75261. dispose(): void;
  75262. }
  75263. /**
  75264. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75265. */
  75266. export class WebXRHandTracking extends WebXRAbstractFeature {
  75267. /**
  75268. * options to use when constructing this feature
  75269. */
  75270. readonly options: IWebXRHandTrackingOptions;
  75271. private static _idCounter;
  75272. /**
  75273. * The module's name
  75274. */
  75275. static readonly Name: string;
  75276. /**
  75277. * The (Babylon) version of this module.
  75278. * This is an integer representing the implementation version.
  75279. * This number does not correspond to the WebXR specs version
  75280. */
  75281. static readonly Version: number;
  75282. /**
  75283. * This observable will notify registered observers when a new hand object was added and initialized
  75284. */
  75285. onHandAddedObservable: Observable<WebXRHand>;
  75286. /**
  75287. * This observable will notify its observers right before the hand object is disposed
  75288. */
  75289. onHandRemovedObservable: Observable<WebXRHand>;
  75290. private _hands;
  75291. /**
  75292. * Creates a new instance of the hit test feature
  75293. * @param _xrSessionManager an instance of WebXRSessionManager
  75294. * @param options options to use when constructing this feature
  75295. */
  75296. constructor(_xrSessionManager: WebXRSessionManager,
  75297. /**
  75298. * options to use when constructing this feature
  75299. */
  75300. options: IWebXRHandTrackingOptions);
  75301. /**
  75302. * Check if the needed objects are defined.
  75303. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75304. */
  75305. isCompatible(): boolean;
  75306. /**
  75307. * attach this feature
  75308. * Will usually be called by the features manager
  75309. *
  75310. * @returns true if successful.
  75311. */
  75312. attach(): boolean;
  75313. /**
  75314. * detach this feature.
  75315. * Will usually be called by the features manager
  75316. *
  75317. * @returns true if successful.
  75318. */
  75319. detach(): boolean;
  75320. /**
  75321. * Dispose this feature and all of the resources attached
  75322. */
  75323. dispose(): void;
  75324. /**
  75325. * Get the hand object according to the controller id
  75326. * @param controllerId the controller id to which we want to get the hand
  75327. * @returns null if not found or the WebXRHand object if found
  75328. */
  75329. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75330. /**
  75331. * Get a hand object according to the requested handedness
  75332. * @param handedness the handedness to request
  75333. * @returns null if not found or the WebXRHand object if found
  75334. */
  75335. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75336. protected _onXRFrame(_xrFrame: XRFrame): void;
  75337. private _attachHand;
  75338. private _detachHand;
  75339. }
  75340. }
  75341. declare module BABYLON {
  75342. /**
  75343. * The motion controller class for all microsoft mixed reality controllers
  75344. */
  75345. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75346. protected readonly _mapping: {
  75347. defaultButton: {
  75348. valueNodeName: string;
  75349. unpressedNodeName: string;
  75350. pressedNodeName: string;
  75351. };
  75352. defaultAxis: {
  75353. valueNodeName: string;
  75354. minNodeName: string;
  75355. maxNodeName: string;
  75356. };
  75357. buttons: {
  75358. "xr-standard-trigger": {
  75359. rootNodeName: string;
  75360. componentProperty: string;
  75361. states: string[];
  75362. };
  75363. "xr-standard-squeeze": {
  75364. rootNodeName: string;
  75365. componentProperty: string;
  75366. states: string[];
  75367. };
  75368. "xr-standard-touchpad": {
  75369. rootNodeName: string;
  75370. labelAnchorNodeName: string;
  75371. touchPointNodeName: string;
  75372. };
  75373. "xr-standard-thumbstick": {
  75374. rootNodeName: string;
  75375. componentProperty: string;
  75376. states: string[];
  75377. };
  75378. };
  75379. axes: {
  75380. "xr-standard-touchpad": {
  75381. "x-axis": {
  75382. rootNodeName: string;
  75383. };
  75384. "y-axis": {
  75385. rootNodeName: string;
  75386. };
  75387. };
  75388. "xr-standard-thumbstick": {
  75389. "x-axis": {
  75390. rootNodeName: string;
  75391. };
  75392. "y-axis": {
  75393. rootNodeName: string;
  75394. };
  75395. };
  75396. };
  75397. };
  75398. /**
  75399. * The base url used to load the left and right controller models
  75400. */
  75401. static MODEL_BASE_URL: string;
  75402. /**
  75403. * The name of the left controller model file
  75404. */
  75405. static MODEL_LEFT_FILENAME: string;
  75406. /**
  75407. * The name of the right controller model file
  75408. */
  75409. static MODEL_RIGHT_FILENAME: string;
  75410. profileId: string;
  75411. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75412. protected _getFilenameAndPath(): {
  75413. filename: string;
  75414. path: string;
  75415. };
  75416. protected _getModelLoadingConstraints(): boolean;
  75417. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75418. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75419. protected _updateModel(): void;
  75420. }
  75421. }
  75422. declare module BABYLON {
  75423. /**
  75424. * The motion controller class for oculus touch (quest, rift).
  75425. * This class supports legacy mapping as well the standard xr mapping
  75426. */
  75427. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75428. private _forceLegacyControllers;
  75429. private _modelRootNode;
  75430. /**
  75431. * The base url used to load the left and right controller models
  75432. */
  75433. static MODEL_BASE_URL: string;
  75434. /**
  75435. * The name of the left controller model file
  75436. */
  75437. static MODEL_LEFT_FILENAME: string;
  75438. /**
  75439. * The name of the right controller model file
  75440. */
  75441. static MODEL_RIGHT_FILENAME: string;
  75442. /**
  75443. * Base Url for the Quest controller model.
  75444. */
  75445. static QUEST_MODEL_BASE_URL: string;
  75446. profileId: string;
  75447. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75448. protected _getFilenameAndPath(): {
  75449. filename: string;
  75450. path: string;
  75451. };
  75452. protected _getModelLoadingConstraints(): boolean;
  75453. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75454. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75455. protected _updateModel(): void;
  75456. /**
  75457. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75458. * between the touch and touch 2.
  75459. */
  75460. private _isQuest;
  75461. }
  75462. }
  75463. declare module BABYLON {
  75464. /**
  75465. * The motion controller class for the standard HTC-Vive controllers
  75466. */
  75467. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75468. private _modelRootNode;
  75469. /**
  75470. * The base url used to load the left and right controller models
  75471. */
  75472. static MODEL_BASE_URL: string;
  75473. /**
  75474. * File name for the controller model.
  75475. */
  75476. static MODEL_FILENAME: string;
  75477. profileId: string;
  75478. /**
  75479. * Create a new Vive motion controller object
  75480. * @param scene the scene to use to create this controller
  75481. * @param gamepadObject the corresponding gamepad object
  75482. * @param handedness the handedness of the controller
  75483. */
  75484. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75485. protected _getFilenameAndPath(): {
  75486. filename: string;
  75487. path: string;
  75488. };
  75489. protected _getModelLoadingConstraints(): boolean;
  75490. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75491. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75492. protected _updateModel(): void;
  75493. }
  75494. }
  75495. declare module BABYLON {
  75496. /**
  75497. * A cursor which tracks a point on a path
  75498. */
  75499. export class PathCursor {
  75500. private path;
  75501. /**
  75502. * Stores path cursor callbacks for when an onchange event is triggered
  75503. */
  75504. private _onchange;
  75505. /**
  75506. * The value of the path cursor
  75507. */
  75508. value: number;
  75509. /**
  75510. * The animation array of the path cursor
  75511. */
  75512. animations: Animation[];
  75513. /**
  75514. * Initializes the path cursor
  75515. * @param path The path to track
  75516. */
  75517. constructor(path: Path2);
  75518. /**
  75519. * Gets the cursor point on the path
  75520. * @returns A point on the path cursor at the cursor location
  75521. */
  75522. getPoint(): Vector3;
  75523. /**
  75524. * Moves the cursor ahead by the step amount
  75525. * @param step The amount to move the cursor forward
  75526. * @returns This path cursor
  75527. */
  75528. moveAhead(step?: number): PathCursor;
  75529. /**
  75530. * Moves the cursor behind by the step amount
  75531. * @param step The amount to move the cursor back
  75532. * @returns This path cursor
  75533. */
  75534. moveBack(step?: number): PathCursor;
  75535. /**
  75536. * Moves the cursor by the step amount
  75537. * If the step amount is greater than one, an exception is thrown
  75538. * @param step The amount to move the cursor
  75539. * @returns This path cursor
  75540. */
  75541. move(step: number): PathCursor;
  75542. /**
  75543. * Ensures that the value is limited between zero and one
  75544. * @returns This path cursor
  75545. */
  75546. private ensureLimits;
  75547. /**
  75548. * Runs onchange callbacks on change (used by the animation engine)
  75549. * @returns This path cursor
  75550. */
  75551. private raiseOnChange;
  75552. /**
  75553. * Executes a function on change
  75554. * @param f A path cursor onchange callback
  75555. * @returns This path cursor
  75556. */
  75557. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75558. }
  75559. }
  75560. declare module BABYLON {
  75561. /** @hidden */
  75562. export var blurPixelShader: {
  75563. name: string;
  75564. shader: string;
  75565. };
  75566. }
  75567. declare module BABYLON {
  75568. /** @hidden */
  75569. export var pointCloudVertexDeclaration: {
  75570. name: string;
  75571. shader: string;
  75572. };
  75573. }
  75574. // Mixins
  75575. interface Window {
  75576. mozIndexedDB: IDBFactory;
  75577. webkitIndexedDB: IDBFactory;
  75578. msIndexedDB: IDBFactory;
  75579. webkitURL: typeof URL;
  75580. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  75581. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  75582. WebGLRenderingContext: WebGLRenderingContext;
  75583. MSGesture: MSGesture;
  75584. CANNON: any;
  75585. AudioContext: AudioContext;
  75586. webkitAudioContext: AudioContext;
  75587. PointerEvent: any;
  75588. Math: Math;
  75589. Uint8Array: Uint8ArrayConstructor;
  75590. Float32Array: Float32ArrayConstructor;
  75591. mozURL: typeof URL;
  75592. msURL: typeof URL;
  75593. VRFrameData: any; // WebVR, from specs 1.1
  75594. DracoDecoderModule: any;
  75595. setImmediate(handler: (...args: any[]) => void): number;
  75596. }
  75597. interface HTMLCanvasElement {
  75598. requestPointerLock(): void;
  75599. msRequestPointerLock?(): void;
  75600. mozRequestPointerLock?(): void;
  75601. webkitRequestPointerLock?(): void;
  75602. /** Track wether a record is in progress */
  75603. isRecording: boolean;
  75604. /** Capture Stream method defined by some browsers */
  75605. captureStream(fps?: number): MediaStream;
  75606. }
  75607. interface CanvasRenderingContext2D {
  75608. msImageSmoothingEnabled: boolean;
  75609. }
  75610. interface MouseEvent {
  75611. mozMovementX: number;
  75612. mozMovementY: number;
  75613. webkitMovementX: number;
  75614. webkitMovementY: number;
  75615. msMovementX: number;
  75616. msMovementY: number;
  75617. }
  75618. interface Navigator {
  75619. mozGetVRDevices: (any: any) => any;
  75620. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75621. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75622. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75623. webkitGetGamepads(): Gamepad[];
  75624. msGetGamepads(): Gamepad[];
  75625. webkitGamepads(): Gamepad[];
  75626. }
  75627. interface HTMLVideoElement {
  75628. mozSrcObject: any;
  75629. }
  75630. interface Math {
  75631. fround(x: number): number;
  75632. imul(a: number, b: number): number;
  75633. }
  75634. interface WebGLRenderingContext {
  75635. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  75636. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  75637. vertexAttribDivisor(index: number, divisor: number): void;
  75638. createVertexArray(): any;
  75639. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  75640. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  75641. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  75642. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  75643. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  75644. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  75645. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  75646. // Queries
  75647. createQuery(): WebGLQuery;
  75648. deleteQuery(query: WebGLQuery): void;
  75649. beginQuery(target: number, query: WebGLQuery): void;
  75650. endQuery(target: number): void;
  75651. getQueryParameter(query: WebGLQuery, pname: number): any;
  75652. getQuery(target: number, pname: number): any;
  75653. MAX_SAMPLES: number;
  75654. RGBA8: number;
  75655. READ_FRAMEBUFFER: number;
  75656. DRAW_FRAMEBUFFER: number;
  75657. UNIFORM_BUFFER: number;
  75658. HALF_FLOAT_OES: number;
  75659. RGBA16F: number;
  75660. RGBA32F: number;
  75661. R32F: number;
  75662. RG32F: number;
  75663. RGB32F: number;
  75664. R16F: number;
  75665. RG16F: number;
  75666. RGB16F: number;
  75667. RED: number;
  75668. RG: number;
  75669. R8: number;
  75670. RG8: number;
  75671. UNSIGNED_INT_24_8: number;
  75672. DEPTH24_STENCIL8: number;
  75673. MIN: number;
  75674. MAX: number;
  75675. /* Multiple Render Targets */
  75676. drawBuffers(buffers: number[]): void;
  75677. readBuffer(src: number): void;
  75678. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  75679. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  75680. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  75681. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  75682. // Occlusion Query
  75683. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  75684. ANY_SAMPLES_PASSED: number;
  75685. QUERY_RESULT_AVAILABLE: number;
  75686. QUERY_RESULT: number;
  75687. }
  75688. interface WebGLProgram {
  75689. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  75690. }
  75691. interface EXT_disjoint_timer_query {
  75692. QUERY_COUNTER_BITS_EXT: number;
  75693. TIME_ELAPSED_EXT: number;
  75694. TIMESTAMP_EXT: number;
  75695. GPU_DISJOINT_EXT: number;
  75696. QUERY_RESULT_EXT: number;
  75697. QUERY_RESULT_AVAILABLE_EXT: number;
  75698. queryCounterEXT(query: WebGLQuery, target: number): void;
  75699. createQueryEXT(): WebGLQuery;
  75700. beginQueryEXT(target: number, query: WebGLQuery): void;
  75701. endQueryEXT(target: number): void;
  75702. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  75703. deleteQueryEXT(query: WebGLQuery): void;
  75704. }
  75705. interface WebGLUniformLocation {
  75706. _currentState: any;
  75707. }
  75708. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  75709. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  75710. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  75711. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75712. interface WebGLRenderingContext {
  75713. readonly RASTERIZER_DISCARD: number;
  75714. readonly DEPTH_COMPONENT24: number;
  75715. readonly TEXTURE_3D: number;
  75716. readonly TEXTURE_2D_ARRAY: number;
  75717. readonly TEXTURE_COMPARE_FUNC: number;
  75718. readonly TEXTURE_COMPARE_MODE: number;
  75719. readonly COMPARE_REF_TO_TEXTURE: number;
  75720. readonly TEXTURE_WRAP_R: number;
  75721. readonly HALF_FLOAT: number;
  75722. readonly RGB8: number;
  75723. readonly RED_INTEGER: number;
  75724. readonly RG_INTEGER: number;
  75725. readonly RGB_INTEGER: number;
  75726. readonly RGBA_INTEGER: number;
  75727. readonly R8_SNORM: number;
  75728. readonly RG8_SNORM: number;
  75729. readonly RGB8_SNORM: number;
  75730. readonly RGBA8_SNORM: number;
  75731. readonly R8I: number;
  75732. readonly RG8I: number;
  75733. readonly RGB8I: number;
  75734. readonly RGBA8I: number;
  75735. readonly R8UI: number;
  75736. readonly RG8UI: number;
  75737. readonly RGB8UI: number;
  75738. readonly RGBA8UI: number;
  75739. readonly R16I: number;
  75740. readonly RG16I: number;
  75741. readonly RGB16I: number;
  75742. readonly RGBA16I: number;
  75743. readonly R16UI: number;
  75744. readonly RG16UI: number;
  75745. readonly RGB16UI: number;
  75746. readonly RGBA16UI: number;
  75747. readonly R32I: number;
  75748. readonly RG32I: number;
  75749. readonly RGB32I: number;
  75750. readonly RGBA32I: number;
  75751. readonly R32UI: number;
  75752. readonly RG32UI: number;
  75753. readonly RGB32UI: number;
  75754. readonly RGBA32UI: number;
  75755. readonly RGB10_A2UI: number;
  75756. readonly R11F_G11F_B10F: number;
  75757. readonly RGB9_E5: number;
  75758. readonly RGB10_A2: number;
  75759. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  75760. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  75761. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  75762. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75763. readonly DEPTH_COMPONENT32F: number;
  75764. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  75765. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  75766. 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;
  75767. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  75768. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  75769. readonly TRANSFORM_FEEDBACK: number;
  75770. readonly INTERLEAVED_ATTRIBS: number;
  75771. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  75772. createTransformFeedback(): WebGLTransformFeedback;
  75773. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  75774. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  75775. beginTransformFeedback(primitiveMode: number): void;
  75776. endTransformFeedback(): void;
  75777. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  75778. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75779. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75780. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75781. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  75782. }
  75783. interface ImageBitmap {
  75784. readonly width: number;
  75785. readonly height: number;
  75786. close(): void;
  75787. }
  75788. interface WebGLQuery extends WebGLObject {
  75789. }
  75790. declare var WebGLQuery: {
  75791. prototype: WebGLQuery;
  75792. new(): WebGLQuery;
  75793. };
  75794. interface WebGLSampler extends WebGLObject {
  75795. }
  75796. declare var WebGLSampler: {
  75797. prototype: WebGLSampler;
  75798. new(): WebGLSampler;
  75799. };
  75800. interface WebGLSync extends WebGLObject {
  75801. }
  75802. declare var WebGLSync: {
  75803. prototype: WebGLSync;
  75804. new(): WebGLSync;
  75805. };
  75806. interface WebGLTransformFeedback extends WebGLObject {
  75807. }
  75808. declare var WebGLTransformFeedback: {
  75809. prototype: WebGLTransformFeedback;
  75810. new(): WebGLTransformFeedback;
  75811. };
  75812. interface WebGLVertexArrayObject extends WebGLObject {
  75813. }
  75814. declare var WebGLVertexArrayObject: {
  75815. prototype: WebGLVertexArrayObject;
  75816. new(): WebGLVertexArrayObject;
  75817. };
  75818. // Type definitions for WebVR API
  75819. // Project: https://w3c.github.io/webvr/
  75820. // Definitions by: six a <https://github.com/lostfictions>
  75821. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75822. interface VRDisplay extends EventTarget {
  75823. /**
  75824. * Dictionary of capabilities describing the VRDisplay.
  75825. */
  75826. readonly capabilities: VRDisplayCapabilities;
  75827. /**
  75828. * z-depth defining the far plane of the eye view frustum
  75829. * enables mapping of values in the render target depth
  75830. * attachment to scene coordinates. Initially set to 10000.0.
  75831. */
  75832. depthFar: number;
  75833. /**
  75834. * z-depth defining the near plane of the eye view frustum
  75835. * enables mapping of values in the render target depth
  75836. * attachment to scene coordinates. Initially set to 0.01.
  75837. */
  75838. depthNear: number;
  75839. /**
  75840. * An identifier for this distinct VRDisplay. Used as an
  75841. * association point in the Gamepad API.
  75842. */
  75843. readonly displayId: number;
  75844. /**
  75845. * A display name, a user-readable name identifying it.
  75846. */
  75847. readonly displayName: string;
  75848. readonly isConnected: boolean;
  75849. readonly isPresenting: boolean;
  75850. /**
  75851. * If this VRDisplay supports room-scale experiences, the optional
  75852. * stage attribute contains details on the room-scale parameters.
  75853. */
  75854. readonly stageParameters: VRStageParameters | null;
  75855. /**
  75856. * Passing the value returned by `requestAnimationFrame` to
  75857. * `cancelAnimationFrame` will unregister the callback.
  75858. * @param handle Define the hanle of the request to cancel
  75859. */
  75860. cancelAnimationFrame(handle: number): void;
  75861. /**
  75862. * Stops presenting to the VRDisplay.
  75863. * @returns a promise to know when it stopped
  75864. */
  75865. exitPresent(): Promise<void>;
  75866. /**
  75867. * Return the current VREyeParameters for the given eye.
  75868. * @param whichEye Define the eye we want the parameter for
  75869. * @returns the eye parameters
  75870. */
  75871. getEyeParameters(whichEye: string): VREyeParameters;
  75872. /**
  75873. * Populates the passed VRFrameData with the information required to render
  75874. * the current frame.
  75875. * @param frameData Define the data structure to populate
  75876. * @returns true if ok otherwise false
  75877. */
  75878. getFrameData(frameData: VRFrameData): boolean;
  75879. /**
  75880. * Get the layers currently being presented.
  75881. * @returns the list of VR layers
  75882. */
  75883. getLayers(): VRLayer[];
  75884. /**
  75885. * Return a VRPose containing the future predicted pose of the VRDisplay
  75886. * when the current frame will be presented. The value returned will not
  75887. * change until JavaScript has returned control to the browser.
  75888. *
  75889. * The VRPose will contain the position, orientation, velocity,
  75890. * and acceleration of each of these properties.
  75891. * @returns the pose object
  75892. */
  75893. getPose(): VRPose;
  75894. /**
  75895. * Return the current instantaneous pose of the VRDisplay, with no
  75896. * prediction applied.
  75897. * @returns the current instantaneous pose
  75898. */
  75899. getImmediatePose(): VRPose;
  75900. /**
  75901. * The callback passed to `requestAnimationFrame` will be called
  75902. * any time a new frame should be rendered. When the VRDisplay is
  75903. * presenting the callback will be called at the native refresh
  75904. * rate of the HMD. When not presenting this function acts
  75905. * identically to how window.requestAnimationFrame acts. Content should
  75906. * make no assumptions of frame rate or vsync behavior as the HMD runs
  75907. * asynchronously from other displays and at differing refresh rates.
  75908. * @param callback Define the eaction to run next frame
  75909. * @returns the request handle it
  75910. */
  75911. requestAnimationFrame(callback: FrameRequestCallback): number;
  75912. /**
  75913. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  75914. * Repeat calls while already presenting will update the VRLayers being displayed.
  75915. * @param layers Define the list of layer to present
  75916. * @returns a promise to know when the request has been fulfilled
  75917. */
  75918. requestPresent(layers: VRLayer[]): Promise<void>;
  75919. /**
  75920. * Reset the pose for this display, treating its current position and
  75921. * orientation as the "origin/zero" values. VRPose.position,
  75922. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  75923. * updated when calling resetPose(). This should be called in only
  75924. * sitting-space experiences.
  75925. */
  75926. resetPose(): void;
  75927. /**
  75928. * The VRLayer provided to the VRDisplay will be captured and presented
  75929. * in the HMD. Calling this function has the same effect on the source
  75930. * canvas as any other operation that uses its source image, and canvases
  75931. * created without preserveDrawingBuffer set to true will be cleared.
  75932. * @param pose Define the pose to submit
  75933. */
  75934. submitFrame(pose?: VRPose): void;
  75935. }
  75936. declare var VRDisplay: {
  75937. prototype: VRDisplay;
  75938. new(): VRDisplay;
  75939. };
  75940. interface VRLayer {
  75941. leftBounds?: number[] | Float32Array | null;
  75942. rightBounds?: number[] | Float32Array | null;
  75943. source?: HTMLCanvasElement | null;
  75944. }
  75945. interface VRDisplayCapabilities {
  75946. readonly canPresent: boolean;
  75947. readonly hasExternalDisplay: boolean;
  75948. readonly hasOrientation: boolean;
  75949. readonly hasPosition: boolean;
  75950. readonly maxLayers: number;
  75951. }
  75952. interface VREyeParameters {
  75953. /** @deprecated */
  75954. readonly fieldOfView: VRFieldOfView;
  75955. readonly offset: Float32Array;
  75956. readonly renderHeight: number;
  75957. readonly renderWidth: number;
  75958. }
  75959. interface VRFieldOfView {
  75960. readonly downDegrees: number;
  75961. readonly leftDegrees: number;
  75962. readonly rightDegrees: number;
  75963. readonly upDegrees: number;
  75964. }
  75965. interface VRFrameData {
  75966. readonly leftProjectionMatrix: Float32Array;
  75967. readonly leftViewMatrix: Float32Array;
  75968. readonly pose: VRPose;
  75969. readonly rightProjectionMatrix: Float32Array;
  75970. readonly rightViewMatrix: Float32Array;
  75971. readonly timestamp: number;
  75972. }
  75973. interface VRPose {
  75974. readonly angularAcceleration: Float32Array | null;
  75975. readonly angularVelocity: Float32Array | null;
  75976. readonly linearAcceleration: Float32Array | null;
  75977. readonly linearVelocity: Float32Array | null;
  75978. readonly orientation: Float32Array | null;
  75979. readonly position: Float32Array | null;
  75980. readonly timestamp: number;
  75981. }
  75982. interface VRStageParameters {
  75983. sittingToStandingTransform?: Float32Array;
  75984. sizeX?: number;
  75985. sizeY?: number;
  75986. }
  75987. interface Navigator {
  75988. getVRDisplays(): Promise<VRDisplay[]>;
  75989. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  75990. }
  75991. interface Window {
  75992. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  75993. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  75994. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  75995. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75996. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75997. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  75998. }
  75999. interface Gamepad {
  76000. readonly displayId: number;
  76001. }
  76002. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  76003. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  76004. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  76005. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  76006. type XRHandedness = "none" | "left" | "right";
  76007. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  76008. type XREye = "none" | "left" | "right";
  76009. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  76010. interface XRSpace extends EventTarget {}
  76011. interface XRRenderState {
  76012. depthNear?: number;
  76013. depthFar?: number;
  76014. inlineVerticalFieldOfView?: number;
  76015. baseLayer?: XRWebGLLayer;
  76016. }
  76017. interface XRInputSource {
  76018. handedness: XRHandedness;
  76019. targetRayMode: XRTargetRayMode;
  76020. targetRaySpace: XRSpace;
  76021. gripSpace: XRSpace | undefined;
  76022. gamepad: Gamepad | undefined;
  76023. profiles: Array<string>;
  76024. hand: XRHand | undefined;
  76025. }
  76026. interface XRSessionInit {
  76027. optionalFeatures?: string[];
  76028. requiredFeatures?: string[];
  76029. }
  76030. interface XRSession {
  76031. addEventListener: Function;
  76032. removeEventListener: Function;
  76033. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76034. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76035. requestAnimationFrame: Function;
  76036. end(): Promise<void>;
  76037. renderState: XRRenderState;
  76038. inputSources: Array<XRInputSource>;
  76039. // hit test
  76040. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76041. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76042. // legacy AR hit test
  76043. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76044. // legacy plane detection
  76045. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76046. }
  76047. interface XRReferenceSpace extends XRSpace {
  76048. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76049. onreset: any;
  76050. }
  76051. type XRPlaneSet = Set<XRPlane>;
  76052. type XRAnchorSet = Set<XRAnchor>;
  76053. interface XRFrame {
  76054. session: XRSession;
  76055. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76056. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76057. // AR
  76058. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76059. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76060. // Anchors
  76061. trackedAnchors?: XRAnchorSet;
  76062. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76063. // Planes
  76064. worldInformation: {
  76065. detectedPlanes?: XRPlaneSet;
  76066. };
  76067. // Hand tracking
  76068. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76069. }
  76070. interface XRViewerPose extends XRPose {
  76071. views: Array<XRView>;
  76072. }
  76073. interface XRPose {
  76074. transform: XRRigidTransform;
  76075. emulatedPosition: boolean;
  76076. }
  76077. interface XRWebGLLayerOptions {
  76078. antialias?: boolean;
  76079. depth?: boolean;
  76080. stencil?: boolean;
  76081. alpha?: boolean;
  76082. multiview?: boolean;
  76083. framebufferScaleFactor?: number;
  76084. }
  76085. declare var XRWebGLLayer: {
  76086. prototype: XRWebGLLayer;
  76087. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76088. };
  76089. interface XRWebGLLayer {
  76090. framebuffer: WebGLFramebuffer;
  76091. framebufferWidth: number;
  76092. framebufferHeight: number;
  76093. getViewport: Function;
  76094. }
  76095. declare class XRRigidTransform {
  76096. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  76097. position: DOMPointReadOnly;
  76098. orientation: DOMPointReadOnly;
  76099. matrix: Float32Array;
  76100. inverse: XRRigidTransform;
  76101. }
  76102. interface XRView {
  76103. eye: XREye;
  76104. projectionMatrix: Float32Array;
  76105. transform: XRRigidTransform;
  76106. }
  76107. interface XRInputSourceChangeEvent {
  76108. session: XRSession;
  76109. removed: Array<XRInputSource>;
  76110. added: Array<XRInputSource>;
  76111. }
  76112. interface XRInputSourceEvent extends Event {
  76113. readonly frame: XRFrame;
  76114. readonly inputSource: XRInputSource;
  76115. }
  76116. // Experimental(er) features
  76117. declare class XRRay {
  76118. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76119. origin: DOMPointReadOnly;
  76120. direction: DOMPointReadOnly;
  76121. matrix: Float32Array;
  76122. }
  76123. declare enum XRHitTestTrackableType {
  76124. "point",
  76125. "plane",
  76126. "mesh",
  76127. }
  76128. interface XRHitResult {
  76129. hitMatrix: Float32Array;
  76130. }
  76131. interface XRTransientInputHitTestResult {
  76132. readonly inputSource: XRInputSource;
  76133. readonly results: Array<XRHitTestResult>;
  76134. }
  76135. interface XRHitTestResult {
  76136. getPose(baseSpace: XRSpace): XRPose | undefined;
  76137. // When anchor system is enabled
  76138. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76139. }
  76140. interface XRHitTestSource {
  76141. cancel(): void;
  76142. }
  76143. interface XRTransientInputHitTestSource {
  76144. cancel(): void;
  76145. }
  76146. interface XRHitTestOptionsInit {
  76147. space: XRSpace;
  76148. entityTypes?: Array<XRHitTestTrackableType>;
  76149. offsetRay?: XRRay;
  76150. }
  76151. interface XRTransientInputHitTestOptionsInit {
  76152. profile: string;
  76153. entityTypes?: Array<XRHitTestTrackableType>;
  76154. offsetRay?: XRRay;
  76155. }
  76156. interface XRAnchor {
  76157. anchorSpace: XRSpace;
  76158. delete(): void;
  76159. }
  76160. interface XRPlane {
  76161. orientation: "Horizontal" | "Vertical";
  76162. planeSpace: XRSpace;
  76163. polygon: Array<DOMPointReadOnly>;
  76164. lastChangedTime: number;
  76165. }
  76166. interface XRJointSpace extends XRSpace {}
  76167. interface XRJointPose extends XRPose {
  76168. radius: number | undefined;
  76169. }
  76170. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  76171. readonly length: number;
  76172. [index: number]: XRJointSpace;
  76173. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  76174. readonly WRIST: number;
  76175. readonly THUMB_METACARPAL: number;
  76176. readonly THUMB_PHALANX_PROXIMAL: number;
  76177. readonly THUMB_PHALANX_DISTAL: number;
  76178. readonly THUMB_PHALANX_TIP: number;
  76179. readonly INDEX_METACARPAL: number;
  76180. readonly INDEX_PHALANX_PROXIMAL: number;
  76181. readonly INDEX_PHALANX_INTERMEDIATE: number;
  76182. readonly INDEX_PHALANX_DISTAL: number;
  76183. readonly INDEX_PHALANX_TIP: number;
  76184. readonly MIDDLE_METACARPAL: number;
  76185. readonly MIDDLE_PHALANX_PROXIMAL: number;
  76186. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  76187. readonly MIDDLE_PHALANX_DISTAL: number;
  76188. readonly MIDDLE_PHALANX_TIP: number;
  76189. readonly RING_METACARPAL: number;
  76190. readonly RING_PHALANX_PROXIMAL: number;
  76191. readonly RING_PHALANX_INTERMEDIATE: number;
  76192. readonly RING_PHALANX_DISTAL: number;
  76193. readonly RING_PHALANX_TIP: number;
  76194. readonly LITTLE_METACARPAL: number;
  76195. readonly LITTLE_PHALANX_PROXIMAL: number;
  76196. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  76197. readonly LITTLE_PHALANX_DISTAL: number;
  76198. readonly LITTLE_PHALANX_TIP: number;
  76199. }
  76200. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  76201. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  76202. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  76203. interface XRSession {
  76204. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  76205. }
  76206. interface XRFrame {
  76207. featurePointCloud? : Array<number>;
  76208. }
  76209. /**
  76210. * @ignore
  76211. */
  76212. declare module BABYLON.GLTF2.Exporter {
  76213. }
  76214. /**
  76215. * @ignore
  76216. */
  76217. declare module BABYLON.GLTF1 {
  76218. }
  76219. declare module BABYLON.GUI {
  76220. /**
  76221. * Class used to specific a value and its associated unit
  76222. */
  76223. export class ValueAndUnit {
  76224. /** defines the unit to store */
  76225. unit: number;
  76226. /** defines a boolean indicating if the value can be negative */
  76227. negativeValueAllowed: boolean;
  76228. private _value;
  76229. private _originalUnit;
  76230. /**
  76231. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  76232. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76233. */
  76234. ignoreAdaptiveScaling: boolean;
  76235. /**
  76236. * Creates a new ValueAndUnit
  76237. * @param value defines the value to store
  76238. * @param unit defines the unit to store
  76239. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  76240. */
  76241. constructor(value: number,
  76242. /** defines the unit to store */
  76243. unit?: number,
  76244. /** defines a boolean indicating if the value can be negative */
  76245. negativeValueAllowed?: boolean);
  76246. /** Gets a boolean indicating if the value is a percentage */
  76247. get isPercentage(): boolean;
  76248. /** Gets a boolean indicating if the value is store as pixel */
  76249. get isPixel(): boolean;
  76250. /** Gets direct internal value */
  76251. get internalValue(): number;
  76252. /**
  76253. * Gets value as pixel
  76254. * @param host defines the root host
  76255. * @param refValue defines the reference value for percentages
  76256. * @returns the value as pixel
  76257. */
  76258. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  76259. /**
  76260. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  76261. * @param value defines the value to store
  76262. * @param unit defines the unit to store
  76263. * @returns the current ValueAndUnit
  76264. */
  76265. updateInPlace(value: number, unit?: number): ValueAndUnit;
  76266. /**
  76267. * Gets the value accordingly to its unit
  76268. * @param host defines the root host
  76269. * @returns the value
  76270. */
  76271. getValue(host: AdvancedDynamicTexture): number;
  76272. /**
  76273. * Gets a string representation of the value
  76274. * @param host defines the root host
  76275. * @param decimals defines an optional number of decimals to display
  76276. * @returns a string
  76277. */
  76278. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  76279. /**
  76280. * Store a value parsed from a string
  76281. * @param source defines the source string
  76282. * @returns true if the value was successfully parsed
  76283. */
  76284. fromString(source: string | number): boolean;
  76285. private static _Regex;
  76286. private static _UNITMODE_PERCENTAGE;
  76287. private static _UNITMODE_PIXEL;
  76288. /** UNITMODE_PERCENTAGE */
  76289. static get UNITMODE_PERCENTAGE(): number;
  76290. /** UNITMODE_PIXEL */
  76291. static get UNITMODE_PIXEL(): number;
  76292. }
  76293. }
  76294. declare module BABYLON.GUI {
  76295. /**
  76296. * Define a style used by control to automatically setup properties based on a template.
  76297. * Only support font related properties so far
  76298. */
  76299. export class Style implements BABYLON.IDisposable {
  76300. private _fontFamily;
  76301. private _fontStyle;
  76302. private _fontWeight;
  76303. /** @hidden */
  76304. _host: AdvancedDynamicTexture;
  76305. /** @hidden */
  76306. _fontSize: ValueAndUnit;
  76307. /**
  76308. * BABYLON.Observable raised when the style values are changed
  76309. */
  76310. onChangedObservable: BABYLON.Observable<Style>;
  76311. /**
  76312. * Creates a new style object
  76313. * @param host defines the AdvancedDynamicTexture which hosts this style
  76314. */
  76315. constructor(host: AdvancedDynamicTexture);
  76316. /**
  76317. * Gets or sets the font size
  76318. */
  76319. get fontSize(): string | number;
  76320. set fontSize(value: string | number);
  76321. /**
  76322. * Gets or sets the font family
  76323. */
  76324. get fontFamily(): string;
  76325. set fontFamily(value: string);
  76326. /**
  76327. * Gets or sets the font style
  76328. */
  76329. get fontStyle(): string;
  76330. set fontStyle(value: string);
  76331. /** Gets or sets font weight */
  76332. get fontWeight(): string;
  76333. set fontWeight(value: string);
  76334. /** Dispose all associated resources */
  76335. dispose(): void;
  76336. }
  76337. }
  76338. declare module BABYLON.GUI {
  76339. /**
  76340. * Class used to transport BABYLON.Vector2 information for pointer events
  76341. */
  76342. export class Vector2WithInfo extends BABYLON.Vector2 {
  76343. /** defines the current mouse button index */
  76344. buttonIndex: number;
  76345. /**
  76346. * Creates a new Vector2WithInfo
  76347. * @param source defines the vector2 data to transport
  76348. * @param buttonIndex defines the current mouse button index
  76349. */
  76350. constructor(source: BABYLON.Vector2,
  76351. /** defines the current mouse button index */
  76352. buttonIndex?: number);
  76353. }
  76354. /** Class used to provide 2D matrix features */
  76355. export class Matrix2D {
  76356. /** Gets the internal array of 6 floats used to store matrix data */
  76357. m: Float32Array;
  76358. /**
  76359. * Creates a new matrix
  76360. * @param m00 defines value for (0, 0)
  76361. * @param m01 defines value for (0, 1)
  76362. * @param m10 defines value for (1, 0)
  76363. * @param m11 defines value for (1, 1)
  76364. * @param m20 defines value for (2, 0)
  76365. * @param m21 defines value for (2, 1)
  76366. */
  76367. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  76368. /**
  76369. * Fills the matrix from direct values
  76370. * @param m00 defines value for (0, 0)
  76371. * @param m01 defines value for (0, 1)
  76372. * @param m10 defines value for (1, 0)
  76373. * @param m11 defines value for (1, 1)
  76374. * @param m20 defines value for (2, 0)
  76375. * @param m21 defines value for (2, 1)
  76376. * @returns the current modified matrix
  76377. */
  76378. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  76379. /**
  76380. * Gets matrix determinant
  76381. * @returns the determinant
  76382. */
  76383. determinant(): number;
  76384. /**
  76385. * Inverses the matrix and stores it in a target matrix
  76386. * @param result defines the target matrix
  76387. * @returns the current matrix
  76388. */
  76389. invertToRef(result: Matrix2D): Matrix2D;
  76390. /**
  76391. * Multiplies the current matrix with another one
  76392. * @param other defines the second operand
  76393. * @param result defines the target matrix
  76394. * @returns the current matrix
  76395. */
  76396. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  76397. /**
  76398. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  76399. * @param x defines the x coordinate to transform
  76400. * @param y defines the x coordinate to transform
  76401. * @param result defines the target vector2
  76402. * @returns the current matrix
  76403. */
  76404. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  76405. /**
  76406. * Creates an identity matrix
  76407. * @returns a new matrix
  76408. */
  76409. static Identity(): Matrix2D;
  76410. /**
  76411. * Creates a translation matrix and stores it in a target matrix
  76412. * @param x defines the x coordinate of the translation
  76413. * @param y defines the y coordinate of the translation
  76414. * @param result defines the target matrix
  76415. */
  76416. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  76417. /**
  76418. * Creates a scaling matrix and stores it in a target matrix
  76419. * @param x defines the x coordinate of the scaling
  76420. * @param y defines the y coordinate of the scaling
  76421. * @param result defines the target matrix
  76422. */
  76423. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  76424. /**
  76425. * Creates a rotation matrix and stores it in a target matrix
  76426. * @param angle defines the rotation angle
  76427. * @param result defines the target matrix
  76428. */
  76429. static RotationToRef(angle: number, result: Matrix2D): void;
  76430. private static _TempPreTranslationMatrix;
  76431. private static _TempPostTranslationMatrix;
  76432. private static _TempRotationMatrix;
  76433. private static _TempScalingMatrix;
  76434. private static _TempCompose0;
  76435. private static _TempCompose1;
  76436. private static _TempCompose2;
  76437. /**
  76438. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  76439. * @param tx defines the x coordinate of the translation
  76440. * @param ty defines the y coordinate of the translation
  76441. * @param angle defines the rotation angle
  76442. * @param scaleX defines the x coordinate of the scaling
  76443. * @param scaleY defines the y coordinate of the scaling
  76444. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  76445. * @param result defines the target matrix
  76446. */
  76447. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  76448. }
  76449. }
  76450. declare module BABYLON.GUI {
  76451. /**
  76452. * Class used to store 2D control sizes
  76453. */
  76454. export class Measure {
  76455. /** defines left coordinate */
  76456. left: number;
  76457. /** defines top coordinate */
  76458. top: number;
  76459. /** defines width dimension */
  76460. width: number;
  76461. /** defines height dimension */
  76462. height: number;
  76463. /**
  76464. * Creates a new measure
  76465. * @param left defines left coordinate
  76466. * @param top defines top coordinate
  76467. * @param width defines width dimension
  76468. * @param height defines height dimension
  76469. */
  76470. constructor(
  76471. /** defines left coordinate */
  76472. left: number,
  76473. /** defines top coordinate */
  76474. top: number,
  76475. /** defines width dimension */
  76476. width: number,
  76477. /** defines height dimension */
  76478. height: number);
  76479. /**
  76480. * Copy from another measure
  76481. * @param other defines the other measure to copy from
  76482. */
  76483. copyFrom(other: Measure): void;
  76484. /**
  76485. * Copy from a group of 4 floats
  76486. * @param left defines left coordinate
  76487. * @param top defines top coordinate
  76488. * @param width defines width dimension
  76489. * @param height defines height dimension
  76490. */
  76491. copyFromFloats(left: number, top: number, width: number, height: number): void;
  76492. /**
  76493. * Computes the axis aligned bounding box measure for two given measures
  76494. * @param a Input measure
  76495. * @param b Input measure
  76496. * @param result the resulting bounding measure
  76497. */
  76498. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  76499. /**
  76500. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76501. * @param transform the matrix to transform the measure before computing the AABB
  76502. * @param addX number to add to left
  76503. * @param addY number to add to top
  76504. * @param addWidth number to add to width
  76505. * @param addHeight number to add to height
  76506. * @param result the resulting AABB
  76507. */
  76508. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  76509. /**
  76510. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76511. * @param transform the matrix to transform the measure before computing the AABB
  76512. * @param result the resulting AABB
  76513. */
  76514. transformToRef(transform: Matrix2D, result: Measure): void;
  76515. /**
  76516. * Check equality between this measure and another one
  76517. * @param other defines the other measures
  76518. * @returns true if both measures are equals
  76519. */
  76520. isEqualsTo(other: Measure): boolean;
  76521. /**
  76522. * Creates an empty measure
  76523. * @returns a new measure
  76524. */
  76525. static Empty(): Measure;
  76526. }
  76527. }
  76528. declare module BABYLON.GUI {
  76529. /**
  76530. * Interface used to define a control that can receive focus
  76531. */
  76532. export interface IFocusableControl {
  76533. /**
  76534. * Function called when the control receives the focus
  76535. */
  76536. onFocus(): void;
  76537. /**
  76538. * Function called when the control loses the focus
  76539. */
  76540. onBlur(): void;
  76541. /**
  76542. * Function called to let the control handle keyboard events
  76543. * @param evt defines the current keyboard event
  76544. */
  76545. processKeyboard(evt: KeyboardEvent): void;
  76546. /**
  76547. * Function called to get the list of controls that should not steal the focus from this control
  76548. * @returns an array of controls
  76549. */
  76550. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76551. }
  76552. /**
  76553. * Class used to create texture to support 2D GUI elements
  76554. * @see https://doc.babylonjs.com/how_to/gui
  76555. */
  76556. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  76557. private _isDirty;
  76558. private _renderObserver;
  76559. private _resizeObserver;
  76560. private _preKeyboardObserver;
  76561. private _pointerMoveObserver;
  76562. private _pointerObserver;
  76563. private _canvasPointerOutObserver;
  76564. private _canvasBlurObserver;
  76565. private _background;
  76566. /** @hidden */
  76567. _rootContainer: Container;
  76568. /** @hidden */
  76569. _lastPickedControl: Control;
  76570. /** @hidden */
  76571. _lastControlOver: {
  76572. [pointerId: number]: Control;
  76573. };
  76574. /** @hidden */
  76575. _lastControlDown: {
  76576. [pointerId: number]: Control;
  76577. };
  76578. /** @hidden */
  76579. _capturingControl: {
  76580. [pointerId: number]: Control;
  76581. };
  76582. /** @hidden */
  76583. _shouldBlockPointer: boolean;
  76584. /** @hidden */
  76585. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  76586. /** @hidden */
  76587. _linkedControls: Control[];
  76588. private _isFullscreen;
  76589. private _fullscreenViewport;
  76590. private _idealWidth;
  76591. private _idealHeight;
  76592. private _useSmallestIdeal;
  76593. private _renderAtIdealSize;
  76594. private _focusedControl;
  76595. private _blockNextFocusCheck;
  76596. private _renderScale;
  76597. private _rootElement;
  76598. private _cursorChanged;
  76599. private _defaultMousePointerId;
  76600. /** @hidden */
  76601. _numLayoutCalls: number;
  76602. /** Gets the number of layout calls made the last time the ADT has been rendered */
  76603. get numLayoutCalls(): number;
  76604. /** @hidden */
  76605. _numRenderCalls: number;
  76606. /** Gets the number of render calls made the last time the ADT has been rendered */
  76607. get numRenderCalls(): number;
  76608. /**
  76609. * Define type to string to ensure compatibility across browsers
  76610. * Safari doesn't support DataTransfer constructor
  76611. */
  76612. private _clipboardData;
  76613. /**
  76614. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  76615. */
  76616. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  76617. /**
  76618. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  76619. */
  76620. onControlPickedObservable: BABYLON.Observable<Control>;
  76621. /**
  76622. * BABYLON.Observable event triggered before layout is evaluated
  76623. */
  76624. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76625. /**
  76626. * BABYLON.Observable event triggered after the layout was evaluated
  76627. */
  76628. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76629. /**
  76630. * BABYLON.Observable event triggered before the texture is rendered
  76631. */
  76632. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76633. /**
  76634. * BABYLON.Observable event triggered after the texture was rendered
  76635. */
  76636. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76637. /**
  76638. * Gets or sets a boolean defining if alpha is stored as premultiplied
  76639. */
  76640. premulAlpha: boolean;
  76641. /**
  76642. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  76643. * Useful when you want more antialiasing
  76644. */
  76645. get renderScale(): number;
  76646. set renderScale(value: number);
  76647. /** Gets or sets the background color */
  76648. get background(): string;
  76649. set background(value: string);
  76650. /**
  76651. * Gets or sets the ideal width used to design controls.
  76652. * The GUI will then rescale everything accordingly
  76653. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76654. */
  76655. get idealWidth(): number;
  76656. set idealWidth(value: number);
  76657. /**
  76658. * Gets or sets the ideal height used to design controls.
  76659. * The GUI will then rescale everything accordingly
  76660. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76661. */
  76662. get idealHeight(): number;
  76663. set idealHeight(value: number);
  76664. /**
  76665. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  76666. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76667. */
  76668. get useSmallestIdeal(): boolean;
  76669. set useSmallestIdeal(value: boolean);
  76670. /**
  76671. * Gets or sets a boolean indicating if adaptive scaling must be used
  76672. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76673. */
  76674. get renderAtIdealSize(): boolean;
  76675. set renderAtIdealSize(value: boolean);
  76676. /**
  76677. * Gets the ratio used when in "ideal mode"
  76678. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76679. * */
  76680. get idealRatio(): number;
  76681. /**
  76682. * Gets the underlying layer used to render the texture when in fullscreen mode
  76683. */
  76684. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  76685. /**
  76686. * Gets the root container control
  76687. */
  76688. get rootContainer(): Container;
  76689. /**
  76690. * Returns an array containing the root container.
  76691. * This is mostly used to let the Inspector introspects the ADT
  76692. * @returns an array containing the rootContainer
  76693. */
  76694. getChildren(): Array<Container>;
  76695. /**
  76696. * Will return all controls that are inside this texture
  76697. * @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
  76698. * @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
  76699. * @return all child controls
  76700. */
  76701. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76702. /**
  76703. * Gets or sets the current focused control
  76704. */
  76705. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  76706. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  76707. /**
  76708. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  76709. */
  76710. get isForeground(): boolean;
  76711. set isForeground(value: boolean);
  76712. /**
  76713. * Gets or set information about clipboardData
  76714. */
  76715. get clipboardData(): string;
  76716. set clipboardData(value: string);
  76717. /**
  76718. * Creates a new AdvancedDynamicTexture
  76719. * @param name defines the name of the texture
  76720. * @param width defines the width of the texture
  76721. * @param height defines the height of the texture
  76722. * @param scene defines the hosting scene
  76723. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  76724. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76725. */
  76726. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  76727. /**
  76728. * Get the current class name of the texture useful for serialization or dynamic coding.
  76729. * @returns "AdvancedDynamicTexture"
  76730. */
  76731. getClassName(): string;
  76732. /**
  76733. * Function used to execute a function on all controls
  76734. * @param func defines the function to execute
  76735. * @param container defines the container where controls belong. If null the root container will be used
  76736. */
  76737. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  76738. private _useInvalidateRectOptimization;
  76739. /**
  76740. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  76741. */
  76742. get useInvalidateRectOptimization(): boolean;
  76743. set useInvalidateRectOptimization(value: boolean);
  76744. private _invalidatedRectangle;
  76745. /**
  76746. * Invalidates a rectangle area on the gui texture
  76747. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  76748. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  76749. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  76750. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  76751. */
  76752. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  76753. /**
  76754. * Marks the texture as dirty forcing a complete update
  76755. */
  76756. markAsDirty(): void;
  76757. /**
  76758. * Helper function used to create a new style
  76759. * @returns a new style
  76760. * @see https://doc.babylonjs.com/how_to/gui#styles
  76761. */
  76762. createStyle(): Style;
  76763. /**
  76764. * Adds a new control to the root container
  76765. * @param control defines the control to add
  76766. * @returns the current texture
  76767. */
  76768. addControl(control: Control): AdvancedDynamicTexture;
  76769. /**
  76770. * Removes a control from the root container
  76771. * @param control defines the control to remove
  76772. * @returns the current texture
  76773. */
  76774. removeControl(control: Control): AdvancedDynamicTexture;
  76775. /**
  76776. * Release all resources
  76777. */
  76778. dispose(): void;
  76779. private _onResize;
  76780. /** @hidden */
  76781. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  76782. /**
  76783. * Get screen coordinates for a vector3
  76784. * @param position defines the position to project
  76785. * @param worldMatrix defines the world matrix to use
  76786. * @returns the projected position
  76787. */
  76788. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  76789. private _checkUpdate;
  76790. private _clearMeasure;
  76791. private _render;
  76792. /** @hidden */
  76793. _changeCursor(cursor: string): void;
  76794. /** @hidden */
  76795. _registerLastControlDown(control: Control, pointerId: number): void;
  76796. private _doPicking;
  76797. /** @hidden */
  76798. _cleanControlAfterRemovalFromList(list: {
  76799. [pointerId: number]: Control;
  76800. }, control: Control): void;
  76801. /** @hidden */
  76802. _cleanControlAfterRemoval(control: Control): void;
  76803. /** Attach to all scene events required to support pointer events */
  76804. attach(): void;
  76805. /** @hidden */
  76806. private onClipboardCopy;
  76807. /** @hidden */
  76808. private onClipboardCut;
  76809. /** @hidden */
  76810. private onClipboardPaste;
  76811. /**
  76812. * Register the clipboard Events onto the canvas
  76813. */
  76814. registerClipboardEvents(): void;
  76815. /**
  76816. * Unregister the clipboard Events from the canvas
  76817. */
  76818. unRegisterClipboardEvents(): void;
  76819. /**
  76820. * Connect the texture to a hosting mesh to enable interactions
  76821. * @param mesh defines the mesh to attach to
  76822. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  76823. */
  76824. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  76825. /**
  76826. * Move the focus to a specific control
  76827. * @param control defines the control which will receive the focus
  76828. */
  76829. moveFocusToControl(control: IFocusableControl): void;
  76830. private _manageFocus;
  76831. private _attachToOnPointerOut;
  76832. private _attachToOnBlur;
  76833. /**
  76834. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  76835. * @param mesh defines the mesh which will receive the texture
  76836. * @param width defines the texture width (1024 by default)
  76837. * @param height defines the texture height (1024 by default)
  76838. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  76839. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  76840. * @returns a new AdvancedDynamicTexture
  76841. */
  76842. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  76843. /**
  76844. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  76845. * In this mode the texture will rely on a layer for its rendering.
  76846. * This allows it to be treated like any other layer.
  76847. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  76848. * LayerMask is set through advancedTexture.layer.layerMask
  76849. * @param name defines name for the texture
  76850. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  76851. * @param scene defines the hsoting scene
  76852. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  76853. * @returns a new AdvancedDynamicTexture
  76854. */
  76855. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  76856. }
  76857. }
  76858. declare module BABYLON.GUI {
  76859. /**
  76860. * Root class used for all 2D controls
  76861. * @see https://doc.babylonjs.com/how_to/gui#controls
  76862. */
  76863. export class Control {
  76864. /** defines the name of the control */
  76865. name?: string | undefined;
  76866. /**
  76867. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  76868. */
  76869. static AllowAlphaInheritance: boolean;
  76870. private _alpha;
  76871. private _alphaSet;
  76872. private _zIndex;
  76873. /** @hidden */
  76874. _host: AdvancedDynamicTexture;
  76875. /** Gets or sets the control parent */
  76876. parent: BABYLON.Nullable<Container>;
  76877. /** @hidden */
  76878. _currentMeasure: Measure;
  76879. private _fontFamily;
  76880. private _fontStyle;
  76881. private _fontWeight;
  76882. private _fontSize;
  76883. private _font;
  76884. /** @hidden */
  76885. _width: ValueAndUnit;
  76886. /** @hidden */
  76887. _height: ValueAndUnit;
  76888. /** @hidden */
  76889. protected _fontOffset: {
  76890. ascent: number;
  76891. height: number;
  76892. descent: number;
  76893. };
  76894. private _color;
  76895. private _style;
  76896. private _styleObserver;
  76897. /** @hidden */
  76898. protected _horizontalAlignment: number;
  76899. /** @hidden */
  76900. protected _verticalAlignment: number;
  76901. /** @hidden */
  76902. protected _isDirty: boolean;
  76903. /** @hidden */
  76904. protected _wasDirty: boolean;
  76905. /** @hidden */
  76906. _tempParentMeasure: Measure;
  76907. /** @hidden */
  76908. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  76909. /** @hidden */
  76910. protected _cachedParentMeasure: Measure;
  76911. private _paddingLeft;
  76912. private _paddingRight;
  76913. private _paddingTop;
  76914. private _paddingBottom;
  76915. /** @hidden */
  76916. _left: ValueAndUnit;
  76917. /** @hidden */
  76918. _top: ValueAndUnit;
  76919. private _scaleX;
  76920. private _scaleY;
  76921. private _rotation;
  76922. private _transformCenterX;
  76923. private _transformCenterY;
  76924. /** @hidden */
  76925. _transformMatrix: Matrix2D;
  76926. /** @hidden */
  76927. protected _invertTransformMatrix: Matrix2D;
  76928. /** @hidden */
  76929. protected _transformedPosition: BABYLON.Vector2;
  76930. private _isMatrixDirty;
  76931. private _cachedOffsetX;
  76932. private _cachedOffsetY;
  76933. private _isVisible;
  76934. private _isHighlighted;
  76935. /** @hidden */
  76936. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  76937. private _fontSet;
  76938. private _dummyVector2;
  76939. private _downCount;
  76940. private _enterCount;
  76941. private _doNotRender;
  76942. private _downPointerIds;
  76943. protected _isEnabled: boolean;
  76944. protected _disabledColor: string;
  76945. protected _disabledColorItem: string;
  76946. /** @hidden */
  76947. protected _rebuildLayout: boolean;
  76948. /** @hidden */
  76949. _customData: any;
  76950. /** @hidden */
  76951. _isClipped: boolean;
  76952. /** @hidden */
  76953. _automaticSize: boolean;
  76954. /** @hidden */
  76955. _tag: any;
  76956. /**
  76957. * 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
  76958. */
  76959. uniqueId: number;
  76960. /**
  76961. * Gets or sets an object used to store user defined information for the node
  76962. */
  76963. metadata: any;
  76964. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  76965. isHitTestVisible: boolean;
  76966. /** Gets or sets a boolean indicating if the control can block pointer events */
  76967. isPointerBlocker: boolean;
  76968. /** Gets or sets a boolean indicating if the control can be focusable */
  76969. isFocusInvisible: boolean;
  76970. /**
  76971. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  76972. * 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
  76973. */
  76974. clipChildren: boolean;
  76975. /**
  76976. * Gets or sets a boolean indicating that control content must be clipped
  76977. * 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
  76978. */
  76979. clipContent: boolean;
  76980. /**
  76981. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  76982. */
  76983. useBitmapCache: boolean;
  76984. private _cacheData;
  76985. private _shadowOffsetX;
  76986. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  76987. get shadowOffsetX(): number;
  76988. set shadowOffsetX(value: number);
  76989. private _shadowOffsetY;
  76990. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  76991. get shadowOffsetY(): number;
  76992. set shadowOffsetY(value: number);
  76993. private _shadowBlur;
  76994. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  76995. get shadowBlur(): number;
  76996. set shadowBlur(value: number);
  76997. private _shadowColor;
  76998. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  76999. get shadowColor(): string;
  77000. set shadowColor(value: string);
  77001. /** Gets or sets the cursor to use when the control is hovered */
  77002. hoverCursor: string;
  77003. /** @hidden */
  77004. protected _linkOffsetX: ValueAndUnit;
  77005. /** @hidden */
  77006. protected _linkOffsetY: ValueAndUnit;
  77007. /** Gets the control type name */
  77008. get typeName(): string;
  77009. /**
  77010. * Get the current class name of the control.
  77011. * @returns current class name
  77012. */
  77013. getClassName(): string;
  77014. /**
  77015. * An event triggered when pointer wheel is scrolled
  77016. */
  77017. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  77018. /**
  77019. * An event triggered when the pointer move over the control.
  77020. */
  77021. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  77022. /**
  77023. * An event triggered when the pointer move out of the control.
  77024. */
  77025. onPointerOutObservable: BABYLON.Observable<Control>;
  77026. /**
  77027. * An event triggered when the pointer taps the control
  77028. */
  77029. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  77030. /**
  77031. * An event triggered when pointer up
  77032. */
  77033. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  77034. /**
  77035. * An event triggered when a control is clicked on
  77036. */
  77037. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  77038. /**
  77039. * An event triggered when pointer enters the control
  77040. */
  77041. onPointerEnterObservable: BABYLON.Observable<Control>;
  77042. /**
  77043. * An event triggered when the control is marked as dirty
  77044. */
  77045. onDirtyObservable: BABYLON.Observable<Control>;
  77046. /**
  77047. * An event triggered before drawing the control
  77048. */
  77049. onBeforeDrawObservable: BABYLON.Observable<Control>;
  77050. /**
  77051. * An event triggered after the control was drawn
  77052. */
  77053. onAfterDrawObservable: BABYLON.Observable<Control>;
  77054. /**
  77055. * An event triggered when the control has been disposed
  77056. */
  77057. onDisposeObservable: BABYLON.Observable<Control>;
  77058. /**
  77059. * Get the hosting AdvancedDynamicTexture
  77060. */
  77061. get host(): AdvancedDynamicTexture;
  77062. /** Gets or set information about font offsets (used to render and align text) */
  77063. get fontOffset(): {
  77064. ascent: number;
  77065. height: number;
  77066. descent: number;
  77067. };
  77068. set fontOffset(offset: {
  77069. ascent: number;
  77070. height: number;
  77071. descent: number;
  77072. });
  77073. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  77074. get alpha(): number;
  77075. set alpha(value: number);
  77076. /**
  77077. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  77078. */
  77079. get isHighlighted(): boolean;
  77080. set isHighlighted(value: boolean);
  77081. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  77082. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77083. */
  77084. get scaleX(): number;
  77085. set scaleX(value: number);
  77086. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  77087. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77088. */
  77089. get scaleY(): number;
  77090. set scaleY(value: number);
  77091. /** Gets or sets the rotation angle (0 by default)
  77092. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77093. */
  77094. get rotation(): number;
  77095. set rotation(value: number);
  77096. /** Gets or sets the transformation center on Y axis (0 by default)
  77097. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77098. */
  77099. get transformCenterY(): number;
  77100. set transformCenterY(value: number);
  77101. /** Gets or sets the transformation center on X axis (0 by default)
  77102. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77103. */
  77104. get transformCenterX(): number;
  77105. set transformCenterX(value: number);
  77106. /**
  77107. * Gets or sets the horizontal alignment
  77108. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77109. */
  77110. get horizontalAlignment(): number;
  77111. set horizontalAlignment(value: number);
  77112. /**
  77113. * Gets or sets the vertical alignment
  77114. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77115. */
  77116. get verticalAlignment(): number;
  77117. set verticalAlignment(value: number);
  77118. /**
  77119. * Gets or sets a fixed ratio for this control.
  77120. * When different from 0, the ratio is used to compute the "second" dimension.
  77121. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  77122. * second dimension is computed as first dimension * fixedRatio
  77123. */
  77124. fixedRatio: number;
  77125. private _fixedRatioMasterIsWidth;
  77126. /**
  77127. * Gets or sets control width
  77128. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77129. */
  77130. get width(): string | number;
  77131. set width(value: string | number);
  77132. /**
  77133. * Gets or sets the control width in pixel
  77134. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77135. */
  77136. get widthInPixels(): number;
  77137. set widthInPixels(value: number);
  77138. /**
  77139. * Gets or sets control height
  77140. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77141. */
  77142. get height(): string | number;
  77143. set height(value: string | number);
  77144. /**
  77145. * Gets or sets control height in pixel
  77146. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77147. */
  77148. get heightInPixels(): number;
  77149. set heightInPixels(value: number);
  77150. /** Gets or set font family */
  77151. get fontFamily(): string;
  77152. set fontFamily(value: string);
  77153. /** Gets or sets font style */
  77154. get fontStyle(): string;
  77155. set fontStyle(value: string);
  77156. /** Gets or sets font weight */
  77157. get fontWeight(): string;
  77158. set fontWeight(value: string);
  77159. /**
  77160. * Gets or sets style
  77161. * @see https://doc.babylonjs.com/how_to/gui#styles
  77162. */
  77163. get style(): BABYLON.Nullable<Style>;
  77164. set style(value: BABYLON.Nullable<Style>);
  77165. /** @hidden */
  77166. get _isFontSizeInPercentage(): boolean;
  77167. /** Gets or sets font size in pixels */
  77168. get fontSizeInPixels(): number;
  77169. set fontSizeInPixels(value: number);
  77170. /** Gets or sets font size */
  77171. get fontSize(): string | number;
  77172. set fontSize(value: string | number);
  77173. /** Gets or sets foreground color */
  77174. get color(): string;
  77175. set color(value: string);
  77176. /** Gets or sets z index which is used to reorder controls on the z axis */
  77177. get zIndex(): number;
  77178. set zIndex(value: number);
  77179. /** Gets or sets a boolean indicating if the control can be rendered */
  77180. get notRenderable(): boolean;
  77181. set notRenderable(value: boolean);
  77182. /** Gets or sets a boolean indicating if the control is visible */
  77183. get isVisible(): boolean;
  77184. set isVisible(value: boolean);
  77185. /** Gets a boolean indicating that the control needs to update its rendering */
  77186. get isDirty(): boolean;
  77187. /**
  77188. * Gets the current linked mesh (or null if none)
  77189. */
  77190. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77191. /**
  77192. * Gets or sets a value indicating the padding to use on the left of the control
  77193. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77194. */
  77195. get paddingLeft(): string | number;
  77196. set paddingLeft(value: string | number);
  77197. /**
  77198. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  77199. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77200. */
  77201. get paddingLeftInPixels(): number;
  77202. set paddingLeftInPixels(value: number);
  77203. /**
  77204. * Gets or sets a value indicating the padding to use on the right of the control
  77205. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77206. */
  77207. get paddingRight(): string | number;
  77208. set paddingRight(value: string | number);
  77209. /**
  77210. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  77211. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77212. */
  77213. get paddingRightInPixels(): number;
  77214. set paddingRightInPixels(value: number);
  77215. /**
  77216. * Gets or sets a value indicating the padding to use on the top of the control
  77217. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77218. */
  77219. get paddingTop(): string | number;
  77220. set paddingTop(value: string | number);
  77221. /**
  77222. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  77223. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77224. */
  77225. get paddingTopInPixels(): number;
  77226. set paddingTopInPixels(value: number);
  77227. /**
  77228. * Gets or sets a value indicating the padding to use on the bottom of the control
  77229. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77230. */
  77231. get paddingBottom(): string | number;
  77232. set paddingBottom(value: string | number);
  77233. /**
  77234. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  77235. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77236. */
  77237. get paddingBottomInPixels(): number;
  77238. set paddingBottomInPixels(value: number);
  77239. /**
  77240. * Gets or sets a value indicating the left coordinate of the control
  77241. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77242. */
  77243. get left(): string | number;
  77244. set left(value: string | number);
  77245. /**
  77246. * Gets or sets a value indicating the left coordinate in pixels of the control
  77247. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77248. */
  77249. get leftInPixels(): number;
  77250. set leftInPixels(value: number);
  77251. /**
  77252. * Gets or sets a value indicating the top coordinate of the control
  77253. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77254. */
  77255. get top(): string | number;
  77256. set top(value: string | number);
  77257. /**
  77258. * Gets or sets a value indicating the top coordinate in pixels of the control
  77259. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77260. */
  77261. get topInPixels(): number;
  77262. set topInPixels(value: number);
  77263. /**
  77264. * Gets or sets a value indicating the offset on X axis to the linked mesh
  77265. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77266. */
  77267. get linkOffsetX(): string | number;
  77268. set linkOffsetX(value: string | number);
  77269. /**
  77270. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  77271. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77272. */
  77273. get linkOffsetXInPixels(): number;
  77274. set linkOffsetXInPixels(value: number);
  77275. /**
  77276. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  77277. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77278. */
  77279. get linkOffsetY(): string | number;
  77280. set linkOffsetY(value: string | number);
  77281. /**
  77282. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  77283. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77284. */
  77285. get linkOffsetYInPixels(): number;
  77286. set linkOffsetYInPixels(value: number);
  77287. /** Gets the center coordinate on X axis */
  77288. get centerX(): number;
  77289. /** Gets the center coordinate on Y axis */
  77290. get centerY(): number;
  77291. /** Gets or sets if control is Enabled*/
  77292. get isEnabled(): boolean;
  77293. set isEnabled(value: boolean);
  77294. /** Gets or sets background color of control if it's disabled*/
  77295. get disabledColor(): string;
  77296. set disabledColor(value: string);
  77297. /** Gets or sets front color of control if it's disabled*/
  77298. get disabledColorItem(): string;
  77299. set disabledColorItem(value: string);
  77300. /**
  77301. * Creates a new control
  77302. * @param name defines the name of the control
  77303. */
  77304. constructor(
  77305. /** defines the name of the control */
  77306. name?: string | undefined);
  77307. /** @hidden */
  77308. protected _getTypeName(): string;
  77309. /**
  77310. * Gets the first ascendant in the hierarchy of the given type
  77311. * @param className defines the required type
  77312. * @returns the ascendant or null if not found
  77313. */
  77314. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  77315. /** @hidden */
  77316. _resetFontCache(): void;
  77317. /**
  77318. * Determines if a container is an ascendant of the current control
  77319. * @param container defines the container to look for
  77320. * @returns true if the container is one of the ascendant of the control
  77321. */
  77322. isAscendant(container: Control): boolean;
  77323. /**
  77324. * Gets coordinates in local control space
  77325. * @param globalCoordinates defines the coordinates to transform
  77326. * @returns the new coordinates in local space
  77327. */
  77328. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77329. /**
  77330. * Gets coordinates in local control space
  77331. * @param globalCoordinates defines the coordinates to transform
  77332. * @param result defines the target vector2 where to store the result
  77333. * @returns the current control
  77334. */
  77335. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  77336. /**
  77337. * Gets coordinates in parent local control space
  77338. * @param globalCoordinates defines the coordinates to transform
  77339. * @returns the new coordinates in parent local space
  77340. */
  77341. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77342. /**
  77343. * Move the current control to a vector3 position projected onto the screen.
  77344. * @param position defines the target position
  77345. * @param scene defines the hosting scene
  77346. */
  77347. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  77348. /**
  77349. * Will store all controls that have this control as ascendant in a given array
  77350. * @param results defines the array where to store the descendants
  77351. * @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
  77352. * @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
  77353. */
  77354. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77355. /**
  77356. * Will return all controls that have this control as ascendant
  77357. * @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
  77358. * @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
  77359. * @return all child controls
  77360. */
  77361. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77362. /**
  77363. * Link current control with a target mesh
  77364. * @param mesh defines the mesh to link with
  77365. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77366. */
  77367. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  77368. /** @hidden */
  77369. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  77370. /** @hidden */
  77371. _offsetLeft(offset: number): void;
  77372. /** @hidden */
  77373. _offsetTop(offset: number): void;
  77374. /** @hidden */
  77375. _markMatrixAsDirty(): void;
  77376. /** @hidden */
  77377. _flagDescendantsAsMatrixDirty(): void;
  77378. /** @hidden */
  77379. _intersectsRect(rect: Measure): boolean;
  77380. /** @hidden */
  77381. protected invalidateRect(): void;
  77382. /** @hidden */
  77383. _markAsDirty(force?: boolean): void;
  77384. /** @hidden */
  77385. _markAllAsDirty(): void;
  77386. /** @hidden */
  77387. _link(host: AdvancedDynamicTexture): void;
  77388. /** @hidden */
  77389. protected _transform(context?: CanvasRenderingContext2D): void;
  77390. /** @hidden */
  77391. _renderHighlight(context: CanvasRenderingContext2D): void;
  77392. /** @hidden */
  77393. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77394. /** @hidden */
  77395. protected _applyStates(context: CanvasRenderingContext2D): void;
  77396. /** @hidden */
  77397. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77398. /** @hidden */
  77399. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77400. protected _evaluateClippingState(parentMeasure: Measure): void;
  77401. /** @hidden */
  77402. _measure(): void;
  77403. /** @hidden */
  77404. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77405. /** @hidden */
  77406. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77407. /** @hidden */
  77408. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77409. /** @hidden */
  77410. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77411. private static _ClipMeasure;
  77412. private _tmpMeasureA;
  77413. private _clip;
  77414. /** @hidden */
  77415. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  77416. /** @hidden */
  77417. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77418. /**
  77419. * Tests if a given coordinates belong to the current control
  77420. * @param x defines x coordinate to test
  77421. * @param y defines y coordinate to test
  77422. * @returns true if the coordinates are inside the control
  77423. */
  77424. contains(x: number, y: number): boolean;
  77425. /** @hidden */
  77426. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77427. /** @hidden */
  77428. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77429. /** @hidden */
  77430. _onPointerEnter(target: Control): boolean;
  77431. /** @hidden */
  77432. _onPointerOut(target: Control, force?: boolean): void;
  77433. /** @hidden */
  77434. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77435. /** @hidden */
  77436. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77437. /** @hidden */
  77438. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77439. /** @hidden */
  77440. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  77441. /** @hidden */
  77442. _onCanvasBlur(): void;
  77443. /** @hidden */
  77444. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77445. private _prepareFont;
  77446. /** Releases associated resources */
  77447. dispose(): void;
  77448. private static _HORIZONTAL_ALIGNMENT_LEFT;
  77449. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  77450. private static _HORIZONTAL_ALIGNMENT_CENTER;
  77451. private static _VERTICAL_ALIGNMENT_TOP;
  77452. private static _VERTICAL_ALIGNMENT_BOTTOM;
  77453. private static _VERTICAL_ALIGNMENT_CENTER;
  77454. /** HORIZONTAL_ALIGNMENT_LEFT */
  77455. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  77456. /** HORIZONTAL_ALIGNMENT_RIGHT */
  77457. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  77458. /** HORIZONTAL_ALIGNMENT_CENTER */
  77459. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  77460. /** VERTICAL_ALIGNMENT_TOP */
  77461. static get VERTICAL_ALIGNMENT_TOP(): number;
  77462. /** VERTICAL_ALIGNMENT_BOTTOM */
  77463. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  77464. /** VERTICAL_ALIGNMENT_CENTER */
  77465. static get VERTICAL_ALIGNMENT_CENTER(): number;
  77466. private static _FontHeightSizes;
  77467. /** @hidden */
  77468. static _GetFontOffset(font: string): {
  77469. ascent: number;
  77470. height: number;
  77471. descent: number;
  77472. };
  77473. /**
  77474. * Creates a stack panel that can be used to render headers
  77475. * @param control defines the control to associate with the header
  77476. * @param text defines the text of the header
  77477. * @param size defines the size of the header
  77478. * @param options defines options used to configure the header
  77479. * @returns a new StackPanel
  77480. * @ignore
  77481. * @hidden
  77482. */
  77483. static AddHeader: (control: Control, text: string, size: string | number, options: {
  77484. isHorizontal: boolean;
  77485. controlFirst: boolean;
  77486. }) => any;
  77487. /** @hidden */
  77488. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  77489. }
  77490. }
  77491. declare module BABYLON.GUI {
  77492. /**
  77493. * Root class for 2D containers
  77494. * @see https://doc.babylonjs.com/how_to/gui#containers
  77495. */
  77496. export class Container extends Control {
  77497. name?: string | undefined;
  77498. /** @hidden */
  77499. _children: Control[];
  77500. /** @hidden */
  77501. protected _measureForChildren: Measure;
  77502. /** @hidden */
  77503. protected _background: string;
  77504. /** @hidden */
  77505. protected _adaptWidthToChildren: boolean;
  77506. /** @hidden */
  77507. protected _adaptHeightToChildren: boolean;
  77508. /**
  77509. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  77510. */
  77511. logLayoutCycleErrors: boolean;
  77512. /**
  77513. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  77514. */
  77515. maxLayoutCycle: number;
  77516. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  77517. get adaptHeightToChildren(): boolean;
  77518. set adaptHeightToChildren(value: boolean);
  77519. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  77520. get adaptWidthToChildren(): boolean;
  77521. set adaptWidthToChildren(value: boolean);
  77522. /** Gets or sets background color */
  77523. get background(): string;
  77524. set background(value: string);
  77525. /** Gets the list of children */
  77526. get children(): Control[];
  77527. /**
  77528. * Creates a new Container
  77529. * @param name defines the name of the container
  77530. */
  77531. constructor(name?: string | undefined);
  77532. protected _getTypeName(): string;
  77533. _flagDescendantsAsMatrixDirty(): void;
  77534. /**
  77535. * Gets a child using its name
  77536. * @param name defines the child name to look for
  77537. * @returns the child control if found
  77538. */
  77539. getChildByName(name: string): BABYLON.Nullable<Control>;
  77540. /**
  77541. * Gets a child using its type and its name
  77542. * @param name defines the child name to look for
  77543. * @param type defines the child type to look for
  77544. * @returns the child control if found
  77545. */
  77546. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  77547. /**
  77548. * Search for a specific control in children
  77549. * @param control defines the control to look for
  77550. * @returns true if the control is in child list
  77551. */
  77552. containsControl(control: Control): boolean;
  77553. /**
  77554. * Adds a new control to the current container
  77555. * @param control defines the control to add
  77556. * @returns the current container
  77557. */
  77558. addControl(control: BABYLON.Nullable<Control>): Container;
  77559. /**
  77560. * Removes all controls from the current container
  77561. * @returns the current container
  77562. */
  77563. clearControls(): Container;
  77564. /**
  77565. * Removes a control from the current container
  77566. * @param control defines the control to remove
  77567. * @returns the current container
  77568. */
  77569. removeControl(control: Control): Container;
  77570. /** @hidden */
  77571. _reOrderControl(control: Control): void;
  77572. /** @hidden */
  77573. _offsetLeft(offset: number): void;
  77574. /** @hidden */
  77575. _offsetTop(offset: number): void;
  77576. /** @hidden */
  77577. _markAllAsDirty(): void;
  77578. /** @hidden */
  77579. protected _localDraw(context: CanvasRenderingContext2D): void;
  77580. /** @hidden */
  77581. _link(host: AdvancedDynamicTexture): void;
  77582. /** @hidden */
  77583. protected _beforeLayout(): void;
  77584. /** @hidden */
  77585. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77586. /** @hidden */
  77587. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77588. protected _postMeasure(): void;
  77589. /** @hidden */
  77590. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77591. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77592. /** @hidden */
  77593. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77594. /** @hidden */
  77595. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77596. /** Releases associated resources */
  77597. dispose(): void;
  77598. }
  77599. }
  77600. declare module BABYLON.GUI {
  77601. /** Class used to create rectangle container */
  77602. export class Rectangle extends Container {
  77603. name?: string | undefined;
  77604. private _thickness;
  77605. private _cornerRadius;
  77606. /** Gets or sets border thickness */
  77607. get thickness(): number;
  77608. set thickness(value: number);
  77609. /** Gets or sets the corner radius angle */
  77610. get cornerRadius(): number;
  77611. set cornerRadius(value: number);
  77612. /**
  77613. * Creates a new Rectangle
  77614. * @param name defines the control name
  77615. */
  77616. constructor(name?: string | undefined);
  77617. protected _getTypeName(): string;
  77618. protected _localDraw(context: CanvasRenderingContext2D): void;
  77619. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77620. private _drawRoundedRect;
  77621. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77622. }
  77623. }
  77624. declare module BABYLON.GUI {
  77625. /**
  77626. * Enum that determines the text-wrapping mode to use.
  77627. */
  77628. export enum TextWrapping {
  77629. /**
  77630. * Clip the text when it's larger than Control.width; this is the default mode.
  77631. */
  77632. Clip = 0,
  77633. /**
  77634. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  77635. */
  77636. WordWrap = 1,
  77637. /**
  77638. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  77639. */
  77640. Ellipsis = 2
  77641. }
  77642. /**
  77643. * Class used to create text block control
  77644. */
  77645. export class TextBlock extends Control {
  77646. /**
  77647. * Defines the name of the control
  77648. */
  77649. name?: string | undefined;
  77650. private _text;
  77651. private _textWrapping;
  77652. private _textHorizontalAlignment;
  77653. private _textVerticalAlignment;
  77654. private _lines;
  77655. private _resizeToFit;
  77656. private _lineSpacing;
  77657. private _outlineWidth;
  77658. private _outlineColor;
  77659. private _underline;
  77660. private _lineThrough;
  77661. /**
  77662. * An event triggered after the text is changed
  77663. */
  77664. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  77665. /**
  77666. * An event triggered after the text was broken up into lines
  77667. */
  77668. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  77669. /**
  77670. * Function used to split a string into words. By default, a string is split at each space character found
  77671. */
  77672. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  77673. /**
  77674. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  77675. */
  77676. get lines(): any[];
  77677. /**
  77678. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77679. */
  77680. get resizeToFit(): boolean;
  77681. /**
  77682. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77683. */
  77684. set resizeToFit(value: boolean);
  77685. /**
  77686. * Gets or sets a boolean indicating if text must be wrapped
  77687. */
  77688. get textWrapping(): TextWrapping | boolean;
  77689. /**
  77690. * Gets or sets a boolean indicating if text must be wrapped
  77691. */
  77692. set textWrapping(value: TextWrapping | boolean);
  77693. /**
  77694. * Gets or sets text to display
  77695. */
  77696. get text(): string;
  77697. /**
  77698. * Gets or sets text to display
  77699. */
  77700. set text(value: string);
  77701. /**
  77702. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77703. */
  77704. get textHorizontalAlignment(): number;
  77705. /**
  77706. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77707. */
  77708. set textHorizontalAlignment(value: number);
  77709. /**
  77710. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77711. */
  77712. get textVerticalAlignment(): number;
  77713. /**
  77714. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77715. */
  77716. set textVerticalAlignment(value: number);
  77717. /**
  77718. * Gets or sets line spacing value
  77719. */
  77720. set lineSpacing(value: string | number);
  77721. /**
  77722. * Gets or sets line spacing value
  77723. */
  77724. get lineSpacing(): string | number;
  77725. /**
  77726. * Gets or sets outlineWidth of the text to display
  77727. */
  77728. get outlineWidth(): number;
  77729. /**
  77730. * Gets or sets outlineWidth of the text to display
  77731. */
  77732. set outlineWidth(value: number);
  77733. /**
  77734. * Gets or sets a boolean indicating that text must have underline
  77735. */
  77736. get underline(): boolean;
  77737. /**
  77738. * Gets or sets a boolean indicating that text must have underline
  77739. */
  77740. set underline(value: boolean);
  77741. /**
  77742. * Gets or sets an boolean indicating that text must be crossed out
  77743. */
  77744. get lineThrough(): boolean;
  77745. /**
  77746. * Gets or sets an boolean indicating that text must be crossed out
  77747. */
  77748. set lineThrough(value: boolean);
  77749. /**
  77750. * Gets or sets outlineColor of the text to display
  77751. */
  77752. get outlineColor(): string;
  77753. /**
  77754. * Gets or sets outlineColor of the text to display
  77755. */
  77756. set outlineColor(value: string);
  77757. /**
  77758. * Creates a new TextBlock object
  77759. * @param name defines the name of the control
  77760. * @param text defines the text to display (emptry string by default)
  77761. */
  77762. constructor(
  77763. /**
  77764. * Defines the name of the control
  77765. */
  77766. name?: string | undefined, text?: string);
  77767. protected _getTypeName(): string;
  77768. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77769. private _drawText;
  77770. /** @hidden */
  77771. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77772. protected _applyStates(context: CanvasRenderingContext2D): void;
  77773. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  77774. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  77775. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  77776. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  77777. protected _renderLines(context: CanvasRenderingContext2D): void;
  77778. /**
  77779. * Given a width constraint applied on the text block, find the expected height
  77780. * @returns expected height
  77781. */
  77782. computeExpectedHeight(): number;
  77783. dispose(): void;
  77784. }
  77785. }
  77786. declare module BABYLON.GUI {
  77787. /**
  77788. * Class used to create 2D images
  77789. */
  77790. export class Image extends Control {
  77791. name?: string | undefined;
  77792. private _workingCanvas;
  77793. private _domImage;
  77794. private _imageWidth;
  77795. private _imageHeight;
  77796. private _loaded;
  77797. private _stretch;
  77798. private _source;
  77799. private _autoScale;
  77800. private _sourceLeft;
  77801. private _sourceTop;
  77802. private _sourceWidth;
  77803. private _sourceHeight;
  77804. private _svgAttributesComputationCompleted;
  77805. private _isSVG;
  77806. private _cellWidth;
  77807. private _cellHeight;
  77808. private _cellId;
  77809. private _populateNinePatchSlicesFromImage;
  77810. private _sliceLeft;
  77811. private _sliceRight;
  77812. private _sliceTop;
  77813. private _sliceBottom;
  77814. private _detectPointerOnOpaqueOnly;
  77815. private _imageDataCache;
  77816. /**
  77817. * BABYLON.Observable notified when the content is loaded
  77818. */
  77819. onImageLoadedObservable: BABYLON.Observable<Image>;
  77820. /**
  77821. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  77822. */
  77823. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  77824. /**
  77825. * Gets a boolean indicating that the content is loaded
  77826. */
  77827. get isLoaded(): boolean;
  77828. /**
  77829. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  77830. */
  77831. get populateNinePatchSlicesFromImage(): boolean;
  77832. set populateNinePatchSlicesFromImage(value: boolean);
  77833. /**
  77834. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  77835. * Beware using this as this will comsume more memory as the image has to be stored twice
  77836. */
  77837. get detectPointerOnOpaqueOnly(): boolean;
  77838. set detectPointerOnOpaqueOnly(value: boolean);
  77839. /**
  77840. * Gets or sets the left value for slicing (9-patch)
  77841. */
  77842. get sliceLeft(): number;
  77843. set sliceLeft(value: number);
  77844. /**
  77845. * Gets or sets the right value for slicing (9-patch)
  77846. */
  77847. get sliceRight(): number;
  77848. set sliceRight(value: number);
  77849. /**
  77850. * Gets or sets the top value for slicing (9-patch)
  77851. */
  77852. get sliceTop(): number;
  77853. set sliceTop(value: number);
  77854. /**
  77855. * Gets or sets the bottom value for slicing (9-patch)
  77856. */
  77857. get sliceBottom(): number;
  77858. set sliceBottom(value: number);
  77859. /**
  77860. * Gets or sets the left coordinate in the source image
  77861. */
  77862. get sourceLeft(): number;
  77863. set sourceLeft(value: number);
  77864. /**
  77865. * Gets or sets the top coordinate in the source image
  77866. */
  77867. get sourceTop(): number;
  77868. set sourceTop(value: number);
  77869. /**
  77870. * Gets or sets the width to capture in the source image
  77871. */
  77872. get sourceWidth(): number;
  77873. set sourceWidth(value: number);
  77874. /**
  77875. * Gets or sets the height to capture in the source image
  77876. */
  77877. get sourceHeight(): number;
  77878. set sourceHeight(value: number);
  77879. /** Indicates if the format of the image is SVG */
  77880. get isSVG(): boolean;
  77881. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  77882. get svgAttributesComputationCompleted(): boolean;
  77883. /**
  77884. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  77885. * @see https://doc.babylonjs.com/how_to/gui#image
  77886. */
  77887. get autoScale(): boolean;
  77888. set autoScale(value: boolean);
  77889. /** Gets or sets the streching mode used by the image */
  77890. get stretch(): number;
  77891. set stretch(value: number);
  77892. /** @hidden */
  77893. _rotate90(n: number, preserveProperties?: boolean): Image;
  77894. private _handleRotationForSVGImage;
  77895. private _rotate90SourceProperties;
  77896. /**
  77897. * Gets or sets the internal DOM image used to render the control
  77898. */
  77899. set domImage(value: HTMLImageElement);
  77900. get domImage(): HTMLImageElement;
  77901. private _onImageLoaded;
  77902. private _extractNinePatchSliceDataFromImage;
  77903. /**
  77904. * Gets or sets image source url
  77905. */
  77906. set source(value: BABYLON.Nullable<string>);
  77907. /**
  77908. * Checks for svg document with icon id present
  77909. */
  77910. private _svgCheck;
  77911. /**
  77912. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  77913. * given external svg file and icon id
  77914. */
  77915. private _getSVGAttribs;
  77916. /**
  77917. * Gets or sets the cell width to use when animation sheet is enabled
  77918. * @see https://doc.babylonjs.com/how_to/gui#image
  77919. */
  77920. get cellWidth(): number;
  77921. set cellWidth(value: number);
  77922. /**
  77923. * Gets or sets the cell height to use when animation sheet is enabled
  77924. * @see https://doc.babylonjs.com/how_to/gui#image
  77925. */
  77926. get cellHeight(): number;
  77927. set cellHeight(value: number);
  77928. /**
  77929. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  77930. * @see https://doc.babylonjs.com/how_to/gui#image
  77931. */
  77932. get cellId(): number;
  77933. set cellId(value: number);
  77934. /**
  77935. * Creates a new Image
  77936. * @param name defines the control name
  77937. * @param url defines the image url
  77938. */
  77939. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  77940. /**
  77941. * Tests if a given coordinates belong to the current control
  77942. * @param x defines x coordinate to test
  77943. * @param y defines y coordinate to test
  77944. * @returns true if the coordinates are inside the control
  77945. */
  77946. contains(x: number, y: number): boolean;
  77947. protected _getTypeName(): string;
  77948. /** Force the control to synchronize with its content */
  77949. synchronizeSizeWithContent(): void;
  77950. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77951. private _prepareWorkingCanvasForOpaqueDetection;
  77952. private _drawImage;
  77953. _draw(context: CanvasRenderingContext2D): void;
  77954. private _renderCornerPatch;
  77955. private _renderNinePatch;
  77956. dispose(): void;
  77957. /** STRETCH_NONE */
  77958. static readonly STRETCH_NONE: number;
  77959. /** STRETCH_FILL */
  77960. static readonly STRETCH_FILL: number;
  77961. /** STRETCH_UNIFORM */
  77962. static readonly STRETCH_UNIFORM: number;
  77963. /** STRETCH_EXTEND */
  77964. static readonly STRETCH_EXTEND: number;
  77965. /** NINE_PATCH */
  77966. static readonly STRETCH_NINE_PATCH: number;
  77967. }
  77968. }
  77969. declare module BABYLON.GUI {
  77970. /**
  77971. * Class used to create 2D buttons
  77972. */
  77973. export class Button extends Rectangle {
  77974. name?: string | undefined;
  77975. /**
  77976. * Function called to generate a pointer enter animation
  77977. */
  77978. pointerEnterAnimation: () => void;
  77979. /**
  77980. * Function called to generate a pointer out animation
  77981. */
  77982. pointerOutAnimation: () => void;
  77983. /**
  77984. * Function called to generate a pointer down animation
  77985. */
  77986. pointerDownAnimation: () => void;
  77987. /**
  77988. * Function called to generate a pointer up animation
  77989. */
  77990. pointerUpAnimation: () => void;
  77991. /**
  77992. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  77993. */
  77994. delegatePickingToChildren: boolean;
  77995. private _image;
  77996. /**
  77997. * Returns the image part of the button (if any)
  77998. */
  77999. get image(): BABYLON.Nullable<Image>;
  78000. private _textBlock;
  78001. /**
  78002. * Returns the image part of the button (if any)
  78003. */
  78004. get textBlock(): BABYLON.Nullable<TextBlock>;
  78005. /**
  78006. * Creates a new Button
  78007. * @param name defines the name of the button
  78008. */
  78009. constructor(name?: string | undefined);
  78010. protected _getTypeName(): string;
  78011. /** @hidden */
  78012. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78013. /** @hidden */
  78014. _onPointerEnter(target: Control): boolean;
  78015. /** @hidden */
  78016. _onPointerOut(target: Control, force?: boolean): void;
  78017. /** @hidden */
  78018. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78019. /** @hidden */
  78020. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78021. /**
  78022. * Creates a new button made with an image and a text
  78023. * @param name defines the name of the button
  78024. * @param text defines the text of the button
  78025. * @param imageUrl defines the url of the image
  78026. * @returns a new Button
  78027. */
  78028. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  78029. /**
  78030. * Creates a new button made with an image
  78031. * @param name defines the name of the button
  78032. * @param imageUrl defines the url of the image
  78033. * @returns a new Button
  78034. */
  78035. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  78036. /**
  78037. * Creates a new button made with a text
  78038. * @param name defines the name of the button
  78039. * @param text defines the text of the button
  78040. * @returns a new Button
  78041. */
  78042. static CreateSimpleButton(name: string, text: string): Button;
  78043. /**
  78044. * Creates a new button made with an image and a centered text
  78045. * @param name defines the name of the button
  78046. * @param text defines the text of the button
  78047. * @param imageUrl defines the url of the image
  78048. * @returns a new Button
  78049. */
  78050. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  78051. }
  78052. }
  78053. declare module BABYLON.GUI {
  78054. /**
  78055. * Class used to create a 2D stack panel container
  78056. */
  78057. export class StackPanel extends Container {
  78058. name?: string | undefined;
  78059. private _isVertical;
  78060. private _manualWidth;
  78061. private _manualHeight;
  78062. private _doNotTrackManualChanges;
  78063. /**
  78064. * Gets or sets a boolean indicating that layou warnings should be ignored
  78065. */
  78066. ignoreLayoutWarnings: boolean;
  78067. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  78068. get isVertical(): boolean;
  78069. set isVertical(value: boolean);
  78070. /**
  78071. * Gets or sets panel width.
  78072. * This value should not be set when in horizontal mode as it will be computed automatically
  78073. */
  78074. set width(value: string | number);
  78075. get width(): string | number;
  78076. /**
  78077. * Gets or sets panel height.
  78078. * This value should not be set when in vertical mode as it will be computed automatically
  78079. */
  78080. set height(value: string | number);
  78081. get height(): string | number;
  78082. /**
  78083. * Creates a new StackPanel
  78084. * @param name defines control name
  78085. */
  78086. constructor(name?: string | undefined);
  78087. protected _getTypeName(): string;
  78088. /** @hidden */
  78089. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78090. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78091. protected _postMeasure(): void;
  78092. }
  78093. }
  78094. declare module BABYLON.GUI {
  78095. /**
  78096. * Class used to represent a 2D checkbox
  78097. */
  78098. export class Checkbox extends Control {
  78099. name?: string | undefined;
  78100. private _isChecked;
  78101. private _background;
  78102. private _checkSizeRatio;
  78103. private _thickness;
  78104. /** Gets or sets border thickness */
  78105. get thickness(): number;
  78106. set thickness(value: number);
  78107. /**
  78108. * BABYLON.Observable raised when isChecked property changes
  78109. */
  78110. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78111. /** Gets or sets a value indicating the ratio between overall size and check size */
  78112. get checkSizeRatio(): number;
  78113. set checkSizeRatio(value: number);
  78114. /** Gets or sets background color */
  78115. get background(): string;
  78116. set background(value: string);
  78117. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78118. get isChecked(): boolean;
  78119. set isChecked(value: boolean);
  78120. /**
  78121. * Creates a new CheckBox
  78122. * @param name defines the control name
  78123. */
  78124. constructor(name?: string | undefined);
  78125. protected _getTypeName(): string;
  78126. /** @hidden */
  78127. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78128. /** @hidden */
  78129. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78130. /**
  78131. * Utility function to easily create a checkbox with a header
  78132. * @param title defines the label to use for the header
  78133. * @param onValueChanged defines the callback to call when value changes
  78134. * @returns a StackPanel containing the checkbox and a textBlock
  78135. */
  78136. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  78137. }
  78138. }
  78139. declare module BABYLON.GUI {
  78140. /**
  78141. * Class used to store key control properties
  78142. */
  78143. export class KeyPropertySet {
  78144. /** Width */
  78145. width?: string;
  78146. /** Height */
  78147. height?: string;
  78148. /** Left padding */
  78149. paddingLeft?: string;
  78150. /** Right padding */
  78151. paddingRight?: string;
  78152. /** Top padding */
  78153. paddingTop?: string;
  78154. /** Bottom padding */
  78155. paddingBottom?: string;
  78156. /** Foreground color */
  78157. color?: string;
  78158. /** Background color */
  78159. background?: string;
  78160. }
  78161. /**
  78162. * Class used to create virtual keyboard
  78163. */
  78164. export class VirtualKeyboard extends StackPanel {
  78165. /** BABYLON.Observable raised when a key is pressed */
  78166. onKeyPressObservable: BABYLON.Observable<string>;
  78167. /** Gets or sets default key button width */
  78168. defaultButtonWidth: string;
  78169. /** Gets or sets default key button height */
  78170. defaultButtonHeight: string;
  78171. /** Gets or sets default key button left padding */
  78172. defaultButtonPaddingLeft: string;
  78173. /** Gets or sets default key button right padding */
  78174. defaultButtonPaddingRight: string;
  78175. /** Gets or sets default key button top padding */
  78176. defaultButtonPaddingTop: string;
  78177. /** Gets or sets default key button bottom padding */
  78178. defaultButtonPaddingBottom: string;
  78179. /** Gets or sets default key button foreground color */
  78180. defaultButtonColor: string;
  78181. /** Gets or sets default key button background color */
  78182. defaultButtonBackground: string;
  78183. /** Gets or sets shift button foreground color */
  78184. shiftButtonColor: string;
  78185. /** Gets or sets shift button thickness*/
  78186. selectedShiftThickness: number;
  78187. /** Gets shift key state */
  78188. shiftState: number;
  78189. protected _getTypeName(): string;
  78190. private _createKey;
  78191. /**
  78192. * Adds a new row of keys
  78193. * @param keys defines the list of keys to add
  78194. * @param propertySets defines the associated property sets
  78195. */
  78196. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  78197. /**
  78198. * Set the shift key to a specific state
  78199. * @param shiftState defines the new shift state
  78200. */
  78201. applyShiftState(shiftState: number): void;
  78202. private _currentlyConnectedInputText;
  78203. private _connectedInputTexts;
  78204. private _onKeyPressObserver;
  78205. /** Gets the input text control currently attached to the keyboard */
  78206. get connectedInputText(): BABYLON.Nullable<InputText>;
  78207. /**
  78208. * Connects the keyboard with an input text control
  78209. *
  78210. * @param input defines the target control
  78211. */
  78212. connect(input: InputText): void;
  78213. /**
  78214. * Disconnects the keyboard from connected InputText controls
  78215. *
  78216. * @param input optionally defines a target control, otherwise all are disconnected
  78217. */
  78218. disconnect(input?: InputText): void;
  78219. private _removeConnectedInputObservables;
  78220. /**
  78221. * Release all resources
  78222. */
  78223. dispose(): void;
  78224. /**
  78225. * Creates a new keyboard using a default layout
  78226. *
  78227. * @param name defines control name
  78228. * @returns a new VirtualKeyboard
  78229. */
  78230. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  78231. }
  78232. }
  78233. declare module BABYLON.GUI {
  78234. /**
  78235. * Class used to create input text control
  78236. */
  78237. export class InputText extends Control implements IFocusableControl {
  78238. name?: string | undefined;
  78239. private _text;
  78240. private _placeholderText;
  78241. private _background;
  78242. private _focusedBackground;
  78243. private _focusedColor;
  78244. private _placeholderColor;
  78245. private _thickness;
  78246. private _margin;
  78247. private _autoStretchWidth;
  78248. private _maxWidth;
  78249. private _isFocused;
  78250. private _blinkTimeout;
  78251. private _blinkIsEven;
  78252. private _cursorOffset;
  78253. private _scrollLeft;
  78254. private _textWidth;
  78255. private _clickedCoordinate;
  78256. private _deadKey;
  78257. private _addKey;
  78258. private _currentKey;
  78259. private _isTextHighlightOn;
  78260. private _textHighlightColor;
  78261. private _highligherOpacity;
  78262. private _highlightedText;
  78263. private _startHighlightIndex;
  78264. private _endHighlightIndex;
  78265. private _cursorIndex;
  78266. private _onFocusSelectAll;
  78267. private _isPointerDown;
  78268. private _onClipboardObserver;
  78269. private _onPointerDblTapObserver;
  78270. /** @hidden */
  78271. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  78272. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  78273. promptMessage: string;
  78274. /** Force disable prompt on mobile device */
  78275. disableMobilePrompt: boolean;
  78276. /** BABYLON.Observable raised when the text changes */
  78277. onTextChangedObservable: BABYLON.Observable<InputText>;
  78278. /** BABYLON.Observable raised just before an entered character is to be added */
  78279. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  78280. /** BABYLON.Observable raised when the control gets the focus */
  78281. onFocusObservable: BABYLON.Observable<InputText>;
  78282. /** BABYLON.Observable raised when the control loses the focus */
  78283. onBlurObservable: BABYLON.Observable<InputText>;
  78284. /**Observable raised when the text is highlighted */
  78285. onTextHighlightObservable: BABYLON.Observable<InputText>;
  78286. /**Observable raised when copy event is triggered */
  78287. onTextCopyObservable: BABYLON.Observable<InputText>;
  78288. /** BABYLON.Observable raised when cut event is triggered */
  78289. onTextCutObservable: BABYLON.Observable<InputText>;
  78290. /** BABYLON.Observable raised when paste event is triggered */
  78291. onTextPasteObservable: BABYLON.Observable<InputText>;
  78292. /** BABYLON.Observable raised when a key event was processed */
  78293. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  78294. /** Gets or sets the maximum width allowed by the control */
  78295. get maxWidth(): string | number;
  78296. /** Gets the maximum width allowed by the control in pixels */
  78297. get maxWidthInPixels(): number;
  78298. set maxWidth(value: string | number);
  78299. /** Gets or sets the text highlighter transparency; default: 0.4 */
  78300. get highligherOpacity(): number;
  78301. set highligherOpacity(value: number);
  78302. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  78303. get onFocusSelectAll(): boolean;
  78304. set onFocusSelectAll(value: boolean);
  78305. /** Gets or sets the text hightlight color */
  78306. get textHighlightColor(): string;
  78307. set textHighlightColor(value: string);
  78308. /** Gets or sets control margin */
  78309. get margin(): string;
  78310. /** Gets control margin in pixels */
  78311. get marginInPixels(): number;
  78312. set margin(value: string);
  78313. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  78314. get autoStretchWidth(): boolean;
  78315. set autoStretchWidth(value: boolean);
  78316. /** Gets or sets border thickness */
  78317. get thickness(): number;
  78318. set thickness(value: number);
  78319. /** Gets or sets the background color when focused */
  78320. get focusedBackground(): string;
  78321. set focusedBackground(value: string);
  78322. /** Gets or sets the background color when focused */
  78323. get focusedColor(): string;
  78324. set focusedColor(value: string);
  78325. /** Gets or sets the background color */
  78326. get background(): string;
  78327. set background(value: string);
  78328. /** Gets or sets the placeholder color */
  78329. get placeholderColor(): string;
  78330. set placeholderColor(value: string);
  78331. /** Gets or sets the text displayed when the control is empty */
  78332. get placeholderText(): string;
  78333. set placeholderText(value: string);
  78334. /** Gets or sets the dead key flag */
  78335. get deadKey(): boolean;
  78336. set deadKey(flag: boolean);
  78337. /** Gets or sets the highlight text */
  78338. get highlightedText(): string;
  78339. set highlightedText(text: string);
  78340. /** Gets or sets if the current key should be added */
  78341. get addKey(): boolean;
  78342. set addKey(flag: boolean);
  78343. /** Gets or sets the value of the current key being entered */
  78344. get currentKey(): string;
  78345. set currentKey(key: string);
  78346. /** Gets or sets the text displayed in the control */
  78347. get text(): string;
  78348. set text(value: string);
  78349. /** Gets or sets control width */
  78350. get width(): string | number;
  78351. set width(value: string | number);
  78352. /**
  78353. * Creates a new InputText
  78354. * @param name defines the control name
  78355. * @param text defines the text of the control
  78356. */
  78357. constructor(name?: string | undefined, text?: string);
  78358. /** @hidden */
  78359. onBlur(): void;
  78360. /** @hidden */
  78361. onFocus(): void;
  78362. protected _getTypeName(): string;
  78363. /**
  78364. * Function called to get the list of controls that should not steal the focus from this control
  78365. * @returns an array of controls
  78366. */
  78367. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78368. /** @hidden */
  78369. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  78370. /** @hidden */
  78371. private _updateValueFromCursorIndex;
  78372. /** @hidden */
  78373. private _processDblClick;
  78374. /** @hidden */
  78375. private _selectAllText;
  78376. /**
  78377. * Handles the keyboard event
  78378. * @param evt Defines the KeyboardEvent
  78379. */
  78380. processKeyboard(evt: KeyboardEvent): void;
  78381. /** @hidden */
  78382. private _onCopyText;
  78383. /** @hidden */
  78384. private _onCutText;
  78385. /** @hidden */
  78386. private _onPasteText;
  78387. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78388. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78389. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78390. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78391. protected _beforeRenderText(text: string): string;
  78392. dispose(): void;
  78393. }
  78394. }
  78395. declare module BABYLON.GUI {
  78396. /**
  78397. * Class used to create a 2D grid container
  78398. */
  78399. export class Grid extends Container {
  78400. name?: string | undefined;
  78401. private _rowDefinitions;
  78402. private _columnDefinitions;
  78403. private _cells;
  78404. private _childControls;
  78405. /**
  78406. * Gets the number of columns
  78407. */
  78408. get columnCount(): number;
  78409. /**
  78410. * Gets the number of rows
  78411. */
  78412. get rowCount(): number;
  78413. /** Gets the list of children */
  78414. get children(): Control[];
  78415. /** Gets the list of cells (e.g. the containers) */
  78416. get cells(): {
  78417. [key: string]: Container;
  78418. };
  78419. /**
  78420. * Gets the definition of a specific row
  78421. * @param index defines the index of the row
  78422. * @returns the row definition
  78423. */
  78424. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78425. /**
  78426. * Gets the definition of a specific column
  78427. * @param index defines the index of the column
  78428. * @returns the column definition
  78429. */
  78430. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78431. /**
  78432. * Adds a new row to the grid
  78433. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78434. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  78435. * @returns the current grid
  78436. */
  78437. addRowDefinition(height: number, isPixel?: boolean): Grid;
  78438. /**
  78439. * Adds a new column to the grid
  78440. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78441. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78442. * @returns the current grid
  78443. */
  78444. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  78445. /**
  78446. * Update a row definition
  78447. * @param index defines the index of the row to update
  78448. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78449. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  78450. * @returns the current grid
  78451. */
  78452. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  78453. /**
  78454. * Update a column definition
  78455. * @param index defines the index of the column to update
  78456. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78457. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78458. * @returns the current grid
  78459. */
  78460. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  78461. /**
  78462. * Gets the list of children stored in a specific cell
  78463. * @param row defines the row to check
  78464. * @param column defines the column to check
  78465. * @returns the list of controls
  78466. */
  78467. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  78468. /**
  78469. * Gets a string representing the child cell info (row x column)
  78470. * @param child defines the control to get info from
  78471. * @returns a string containing the child cell info (row x column)
  78472. */
  78473. getChildCellInfo(child: Control): string;
  78474. private _removeCell;
  78475. private _offsetCell;
  78476. /**
  78477. * Remove a column definition at specified index
  78478. * @param index defines the index of the column to remove
  78479. * @returns the current grid
  78480. */
  78481. removeColumnDefinition(index: number): Grid;
  78482. /**
  78483. * Remove a row definition at specified index
  78484. * @param index defines the index of the row to remove
  78485. * @returns the current grid
  78486. */
  78487. removeRowDefinition(index: number): Grid;
  78488. /**
  78489. * Adds a new control to the current grid
  78490. * @param control defines the control to add
  78491. * @param row defines the row where to add the control (0 by default)
  78492. * @param column defines the column where to add the control (0 by default)
  78493. * @returns the current grid
  78494. */
  78495. addControl(control: Control, row?: number, column?: number): Grid;
  78496. /**
  78497. * Removes a control from the current container
  78498. * @param control defines the control to remove
  78499. * @returns the current container
  78500. */
  78501. removeControl(control: Control): Container;
  78502. /**
  78503. * Creates a new Grid
  78504. * @param name defines control name
  78505. */
  78506. constructor(name?: string | undefined);
  78507. protected _getTypeName(): string;
  78508. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  78509. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78510. _flagDescendantsAsMatrixDirty(): void;
  78511. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78512. /** Releases associated resources */
  78513. dispose(): void;
  78514. }
  78515. }
  78516. declare module BABYLON.GUI {
  78517. /** Class used to create color pickers */
  78518. export class ColorPicker extends Control {
  78519. name?: string | undefined;
  78520. private static _Epsilon;
  78521. private _colorWheelCanvas;
  78522. private _value;
  78523. private _tmpColor;
  78524. private _pointerStartedOnSquare;
  78525. private _pointerStartedOnWheel;
  78526. private _squareLeft;
  78527. private _squareTop;
  78528. private _squareSize;
  78529. private _h;
  78530. private _s;
  78531. private _v;
  78532. private _lastPointerDownID;
  78533. /**
  78534. * BABYLON.Observable raised when the value changes
  78535. */
  78536. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  78537. /** Gets or sets the color of the color picker */
  78538. get value(): BABYLON.Color3;
  78539. set value(value: BABYLON.Color3);
  78540. /**
  78541. * Gets or sets control width
  78542. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78543. */
  78544. get width(): string | number;
  78545. set width(value: string | number);
  78546. /**
  78547. * Gets or sets control height
  78548. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78549. */
  78550. get height(): string | number;
  78551. /** Gets or sets control height */
  78552. set height(value: string | number);
  78553. /** Gets or sets control size */
  78554. get size(): string | number;
  78555. set size(value: string | number);
  78556. /**
  78557. * Creates a new ColorPicker
  78558. * @param name defines the control name
  78559. */
  78560. constructor(name?: string | undefined);
  78561. protected _getTypeName(): string;
  78562. /** @hidden */
  78563. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78564. private _updateSquareProps;
  78565. private _drawGradientSquare;
  78566. private _drawCircle;
  78567. private _createColorWheelCanvas;
  78568. /** @hidden */
  78569. _draw(context: CanvasRenderingContext2D): void;
  78570. private _pointerIsDown;
  78571. private _updateValueFromPointer;
  78572. private _isPointOnSquare;
  78573. private _isPointOnWheel;
  78574. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78575. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78576. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78577. _onCanvasBlur(): void;
  78578. /**
  78579. * This function expands the color picker by creating a color picker dialog with manual
  78580. * color value input and the ability to save colors into an array to be used later in
  78581. * subsequent launches of the dialogue.
  78582. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  78583. * @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.
  78584. * @returns picked color as a hex string and the saved colors array as hex strings.
  78585. */
  78586. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  78587. pickerWidth?: string;
  78588. pickerHeight?: string;
  78589. headerHeight?: string;
  78590. lastColor?: string;
  78591. swatchLimit?: number;
  78592. numSwatchesPerLine?: number;
  78593. savedColors?: Array<string>;
  78594. }): Promise<{
  78595. savedColors?: string[];
  78596. pickedColor: string;
  78597. }>;
  78598. }
  78599. }
  78600. declare module BABYLON.GUI {
  78601. /** Class used to create 2D ellipse containers */
  78602. export class Ellipse extends Container {
  78603. name?: string | undefined;
  78604. private _thickness;
  78605. /** Gets or sets border thickness */
  78606. get thickness(): number;
  78607. set thickness(value: number);
  78608. /**
  78609. * Creates a new Ellipse
  78610. * @param name defines the control name
  78611. */
  78612. constructor(name?: string | undefined);
  78613. protected _getTypeName(): string;
  78614. protected _localDraw(context: CanvasRenderingContext2D): void;
  78615. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78616. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78617. }
  78618. }
  78619. declare module BABYLON.GUI {
  78620. /**
  78621. * Class used to create a password control
  78622. */
  78623. export class InputPassword extends InputText {
  78624. protected _beforeRenderText(text: string): string;
  78625. }
  78626. }
  78627. declare module BABYLON.GUI {
  78628. /** Class used to render 2D lines */
  78629. export class Line extends Control {
  78630. name?: string | undefined;
  78631. private _lineWidth;
  78632. private _x1;
  78633. private _y1;
  78634. private _x2;
  78635. private _y2;
  78636. private _dash;
  78637. private _connectedControl;
  78638. private _connectedControlDirtyObserver;
  78639. /** Gets or sets the dash pattern */
  78640. get dash(): Array<number>;
  78641. set dash(value: Array<number>);
  78642. /** Gets or sets the control connected with the line end */
  78643. get connectedControl(): Control;
  78644. set connectedControl(value: Control);
  78645. /** Gets or sets start coordinates on X axis */
  78646. get x1(): string | number;
  78647. set x1(value: string | number);
  78648. /** Gets or sets start coordinates on Y axis */
  78649. get y1(): string | number;
  78650. set y1(value: string | number);
  78651. /** Gets or sets end coordinates on X axis */
  78652. get x2(): string | number;
  78653. set x2(value: string | number);
  78654. /** Gets or sets end coordinates on Y axis */
  78655. get y2(): string | number;
  78656. set y2(value: string | number);
  78657. /** Gets or sets line width */
  78658. get lineWidth(): number;
  78659. set lineWidth(value: number);
  78660. /** Gets or sets horizontal alignment */
  78661. set horizontalAlignment(value: number);
  78662. /** Gets or sets vertical alignment */
  78663. set verticalAlignment(value: number);
  78664. private get _effectiveX2();
  78665. private get _effectiveY2();
  78666. /**
  78667. * Creates a new Line
  78668. * @param name defines the control name
  78669. */
  78670. constructor(name?: string | undefined);
  78671. protected _getTypeName(): string;
  78672. _draw(context: CanvasRenderingContext2D): void;
  78673. _measure(): void;
  78674. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78675. /**
  78676. * Move one end of the line given 3D cartesian coordinates.
  78677. * @param position Targeted world position
  78678. * @param scene BABYLON.Scene
  78679. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78680. */
  78681. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  78682. /**
  78683. * Move one end of the line to a position in screen absolute space.
  78684. * @param projectedPosition Position in screen absolute space (X, Y)
  78685. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78686. */
  78687. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  78688. }
  78689. }
  78690. declare module BABYLON.GUI {
  78691. /**
  78692. * Class used to store a point for a MultiLine object.
  78693. * The point can be pure 2D coordinates, a mesh or a control
  78694. */
  78695. export class MultiLinePoint {
  78696. private _multiLine;
  78697. private _x;
  78698. private _y;
  78699. private _control;
  78700. private _mesh;
  78701. private _controlObserver;
  78702. private _meshObserver;
  78703. /** @hidden */
  78704. _point: BABYLON.Vector2;
  78705. /**
  78706. * Creates a new MultiLinePoint
  78707. * @param multiLine defines the source MultiLine object
  78708. */
  78709. constructor(multiLine: MultiLine);
  78710. /** Gets or sets x coordinate */
  78711. get x(): string | number;
  78712. set x(value: string | number);
  78713. /** Gets or sets y coordinate */
  78714. get y(): string | number;
  78715. set y(value: string | number);
  78716. /** Gets or sets the control associated with this point */
  78717. get control(): BABYLON.Nullable<Control>;
  78718. set control(value: BABYLON.Nullable<Control>);
  78719. /** Gets or sets the mesh associated with this point */
  78720. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78721. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  78722. /** Resets links */
  78723. resetLinks(): void;
  78724. /**
  78725. * Gets a translation vector
  78726. * @returns the translation vector
  78727. */
  78728. translate(): BABYLON.Vector2;
  78729. private _translatePoint;
  78730. /** Release associated resources */
  78731. dispose(): void;
  78732. }
  78733. }
  78734. declare module BABYLON.GUI {
  78735. /**
  78736. * Class used to create multi line control
  78737. */
  78738. export class MultiLine extends Control {
  78739. name?: string | undefined;
  78740. private _lineWidth;
  78741. private _dash;
  78742. private _points;
  78743. private _minX;
  78744. private _minY;
  78745. private _maxX;
  78746. private _maxY;
  78747. /**
  78748. * Creates a new MultiLine
  78749. * @param name defines the control name
  78750. */
  78751. constructor(name?: string | undefined);
  78752. /** Gets or sets dash pattern */
  78753. get dash(): Array<number>;
  78754. set dash(value: Array<number>);
  78755. /**
  78756. * Gets point stored at specified index
  78757. * @param index defines the index to look for
  78758. * @returns the requested point if found
  78759. */
  78760. getAt(index: number): MultiLinePoint;
  78761. /** Function called when a point is updated */
  78762. onPointUpdate: () => void;
  78763. /**
  78764. * Adds new points to the point collection
  78765. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  78766. * @returns the list of created MultiLinePoint
  78767. */
  78768. add(...items: (AbstractMesh | Control | {
  78769. x: string | number;
  78770. y: string | number;
  78771. })[]): MultiLinePoint[];
  78772. /**
  78773. * Adds a new point to the point collection
  78774. * @param item defines the item (mesh, control or 2d coordiantes) to add
  78775. * @returns the created MultiLinePoint
  78776. */
  78777. push(item?: (AbstractMesh | Control | {
  78778. x: string | number;
  78779. y: string | number;
  78780. })): MultiLinePoint;
  78781. /**
  78782. * Remove a specific value or point from the active point collection
  78783. * @param value defines the value or point to remove
  78784. */
  78785. remove(value: number | MultiLinePoint): void;
  78786. /**
  78787. * Resets this object to initial state (no point)
  78788. */
  78789. reset(): void;
  78790. /**
  78791. * Resets all links
  78792. */
  78793. resetLinks(): void;
  78794. /** Gets or sets line width */
  78795. get lineWidth(): number;
  78796. set lineWidth(value: number);
  78797. set horizontalAlignment(value: number);
  78798. set verticalAlignment(value: number);
  78799. protected _getTypeName(): string;
  78800. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78801. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78802. _measure(): void;
  78803. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78804. dispose(): void;
  78805. }
  78806. }
  78807. declare module BABYLON.GUI {
  78808. /**
  78809. * Class used to create radio button controls
  78810. */
  78811. export class RadioButton extends Control {
  78812. name?: string | undefined;
  78813. private _isChecked;
  78814. private _background;
  78815. private _checkSizeRatio;
  78816. private _thickness;
  78817. /** Gets or sets border thickness */
  78818. get thickness(): number;
  78819. set thickness(value: number);
  78820. /** Gets or sets group name */
  78821. group: string;
  78822. /** BABYLON.Observable raised when isChecked is changed */
  78823. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78824. /** Gets or sets a value indicating the ratio between overall size and check size */
  78825. get checkSizeRatio(): number;
  78826. set checkSizeRatio(value: number);
  78827. /** Gets or sets background color */
  78828. get background(): string;
  78829. set background(value: string);
  78830. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78831. get isChecked(): boolean;
  78832. set isChecked(value: boolean);
  78833. /**
  78834. * Creates a new RadioButton
  78835. * @param name defines the control name
  78836. */
  78837. constructor(name?: string | undefined);
  78838. protected _getTypeName(): string;
  78839. _draw(context: CanvasRenderingContext2D): void;
  78840. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78841. /**
  78842. * Utility function to easily create a radio button with a header
  78843. * @param title defines the label to use for the header
  78844. * @param group defines the group to use for the radio button
  78845. * @param isChecked defines the initial state of the radio button
  78846. * @param onValueChanged defines the callback to call when value changes
  78847. * @returns a StackPanel containing the radio button and a textBlock
  78848. */
  78849. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  78850. }
  78851. }
  78852. declare module BABYLON.GUI {
  78853. /**
  78854. * Class used to create slider controls
  78855. */
  78856. export class BaseSlider extends Control {
  78857. name?: string | undefined;
  78858. protected _thumbWidth: ValueAndUnit;
  78859. private _minimum;
  78860. private _maximum;
  78861. private _value;
  78862. private _isVertical;
  78863. protected _barOffset: ValueAndUnit;
  78864. private _isThumbClamped;
  78865. protected _displayThumb: boolean;
  78866. private _step;
  78867. private _lastPointerDownID;
  78868. protected _effectiveBarOffset: number;
  78869. protected _renderLeft: number;
  78870. protected _renderTop: number;
  78871. protected _renderWidth: number;
  78872. protected _renderHeight: number;
  78873. protected _backgroundBoxLength: number;
  78874. protected _backgroundBoxThickness: number;
  78875. protected _effectiveThumbThickness: number;
  78876. /** BABYLON.Observable raised when the sldier value changes */
  78877. onValueChangedObservable: BABYLON.Observable<number>;
  78878. /** Gets or sets a boolean indicating if the thumb must be rendered */
  78879. get displayThumb(): boolean;
  78880. set displayThumb(value: boolean);
  78881. /** Gets or sets a step to apply to values (0 by default) */
  78882. get step(): number;
  78883. set step(value: number);
  78884. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  78885. get barOffset(): string | number;
  78886. /** Gets main bar offset in pixels*/
  78887. get barOffsetInPixels(): number;
  78888. set barOffset(value: string | number);
  78889. /** Gets or sets thumb width */
  78890. get thumbWidth(): string | number;
  78891. /** Gets thumb width in pixels */
  78892. get thumbWidthInPixels(): number;
  78893. set thumbWidth(value: string | number);
  78894. /** Gets or sets minimum value */
  78895. get minimum(): number;
  78896. set minimum(value: number);
  78897. /** Gets or sets maximum value */
  78898. get maximum(): number;
  78899. set maximum(value: number);
  78900. /** Gets or sets current value */
  78901. get value(): number;
  78902. set value(value: number);
  78903. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  78904. get isVertical(): boolean;
  78905. set isVertical(value: boolean);
  78906. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  78907. get isThumbClamped(): boolean;
  78908. set isThumbClamped(value: boolean);
  78909. /**
  78910. * Creates a new BaseSlider
  78911. * @param name defines the control name
  78912. */
  78913. constructor(name?: string | undefined);
  78914. protected _getTypeName(): string;
  78915. protected _getThumbPosition(): number;
  78916. protected _getThumbThickness(type: string): number;
  78917. protected _prepareRenderingData(type: string): void;
  78918. private _pointerIsDown;
  78919. /** @hidden */
  78920. protected _updateValueFromPointer(x: number, y: number): void;
  78921. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78922. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78923. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78924. _onCanvasBlur(): void;
  78925. }
  78926. }
  78927. declare module BABYLON.GUI {
  78928. /**
  78929. * Class used to create slider controls
  78930. */
  78931. export class Slider extends BaseSlider {
  78932. name?: string | undefined;
  78933. private _background;
  78934. private _borderColor;
  78935. private _thumbColor;
  78936. private _isThumbCircle;
  78937. protected _displayValueBar: boolean;
  78938. /** Gets or sets a boolean indicating if the value bar must be rendered */
  78939. get displayValueBar(): boolean;
  78940. set displayValueBar(value: boolean);
  78941. /** Gets or sets border color */
  78942. get borderColor(): string;
  78943. set borderColor(value: string);
  78944. /** Gets or sets background color */
  78945. get background(): string;
  78946. set background(value: string);
  78947. /** Gets or sets thumb's color */
  78948. get thumbColor(): string;
  78949. set thumbColor(value: string);
  78950. /** Gets or sets a boolean indicating if the thumb should be round or square */
  78951. get isThumbCircle(): boolean;
  78952. set isThumbCircle(value: boolean);
  78953. /**
  78954. * Creates a new Slider
  78955. * @param name defines the control name
  78956. */
  78957. constructor(name?: string | undefined);
  78958. protected _getTypeName(): string;
  78959. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78960. }
  78961. }
  78962. declare module BABYLON.GUI {
  78963. /** Class used to create a RadioGroup
  78964. * which contains groups of radio buttons
  78965. */
  78966. export class SelectorGroup {
  78967. /** name of SelectorGroup */
  78968. name: string;
  78969. private _groupPanel;
  78970. private _selectors;
  78971. private _groupHeader;
  78972. /**
  78973. * Creates a new SelectorGroup
  78974. * @param name of group, used as a group heading
  78975. */
  78976. constructor(
  78977. /** name of SelectorGroup */
  78978. name: string);
  78979. /** Gets the groupPanel of the SelectorGroup */
  78980. get groupPanel(): StackPanel;
  78981. /** Gets the selectors array */
  78982. get selectors(): StackPanel[];
  78983. /** Gets and sets the group header */
  78984. get header(): string;
  78985. set header(label: string);
  78986. /** @hidden */
  78987. private _addGroupHeader;
  78988. /** @hidden*/
  78989. _getSelector(selectorNb: number): StackPanel | undefined;
  78990. /** Removes the selector at the given position
  78991. * @param selectorNb the position of the selector within the group
  78992. */
  78993. removeSelector(selectorNb: number): void;
  78994. }
  78995. /** Class used to create a CheckboxGroup
  78996. * which contains groups of checkbox buttons
  78997. */
  78998. export class CheckboxGroup extends SelectorGroup {
  78999. /** Adds a checkbox as a control
  79000. * @param text is the label for the selector
  79001. * @param func is the function called when the Selector is checked
  79002. * @param checked is true when Selector is checked
  79003. */
  79004. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  79005. /** @hidden */
  79006. _setSelectorLabel(selectorNb: number, label: string): void;
  79007. /** @hidden */
  79008. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79009. /** @hidden */
  79010. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79011. /** @hidden */
  79012. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79013. }
  79014. /** Class used to create a RadioGroup
  79015. * which contains groups of radio buttons
  79016. */
  79017. export class RadioGroup extends SelectorGroup {
  79018. private _selectNb;
  79019. /** Adds a radio button as a control
  79020. * @param label is the label for the selector
  79021. * @param func is the function called when the Selector is checked
  79022. * @param checked is true when Selector is checked
  79023. */
  79024. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  79025. /** @hidden */
  79026. _setSelectorLabel(selectorNb: number, label: string): void;
  79027. /** @hidden */
  79028. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79029. /** @hidden */
  79030. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79031. /** @hidden */
  79032. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79033. }
  79034. /** Class used to create a SliderGroup
  79035. * which contains groups of slider buttons
  79036. */
  79037. export class SliderGroup extends SelectorGroup {
  79038. /**
  79039. * Adds a slider to the SelectorGroup
  79040. * @param label is the label for the SliderBar
  79041. * @param func is the function called when the Slider moves
  79042. * @param unit is a string describing the units used, eg degrees or metres
  79043. * @param min is the minimum value for the Slider
  79044. * @param max is the maximum value for the Slider
  79045. * @param value is the start value for the Slider between min and max
  79046. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  79047. */
  79048. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  79049. /** @hidden */
  79050. _setSelectorLabel(selectorNb: number, label: string): void;
  79051. /** @hidden */
  79052. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79053. /** @hidden */
  79054. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79055. /** @hidden */
  79056. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79057. }
  79058. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  79059. * @see https://doc.babylonjs.com/how_to/selector
  79060. */
  79061. export class SelectionPanel extends Rectangle {
  79062. /** name of SelectionPanel */
  79063. name: string;
  79064. /** an array of SelectionGroups */
  79065. groups: SelectorGroup[];
  79066. private _panel;
  79067. private _buttonColor;
  79068. private _buttonBackground;
  79069. private _headerColor;
  79070. private _barColor;
  79071. private _barHeight;
  79072. private _spacerHeight;
  79073. private _labelColor;
  79074. private _groups;
  79075. private _bars;
  79076. /**
  79077. * Creates a new SelectionPanel
  79078. * @param name of SelectionPanel
  79079. * @param groups is an array of SelectionGroups
  79080. */
  79081. constructor(
  79082. /** name of SelectionPanel */
  79083. name: string,
  79084. /** an array of SelectionGroups */
  79085. groups?: SelectorGroup[]);
  79086. protected _getTypeName(): string;
  79087. /** Gets or sets the headerColor */
  79088. get headerColor(): string;
  79089. set headerColor(color: string);
  79090. private _setHeaderColor;
  79091. /** Gets or sets the button color */
  79092. get buttonColor(): string;
  79093. set buttonColor(color: string);
  79094. private _setbuttonColor;
  79095. /** Gets or sets the label color */
  79096. get labelColor(): string;
  79097. set labelColor(color: string);
  79098. private _setLabelColor;
  79099. /** Gets or sets the button background */
  79100. get buttonBackground(): string;
  79101. set buttonBackground(color: string);
  79102. private _setButtonBackground;
  79103. /** Gets or sets the color of separator bar */
  79104. get barColor(): string;
  79105. set barColor(color: string);
  79106. private _setBarColor;
  79107. /** Gets or sets the height of separator bar */
  79108. get barHeight(): string;
  79109. set barHeight(value: string);
  79110. private _setBarHeight;
  79111. /** Gets or sets the height of spacers*/
  79112. get spacerHeight(): string;
  79113. set spacerHeight(value: string);
  79114. private _setSpacerHeight;
  79115. /** Adds a bar between groups */
  79116. private _addSpacer;
  79117. /** Add a group to the selection panel
  79118. * @param group is the selector group to add
  79119. */
  79120. addGroup(group: SelectorGroup): void;
  79121. /** Remove the group from the given position
  79122. * @param groupNb is the position of the group in the list
  79123. */
  79124. removeGroup(groupNb: number): void;
  79125. /** Change a group header label
  79126. * @param label is the new group header label
  79127. * @param groupNb is the number of the group to relabel
  79128. * */
  79129. setHeaderName(label: string, groupNb: number): void;
  79130. /** Change selector label to the one given
  79131. * @param label is the new selector label
  79132. * @param groupNb is the number of the groupcontaining the selector
  79133. * @param selectorNb is the number of the selector within a group to relabel
  79134. * */
  79135. relabel(label: string, groupNb: number, selectorNb: number): void;
  79136. /** For a given group position remove the selector at the given position
  79137. * @param groupNb is the number of the group to remove the selector from
  79138. * @param selectorNb is the number of the selector within the group
  79139. */
  79140. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  79141. /** For a given group position of correct type add a checkbox button
  79142. * @param groupNb is the number of the group to remove the selector from
  79143. * @param label is the label for the selector
  79144. * @param func is the function called when the Selector is checked
  79145. * @param checked is true when Selector is checked
  79146. */
  79147. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79148. /** For a given group position of correct type add a radio button
  79149. * @param groupNb is the number of the group to remove the selector from
  79150. * @param label is the label for the selector
  79151. * @param func is the function called when the Selector is checked
  79152. * @param checked is true when Selector is checked
  79153. */
  79154. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79155. /**
  79156. * For a given slider group add a slider
  79157. * @param groupNb is the number of the group to add the slider to
  79158. * @param label is the label for the Slider
  79159. * @param func is the function called when the Slider moves
  79160. * @param unit is a string describing the units used, eg degrees or metres
  79161. * @param min is the minimum value for the Slider
  79162. * @param max is the maximum value for the Slider
  79163. * @param value is the start value for the Slider between min and max
  79164. * @param onVal is the function used to format the value displayed, eg radians to degrees
  79165. */
  79166. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  79167. }
  79168. }
  79169. declare module BABYLON.GUI {
  79170. /**
  79171. * Class used to hold a the container for ScrollViewer
  79172. * @hidden
  79173. */
  79174. export class _ScrollViewerWindow extends Container {
  79175. parentClientWidth: number;
  79176. parentClientHeight: number;
  79177. private _freezeControls;
  79178. private _parentMeasure;
  79179. private _oldLeft;
  79180. private _oldTop;
  79181. get freezeControls(): boolean;
  79182. set freezeControls(value: boolean);
  79183. private _bucketWidth;
  79184. private _bucketHeight;
  79185. private _buckets;
  79186. private _bucketLen;
  79187. get bucketWidth(): number;
  79188. get bucketHeight(): number;
  79189. setBucketSizes(width: number, height: number): void;
  79190. private _useBuckets;
  79191. private _makeBuckets;
  79192. private _dispatchInBuckets;
  79193. private _updateMeasures;
  79194. private _updateChildrenMeasures;
  79195. private _restoreMeasures;
  79196. /**
  79197. * Creates a new ScrollViewerWindow
  79198. * @param name of ScrollViewerWindow
  79199. */
  79200. constructor(name?: string);
  79201. protected _getTypeName(): string;
  79202. /** @hidden */
  79203. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79204. /** @hidden */
  79205. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79206. private _scrollChildren;
  79207. private _scrollChildrenWithBuckets;
  79208. /** @hidden */
  79209. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79210. protected _postMeasure(): void;
  79211. }
  79212. }
  79213. declare module BABYLON.GUI {
  79214. /**
  79215. * Class used to create slider controls
  79216. */
  79217. export class ScrollBar extends BaseSlider {
  79218. name?: string | undefined;
  79219. private _background;
  79220. private _borderColor;
  79221. private _tempMeasure;
  79222. /** Gets or sets border color */
  79223. get borderColor(): string;
  79224. set borderColor(value: string);
  79225. /** Gets or sets background color */
  79226. get background(): string;
  79227. set background(value: string);
  79228. /**
  79229. * Creates a new Slider
  79230. * @param name defines the control name
  79231. */
  79232. constructor(name?: string | undefined);
  79233. protected _getTypeName(): string;
  79234. protected _getThumbThickness(): number;
  79235. _draw(context: CanvasRenderingContext2D): void;
  79236. private _first;
  79237. private _originX;
  79238. private _originY;
  79239. /** @hidden */
  79240. protected _updateValueFromPointer(x: number, y: number): void;
  79241. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79242. }
  79243. }
  79244. declare module BABYLON.GUI {
  79245. /**
  79246. * Class used to create slider controls
  79247. */
  79248. export class ImageScrollBar extends BaseSlider {
  79249. name?: string | undefined;
  79250. private _backgroundBaseImage;
  79251. private _backgroundImage;
  79252. private _thumbImage;
  79253. private _thumbBaseImage;
  79254. private _thumbLength;
  79255. private _thumbHeight;
  79256. private _barImageHeight;
  79257. private _tempMeasure;
  79258. /** Number of 90° rotation to apply on the images when in vertical mode */
  79259. num90RotationInVerticalMode: number;
  79260. /**
  79261. * Gets or sets the image used to render the background for horizontal bar
  79262. */
  79263. get backgroundImage(): Image;
  79264. set backgroundImage(value: Image);
  79265. /**
  79266. * Gets or sets the image used to render the thumb
  79267. */
  79268. get thumbImage(): Image;
  79269. set thumbImage(value: Image);
  79270. /**
  79271. * Gets or sets the length of the thumb
  79272. */
  79273. get thumbLength(): number;
  79274. set thumbLength(value: number);
  79275. /**
  79276. * Gets or sets the height of the thumb
  79277. */
  79278. get thumbHeight(): number;
  79279. set thumbHeight(value: number);
  79280. /**
  79281. * Gets or sets the height of the bar image
  79282. */
  79283. get barImageHeight(): number;
  79284. set barImageHeight(value: number);
  79285. /**
  79286. * Creates a new ImageScrollBar
  79287. * @param name defines the control name
  79288. */
  79289. constructor(name?: string | undefined);
  79290. protected _getTypeName(): string;
  79291. protected _getThumbThickness(): number;
  79292. _draw(context: CanvasRenderingContext2D): void;
  79293. private _first;
  79294. private _originX;
  79295. private _originY;
  79296. /** @hidden */
  79297. protected _updateValueFromPointer(x: number, y: number): void;
  79298. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79299. }
  79300. }
  79301. declare module BABYLON.GUI {
  79302. /**
  79303. * Class used to hold a viewer window and sliders in a grid
  79304. */
  79305. export class ScrollViewer extends Rectangle {
  79306. private _grid;
  79307. private _horizontalBarSpace;
  79308. private _verticalBarSpace;
  79309. private _dragSpace;
  79310. private _horizontalBar;
  79311. private _verticalBar;
  79312. private _barColor;
  79313. private _barBackground;
  79314. private _barImage;
  79315. private _horizontalBarImage;
  79316. private _verticalBarImage;
  79317. private _barBackgroundImage;
  79318. private _horizontalBarBackgroundImage;
  79319. private _verticalBarBackgroundImage;
  79320. private _barSize;
  79321. private _window;
  79322. private _pointerIsOver;
  79323. private _wheelPrecision;
  79324. private _onWheelObserver;
  79325. private _clientWidth;
  79326. private _clientHeight;
  79327. private _useImageBar;
  79328. private _thumbLength;
  79329. private _thumbHeight;
  79330. private _barImageHeight;
  79331. private _horizontalBarImageHeight;
  79332. private _verticalBarImageHeight;
  79333. private _oldWindowContentsWidth;
  79334. private _oldWindowContentsHeight;
  79335. /**
  79336. * Gets the horizontal scrollbar
  79337. */
  79338. get horizontalBar(): ScrollBar | ImageScrollBar;
  79339. /**
  79340. * Gets the vertical scrollbar
  79341. */
  79342. get verticalBar(): ScrollBar | ImageScrollBar;
  79343. /**
  79344. * Adds a new control to the current container
  79345. * @param control defines the control to add
  79346. * @returns the current container
  79347. */
  79348. addControl(control: BABYLON.Nullable<Control>): Container;
  79349. /**
  79350. * Removes a control from the current container
  79351. * @param control defines the control to remove
  79352. * @returns the current container
  79353. */
  79354. removeControl(control: Control): Container;
  79355. /** Gets the list of children */
  79356. get children(): Control[];
  79357. _flagDescendantsAsMatrixDirty(): void;
  79358. /**
  79359. * Freezes or unfreezes the controls in the window.
  79360. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  79361. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  79362. */
  79363. get freezeControls(): boolean;
  79364. set freezeControls(value: boolean);
  79365. /** Gets the bucket width */
  79366. get bucketWidth(): number;
  79367. /** Gets the bucket height */
  79368. get bucketHeight(): number;
  79369. /**
  79370. * Sets the bucket sizes.
  79371. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  79372. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  79373. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  79374. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  79375. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  79376. * used), that's why it is not enabled by default.
  79377. * @param width width of the bucket
  79378. * @param height height of the bucket
  79379. */
  79380. setBucketSizes(width: number, height: number): void;
  79381. private _forceHorizontalBar;
  79382. private _forceVerticalBar;
  79383. /**
  79384. * Forces the horizontal scroll bar to be displayed
  79385. */
  79386. get forceHorizontalBar(): boolean;
  79387. set forceHorizontalBar(value: boolean);
  79388. /**
  79389. * Forces the vertical scroll bar to be displayed
  79390. */
  79391. get forceVerticalBar(): boolean;
  79392. set forceVerticalBar(value: boolean);
  79393. /**
  79394. * Creates a new ScrollViewer
  79395. * @param name of ScrollViewer
  79396. */
  79397. constructor(name?: string, isImageBased?: boolean);
  79398. /** Reset the scroll viewer window to initial size */
  79399. resetWindow(): void;
  79400. protected _getTypeName(): string;
  79401. private _buildClientSizes;
  79402. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79403. protected _postMeasure(): void;
  79404. /**
  79405. * Gets or sets the mouse wheel precision
  79406. * from 0 to 1 with a default value of 0.05
  79407. * */
  79408. get wheelPrecision(): number;
  79409. set wheelPrecision(value: number);
  79410. /** Gets or sets the scroll bar container background color */
  79411. get scrollBackground(): string;
  79412. set scrollBackground(color: string);
  79413. /** Gets or sets the bar color */
  79414. get barColor(): string;
  79415. set barColor(color: string);
  79416. /** Gets or sets the bar image */
  79417. get thumbImage(): Image;
  79418. set thumbImage(value: Image);
  79419. /** Gets or sets the horizontal bar image */
  79420. get horizontalThumbImage(): Image;
  79421. set horizontalThumbImage(value: Image);
  79422. /** Gets or sets the vertical bar image */
  79423. get verticalThumbImage(): Image;
  79424. set verticalThumbImage(value: Image);
  79425. /** Gets or sets the size of the bar */
  79426. get barSize(): number;
  79427. set barSize(value: number);
  79428. /** Gets or sets the length of the thumb */
  79429. get thumbLength(): number;
  79430. set thumbLength(value: number);
  79431. /** Gets or sets the height of the thumb */
  79432. get thumbHeight(): number;
  79433. set thumbHeight(value: number);
  79434. /** Gets or sets the height of the bar image */
  79435. get barImageHeight(): number;
  79436. set barImageHeight(value: number);
  79437. /** Gets or sets the height of the horizontal bar image */
  79438. get horizontalBarImageHeight(): number;
  79439. set horizontalBarImageHeight(value: number);
  79440. /** Gets or sets the height of the vertical bar image */
  79441. get verticalBarImageHeight(): number;
  79442. set verticalBarImageHeight(value: number);
  79443. /** Gets or sets the bar background */
  79444. get barBackground(): string;
  79445. set barBackground(color: string);
  79446. /** Gets or sets the bar background image */
  79447. get barImage(): Image;
  79448. set barImage(value: Image);
  79449. /** Gets or sets the horizontal bar background image */
  79450. get horizontalBarImage(): Image;
  79451. set horizontalBarImage(value: Image);
  79452. /** Gets or sets the vertical bar background image */
  79453. get verticalBarImage(): Image;
  79454. set verticalBarImage(value: Image);
  79455. private _setWindowPosition;
  79456. /** @hidden */
  79457. private _updateScroller;
  79458. _link(host: AdvancedDynamicTexture): void;
  79459. /** @hidden */
  79460. private _addBar;
  79461. /** @hidden */
  79462. private _attachWheel;
  79463. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79464. /** Releases associated resources */
  79465. dispose(): void;
  79466. }
  79467. }
  79468. declare module BABYLON.GUI {
  79469. /** Class used to render a grid */
  79470. export class DisplayGrid extends Control {
  79471. name?: string | undefined;
  79472. private _cellWidth;
  79473. private _cellHeight;
  79474. private _minorLineTickness;
  79475. private _minorLineColor;
  79476. private _majorLineTickness;
  79477. private _majorLineColor;
  79478. private _majorLineFrequency;
  79479. private _background;
  79480. private _displayMajorLines;
  79481. private _displayMinorLines;
  79482. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  79483. get displayMinorLines(): boolean;
  79484. set displayMinorLines(value: boolean);
  79485. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  79486. get displayMajorLines(): boolean;
  79487. set displayMajorLines(value: boolean);
  79488. /** Gets or sets background color (Black by default) */
  79489. get background(): string;
  79490. set background(value: string);
  79491. /** Gets or sets the width of each cell (20 by default) */
  79492. get cellWidth(): number;
  79493. set cellWidth(value: number);
  79494. /** Gets or sets the height of each cell (20 by default) */
  79495. get cellHeight(): number;
  79496. set cellHeight(value: number);
  79497. /** Gets or sets the tickness of minor lines (1 by default) */
  79498. get minorLineTickness(): number;
  79499. set minorLineTickness(value: number);
  79500. /** Gets or sets the color of minor lines (DarkGray by default) */
  79501. get minorLineColor(): string;
  79502. set minorLineColor(value: string);
  79503. /** Gets or sets the tickness of major lines (2 by default) */
  79504. get majorLineTickness(): number;
  79505. set majorLineTickness(value: number);
  79506. /** Gets or sets the color of major lines (White by default) */
  79507. get majorLineColor(): string;
  79508. set majorLineColor(value: string);
  79509. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  79510. get majorLineFrequency(): number;
  79511. set majorLineFrequency(value: number);
  79512. /**
  79513. * Creates a new GridDisplayRectangle
  79514. * @param name defines the control name
  79515. */
  79516. constructor(name?: string | undefined);
  79517. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79518. protected _getTypeName(): string;
  79519. }
  79520. }
  79521. declare module BABYLON.GUI {
  79522. /**
  79523. * Class used to create slider controls based on images
  79524. */
  79525. export class ImageBasedSlider extends BaseSlider {
  79526. name?: string | undefined;
  79527. private _backgroundImage;
  79528. private _thumbImage;
  79529. private _valueBarImage;
  79530. private _tempMeasure;
  79531. get displayThumb(): boolean;
  79532. set displayThumb(value: boolean);
  79533. /**
  79534. * Gets or sets the image used to render the background
  79535. */
  79536. get backgroundImage(): Image;
  79537. set backgroundImage(value: Image);
  79538. /**
  79539. * Gets or sets the image used to render the value bar
  79540. */
  79541. get valueBarImage(): Image;
  79542. set valueBarImage(value: Image);
  79543. /**
  79544. * Gets or sets the image used to render the thumb
  79545. */
  79546. get thumbImage(): Image;
  79547. set thumbImage(value: Image);
  79548. /**
  79549. * Creates a new ImageBasedSlider
  79550. * @param name defines the control name
  79551. */
  79552. constructor(name?: string | undefined);
  79553. protected _getTypeName(): string;
  79554. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79555. }
  79556. }
  79557. declare module BABYLON.GUI {
  79558. /**
  79559. * Forcing an export so that this code will execute
  79560. * @hidden
  79561. */
  79562. const name = "Statics";
  79563. }
  79564. declare module BABYLON.GUI {
  79565. /**
  79566. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  79567. */
  79568. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  79569. /**
  79570. * Define the instrumented AdvancedDynamicTexture.
  79571. */
  79572. texture: AdvancedDynamicTexture;
  79573. private _captureRenderTime;
  79574. private _renderTime;
  79575. private _captureLayoutTime;
  79576. private _layoutTime;
  79577. private _onBeginRenderObserver;
  79578. private _onEndRenderObserver;
  79579. private _onBeginLayoutObserver;
  79580. private _onEndLayoutObserver;
  79581. /**
  79582. * Gets the perf counter used to capture render time
  79583. */
  79584. get renderTimeCounter(): BABYLON.PerfCounter;
  79585. /**
  79586. * Gets the perf counter used to capture layout time
  79587. */
  79588. get layoutTimeCounter(): BABYLON.PerfCounter;
  79589. /**
  79590. * Enable or disable the render time capture
  79591. */
  79592. get captureRenderTime(): boolean;
  79593. set captureRenderTime(value: boolean);
  79594. /**
  79595. * Enable or disable the layout time capture
  79596. */
  79597. get captureLayoutTime(): boolean;
  79598. set captureLayoutTime(value: boolean);
  79599. /**
  79600. * Instantiates a new advanced dynamic texture instrumentation.
  79601. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  79602. * @param texture Defines the AdvancedDynamicTexture to instrument
  79603. */
  79604. constructor(
  79605. /**
  79606. * Define the instrumented AdvancedDynamicTexture.
  79607. */
  79608. texture: AdvancedDynamicTexture);
  79609. /**
  79610. * Dispose and release associated resources.
  79611. */
  79612. dispose(): void;
  79613. }
  79614. }
  79615. declare module BABYLON.GUI {
  79616. /**
  79617. * Class used to load GUI via XML.
  79618. */
  79619. export class XmlLoader {
  79620. private _nodes;
  79621. private _nodeTypes;
  79622. private _isLoaded;
  79623. private _objectAttributes;
  79624. private _parentClass;
  79625. /**
  79626. * Create a new xml loader
  79627. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  79628. */
  79629. constructor(parentClass?: null);
  79630. private _getChainElement;
  79631. private _getClassAttribute;
  79632. private _createGuiElement;
  79633. private _parseGrid;
  79634. private _parseElement;
  79635. private _prepareSourceElement;
  79636. private _parseElementsFromSource;
  79637. private _parseXml;
  79638. /**
  79639. * Gets if the loading has finished.
  79640. * @returns whether the loading has finished or not
  79641. */
  79642. isLoaded(): boolean;
  79643. /**
  79644. * Gets a loaded node / control by id.
  79645. * @param id the Controls id set in the xml
  79646. * @returns element of type Control
  79647. */
  79648. getNodeById(id: string): any;
  79649. /**
  79650. * Gets all loaded nodes / controls
  79651. * @returns Array of controls
  79652. */
  79653. getNodes(): any;
  79654. /**
  79655. * Initiates the xml layout loading
  79656. * @param xmlFile defines the xml layout to load
  79657. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  79658. * @param callback defines the callback called on layout load.
  79659. */
  79660. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  79661. }
  79662. }
  79663. declare module BABYLON.GUI {
  79664. /**
  79665. * Class used to create containers for controls
  79666. */
  79667. export class Container3D extends Control3D {
  79668. private _blockLayout;
  79669. /**
  79670. * Gets the list of child controls
  79671. */
  79672. protected _children: Control3D[];
  79673. /**
  79674. * Gets the list of child controls
  79675. */
  79676. get children(): Array<Control3D>;
  79677. /**
  79678. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  79679. * This is helpful to optimize layout operation when adding multiple children in a row
  79680. */
  79681. get blockLayout(): boolean;
  79682. set blockLayout(value: boolean);
  79683. /**
  79684. * Creates a new container
  79685. * @param name defines the container name
  79686. */
  79687. constructor(name?: string);
  79688. /**
  79689. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  79690. * @returns the current container
  79691. */
  79692. updateLayout(): Container3D;
  79693. /**
  79694. * Gets a boolean indicating if the given control is in the children of this control
  79695. * @param control defines the control to check
  79696. * @returns true if the control is in the child list
  79697. */
  79698. containsControl(control: Control3D): boolean;
  79699. /**
  79700. * Adds a control to the children of this control
  79701. * @param control defines the control to add
  79702. * @returns the current container
  79703. */
  79704. addControl(control: Control3D): Container3D;
  79705. /**
  79706. * This function will be called everytime a new control is added
  79707. */
  79708. protected _arrangeChildren(): void;
  79709. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79710. /**
  79711. * Removes a control from the children of this control
  79712. * @param control defines the control to remove
  79713. * @returns the current container
  79714. */
  79715. removeControl(control: Control3D): Container3D;
  79716. protected _getTypeName(): string;
  79717. /**
  79718. * Releases all associated resources
  79719. */
  79720. dispose(): void;
  79721. /** Control rotation will remain unchanged */
  79722. static readonly UNSET_ORIENTATION: number;
  79723. /** Control will rotate to make it look at sphere central axis */
  79724. static readonly FACEORIGIN_ORIENTATION: number;
  79725. /** Control will rotate to make it look back at sphere central axis */
  79726. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  79727. /** Control will rotate to look at z axis (0, 0, 1) */
  79728. static readonly FACEFORWARD_ORIENTATION: number;
  79729. /** Control will rotate to look at negative z axis (0, 0, -1) */
  79730. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  79731. }
  79732. }
  79733. declare module BABYLON.GUI {
  79734. /**
  79735. * Class used to manage 3D user interface
  79736. * @see https://doc.babylonjs.com/how_to/gui3d
  79737. */
  79738. export class GUI3DManager implements BABYLON.IDisposable {
  79739. private _scene;
  79740. private _sceneDisposeObserver;
  79741. private _utilityLayer;
  79742. private _rootContainer;
  79743. private _pointerObserver;
  79744. private _pointerOutObserver;
  79745. /** @hidden */
  79746. _lastPickedControl: Control3D;
  79747. /** @hidden */
  79748. _lastControlOver: {
  79749. [pointerId: number]: Control3D;
  79750. };
  79751. /** @hidden */
  79752. _lastControlDown: {
  79753. [pointerId: number]: Control3D;
  79754. };
  79755. /**
  79756. * BABYLON.Observable raised when the point picked by the pointer events changed
  79757. */
  79758. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  79759. /** @hidden */
  79760. _sharedMaterials: {
  79761. [key: string]: BABYLON.Material;
  79762. };
  79763. /** Gets the hosting scene */
  79764. get scene(): BABYLON.Scene;
  79765. /** Gets associated utility layer */
  79766. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  79767. /**
  79768. * Creates a new GUI3DManager
  79769. * @param scene
  79770. */
  79771. constructor(scene?: BABYLON.Scene);
  79772. private _handlePointerOut;
  79773. private _doPicking;
  79774. /**
  79775. * Gets the root container
  79776. */
  79777. get rootContainer(): Container3D;
  79778. /**
  79779. * Gets a boolean indicating if the given control is in the root child list
  79780. * @param control defines the control to check
  79781. * @returns true if the control is in the root child list
  79782. */
  79783. containsControl(control: Control3D): boolean;
  79784. /**
  79785. * Adds a control to the root child list
  79786. * @param control defines the control to add
  79787. * @returns the current manager
  79788. */
  79789. addControl(control: Control3D): GUI3DManager;
  79790. /**
  79791. * Removes a control from the root child list
  79792. * @param control defines the control to remove
  79793. * @returns the current container
  79794. */
  79795. removeControl(control: Control3D): GUI3DManager;
  79796. /**
  79797. * Releases all associated resources
  79798. */
  79799. dispose(): void;
  79800. }
  79801. }
  79802. declare module BABYLON.GUI {
  79803. /**
  79804. * Class used to transport BABYLON.Vector3 information for pointer events
  79805. */
  79806. export class Vector3WithInfo extends BABYLON.Vector3 {
  79807. /** defines the current mouse button index */
  79808. buttonIndex: number;
  79809. /**
  79810. * Creates a new Vector3WithInfo
  79811. * @param source defines the vector3 data to transport
  79812. * @param buttonIndex defines the current mouse button index
  79813. */
  79814. constructor(source: BABYLON.Vector3,
  79815. /** defines the current mouse button index */
  79816. buttonIndex?: number);
  79817. }
  79818. }
  79819. declare module BABYLON.GUI {
  79820. /**
  79821. * Class used as base class for controls
  79822. */
  79823. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  79824. /** Defines the control name */
  79825. name?: string | undefined;
  79826. /** @hidden */
  79827. _host: GUI3DManager;
  79828. private _node;
  79829. private _downCount;
  79830. private _enterCount;
  79831. private _downPointerIds;
  79832. private _isVisible;
  79833. /** Gets or sets the control position in world space */
  79834. get position(): BABYLON.Vector3;
  79835. set position(value: BABYLON.Vector3);
  79836. /** Gets or sets the control scaling in world space */
  79837. get scaling(): BABYLON.Vector3;
  79838. set scaling(value: BABYLON.Vector3);
  79839. /** Callback used to start pointer enter animation */
  79840. pointerEnterAnimation: () => void;
  79841. /** Callback used to start pointer out animation */
  79842. pointerOutAnimation: () => void;
  79843. /** Callback used to start pointer down animation */
  79844. pointerDownAnimation: () => void;
  79845. /** Callback used to start pointer up animation */
  79846. pointerUpAnimation: () => void;
  79847. /**
  79848. * An event triggered when the pointer move over the control
  79849. */
  79850. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  79851. /**
  79852. * An event triggered when the pointer move out of the control
  79853. */
  79854. onPointerOutObservable: BABYLON.Observable<Control3D>;
  79855. /**
  79856. * An event triggered when the pointer taps the control
  79857. */
  79858. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  79859. /**
  79860. * An event triggered when pointer is up
  79861. */
  79862. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  79863. /**
  79864. * An event triggered when a control is clicked on (with a mouse)
  79865. */
  79866. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  79867. /**
  79868. * An event triggered when pointer enters the control
  79869. */
  79870. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  79871. /**
  79872. * Gets or sets the parent container
  79873. */
  79874. parent: BABYLON.Nullable<Container3D>;
  79875. private _behaviors;
  79876. /**
  79877. * Gets the list of attached behaviors
  79878. * @see https://doc.babylonjs.com/features/behaviour
  79879. */
  79880. get behaviors(): BABYLON.Behavior<Control3D>[];
  79881. /**
  79882. * Attach a behavior to the control
  79883. * @see https://doc.babylonjs.com/features/behaviour
  79884. * @param behavior defines the behavior to attach
  79885. * @returns the current control
  79886. */
  79887. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79888. /**
  79889. * Remove an attached behavior
  79890. * @see https://doc.babylonjs.com/features/behaviour
  79891. * @param behavior defines the behavior to attach
  79892. * @returns the current control
  79893. */
  79894. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79895. /**
  79896. * Gets an attached behavior by name
  79897. * @param name defines the name of the behavior to look for
  79898. * @see https://doc.babylonjs.com/features/behaviour
  79899. * @returns null if behavior was not found else the requested behavior
  79900. */
  79901. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  79902. /** Gets or sets a boolean indicating if the control is visible */
  79903. get isVisible(): boolean;
  79904. set isVisible(value: boolean);
  79905. /**
  79906. * Creates a new control
  79907. * @param name defines the control name
  79908. */
  79909. constructor(
  79910. /** Defines the control name */
  79911. name?: string | undefined);
  79912. /**
  79913. * Gets a string representing the class name
  79914. */
  79915. get typeName(): string;
  79916. /**
  79917. * Get the current class name of the control.
  79918. * @returns current class name
  79919. */
  79920. getClassName(): string;
  79921. protected _getTypeName(): string;
  79922. /**
  79923. * Gets the transform node used by this control
  79924. */
  79925. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  79926. /**
  79927. * Gets the mesh used to render this control
  79928. */
  79929. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79930. /**
  79931. * Link the control as child of the given node
  79932. * @param node defines the node to link to. Use null to unlink the control
  79933. * @returns the current control
  79934. */
  79935. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  79936. /** @hidden **/
  79937. _prepareNode(scene: BABYLON.Scene): void;
  79938. /**
  79939. * Node creation.
  79940. * Can be overriden by children
  79941. * @param scene defines the scene where the node must be attached
  79942. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  79943. */
  79944. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79945. /**
  79946. * Affect a material to the given mesh
  79947. * @param mesh defines the mesh which will represent the control
  79948. */
  79949. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79950. /** @hidden */
  79951. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  79952. /** @hidden */
  79953. _onPointerEnter(target: Control3D): boolean;
  79954. /** @hidden */
  79955. _onPointerOut(target: Control3D): void;
  79956. /** @hidden */
  79957. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79958. /** @hidden */
  79959. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79960. /** @hidden */
  79961. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79962. /** @hidden */
  79963. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79964. /** @hidden */
  79965. _disposeNode(): void;
  79966. /**
  79967. * Releases all associated resources
  79968. */
  79969. dispose(): void;
  79970. }
  79971. }
  79972. declare module BABYLON.GUI {
  79973. /**
  79974. * Class used as a root to all buttons
  79975. */
  79976. export class AbstractButton3D extends Control3D {
  79977. /**
  79978. * Creates a new button
  79979. * @param name defines the control name
  79980. */
  79981. constructor(name?: string);
  79982. protected _getTypeName(): string;
  79983. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79984. }
  79985. }
  79986. declare module BABYLON.GUI {
  79987. /**
  79988. * Class used to create a button in 3D
  79989. */
  79990. export class Button3D extends AbstractButton3D {
  79991. /** @hidden */
  79992. protected _currentMaterial: BABYLON.Material;
  79993. private _facadeTexture;
  79994. private _content;
  79995. private _contentResolution;
  79996. private _contentScaleRatio;
  79997. /**
  79998. * Gets or sets the texture resolution used to render content (512 by default)
  79999. */
  80000. get contentResolution(): BABYLON.int;
  80001. set contentResolution(value: BABYLON.int);
  80002. /**
  80003. * Gets or sets the texture scale ratio used to render content (2 by default)
  80004. */
  80005. get contentScaleRatio(): number;
  80006. set contentScaleRatio(value: number);
  80007. protected _disposeFacadeTexture(): void;
  80008. protected _resetContent(): void;
  80009. /**
  80010. * Creates a new button
  80011. * @param name defines the control name
  80012. */
  80013. constructor(name?: string);
  80014. /**
  80015. * Gets or sets the GUI 2D content used to display the button's facade
  80016. */
  80017. get content(): Control;
  80018. set content(value: Control);
  80019. /**
  80020. * Apply the facade texture (created from the content property).
  80021. * This function can be overloaded by child classes
  80022. * @param facadeTexture defines the AdvancedDynamicTexture to use
  80023. */
  80024. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80025. protected _getTypeName(): string;
  80026. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80027. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80028. /**
  80029. * Releases all associated resources
  80030. */
  80031. dispose(): void;
  80032. }
  80033. }
  80034. declare module BABYLON.GUI {
  80035. /**
  80036. * Abstract class used to create a container panel deployed on the surface of a volume
  80037. */
  80038. export abstract class VolumeBasedPanel extends Container3D {
  80039. private _columns;
  80040. private _rows;
  80041. private _rowThenColum;
  80042. private _orientation;
  80043. protected _cellWidth: number;
  80044. protected _cellHeight: number;
  80045. /**
  80046. * Gets or sets the distance between elements
  80047. */
  80048. margin: number;
  80049. /**
  80050. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  80051. * | Value | Type | Description |
  80052. * | ----- | ----------------------------------- | ----------- |
  80053. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  80054. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  80055. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  80056. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  80057. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  80058. */
  80059. get orientation(): number;
  80060. set orientation(value: number);
  80061. /**
  80062. * Gets or sets the number of columns requested (10 by default).
  80063. * The panel will automatically compute the number of rows based on number of child controls.
  80064. */
  80065. get columns(): BABYLON.int;
  80066. set columns(value: BABYLON.int);
  80067. /**
  80068. * Gets or sets a the number of rows requested.
  80069. * The panel will automatically compute the number of columns based on number of child controls.
  80070. */
  80071. get rows(): BABYLON.int;
  80072. set rows(value: BABYLON.int);
  80073. /**
  80074. * Creates new VolumeBasedPanel
  80075. */
  80076. constructor();
  80077. protected _arrangeChildren(): void;
  80078. /** Child classes must implement this function to provide correct control positioning */
  80079. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80080. /** Child classes can implement this function to provide additional processing */
  80081. protected _finalProcessing(): void;
  80082. }
  80083. }
  80084. declare module BABYLON.GUI {
  80085. /**
  80086. * Class used to create a container panel deployed on the surface of a cylinder
  80087. */
  80088. export class CylinderPanel extends VolumeBasedPanel {
  80089. private _radius;
  80090. /**
  80091. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  80092. */
  80093. get radius(): BABYLON.float;
  80094. set radius(value: BABYLON.float);
  80095. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80096. private _cylindricalMapping;
  80097. }
  80098. }
  80099. declare module BABYLON.GUI {
  80100. /** @hidden */
  80101. export var fluentVertexShader: {
  80102. name: string;
  80103. shader: string;
  80104. };
  80105. }
  80106. declare module BABYLON.GUI {
  80107. /** @hidden */
  80108. export var fluentPixelShader: {
  80109. name: string;
  80110. shader: string;
  80111. };
  80112. }
  80113. declare module BABYLON.GUI {
  80114. /** @hidden */
  80115. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  80116. INNERGLOW: boolean;
  80117. BORDER: boolean;
  80118. HOVERLIGHT: boolean;
  80119. TEXTURE: boolean;
  80120. constructor();
  80121. }
  80122. /**
  80123. * Class used to render controls with fluent desgin
  80124. */
  80125. export class FluentMaterial extends BABYLON.PushMaterial {
  80126. /**
  80127. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  80128. */
  80129. innerGlowColorIntensity: number;
  80130. /**
  80131. * Gets or sets the inner glow color (white by default)
  80132. */
  80133. innerGlowColor: BABYLON.Color3;
  80134. /**
  80135. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  80136. */
  80137. albedoColor: BABYLON.Color3;
  80138. /**
  80139. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  80140. */
  80141. renderBorders: boolean;
  80142. /**
  80143. * Gets or sets border width (default is 0.5)
  80144. */
  80145. borderWidth: number;
  80146. /**
  80147. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  80148. */
  80149. edgeSmoothingValue: number;
  80150. /**
  80151. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  80152. */
  80153. borderMinValue: number;
  80154. /**
  80155. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  80156. */
  80157. renderHoverLight: boolean;
  80158. /**
  80159. * Gets or sets the radius used to render the hover light (default is 1.0)
  80160. */
  80161. hoverRadius: number;
  80162. /**
  80163. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  80164. */
  80165. hoverColor: BABYLON.Color4;
  80166. /**
  80167. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  80168. */
  80169. hoverPosition: BABYLON.Vector3;
  80170. private _albedoTexture;
  80171. /** Gets or sets the texture to use for albedo color */
  80172. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80173. /**
  80174. * Creates a new Fluent material
  80175. * @param name defines the name of the material
  80176. * @param scene defines the hosting scene
  80177. */
  80178. constructor(name: string, scene: BABYLON.Scene);
  80179. needAlphaBlending(): boolean;
  80180. needAlphaTesting(): boolean;
  80181. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80182. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80183. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80184. getActiveTextures(): BABYLON.BaseTexture[];
  80185. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80186. dispose(forceDisposeEffect?: boolean): void;
  80187. clone(name: string): FluentMaterial;
  80188. serialize(): any;
  80189. getClassName(): string;
  80190. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  80191. }
  80192. }
  80193. declare module BABYLON.GUI {
  80194. /**
  80195. * Class used to create a holographic button in 3D
  80196. */
  80197. export class HolographicButton extends Button3D {
  80198. private _backPlate;
  80199. private _textPlate;
  80200. private _frontPlate;
  80201. private _text;
  80202. private _imageUrl;
  80203. private _shareMaterials;
  80204. private _frontMaterial;
  80205. private _backMaterial;
  80206. private _plateMaterial;
  80207. private _pickedPointObserver;
  80208. private _tooltipFade;
  80209. private _tooltipTextBlock;
  80210. private _tooltipTexture;
  80211. private _tooltipMesh;
  80212. private _tooltipHoverObserver;
  80213. private _tooltipOutObserver;
  80214. private _disposeTooltip;
  80215. /**
  80216. * Rendering ground id of all the mesh in the button
  80217. */
  80218. set renderingGroupId(id: number);
  80219. get renderingGroupId(): number;
  80220. /**
  80221. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  80222. */
  80223. set tooltipText(text: BABYLON.Nullable<string>);
  80224. get tooltipText(): BABYLON.Nullable<string>;
  80225. /**
  80226. * Gets or sets text for the button
  80227. */
  80228. get text(): string;
  80229. set text(value: string);
  80230. /**
  80231. * Gets or sets the image url for the button
  80232. */
  80233. get imageUrl(): string;
  80234. set imageUrl(value: string);
  80235. /**
  80236. * Gets the back material used by this button
  80237. */
  80238. get backMaterial(): FluentMaterial;
  80239. /**
  80240. * Gets the front material used by this button
  80241. */
  80242. get frontMaterial(): FluentMaterial;
  80243. /**
  80244. * Gets the plate material used by this button
  80245. */
  80246. get plateMaterial(): BABYLON.StandardMaterial;
  80247. /**
  80248. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  80249. */
  80250. get shareMaterials(): boolean;
  80251. /**
  80252. * Creates a new button
  80253. * @param name defines the control name
  80254. */
  80255. constructor(name?: string, shareMaterials?: boolean);
  80256. protected _getTypeName(): string;
  80257. private _rebuildContent;
  80258. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80259. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80260. private _createBackMaterial;
  80261. private _createFrontMaterial;
  80262. private _createPlateMaterial;
  80263. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  80264. /**
  80265. * Releases all associated resources
  80266. */
  80267. dispose(): void;
  80268. }
  80269. }
  80270. declare module BABYLON.GUI {
  80271. /**
  80272. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  80273. */
  80274. export class MeshButton3D extends Button3D {
  80275. /** @hidden */
  80276. protected _currentMesh: BABYLON.Mesh;
  80277. /**
  80278. * Creates a new 3D button based on a mesh
  80279. * @param mesh mesh to become a 3D button
  80280. * @param name defines the control name
  80281. */
  80282. constructor(mesh: BABYLON.Mesh, name?: string);
  80283. protected _getTypeName(): string;
  80284. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80285. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80286. }
  80287. }
  80288. declare module BABYLON.GUI {
  80289. /**
  80290. * Class used to create a container panel deployed on the surface of a plane
  80291. */
  80292. export class PlanePanel extends VolumeBasedPanel {
  80293. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80294. }
  80295. }
  80296. declare module BABYLON.GUI {
  80297. /**
  80298. * Class used to create a container panel where items get randomized planar mapping
  80299. */
  80300. export class ScatterPanel extends VolumeBasedPanel {
  80301. private _iteration;
  80302. /**
  80303. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  80304. */
  80305. get iteration(): BABYLON.float;
  80306. set iteration(value: BABYLON.float);
  80307. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80308. private _scatterMapping;
  80309. protected _finalProcessing(): void;
  80310. }
  80311. }
  80312. declare module BABYLON.GUI {
  80313. /**
  80314. * Class used to create a container panel deployed on the surface of a sphere
  80315. */
  80316. export class SpherePanel extends VolumeBasedPanel {
  80317. private _radius;
  80318. /**
  80319. * Gets or sets the radius of the sphere where to project controls (5 by default)
  80320. */
  80321. get radius(): BABYLON.float;
  80322. set radius(value: BABYLON.float);
  80323. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80324. private _sphericalMapping;
  80325. }
  80326. }
  80327. declare module BABYLON.GUI {
  80328. /**
  80329. * Class used to create a stack panel in 3D on XY plane
  80330. */
  80331. export class StackPanel3D extends Container3D {
  80332. private _isVertical;
  80333. /**
  80334. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  80335. */
  80336. get isVertical(): boolean;
  80337. set isVertical(value: boolean);
  80338. /**
  80339. * Gets or sets the distance between elements
  80340. */
  80341. margin: number;
  80342. /**
  80343. * Creates new StackPanel
  80344. * @param isVertical
  80345. */
  80346. constructor(isVertical?: boolean);
  80347. protected _arrangeChildren(): void;
  80348. }
  80349. }
  80350. declare module BABYLON {
  80351. /**
  80352. * Configuration for glTF validation
  80353. */
  80354. export interface IGLTFValidationConfiguration {
  80355. /**
  80356. * The url of the glTF validator.
  80357. */
  80358. url: string;
  80359. }
  80360. /**
  80361. * glTF validation
  80362. */
  80363. export class GLTFValidation {
  80364. /**
  80365. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  80366. */
  80367. static Configuration: IGLTFValidationConfiguration;
  80368. private static _LoadScriptPromise;
  80369. /**
  80370. * Validate a glTF asset using the glTF-Validator.
  80371. * @param data The JSON of a glTF or the array buffer of a binary glTF
  80372. * @param rootUrl The root url for the glTF
  80373. * @param fileName The file name for the glTF
  80374. * @param getExternalResource The callback to get external resources for the glTF validator
  80375. * @returns A promise that resolves with the glTF validation results once complete
  80376. */
  80377. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  80378. }
  80379. }
  80380. declare module BABYLON {
  80381. /**
  80382. * Mode that determines the coordinate system to use.
  80383. */
  80384. export enum GLTFLoaderCoordinateSystemMode {
  80385. /**
  80386. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  80387. */
  80388. AUTO = 0,
  80389. /**
  80390. * Sets the useRightHandedSystem flag on the scene.
  80391. */
  80392. FORCE_RIGHT_HANDED = 1
  80393. }
  80394. /**
  80395. * Mode that determines what animations will start.
  80396. */
  80397. export enum GLTFLoaderAnimationStartMode {
  80398. /**
  80399. * No animation will start.
  80400. */
  80401. NONE = 0,
  80402. /**
  80403. * The first animation will start.
  80404. */
  80405. FIRST = 1,
  80406. /**
  80407. * All animations will start.
  80408. */
  80409. ALL = 2
  80410. }
  80411. /**
  80412. * Interface that contains the data for the glTF asset.
  80413. */
  80414. export interface IGLTFLoaderData {
  80415. /**
  80416. * The object that represents the glTF JSON.
  80417. */
  80418. json: Object;
  80419. /**
  80420. * The BIN chunk of a binary glTF.
  80421. */
  80422. bin: Nullable<IDataBuffer>;
  80423. }
  80424. /**
  80425. * Interface for extending the loader.
  80426. */
  80427. export interface IGLTFLoaderExtension {
  80428. /**
  80429. * The name of this extension.
  80430. */
  80431. readonly name: string;
  80432. /**
  80433. * Defines whether this extension is enabled.
  80434. */
  80435. enabled: boolean;
  80436. /**
  80437. * Defines the order of this extension.
  80438. * The loader sorts the extensions using these values when loading.
  80439. */
  80440. order?: number;
  80441. }
  80442. /**
  80443. * Loader state.
  80444. */
  80445. export enum GLTFLoaderState {
  80446. /**
  80447. * The asset is loading.
  80448. */
  80449. LOADING = 0,
  80450. /**
  80451. * The asset is ready for rendering.
  80452. */
  80453. READY = 1,
  80454. /**
  80455. * The asset is completely loaded.
  80456. */
  80457. COMPLETE = 2
  80458. }
  80459. /** @hidden */
  80460. export interface IImportMeshAsyncOutput {
  80461. meshes: AbstractMesh[];
  80462. particleSystems: IParticleSystem[];
  80463. skeletons: Skeleton[];
  80464. animationGroups: AnimationGroup[];
  80465. lights: Light[];
  80466. transformNodes: TransformNode[];
  80467. }
  80468. /** @hidden */
  80469. export interface IGLTFLoader extends IDisposable {
  80470. readonly state: Nullable<GLTFLoaderState>;
  80471. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  80472. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  80473. }
  80474. /**
  80475. * File loader for loading glTF files into a scene.
  80476. */
  80477. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80478. /** @hidden */
  80479. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80480. /** @hidden */
  80481. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80482. /**
  80483. * Raised when the asset has been parsed
  80484. */
  80485. onParsedObservable: Observable<IGLTFLoaderData>;
  80486. private _onParsedObserver;
  80487. /**
  80488. * Raised when the asset has been parsed
  80489. */
  80490. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  80491. /**
  80492. * 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.
  80493. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  80494. * Defaults to true.
  80495. * @hidden
  80496. */
  80497. static IncrementalLoading: boolean;
  80498. /**
  80499. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  80500. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  80501. * @hidden
  80502. */
  80503. static HomogeneousCoordinates: boolean;
  80504. /**
  80505. * The coordinate system mode. Defaults to AUTO.
  80506. */
  80507. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  80508. /**
  80509. * The animation start mode. Defaults to FIRST.
  80510. */
  80511. animationStartMode: GLTFLoaderAnimationStartMode;
  80512. /**
  80513. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  80514. */
  80515. compileMaterials: boolean;
  80516. /**
  80517. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  80518. */
  80519. useClipPlane: boolean;
  80520. /**
  80521. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  80522. */
  80523. compileShadowGenerators: boolean;
  80524. /**
  80525. * Defines if the Alpha blended materials are only applied as coverage.
  80526. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  80527. * If true, no extra effects are applied to transparent pixels.
  80528. */
  80529. transparencyAsCoverage: boolean;
  80530. /**
  80531. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  80532. * Enabling will disable offline support and glTF validator.
  80533. * Defaults to false.
  80534. */
  80535. useRangeRequests: boolean;
  80536. /**
  80537. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  80538. */
  80539. createInstances: boolean;
  80540. /**
  80541. * 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.
  80542. */
  80543. alwaysComputeBoundingBox: boolean;
  80544. /**
  80545. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  80546. */
  80547. loadAllMaterials: boolean;
  80548. /**
  80549. * Function called before loading a url referenced by the asset.
  80550. */
  80551. preprocessUrlAsync: (url: string) => Promise<string>;
  80552. /**
  80553. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80554. * 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, ...)
  80555. */
  80556. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  80557. private _onMeshLoadedObserver;
  80558. /**
  80559. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80560. * 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, ...)
  80561. */
  80562. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  80563. /**
  80564. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  80565. */
  80566. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  80567. private _onTextureLoadedObserver;
  80568. /**
  80569. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  80570. */
  80571. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  80572. /**
  80573. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  80574. */
  80575. readonly onMaterialLoadedObservable: Observable<Material>;
  80576. private _onMaterialLoadedObserver;
  80577. /**
  80578. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  80579. */
  80580. set onMaterialLoaded(callback: (material: Material) => void);
  80581. /**
  80582. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  80583. */
  80584. readonly onCameraLoadedObservable: Observable<Camera>;
  80585. private _onCameraLoadedObserver;
  80586. /**
  80587. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  80588. */
  80589. set onCameraLoaded(callback: (camera: Camera) => void);
  80590. /**
  80591. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  80592. * For assets with LODs, raised when all of the LODs are complete.
  80593. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80594. */
  80595. readonly onCompleteObservable: Observable<void>;
  80596. private _onCompleteObserver;
  80597. /**
  80598. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  80599. * For assets with LODs, raised when all of the LODs are complete.
  80600. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80601. */
  80602. set onComplete(callback: () => void);
  80603. /**
  80604. * Observable raised when an error occurs.
  80605. */
  80606. readonly onErrorObservable: Observable<any>;
  80607. private _onErrorObserver;
  80608. /**
  80609. * Callback raised when an error occurs.
  80610. */
  80611. set onError(callback: (reason: any) => void);
  80612. /**
  80613. * Observable raised after the loader is disposed.
  80614. */
  80615. readonly onDisposeObservable: Observable<void>;
  80616. private _onDisposeObserver;
  80617. /**
  80618. * Callback raised after the loader is disposed.
  80619. */
  80620. set onDispose(callback: () => void);
  80621. /**
  80622. * Observable raised after a loader extension is created.
  80623. * Set additional options for a loader extension in this event.
  80624. */
  80625. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  80626. private _onExtensionLoadedObserver;
  80627. /**
  80628. * Callback raised after a loader extension is created.
  80629. */
  80630. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  80631. /**
  80632. * Defines if the loader logging is enabled.
  80633. */
  80634. get loggingEnabled(): boolean;
  80635. set loggingEnabled(value: boolean);
  80636. /**
  80637. * Defines if the loader should capture performance counters.
  80638. */
  80639. get capturePerformanceCounters(): boolean;
  80640. set capturePerformanceCounters(value: boolean);
  80641. /**
  80642. * Defines if the loader should validate the asset.
  80643. */
  80644. validate: boolean;
  80645. /**
  80646. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  80647. */
  80648. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  80649. private _onValidatedObserver;
  80650. /**
  80651. * Callback raised after a loader extension is created.
  80652. */
  80653. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  80654. private _loader;
  80655. private _progressCallback?;
  80656. private _requests;
  80657. private static magicBase64Encoded;
  80658. /**
  80659. * Name of the loader ("gltf")
  80660. */
  80661. name: string;
  80662. /** @hidden */
  80663. extensions: ISceneLoaderPluginExtensions;
  80664. /**
  80665. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  80666. */
  80667. dispose(): void;
  80668. /** @hidden */
  80669. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80670. /** @hidden */
  80671. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80672. /** @hidden */
  80673. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80674. meshes: AbstractMesh[];
  80675. particleSystems: IParticleSystem[];
  80676. skeletons: Skeleton[];
  80677. animationGroups: AnimationGroup[];
  80678. }>;
  80679. /** @hidden */
  80680. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80681. /** @hidden */
  80682. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80683. /** @hidden */
  80684. canDirectLoad(data: string): boolean;
  80685. /** @hidden */
  80686. directLoad(scene: Scene, data: string): Promise<any>;
  80687. /**
  80688. * The callback that allows custom handling of the root url based on the response url.
  80689. * @param rootUrl the original root url
  80690. * @param responseURL the response url if available
  80691. * @returns the new root url
  80692. */
  80693. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  80694. /** @hidden */
  80695. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  80696. /**
  80697. * The loader state or null if the loader is not active.
  80698. */
  80699. get loaderState(): Nullable<GLTFLoaderState>;
  80700. /**
  80701. * Returns a promise that resolves when the asset is completely loaded.
  80702. * @returns a promise that resolves when the asset is completely loaded.
  80703. */
  80704. whenCompleteAsync(): Promise<void>;
  80705. /** @hidden */
  80706. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  80707. /** @hidden */
  80708. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  80709. private _onProgress;
  80710. private _validate;
  80711. private _getLoader;
  80712. private _parseJson;
  80713. private _unpackBinaryAsync;
  80714. private _unpackBinaryV1Async;
  80715. private _unpackBinaryV2Async;
  80716. private static _parseVersion;
  80717. private static _compareVersion;
  80718. private static readonly _logSpaces;
  80719. private _logIndentLevel;
  80720. private _loggingEnabled;
  80721. /** @hidden */
  80722. _log: (message: string) => void;
  80723. /** @hidden */
  80724. _logOpen(message: string): void;
  80725. /** @hidden */
  80726. _logClose(): void;
  80727. private _logEnabled;
  80728. private _logDisabled;
  80729. private _capturePerformanceCounters;
  80730. /** @hidden */
  80731. _startPerformanceCounter: (counterName: string) => void;
  80732. /** @hidden */
  80733. _endPerformanceCounter: (counterName: string) => void;
  80734. private _startPerformanceCounterEnabled;
  80735. private _startPerformanceCounterDisabled;
  80736. private _endPerformanceCounterEnabled;
  80737. private _endPerformanceCounterDisabled;
  80738. }
  80739. }
  80740. declare module BABYLON.GLTF1 {
  80741. /**
  80742. * Enums
  80743. * @hidden
  80744. */
  80745. export enum EComponentType {
  80746. BYTE = 5120,
  80747. UNSIGNED_BYTE = 5121,
  80748. SHORT = 5122,
  80749. UNSIGNED_SHORT = 5123,
  80750. FLOAT = 5126
  80751. }
  80752. /** @hidden */
  80753. export enum EShaderType {
  80754. FRAGMENT = 35632,
  80755. VERTEX = 35633
  80756. }
  80757. /** @hidden */
  80758. export enum EParameterType {
  80759. BYTE = 5120,
  80760. UNSIGNED_BYTE = 5121,
  80761. SHORT = 5122,
  80762. UNSIGNED_SHORT = 5123,
  80763. INT = 5124,
  80764. UNSIGNED_INT = 5125,
  80765. FLOAT = 5126,
  80766. FLOAT_VEC2 = 35664,
  80767. FLOAT_VEC3 = 35665,
  80768. FLOAT_VEC4 = 35666,
  80769. INT_VEC2 = 35667,
  80770. INT_VEC3 = 35668,
  80771. INT_VEC4 = 35669,
  80772. BOOL = 35670,
  80773. BOOL_VEC2 = 35671,
  80774. BOOL_VEC3 = 35672,
  80775. BOOL_VEC4 = 35673,
  80776. FLOAT_MAT2 = 35674,
  80777. FLOAT_MAT3 = 35675,
  80778. FLOAT_MAT4 = 35676,
  80779. SAMPLER_2D = 35678
  80780. }
  80781. /** @hidden */
  80782. export enum ETextureWrapMode {
  80783. CLAMP_TO_EDGE = 33071,
  80784. MIRRORED_REPEAT = 33648,
  80785. REPEAT = 10497
  80786. }
  80787. /** @hidden */
  80788. export enum ETextureFilterType {
  80789. NEAREST = 9728,
  80790. LINEAR = 9728,
  80791. NEAREST_MIPMAP_NEAREST = 9984,
  80792. LINEAR_MIPMAP_NEAREST = 9985,
  80793. NEAREST_MIPMAP_LINEAR = 9986,
  80794. LINEAR_MIPMAP_LINEAR = 9987
  80795. }
  80796. /** @hidden */
  80797. export enum ETextureFormat {
  80798. ALPHA = 6406,
  80799. RGB = 6407,
  80800. RGBA = 6408,
  80801. LUMINANCE = 6409,
  80802. LUMINANCE_ALPHA = 6410
  80803. }
  80804. /** @hidden */
  80805. export enum ECullingType {
  80806. FRONT = 1028,
  80807. BACK = 1029,
  80808. FRONT_AND_BACK = 1032
  80809. }
  80810. /** @hidden */
  80811. export enum EBlendingFunction {
  80812. ZERO = 0,
  80813. ONE = 1,
  80814. SRC_COLOR = 768,
  80815. ONE_MINUS_SRC_COLOR = 769,
  80816. DST_COLOR = 774,
  80817. ONE_MINUS_DST_COLOR = 775,
  80818. SRC_ALPHA = 770,
  80819. ONE_MINUS_SRC_ALPHA = 771,
  80820. DST_ALPHA = 772,
  80821. ONE_MINUS_DST_ALPHA = 773,
  80822. CONSTANT_COLOR = 32769,
  80823. ONE_MINUS_CONSTANT_COLOR = 32770,
  80824. CONSTANT_ALPHA = 32771,
  80825. ONE_MINUS_CONSTANT_ALPHA = 32772,
  80826. SRC_ALPHA_SATURATE = 776
  80827. }
  80828. /** @hidden */
  80829. export interface IGLTFProperty {
  80830. extensions?: {
  80831. [key: string]: any;
  80832. };
  80833. extras?: Object;
  80834. }
  80835. /** @hidden */
  80836. export interface IGLTFChildRootProperty extends IGLTFProperty {
  80837. name?: string;
  80838. }
  80839. /** @hidden */
  80840. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  80841. bufferView: string;
  80842. byteOffset: number;
  80843. byteStride: number;
  80844. count: number;
  80845. type: string;
  80846. componentType: EComponentType;
  80847. max?: number[];
  80848. min?: number[];
  80849. name?: string;
  80850. }
  80851. /** @hidden */
  80852. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  80853. buffer: string;
  80854. byteOffset: number;
  80855. byteLength: number;
  80856. byteStride: number;
  80857. target?: number;
  80858. }
  80859. /** @hidden */
  80860. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  80861. uri: string;
  80862. byteLength?: number;
  80863. type?: string;
  80864. }
  80865. /** @hidden */
  80866. export interface IGLTFShader extends IGLTFChildRootProperty {
  80867. uri: string;
  80868. type: EShaderType;
  80869. }
  80870. /** @hidden */
  80871. export interface IGLTFProgram extends IGLTFChildRootProperty {
  80872. attributes: string[];
  80873. fragmentShader: string;
  80874. vertexShader: string;
  80875. }
  80876. /** @hidden */
  80877. export interface IGLTFTechniqueParameter {
  80878. type: number;
  80879. count?: number;
  80880. semantic?: string;
  80881. node?: string;
  80882. value?: number | boolean | string | Array<any>;
  80883. source?: string;
  80884. babylonValue?: any;
  80885. }
  80886. /** @hidden */
  80887. export interface IGLTFTechniqueCommonProfile {
  80888. lightingModel: string;
  80889. texcoordBindings: Object;
  80890. parameters?: Array<any>;
  80891. }
  80892. /** @hidden */
  80893. export interface IGLTFTechniqueStatesFunctions {
  80894. blendColor?: number[];
  80895. blendEquationSeparate?: number[];
  80896. blendFuncSeparate?: number[];
  80897. colorMask: boolean[];
  80898. cullFace: number[];
  80899. }
  80900. /** @hidden */
  80901. export interface IGLTFTechniqueStates {
  80902. enable: number[];
  80903. functions: IGLTFTechniqueStatesFunctions;
  80904. }
  80905. /** @hidden */
  80906. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  80907. parameters: {
  80908. [key: string]: IGLTFTechniqueParameter;
  80909. };
  80910. program: string;
  80911. attributes: {
  80912. [key: string]: string;
  80913. };
  80914. uniforms: {
  80915. [key: string]: string;
  80916. };
  80917. states: IGLTFTechniqueStates;
  80918. }
  80919. /** @hidden */
  80920. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  80921. technique?: string;
  80922. values: string[];
  80923. }
  80924. /** @hidden */
  80925. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  80926. attributes: {
  80927. [key: string]: string;
  80928. };
  80929. indices: string;
  80930. material: string;
  80931. mode?: number;
  80932. }
  80933. /** @hidden */
  80934. export interface IGLTFMesh extends IGLTFChildRootProperty {
  80935. primitives: IGLTFMeshPrimitive[];
  80936. }
  80937. /** @hidden */
  80938. export interface IGLTFImage extends IGLTFChildRootProperty {
  80939. uri: string;
  80940. }
  80941. /** @hidden */
  80942. export interface IGLTFSampler extends IGLTFChildRootProperty {
  80943. magFilter?: number;
  80944. minFilter?: number;
  80945. wrapS?: number;
  80946. wrapT?: number;
  80947. }
  80948. /** @hidden */
  80949. export interface IGLTFTexture extends IGLTFChildRootProperty {
  80950. sampler: string;
  80951. source: string;
  80952. format?: ETextureFormat;
  80953. internalFormat?: ETextureFormat;
  80954. target?: number;
  80955. type?: number;
  80956. babylonTexture?: Texture;
  80957. }
  80958. /** @hidden */
  80959. export interface IGLTFAmbienLight {
  80960. color?: number[];
  80961. }
  80962. /** @hidden */
  80963. export interface IGLTFDirectionalLight {
  80964. color?: number[];
  80965. }
  80966. /** @hidden */
  80967. export interface IGLTFPointLight {
  80968. color?: number[];
  80969. constantAttenuation?: number;
  80970. linearAttenuation?: number;
  80971. quadraticAttenuation?: number;
  80972. }
  80973. /** @hidden */
  80974. export interface IGLTFSpotLight {
  80975. color?: number[];
  80976. constantAttenuation?: number;
  80977. fallOfAngle?: number;
  80978. fallOffExponent?: number;
  80979. linearAttenuation?: number;
  80980. quadraticAttenuation?: number;
  80981. }
  80982. /** @hidden */
  80983. export interface IGLTFLight extends IGLTFChildRootProperty {
  80984. type: string;
  80985. }
  80986. /** @hidden */
  80987. export interface IGLTFCameraOrthographic {
  80988. xmag: number;
  80989. ymag: number;
  80990. zfar: number;
  80991. znear: number;
  80992. }
  80993. /** @hidden */
  80994. export interface IGLTFCameraPerspective {
  80995. aspectRatio: number;
  80996. yfov: number;
  80997. zfar: number;
  80998. znear: number;
  80999. }
  81000. /** @hidden */
  81001. export interface IGLTFCamera extends IGLTFChildRootProperty {
  81002. type: string;
  81003. }
  81004. /** @hidden */
  81005. export interface IGLTFAnimationChannelTarget {
  81006. id: string;
  81007. path: string;
  81008. }
  81009. /** @hidden */
  81010. export interface IGLTFAnimationChannel {
  81011. sampler: string;
  81012. target: IGLTFAnimationChannelTarget;
  81013. }
  81014. /** @hidden */
  81015. export interface IGLTFAnimationSampler {
  81016. input: string;
  81017. output: string;
  81018. interpolation?: string;
  81019. }
  81020. /** @hidden */
  81021. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  81022. channels?: IGLTFAnimationChannel[];
  81023. parameters?: {
  81024. [key: string]: string;
  81025. };
  81026. samplers?: {
  81027. [key: string]: IGLTFAnimationSampler;
  81028. };
  81029. }
  81030. /** @hidden */
  81031. export interface IGLTFNodeInstanceSkin {
  81032. skeletons: string[];
  81033. skin: string;
  81034. meshes: string[];
  81035. }
  81036. /** @hidden */
  81037. export interface IGLTFSkins extends IGLTFChildRootProperty {
  81038. bindShapeMatrix: number[];
  81039. inverseBindMatrices: string;
  81040. jointNames: string[];
  81041. babylonSkeleton?: Skeleton;
  81042. }
  81043. /** @hidden */
  81044. export interface IGLTFNode extends IGLTFChildRootProperty {
  81045. camera?: string;
  81046. children: string[];
  81047. skin?: string;
  81048. jointName?: string;
  81049. light?: string;
  81050. matrix: number[];
  81051. mesh?: string;
  81052. meshes?: string[];
  81053. rotation?: number[];
  81054. scale?: number[];
  81055. translation?: number[];
  81056. babylonNode?: Node;
  81057. }
  81058. /** @hidden */
  81059. export interface IGLTFScene extends IGLTFChildRootProperty {
  81060. nodes: string[];
  81061. }
  81062. /** @hidden */
  81063. export interface IGLTFRuntime {
  81064. extensions: {
  81065. [key: string]: any;
  81066. };
  81067. accessors: {
  81068. [key: string]: IGLTFAccessor;
  81069. };
  81070. buffers: {
  81071. [key: string]: IGLTFBuffer;
  81072. };
  81073. bufferViews: {
  81074. [key: string]: IGLTFBufferView;
  81075. };
  81076. meshes: {
  81077. [key: string]: IGLTFMesh;
  81078. };
  81079. lights: {
  81080. [key: string]: IGLTFLight;
  81081. };
  81082. cameras: {
  81083. [key: string]: IGLTFCamera;
  81084. };
  81085. nodes: {
  81086. [key: string]: IGLTFNode;
  81087. };
  81088. images: {
  81089. [key: string]: IGLTFImage;
  81090. };
  81091. textures: {
  81092. [key: string]: IGLTFTexture;
  81093. };
  81094. shaders: {
  81095. [key: string]: IGLTFShader;
  81096. };
  81097. programs: {
  81098. [key: string]: IGLTFProgram;
  81099. };
  81100. samplers: {
  81101. [key: string]: IGLTFSampler;
  81102. };
  81103. techniques: {
  81104. [key: string]: IGLTFTechnique;
  81105. };
  81106. materials: {
  81107. [key: string]: IGLTFMaterial;
  81108. };
  81109. animations: {
  81110. [key: string]: IGLTFAnimation;
  81111. };
  81112. skins: {
  81113. [key: string]: IGLTFSkins;
  81114. };
  81115. currentScene?: Object;
  81116. scenes: {
  81117. [key: string]: IGLTFScene;
  81118. };
  81119. extensionsUsed: string[];
  81120. extensionsRequired?: string[];
  81121. buffersCount: number;
  81122. shaderscount: number;
  81123. scene: Scene;
  81124. rootUrl: string;
  81125. loadedBufferCount: number;
  81126. loadedBufferViews: {
  81127. [name: string]: ArrayBufferView;
  81128. };
  81129. loadedShaderCount: number;
  81130. importOnlyMeshes: boolean;
  81131. importMeshesNames?: string[];
  81132. dummyNodes: Node[];
  81133. forAssetContainer: boolean;
  81134. }
  81135. /** @hidden */
  81136. export interface INodeToRoot {
  81137. bone: Bone;
  81138. node: IGLTFNode;
  81139. id: string;
  81140. }
  81141. /** @hidden */
  81142. export interface IJointNode {
  81143. node: IGLTFNode;
  81144. id: string;
  81145. }
  81146. }
  81147. declare module BABYLON.GLTF1 {
  81148. /**
  81149. * Utils functions for GLTF
  81150. * @hidden
  81151. */
  81152. export class GLTFUtils {
  81153. /**
  81154. * Sets the given "parameter" matrix
  81155. * @param scene: the Scene object
  81156. * @param source: the source node where to pick the matrix
  81157. * @param parameter: the GLTF technique parameter
  81158. * @param uniformName: the name of the shader's uniform
  81159. * @param shaderMaterial: the shader material
  81160. */
  81161. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  81162. /**
  81163. * Sets the given "parameter" matrix
  81164. * @param shaderMaterial: the shader material
  81165. * @param uniform: the name of the shader's uniform
  81166. * @param value: the value of the uniform
  81167. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  81168. */
  81169. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  81170. /**
  81171. * Returns the wrap mode of the texture
  81172. * @param mode: the mode value
  81173. */
  81174. static GetWrapMode(mode: number): number;
  81175. /**
  81176. * Returns the byte stride giving an accessor
  81177. * @param accessor: the GLTF accessor objet
  81178. */
  81179. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  81180. /**
  81181. * Returns the texture filter mode giving a mode value
  81182. * @param mode: the filter mode value
  81183. */
  81184. static GetTextureFilterMode(mode: number): ETextureFilterType;
  81185. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  81186. /**
  81187. * Returns a buffer from its accessor
  81188. * @param gltfRuntime: the GLTF runtime
  81189. * @param accessor: the GLTF accessor
  81190. */
  81191. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  81192. /**
  81193. * Decodes a buffer view into a string
  81194. * @param view: the buffer view
  81195. */
  81196. static DecodeBufferToText(view: ArrayBufferView): string;
  81197. /**
  81198. * Returns the default material of gltf. Related to
  81199. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  81200. * @param scene: the Babylon.js scene
  81201. */
  81202. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  81203. private static _DefaultMaterial;
  81204. }
  81205. }
  81206. declare module BABYLON.GLTF1 {
  81207. /**
  81208. * Implementation of the base glTF spec
  81209. * @hidden
  81210. */
  81211. export class GLTFLoaderBase {
  81212. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  81213. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81214. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  81215. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81216. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  81217. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81218. }
  81219. /**
  81220. * glTF V1 Loader
  81221. * @hidden
  81222. */
  81223. export class GLTFLoader implements IGLTFLoader {
  81224. static Extensions: {
  81225. [name: string]: GLTFLoaderExtension;
  81226. };
  81227. static RegisterExtension(extension: GLTFLoaderExtension): void;
  81228. state: Nullable<GLTFLoaderState>;
  81229. dispose(): void;
  81230. private _importMeshAsync;
  81231. /**
  81232. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  81233. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81234. * @param scene the scene the meshes should be added to
  81235. * @param forAssetContainer defines if the entities must be stored in the scene
  81236. * @param data gltf data containing information of the meshes in a loaded file
  81237. * @param rootUrl root url to load from
  81238. * @param onProgress event that fires when loading progress has occured
  81239. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81240. */
  81241. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  81242. private _loadAsync;
  81243. /**
  81244. * Imports all objects from a loaded gltf file and adds them to the scene
  81245. * @param scene the scene the objects should be added to
  81246. * @param data gltf data containing information of the meshes in a loaded file
  81247. * @param rootUrl root url to load from
  81248. * @param onProgress event that fires when loading progress has occured
  81249. * @returns a promise which completes when objects have been loaded to the scene
  81250. */
  81251. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  81252. private _loadShadersAsync;
  81253. private _loadBuffersAsync;
  81254. private _createNodes;
  81255. }
  81256. /** @hidden */
  81257. export abstract class GLTFLoaderExtension {
  81258. private _name;
  81259. constructor(name: string);
  81260. get name(): string;
  81261. /**
  81262. * Defines an override for loading the runtime
  81263. * Return true to stop further extensions from loading the runtime
  81264. */
  81265. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  81266. /**
  81267. * Defines an onverride for creating gltf runtime
  81268. * Return true to stop further extensions from creating the runtime
  81269. */
  81270. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  81271. /**
  81272. * Defines an override for loading buffers
  81273. * Return true to stop further extensions from loading this buffer
  81274. */
  81275. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  81276. /**
  81277. * Defines an override for loading texture buffers
  81278. * Return true to stop further extensions from loading this texture data
  81279. */
  81280. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81281. /**
  81282. * Defines an override for creating textures
  81283. * Return true to stop further extensions from loading this texture
  81284. */
  81285. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  81286. /**
  81287. * Defines an override for loading shader strings
  81288. * Return true to stop further extensions from loading this shader data
  81289. */
  81290. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81291. /**
  81292. * Defines an override for loading materials
  81293. * Return true to stop further extensions from loading this material
  81294. */
  81295. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81296. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  81297. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  81298. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81299. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81300. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  81301. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81302. private static LoadTextureBufferAsync;
  81303. private static CreateTextureAsync;
  81304. private static ApplyExtensions;
  81305. }
  81306. }
  81307. declare module BABYLON.GLTF1 {
  81308. /** @hidden */
  81309. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  81310. private _bin;
  81311. constructor();
  81312. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  81313. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81314. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81315. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81316. }
  81317. }
  81318. declare module BABYLON.GLTF1 {
  81319. /** @hidden */
  81320. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  81321. constructor();
  81322. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  81323. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81324. private _loadTexture;
  81325. }
  81326. }
  81327. declare module BABYLON.GLTF2.Loader {
  81328. /**
  81329. * Loader interface with an index field.
  81330. */
  81331. export interface IArrayItem {
  81332. /**
  81333. * The index of this item in the array.
  81334. */
  81335. index: number;
  81336. }
  81337. /**
  81338. * Loader interface with additional members.
  81339. */
  81340. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  81341. /** @hidden */
  81342. _data?: Promise<ArrayBufferView>;
  81343. /** @hidden */
  81344. _babylonVertexBuffer?: Promise<VertexBuffer>;
  81345. }
  81346. /**
  81347. * Loader interface with additional members.
  81348. */
  81349. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  81350. }
  81351. /** @hidden */
  81352. export interface _IAnimationSamplerData {
  81353. input: Float32Array;
  81354. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  81355. output: Float32Array;
  81356. }
  81357. /**
  81358. * Loader interface with additional members.
  81359. */
  81360. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  81361. /** @hidden */
  81362. _data?: Promise<_IAnimationSamplerData>;
  81363. }
  81364. /**
  81365. * Loader interface with additional members.
  81366. */
  81367. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  81368. channels: IAnimationChannel[];
  81369. samplers: IAnimationSampler[];
  81370. /** @hidden */
  81371. _babylonAnimationGroup?: AnimationGroup;
  81372. }
  81373. /**
  81374. * Loader interface with additional members.
  81375. */
  81376. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  81377. /** @hidden */
  81378. _data?: Promise<ArrayBufferView>;
  81379. }
  81380. /**
  81381. * Loader interface with additional members.
  81382. */
  81383. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  81384. /** @hidden */
  81385. _data?: Promise<ArrayBufferView>;
  81386. /** @hidden */
  81387. _babylonBuffer?: Promise<Buffer>;
  81388. }
  81389. /**
  81390. * Loader interface with additional members.
  81391. */
  81392. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  81393. }
  81394. /**
  81395. * Loader interface with additional members.
  81396. */
  81397. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  81398. /** @hidden */
  81399. _data?: Promise<ArrayBufferView>;
  81400. }
  81401. /**
  81402. * Loader interface with additional members.
  81403. */
  81404. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  81405. }
  81406. /**
  81407. * Loader interface with additional members.
  81408. */
  81409. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  81410. }
  81411. /**
  81412. * Loader interface with additional members.
  81413. */
  81414. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  81415. baseColorTexture?: ITextureInfo;
  81416. metallicRoughnessTexture?: ITextureInfo;
  81417. }
  81418. /**
  81419. * Loader interface with additional members.
  81420. */
  81421. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  81422. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81423. normalTexture?: IMaterialNormalTextureInfo;
  81424. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81425. emissiveTexture?: ITextureInfo;
  81426. /** @hidden */
  81427. _data?: {
  81428. [babylonDrawMode: number]: {
  81429. babylonMaterial: Material;
  81430. babylonMeshes: AbstractMesh[];
  81431. promise: Promise<void>;
  81432. };
  81433. };
  81434. }
  81435. /**
  81436. * Loader interface with additional members.
  81437. */
  81438. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  81439. primitives: IMeshPrimitive[];
  81440. }
  81441. /**
  81442. * Loader interface with additional members.
  81443. */
  81444. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  81445. /** @hidden */
  81446. _instanceData?: {
  81447. babylonSourceMesh: Mesh;
  81448. promise: Promise<any>;
  81449. };
  81450. }
  81451. /**
  81452. * Loader interface with additional members.
  81453. */
  81454. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  81455. /**
  81456. * The parent glTF node.
  81457. */
  81458. parent?: INode;
  81459. /** @hidden */
  81460. _babylonTransformNode?: TransformNode;
  81461. /** @hidden */
  81462. _primitiveBabylonMeshes?: AbstractMesh[];
  81463. /** @hidden */
  81464. _babylonBones?: Bone[];
  81465. /** @hidden */
  81466. _numMorphTargets?: number;
  81467. }
  81468. /** @hidden */
  81469. export interface _ISamplerData {
  81470. noMipMaps: boolean;
  81471. samplingMode: number;
  81472. wrapU: number;
  81473. wrapV: number;
  81474. }
  81475. /**
  81476. * Loader interface with additional members.
  81477. */
  81478. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  81479. /** @hidden */
  81480. _data?: _ISamplerData;
  81481. }
  81482. /**
  81483. * Loader interface with additional members.
  81484. */
  81485. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  81486. }
  81487. /**
  81488. * Loader interface with additional members.
  81489. */
  81490. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  81491. /** @hidden */
  81492. _data?: {
  81493. babylonSkeleton: Skeleton;
  81494. promise: Promise<void>;
  81495. };
  81496. }
  81497. /**
  81498. * Loader interface with additional members.
  81499. */
  81500. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  81501. }
  81502. /**
  81503. * Loader interface with additional members.
  81504. */
  81505. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  81506. }
  81507. /**
  81508. * Loader interface with additional members.
  81509. */
  81510. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  81511. accessors?: IAccessor[];
  81512. animations?: IAnimation[];
  81513. buffers?: IBuffer[];
  81514. bufferViews?: IBufferView[];
  81515. cameras?: ICamera[];
  81516. images?: IImage[];
  81517. materials?: IMaterial[];
  81518. meshes?: IMesh[];
  81519. nodes?: INode[];
  81520. samplers?: ISampler[];
  81521. scenes?: IScene[];
  81522. skins?: ISkin[];
  81523. textures?: ITexture[];
  81524. }
  81525. }
  81526. declare module BABYLON.GLTF2 {
  81527. /**
  81528. * Interface for a glTF loader extension.
  81529. */
  81530. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  81531. /**
  81532. * Called after the loader state changes to LOADING.
  81533. */
  81534. onLoading?(): void;
  81535. /**
  81536. * Called after the loader state changes to READY.
  81537. */
  81538. onReady?(): void;
  81539. /**
  81540. * Define this method to modify the default behavior when loading scenes.
  81541. * @param context The context when loading the asset
  81542. * @param scene The glTF scene property
  81543. * @returns A promise that resolves when the load is complete or null if not handled
  81544. */
  81545. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  81546. /**
  81547. * Define this method to modify the default behavior when loading nodes.
  81548. * @param context The context when loading the asset
  81549. * @param node The glTF node property
  81550. * @param assign A function called synchronously after parsing the glTF properties
  81551. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  81552. */
  81553. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81554. /**
  81555. * Define this method to modify the default behavior when loading cameras.
  81556. * @param context The context when loading the asset
  81557. * @param camera The glTF camera property
  81558. * @param assign A function called synchronously after parsing the glTF properties
  81559. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  81560. */
  81561. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81562. /**
  81563. * @hidden
  81564. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  81565. * @param context The context when loading the asset
  81566. * @param primitive The glTF mesh primitive property
  81567. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  81568. */
  81569. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81570. /**
  81571. * @hidden
  81572. * Define this method to modify the default behavior when loading data for mesh primitives.
  81573. * @param context The context when loading the asset
  81574. * @param name The mesh name when loading the asset
  81575. * @param node The glTF node when loading the asset
  81576. * @param mesh The glTF mesh when loading the asset
  81577. * @param primitive The glTF mesh primitive property
  81578. * @param assign A function called synchronously after parsing the glTF properties
  81579. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81580. */
  81581. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81582. /**
  81583. * @hidden
  81584. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  81585. * @param context The context when loading the asset
  81586. * @param material The glTF material property
  81587. * @param assign A function called synchronously after parsing the glTF properties
  81588. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  81589. */
  81590. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81591. /**
  81592. * Define this method to modify the default behavior when creating materials.
  81593. * @param context The context when loading the asset
  81594. * @param material The glTF material property
  81595. * @param babylonDrawMode The draw mode for the Babylon material
  81596. * @returns The Babylon material or null if not handled
  81597. */
  81598. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81599. /**
  81600. * Define this method to modify the default behavior when loading material properties.
  81601. * @param context The context when loading the asset
  81602. * @param material The glTF material property
  81603. * @param babylonMaterial The Babylon material
  81604. * @returns A promise that resolves when the load is complete or null if not handled
  81605. */
  81606. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81607. /**
  81608. * Define this method to modify the default behavior when loading texture infos.
  81609. * @param context The context when loading the asset
  81610. * @param textureInfo The glTF texture info property
  81611. * @param assign A function called synchronously after parsing the glTF properties
  81612. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81613. */
  81614. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81615. /**
  81616. * @hidden
  81617. * Define this method to modify the default behavior when loading textures.
  81618. * @param context The context when loading the asset
  81619. * @param texture The glTF texture property
  81620. * @param assign A function called synchronously after parsing the glTF properties
  81621. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81622. */
  81623. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81624. /**
  81625. * Define this method to modify the default behavior when loading animations.
  81626. * @param context The context when loading the asset
  81627. * @param animation The glTF animation property
  81628. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  81629. */
  81630. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81631. /**
  81632. * @hidden
  81633. * Define this method to modify the default behavior when loading skins.
  81634. * @param context The context when loading the asset
  81635. * @param node The glTF node property
  81636. * @param skin The glTF skin property
  81637. * @returns A promise that resolves when the load is complete or null if not handled
  81638. */
  81639. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  81640. /**
  81641. * @hidden
  81642. * Define this method to modify the default behavior when loading uris.
  81643. * @param context The context when loading the asset
  81644. * @param property The glTF property associated with the uri
  81645. * @param uri The uri to load
  81646. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81647. */
  81648. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81649. /**
  81650. * Define this method to modify the default behavior when loading buffer views.
  81651. * @param context The context when loading the asset
  81652. * @param bufferView The glTF buffer view property
  81653. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81654. */
  81655. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  81656. /**
  81657. * Define this method to modify the default behavior when loading buffers.
  81658. * @param context The context when loading the asset
  81659. * @param buffer The glTF buffer property
  81660. * @param byteOffset The byte offset to load
  81661. * @param byteLength The byte length to load
  81662. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81663. */
  81664. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81665. }
  81666. }
  81667. declare module BABYLON.GLTF2 {
  81668. /**
  81669. * Helper class for working with arrays when loading the glTF asset
  81670. */
  81671. export class ArrayItem {
  81672. /**
  81673. * Gets an item from the given array.
  81674. * @param context The context when loading the asset
  81675. * @param array The array to get the item from
  81676. * @param index The index to the array
  81677. * @returns The array item
  81678. */
  81679. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  81680. /**
  81681. * Assign an `index` field to each item of the given array.
  81682. * @param array The array of items
  81683. */
  81684. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  81685. }
  81686. /**
  81687. * The glTF 2.0 loader
  81688. */
  81689. export class GLTFLoader implements IGLTFLoader {
  81690. /** @hidden */
  81691. _completePromises: Promise<any>[];
  81692. /** @hidden */
  81693. _forAssetContainer: boolean;
  81694. /** Storage */
  81695. _babylonLights: Light[];
  81696. /** @hidden */
  81697. _disableInstancedMesh: number;
  81698. private _disposed;
  81699. private _parent;
  81700. private _state;
  81701. private _extensions;
  81702. private _rootUrl;
  81703. private _fileName;
  81704. private _uniqueRootUrl;
  81705. private _gltf;
  81706. private _bin;
  81707. private _babylonScene;
  81708. private _rootBabylonMesh;
  81709. private _defaultBabylonMaterialData;
  81710. private static _RegisteredExtensions;
  81711. /**
  81712. * The default glTF sampler.
  81713. */
  81714. static readonly DefaultSampler: ISampler;
  81715. /**
  81716. * Registers a loader extension.
  81717. * @param name The name of the loader extension.
  81718. * @param factory The factory function that creates the loader extension.
  81719. */
  81720. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  81721. /**
  81722. * Unregisters a loader extension.
  81723. * @param name The name of the loader extension.
  81724. * @returns A boolean indicating whether the extension has been unregistered
  81725. */
  81726. static UnregisterExtension(name: string): boolean;
  81727. /**
  81728. * The loader state.
  81729. */
  81730. get state(): Nullable<GLTFLoaderState>;
  81731. /**
  81732. * The object that represents the glTF JSON.
  81733. */
  81734. get gltf(): IGLTF;
  81735. /**
  81736. * The BIN chunk of a binary glTF.
  81737. */
  81738. get bin(): Nullable<IDataBuffer>;
  81739. /**
  81740. * The parent file loader.
  81741. */
  81742. get parent(): GLTFFileLoader;
  81743. /**
  81744. * The Babylon scene when loading the asset.
  81745. */
  81746. get babylonScene(): Scene;
  81747. /**
  81748. * The root Babylon mesh when loading the asset.
  81749. */
  81750. get rootBabylonMesh(): Mesh;
  81751. /** @hidden */
  81752. constructor(parent: GLTFFileLoader);
  81753. /** @hidden */
  81754. dispose(): void;
  81755. /** @hidden */
  81756. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  81757. /** @hidden */
  81758. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81759. private _loadAsync;
  81760. private _loadData;
  81761. private _setupData;
  81762. private _loadExtensions;
  81763. private _checkExtensions;
  81764. private _setState;
  81765. private _createRootNode;
  81766. /**
  81767. * Loads a glTF scene.
  81768. * @param context The context when loading the asset
  81769. * @param scene The glTF scene property
  81770. * @returns A promise that resolves when the load is complete
  81771. */
  81772. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  81773. private _forEachPrimitive;
  81774. private _getMeshes;
  81775. private _getTransformNodes;
  81776. private _getSkeletons;
  81777. private _getAnimationGroups;
  81778. private _startAnimations;
  81779. /**
  81780. * Loads a glTF node.
  81781. * @param context The context when loading the asset
  81782. * @param node The glTF node property
  81783. * @param assign A function called synchronously after parsing the glTF properties
  81784. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  81785. */
  81786. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  81787. private _loadMeshAsync;
  81788. /**
  81789. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  81790. * @param context The context when loading the asset
  81791. * @param name The mesh name when loading the asset
  81792. * @param node The glTF node when loading the asset
  81793. * @param mesh The glTF mesh when loading the asset
  81794. * @param primitive The glTF mesh primitive property
  81795. * @param assign A function called synchronously after parsing the glTF properties
  81796. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81797. */
  81798. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  81799. private _loadVertexDataAsync;
  81800. private _createMorphTargets;
  81801. private _loadMorphTargetsAsync;
  81802. private _loadMorphTargetVertexDataAsync;
  81803. private static _LoadTransform;
  81804. private _loadSkinAsync;
  81805. private _loadBones;
  81806. private _loadBone;
  81807. private _loadSkinInverseBindMatricesDataAsync;
  81808. private _updateBoneMatrices;
  81809. private _getNodeMatrix;
  81810. /**
  81811. * Loads a glTF camera.
  81812. * @param context The context when loading the asset
  81813. * @param camera The glTF camera property
  81814. * @param assign A function called synchronously after parsing the glTF properties
  81815. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  81816. */
  81817. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  81818. private _loadAnimationsAsync;
  81819. /**
  81820. * Loads a glTF animation.
  81821. * @param context The context when loading the asset
  81822. * @param animation The glTF animation property
  81823. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  81824. */
  81825. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  81826. /**
  81827. * @hidden Loads a glTF animation channel.
  81828. * @param context The context when loading the asset
  81829. * @param animationContext The context of the animation when loading the asset
  81830. * @param animation The glTF animation property
  81831. * @param channel The glTF animation channel property
  81832. * @param babylonAnimationGroup The babylon animation group property
  81833. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  81834. * @returns A void promise when the channel load is complete
  81835. */
  81836. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  81837. private _loadAnimationSamplerAsync;
  81838. private _loadBufferAsync;
  81839. /**
  81840. * Loads a glTF buffer view.
  81841. * @param context The context when loading the asset
  81842. * @param bufferView The glTF buffer view property
  81843. * @returns A promise that resolves with the loaded data when the load is complete
  81844. */
  81845. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  81846. private _loadAccessorAsync;
  81847. /** @hidden */
  81848. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  81849. private _loadIndicesAccessorAsync;
  81850. private _loadVertexBufferViewAsync;
  81851. private _loadVertexAccessorAsync;
  81852. private _loadMaterialMetallicRoughnessPropertiesAsync;
  81853. /** @hidden */
  81854. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  81855. private _createDefaultMaterial;
  81856. /**
  81857. * Creates a Babylon material from a glTF material.
  81858. * @param context The context when loading the asset
  81859. * @param material The glTF material property
  81860. * @param babylonDrawMode The draw mode for the Babylon material
  81861. * @returns The Babylon material
  81862. */
  81863. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  81864. /**
  81865. * Loads properties from a glTF material into a Babylon material.
  81866. * @param context The context when loading the asset
  81867. * @param material The glTF material property
  81868. * @param babylonMaterial The Babylon material
  81869. * @returns A promise that resolves when the load is complete
  81870. */
  81871. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81872. /**
  81873. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  81874. * @param context The context when loading the asset
  81875. * @param material The glTF material property
  81876. * @param babylonMaterial The Babylon material
  81877. * @returns A promise that resolves when the load is complete
  81878. */
  81879. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81880. /**
  81881. * Loads the alpha properties from a glTF material into a Babylon material.
  81882. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  81883. * @param context The context when loading the asset
  81884. * @param material The glTF material property
  81885. * @param babylonMaterial The Babylon material
  81886. */
  81887. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  81888. /**
  81889. * Loads a glTF texture info.
  81890. * @param context The context when loading the asset
  81891. * @param textureInfo The glTF texture info property
  81892. * @param assign A function called synchronously after parsing the glTF properties
  81893. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  81894. */
  81895. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81896. /** @hidden */
  81897. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81898. /** @hidden */
  81899. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81900. private _loadSampler;
  81901. /**
  81902. * Loads a glTF image.
  81903. * @param context The context when loading the asset
  81904. * @param image The glTF image property
  81905. * @returns A promise that resolves with the loaded data when the load is complete
  81906. */
  81907. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  81908. /**
  81909. * Loads a glTF uri.
  81910. * @param context The context when loading the asset
  81911. * @param property The glTF property associated with the uri
  81912. * @param uri The base64 or relative uri
  81913. * @returns A promise that resolves with the loaded data when the load is complete
  81914. */
  81915. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  81916. /**
  81917. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  81918. * @param babylonObject the Babylon object with metadata
  81919. * @param pointer the JSON pointer
  81920. */
  81921. static AddPointerMetadata(babylonObject: {
  81922. metadata: any;
  81923. }, pointer: string): void;
  81924. private static _GetTextureWrapMode;
  81925. private static _GetTextureSamplingMode;
  81926. private static _GetTypedArrayConstructor;
  81927. private static _GetTypedArray;
  81928. private static _GetNumComponents;
  81929. private static _ValidateUri;
  81930. /** @hidden */
  81931. static _GetDrawMode(context: string, mode: number | undefined): number;
  81932. private _compileMaterialsAsync;
  81933. private _compileShadowGeneratorsAsync;
  81934. private _forEachExtensions;
  81935. private _applyExtensions;
  81936. private _extensionsOnLoading;
  81937. private _extensionsOnReady;
  81938. private _extensionsLoadSceneAsync;
  81939. private _extensionsLoadNodeAsync;
  81940. private _extensionsLoadCameraAsync;
  81941. private _extensionsLoadVertexDataAsync;
  81942. private _extensionsLoadMeshPrimitiveAsync;
  81943. private _extensionsLoadMaterialAsync;
  81944. private _extensionsCreateMaterial;
  81945. private _extensionsLoadMaterialPropertiesAsync;
  81946. private _extensionsLoadTextureInfoAsync;
  81947. private _extensionsLoadTextureAsync;
  81948. private _extensionsLoadAnimationAsync;
  81949. private _extensionsLoadSkinAsync;
  81950. private _extensionsLoadUriAsync;
  81951. private _extensionsLoadBufferViewAsync;
  81952. private _extensionsLoadBufferAsync;
  81953. /**
  81954. * Helper method called by a loader extension to load an glTF extension.
  81955. * @param context The context when loading the asset
  81956. * @param property The glTF property to load the extension from
  81957. * @param extensionName The name of the extension to load
  81958. * @param actionAsync The action to run
  81959. * @returns The promise returned by actionAsync or null if the extension does not exist
  81960. */
  81961. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81962. /**
  81963. * Helper method called by a loader extension to load a glTF extra.
  81964. * @param context The context when loading the asset
  81965. * @param property The glTF property to load the extra from
  81966. * @param extensionName The name of the extension to load
  81967. * @param actionAsync The action to run
  81968. * @returns The promise returned by actionAsync or null if the extra does not exist
  81969. */
  81970. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81971. /**
  81972. * Checks for presence of an extension.
  81973. * @param name The name of the extension to check
  81974. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  81975. */
  81976. isExtensionUsed(name: string): boolean;
  81977. /**
  81978. * Increments the indentation level and logs a message.
  81979. * @param message The message to log
  81980. */
  81981. logOpen(message: string): void;
  81982. /**
  81983. * Decrements the indentation level.
  81984. */
  81985. logClose(): void;
  81986. /**
  81987. * Logs a message
  81988. * @param message The message to log
  81989. */
  81990. log(message: string): void;
  81991. /**
  81992. * Starts a performance counter.
  81993. * @param counterName The name of the performance counter
  81994. */
  81995. startPerformanceCounter(counterName: string): void;
  81996. /**
  81997. * Ends a performance counter.
  81998. * @param counterName The name of the performance counter
  81999. */
  82000. endPerformanceCounter(counterName: string): void;
  82001. }
  82002. }
  82003. declare module BABYLON.GLTF2.Loader.Extensions {
  82004. /** @hidden */
  82005. interface IEXTLightsImageBased_LightImageBased {
  82006. _babylonTexture?: BaseTexture;
  82007. _loaded?: Promise<void>;
  82008. }
  82009. /**
  82010. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  82011. */
  82012. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  82013. /**
  82014. * The name of this extension.
  82015. */
  82016. readonly name: string;
  82017. /**
  82018. * Defines whether this extension is enabled.
  82019. */
  82020. enabled: boolean;
  82021. private _loader;
  82022. private _lights?;
  82023. /** @hidden */
  82024. constructor(loader: GLTFLoader);
  82025. /** @hidden */
  82026. dispose(): void;
  82027. /** @hidden */
  82028. onLoading(): void;
  82029. /** @hidden */
  82030. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82031. private _loadLightAsync;
  82032. }
  82033. }
  82034. declare module BABYLON.GLTF2.Loader.Extensions {
  82035. /**
  82036. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  82037. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  82038. * !!! Experimental Extension Subject to Changes !!!
  82039. */
  82040. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  82041. /**
  82042. * The name of this extension.
  82043. */
  82044. readonly name: string;
  82045. /**
  82046. * Defines whether this extension is enabled.
  82047. */
  82048. enabled: boolean;
  82049. private _loader;
  82050. /** @hidden */
  82051. constructor(loader: GLTFLoader);
  82052. /** @hidden */
  82053. dispose(): void;
  82054. /** @hidden */
  82055. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82056. }
  82057. }
  82058. declare module BABYLON.GLTF2.Loader.Extensions {
  82059. /**
  82060. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  82061. */
  82062. export class EXT_texture_webp implements IGLTFLoaderExtension {
  82063. /** The name of this extension. */
  82064. readonly name: string;
  82065. /** Defines whether this extension is enabled. */
  82066. enabled: boolean;
  82067. private _loader;
  82068. /** @hidden */
  82069. constructor(loader: GLTFLoader);
  82070. /** @hidden */
  82071. dispose(): void;
  82072. /** @hidden */
  82073. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82074. }
  82075. }
  82076. declare module BABYLON.GLTF2.Loader.Extensions {
  82077. /**
  82078. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  82079. */
  82080. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  82081. /**
  82082. * The name of this extension.
  82083. */
  82084. readonly name: string;
  82085. /**
  82086. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  82087. */
  82088. dracoCompression?: DracoCompression;
  82089. /**
  82090. * Defines whether this extension is enabled.
  82091. */
  82092. enabled: boolean;
  82093. private _loader;
  82094. /** @hidden */
  82095. constructor(loader: GLTFLoader);
  82096. /** @hidden */
  82097. dispose(): void;
  82098. /** @hidden */
  82099. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82100. }
  82101. }
  82102. declare module BABYLON.GLTF2.Loader.Extensions {
  82103. /**
  82104. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  82105. */
  82106. export class KHR_lights implements IGLTFLoaderExtension {
  82107. /**
  82108. * The name of this extension.
  82109. */
  82110. readonly name: string;
  82111. /**
  82112. * Defines whether this extension is enabled.
  82113. */
  82114. enabled: boolean;
  82115. private _loader;
  82116. private _lights?;
  82117. /** @hidden */
  82118. constructor(loader: GLTFLoader);
  82119. /** @hidden */
  82120. dispose(): void;
  82121. /** @hidden */
  82122. onLoading(): void;
  82123. /** @hidden */
  82124. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82125. }
  82126. }
  82127. declare module BABYLON.GLTF2.Loader.Extensions {
  82128. /**
  82129. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  82130. */
  82131. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  82132. /**
  82133. * The name of this extension.
  82134. */
  82135. readonly name: string;
  82136. /**
  82137. * Defines whether this extension is enabled.
  82138. */
  82139. enabled: boolean;
  82140. /**
  82141. * Defines a number that determines the order the extensions are applied.
  82142. */
  82143. order: number;
  82144. private _loader;
  82145. /** @hidden */
  82146. constructor(loader: GLTFLoader);
  82147. /** @hidden */
  82148. dispose(): void;
  82149. /** @hidden */
  82150. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82151. private _loadSpecularGlossinessPropertiesAsync;
  82152. }
  82153. }
  82154. declare module BABYLON.GLTF2.Loader.Extensions {
  82155. /**
  82156. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  82157. */
  82158. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  82159. /**
  82160. * The name of this extension.
  82161. */
  82162. readonly name: string;
  82163. /**
  82164. * Defines whether this extension is enabled.
  82165. */
  82166. enabled: boolean;
  82167. /**
  82168. * Defines a number that determines the order the extensions are applied.
  82169. */
  82170. order: number;
  82171. private _loader;
  82172. /** @hidden */
  82173. constructor(loader: GLTFLoader);
  82174. /** @hidden */
  82175. dispose(): void;
  82176. /** @hidden */
  82177. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82178. private _loadUnlitPropertiesAsync;
  82179. }
  82180. }
  82181. declare module BABYLON.GLTF2.Loader.Extensions {
  82182. /**
  82183. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  82184. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  82185. * !!! Experimental Extension Subject to Changes !!!
  82186. */
  82187. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  82188. /**
  82189. * The name of this extension.
  82190. */
  82191. readonly name: string;
  82192. /**
  82193. * Defines whether this extension is enabled.
  82194. */
  82195. enabled: boolean;
  82196. /**
  82197. * Defines a number that determines the order the extensions are applied.
  82198. */
  82199. order: number;
  82200. private _loader;
  82201. /** @hidden */
  82202. constructor(loader: GLTFLoader);
  82203. /** @hidden */
  82204. dispose(): void;
  82205. /** @hidden */
  82206. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82207. private _loadClearCoatPropertiesAsync;
  82208. }
  82209. }
  82210. declare module BABYLON.GLTF2.Loader.Extensions {
  82211. /**
  82212. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  82213. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  82214. * !!! Experimental Extension Subject to Changes !!!
  82215. */
  82216. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  82217. /**
  82218. * The name of this extension.
  82219. */
  82220. readonly name: string;
  82221. /**
  82222. * Defines whether this extension is enabled.
  82223. */
  82224. enabled: boolean;
  82225. /**
  82226. * Defines a number that determines the order the extensions are applied.
  82227. */
  82228. order: number;
  82229. private _loader;
  82230. /** @hidden */
  82231. constructor(loader: GLTFLoader);
  82232. /** @hidden */
  82233. dispose(): void;
  82234. /** @hidden */
  82235. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82236. private _loadSheenPropertiesAsync;
  82237. }
  82238. }
  82239. declare module BABYLON.GLTF2.Loader.Extensions {
  82240. /**
  82241. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  82242. * !!! Experimental Extension Subject to Changes !!!
  82243. */
  82244. export class KHR_materials_specular implements IGLTFLoaderExtension {
  82245. /**
  82246. * The name of this extension.
  82247. */
  82248. readonly name: string;
  82249. /**
  82250. * Defines whether this extension is enabled.
  82251. */
  82252. enabled: boolean;
  82253. /**
  82254. * Defines a number that determines the order the extensions are applied.
  82255. */
  82256. order: number;
  82257. private _loader;
  82258. /** @hidden */
  82259. constructor(loader: GLTFLoader);
  82260. /** @hidden */
  82261. dispose(): void;
  82262. /** @hidden */
  82263. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82264. private _loadSpecularPropertiesAsync;
  82265. }
  82266. }
  82267. declare module BABYLON.GLTF2.Loader.Extensions {
  82268. /**
  82269. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  82270. * !!! Experimental Extension Subject to Changes !!!
  82271. */
  82272. export class KHR_materials_ior implements IGLTFLoaderExtension {
  82273. /**
  82274. * Default ior Value from the spec.
  82275. */
  82276. private static readonly _DEFAULT_IOR;
  82277. /**
  82278. * The name of this extension.
  82279. */
  82280. readonly name: string;
  82281. /**
  82282. * Defines whether this extension is enabled.
  82283. */
  82284. enabled: boolean;
  82285. /**
  82286. * Defines a number that determines the order the extensions are applied.
  82287. */
  82288. order: number;
  82289. private _loader;
  82290. /** @hidden */
  82291. constructor(loader: GLTFLoader);
  82292. /** @hidden */
  82293. dispose(): void;
  82294. /** @hidden */
  82295. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82296. private _loadIorPropertiesAsync;
  82297. }
  82298. }
  82299. declare module BABYLON.GLTF2.Loader.Extensions {
  82300. /**
  82301. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  82302. * !!! Experimental Extension Subject to Changes !!!
  82303. */
  82304. export class KHR_materials_variants implements IGLTFLoaderExtension {
  82305. /**
  82306. * The name of this extension.
  82307. */
  82308. readonly name: string;
  82309. /**
  82310. * Defines whether this extension is enabled.
  82311. */
  82312. enabled: boolean;
  82313. private _loader;
  82314. private _variants?;
  82315. /** @hidden */
  82316. constructor(loader: GLTFLoader);
  82317. /** @hidden */
  82318. dispose(): void;
  82319. /**
  82320. * Gets the list of available variant names for this asset.
  82321. * @param rootMesh The glTF root mesh
  82322. * @returns the list of all the variant names for this model
  82323. */
  82324. static GetAvailableVariants(rootMesh: Mesh): string[];
  82325. /**
  82326. * Gets the list of available variant names for this asset.
  82327. * @param rootMesh The glTF root mesh
  82328. * @returns the list of all the variant names for this model
  82329. */
  82330. getAvailableVariants(rootMesh: Mesh): string[];
  82331. /**
  82332. * Select a variant given a variant name or a list of variant names.
  82333. * @param rootMesh The glTF root mesh
  82334. * @param variantName The variant name(s) to select.
  82335. */
  82336. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82337. /**
  82338. * Select a variant given a variant name or a list of variant names.
  82339. * @param rootMesh The glTF root mesh
  82340. * @param variantName The variant name(s) to select.
  82341. */
  82342. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82343. /**
  82344. * Reset back to the original before selecting a variant.
  82345. * @param rootMesh The glTF root mesh
  82346. */
  82347. static Reset(rootMesh: Mesh): void;
  82348. /**
  82349. * Reset back to the original before selecting a variant.
  82350. * @param rootMesh The glTF root mesh
  82351. */
  82352. reset(rootMesh: Mesh): void;
  82353. /**
  82354. * Gets the last selected variant name(s) or null if original.
  82355. * @param rootMesh The glTF root mesh
  82356. * @returns The selected variant name(s).
  82357. */
  82358. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82359. /**
  82360. * Gets the last selected variant name(s) or null if original.
  82361. * @param rootMesh The glTF root mesh
  82362. * @returns The selected variant name(s).
  82363. */
  82364. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82365. private static _GetExtensionMetadata;
  82366. /** @hidden */
  82367. onLoading(): void;
  82368. /** @hidden */
  82369. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82370. }
  82371. }
  82372. declare module BABYLON.GLTF2.Loader.Extensions {
  82373. /**
  82374. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  82375. * !!! Experimental Extension Subject to Changes !!!
  82376. */
  82377. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  82378. /**
  82379. * The name of this extension.
  82380. */
  82381. readonly name: string;
  82382. /**
  82383. * Defines whether this extension is enabled.
  82384. */
  82385. enabled: boolean;
  82386. /**
  82387. * Defines a number that determines the order the extensions are applied.
  82388. */
  82389. order: number;
  82390. private _loader;
  82391. /** @hidden */
  82392. constructor(loader: GLTFLoader);
  82393. /** @hidden */
  82394. dispose(): void;
  82395. /** @hidden */
  82396. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82397. private _loadTransparentPropertiesAsync;
  82398. }
  82399. }
  82400. declare module BABYLON.GLTF2.Loader.Extensions {
  82401. /**
  82402. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  82403. */
  82404. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  82405. /**
  82406. * The name of this extension.
  82407. */
  82408. readonly name: string;
  82409. /**
  82410. * Defines whether this extension is enabled.
  82411. */
  82412. enabled: boolean;
  82413. /** @hidden */
  82414. constructor(loader: GLTFLoader);
  82415. /** @hidden */
  82416. dispose(): void;
  82417. }
  82418. }
  82419. declare module BABYLON.GLTF2.Loader.Extensions {
  82420. /**
  82421. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  82422. * !!! Experimental Extension Subject to Changes !!!
  82423. */
  82424. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  82425. /** The name of this extension. */
  82426. readonly name: string;
  82427. /** Defines whether this extension is enabled. */
  82428. enabled: boolean;
  82429. private _loader;
  82430. /** @hidden */
  82431. constructor(loader: GLTFLoader);
  82432. /** @hidden */
  82433. dispose(): void;
  82434. /** @hidden */
  82435. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82436. }
  82437. }
  82438. declare module BABYLON.GLTF2.Loader.Extensions {
  82439. /**
  82440. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  82441. */
  82442. export class KHR_texture_transform implements IGLTFLoaderExtension {
  82443. /**
  82444. * The name of this extension.
  82445. */
  82446. readonly name: string;
  82447. /**
  82448. * Defines whether this extension is enabled.
  82449. */
  82450. enabled: boolean;
  82451. private _loader;
  82452. /** @hidden */
  82453. constructor(loader: GLTFLoader);
  82454. /** @hidden */
  82455. dispose(): void;
  82456. /** @hidden */
  82457. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82458. }
  82459. }
  82460. declare module BABYLON.GLTF2.Loader.Extensions {
  82461. /**
  82462. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  82463. * !!! Experimental Extension Subject to Changes !!!
  82464. */
  82465. export class KHR_xmp implements IGLTFLoaderExtension {
  82466. /**
  82467. * The name of this extension.
  82468. */
  82469. readonly name: string;
  82470. /**
  82471. * Defines whether this extension is enabled.
  82472. */
  82473. enabled: boolean;
  82474. /**
  82475. * Defines a number that determines the order the extensions are applied.
  82476. */
  82477. order: number;
  82478. private _loader;
  82479. /** @hidden */
  82480. constructor(loader: GLTFLoader);
  82481. /** @hidden */
  82482. dispose(): void;
  82483. /**
  82484. * Called after the loader state changes to LOADING.
  82485. */
  82486. onLoading(): void;
  82487. }
  82488. }
  82489. declare module BABYLON.GLTF2.Loader.Extensions {
  82490. /**
  82491. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  82492. */
  82493. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  82494. /**
  82495. * The name of this extension.
  82496. */
  82497. readonly name: string;
  82498. /**
  82499. * Defines whether this extension is enabled.
  82500. */
  82501. enabled: boolean;
  82502. private _loader;
  82503. private _clips;
  82504. private _emitters;
  82505. /** @hidden */
  82506. constructor(loader: GLTFLoader);
  82507. /** @hidden */
  82508. dispose(): void;
  82509. /** @hidden */
  82510. onLoading(): void;
  82511. /** @hidden */
  82512. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82513. /** @hidden */
  82514. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82515. /** @hidden */
  82516. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82517. private _loadClipAsync;
  82518. private _loadEmitterAsync;
  82519. private _getEventAction;
  82520. private _loadAnimationEventAsync;
  82521. }
  82522. }
  82523. declare module BABYLON.GLTF2.Loader.Extensions {
  82524. /**
  82525. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  82526. */
  82527. export class MSFT_lod implements IGLTFLoaderExtension {
  82528. /**
  82529. * The name of this extension.
  82530. */
  82531. readonly name: string;
  82532. /**
  82533. * Defines whether this extension is enabled.
  82534. */
  82535. enabled: boolean;
  82536. /**
  82537. * Defines a number that determines the order the extensions are applied.
  82538. */
  82539. order: number;
  82540. /**
  82541. * Maximum number of LODs to load, starting from the lowest LOD.
  82542. */
  82543. maxLODsToLoad: number;
  82544. /**
  82545. * Observable raised when all node LODs of one level are loaded.
  82546. * The event data is the index of the loaded LOD starting from zero.
  82547. * Dispose the loader to cancel the loading of the next level of LODs.
  82548. */
  82549. onNodeLODsLoadedObservable: Observable<number>;
  82550. /**
  82551. * Observable raised when all material LODs of one level are loaded.
  82552. * The event data is the index of the loaded LOD starting from zero.
  82553. * Dispose the loader to cancel the loading of the next level of LODs.
  82554. */
  82555. onMaterialLODsLoadedObservable: Observable<number>;
  82556. private _loader;
  82557. private _bufferLODs;
  82558. private _nodeIndexLOD;
  82559. private _nodeSignalLODs;
  82560. private _nodePromiseLODs;
  82561. private _nodeBufferLODs;
  82562. private _materialIndexLOD;
  82563. private _materialSignalLODs;
  82564. private _materialPromiseLODs;
  82565. private _materialBufferLODs;
  82566. /** @hidden */
  82567. constructor(loader: GLTFLoader);
  82568. /** @hidden */
  82569. dispose(): void;
  82570. /** @hidden */
  82571. onReady(): void;
  82572. /** @hidden */
  82573. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82574. /** @hidden */
  82575. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82576. /** @hidden */
  82577. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82578. /** @hidden */
  82579. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82580. /** @hidden */
  82581. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82582. private _loadBufferLOD;
  82583. /**
  82584. * Gets an array of LOD properties from lowest to highest.
  82585. */
  82586. private _getLODs;
  82587. private _disposeTransformNode;
  82588. private _disposeMaterials;
  82589. }
  82590. }
  82591. declare module BABYLON.GLTF2.Loader.Extensions {
  82592. /** @hidden */
  82593. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  82594. readonly name: string;
  82595. enabled: boolean;
  82596. private _loader;
  82597. constructor(loader: GLTFLoader);
  82598. dispose(): void;
  82599. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82600. }
  82601. }
  82602. declare module BABYLON.GLTF2.Loader.Extensions {
  82603. /** @hidden */
  82604. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  82605. readonly name: string;
  82606. enabled: boolean;
  82607. private _loader;
  82608. constructor(loader: GLTFLoader);
  82609. dispose(): void;
  82610. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82611. }
  82612. }
  82613. declare module BABYLON.GLTF2.Loader.Extensions {
  82614. /**
  82615. * Store glTF extras (if present) in BJS objects' metadata
  82616. */
  82617. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  82618. /**
  82619. * The name of this extension.
  82620. */
  82621. readonly name: string;
  82622. /**
  82623. * Defines whether this extension is enabled.
  82624. */
  82625. enabled: boolean;
  82626. private _loader;
  82627. private _assignExtras;
  82628. /** @hidden */
  82629. constructor(loader: GLTFLoader);
  82630. /** @hidden */
  82631. dispose(): void;
  82632. /** @hidden */
  82633. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82634. /** @hidden */
  82635. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82636. /** @hidden */
  82637. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82638. }
  82639. }
  82640. declare module BABYLON {
  82641. /**
  82642. * Class reading and parsing the MTL file bundled with the obj file.
  82643. */
  82644. export class MTLFileLoader {
  82645. /**
  82646. * Invert Y-Axis of referenced textures on load
  82647. */
  82648. static INVERT_TEXTURE_Y: boolean;
  82649. /**
  82650. * All material loaded from the mtl will be set here
  82651. */
  82652. materials: StandardMaterial[];
  82653. /**
  82654. * This function will read the mtl file and create each material described inside
  82655. * This function could be improve by adding :
  82656. * -some component missing (Ni, Tf...)
  82657. * -including the specific options available
  82658. *
  82659. * @param scene defines the scene the material will be created in
  82660. * @param data defines the mtl data to parse
  82661. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  82662. * @param forAssetContainer defines if the material should be registered in the scene
  82663. */
  82664. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  82665. /**
  82666. * Gets the texture for the material.
  82667. *
  82668. * If the material is imported from input file,
  82669. * We sanitize the url to ensure it takes the textre from aside the material.
  82670. *
  82671. * @param rootUrl The root url to load from
  82672. * @param value The value stored in the mtl
  82673. * @return The Texture
  82674. */
  82675. private static _getTexture;
  82676. }
  82677. }
  82678. declare module BABYLON {
  82679. /**
  82680. * Options for loading OBJ/MTL files
  82681. */
  82682. type MeshLoadOptions = {
  82683. /**
  82684. * Defines if UVs are optimized by default during load.
  82685. */
  82686. OptimizeWithUV: boolean;
  82687. /**
  82688. * Defines custom scaling of UV coordinates of loaded meshes.
  82689. */
  82690. UVScaling: Vector2;
  82691. /**
  82692. * Invert model on y-axis (does a model scaling inversion)
  82693. */
  82694. InvertY: boolean;
  82695. /**
  82696. * Invert Y-Axis of referenced textures on load
  82697. */
  82698. InvertTextureY: boolean;
  82699. /**
  82700. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82701. */
  82702. ImportVertexColors: boolean;
  82703. /**
  82704. * Compute the normals for the model, even if normals are present in the file.
  82705. */
  82706. ComputeNormals: boolean;
  82707. /**
  82708. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82709. */
  82710. SkipMaterials: boolean;
  82711. /**
  82712. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82713. */
  82714. MaterialLoadingFailsSilently: boolean;
  82715. };
  82716. /**
  82717. * OBJ file type loader.
  82718. * This is a babylon scene loader plugin.
  82719. */
  82720. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82721. /**
  82722. * Defines if UVs are optimized by default during load.
  82723. */
  82724. static OPTIMIZE_WITH_UV: boolean;
  82725. /**
  82726. * Invert model on y-axis (does a model scaling inversion)
  82727. */
  82728. static INVERT_Y: boolean;
  82729. /**
  82730. * Invert Y-Axis of referenced textures on load
  82731. */
  82732. static get INVERT_TEXTURE_Y(): boolean;
  82733. static set INVERT_TEXTURE_Y(value: boolean);
  82734. /**
  82735. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82736. */
  82737. static IMPORT_VERTEX_COLORS: boolean;
  82738. /**
  82739. * Compute the normals for the model, even if normals are present in the file.
  82740. */
  82741. static COMPUTE_NORMALS: boolean;
  82742. /**
  82743. * Defines custom scaling of UV coordinates of loaded meshes.
  82744. */
  82745. static UV_SCALING: Vector2;
  82746. /**
  82747. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82748. */
  82749. static SKIP_MATERIALS: boolean;
  82750. /**
  82751. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82752. *
  82753. * Defaults to true for backwards compatibility.
  82754. */
  82755. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  82756. /**
  82757. * Defines the name of the plugin.
  82758. */
  82759. name: string;
  82760. /**
  82761. * Defines the extension the plugin is able to load.
  82762. */
  82763. extensions: string;
  82764. /** @hidden */
  82765. obj: RegExp;
  82766. /** @hidden */
  82767. group: RegExp;
  82768. /** @hidden */
  82769. mtllib: RegExp;
  82770. /** @hidden */
  82771. usemtl: RegExp;
  82772. /** @hidden */
  82773. smooth: RegExp;
  82774. /** @hidden */
  82775. vertexPattern: RegExp;
  82776. /** @hidden */
  82777. normalPattern: RegExp;
  82778. /** @hidden */
  82779. uvPattern: RegExp;
  82780. /** @hidden */
  82781. facePattern1: RegExp;
  82782. /** @hidden */
  82783. facePattern2: RegExp;
  82784. /** @hidden */
  82785. facePattern3: RegExp;
  82786. /** @hidden */
  82787. facePattern4: RegExp;
  82788. /** @hidden */
  82789. facePattern5: RegExp;
  82790. private _forAssetContainer;
  82791. private _meshLoadOptions;
  82792. /**
  82793. * Creates loader for .OBJ files
  82794. *
  82795. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  82796. */
  82797. constructor(meshLoadOptions?: MeshLoadOptions);
  82798. private static get currentMeshLoadOptions();
  82799. /**
  82800. * Calls synchronously the MTL file attached to this obj.
  82801. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  82802. * Without this function materials are not displayed in the first frame (but displayed after).
  82803. * In consequence it is impossible to get material information in your HTML file
  82804. *
  82805. * @param url The URL of the MTL file
  82806. * @param rootUrl
  82807. * @param onSuccess Callback function to be called when the MTL file is loaded
  82808. * @private
  82809. */
  82810. private _loadMTL;
  82811. /**
  82812. * Instantiates a OBJ file loader plugin.
  82813. * @returns the created plugin
  82814. */
  82815. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  82816. /**
  82817. * If the data string can be loaded directly.
  82818. *
  82819. * @param data string containing the file data
  82820. * @returns if the data can be loaded directly
  82821. */
  82822. canDirectLoad(data: string): boolean;
  82823. /**
  82824. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  82825. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82826. * @param scene the scene the meshes should be added to
  82827. * @param data the OBJ data to load
  82828. * @param rootUrl root url to load from
  82829. * @param onProgress event that fires when loading progress has occured
  82830. * @param fileName Defines the name of the file to load
  82831. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82832. */
  82833. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82834. meshes: AbstractMesh[];
  82835. particleSystems: IParticleSystem[];
  82836. skeletons: Skeleton[];
  82837. animationGroups: AnimationGroup[];
  82838. }>;
  82839. /**
  82840. * Imports all objects from the loaded OBJ data and adds them to the scene
  82841. * @param scene the scene the objects should be added to
  82842. * @param data the OBJ data to load
  82843. * @param rootUrl root url to load from
  82844. * @param onProgress event that fires when loading progress has occured
  82845. * @param fileName Defines the name of the file to load
  82846. * @returns a promise which completes when objects have been loaded to the scene
  82847. */
  82848. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82849. /**
  82850. * Load into an asset container.
  82851. * @param scene The scene to load into
  82852. * @param data The data to import
  82853. * @param rootUrl The root url for scene and resources
  82854. * @param onProgress The callback when the load progresses
  82855. * @param fileName Defines the name of the file to load
  82856. * @returns The loaded asset container
  82857. */
  82858. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82859. /**
  82860. * Read the OBJ file and create an Array of meshes.
  82861. * Each mesh contains all information given by the OBJ and the MTL file.
  82862. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  82863. *
  82864. * @param meshesNames
  82865. * @param scene Scene The scene where are displayed the data
  82866. * @param data String The content of the obj file
  82867. * @param rootUrl String The path to the folder
  82868. * @returns Array<AbstractMesh>
  82869. * @private
  82870. */
  82871. private _parseSolid;
  82872. }
  82873. }
  82874. declare module BABYLON {
  82875. /**
  82876. * STL file type loader.
  82877. * This is a babylon scene loader plugin.
  82878. */
  82879. export class STLFileLoader implements ISceneLoaderPlugin {
  82880. /** @hidden */
  82881. solidPattern: RegExp;
  82882. /** @hidden */
  82883. facetsPattern: RegExp;
  82884. /** @hidden */
  82885. normalPattern: RegExp;
  82886. /** @hidden */
  82887. vertexPattern: RegExp;
  82888. /**
  82889. * Defines the name of the plugin.
  82890. */
  82891. name: string;
  82892. /**
  82893. * Defines the extensions the stl loader is able to load.
  82894. * force data to come in as an ArrayBuffer
  82895. * we'll convert to string if it looks like it's an ASCII .stl
  82896. */
  82897. extensions: ISceneLoaderPluginExtensions;
  82898. /**
  82899. * Import meshes into a scene.
  82900. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  82901. * @param scene The scene to import into
  82902. * @param data The data to import
  82903. * @param rootUrl The root url for scene and resources
  82904. * @param meshes The meshes array to import into
  82905. * @param particleSystems The particle systems array to import into
  82906. * @param skeletons The skeletons array to import into
  82907. * @param onError The callback when import fails
  82908. * @returns True if successful or false otherwise
  82909. */
  82910. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  82911. /**
  82912. * Load into a scene.
  82913. * @param scene The scene to load into
  82914. * @param data The data to import
  82915. * @param rootUrl The root url for scene and resources
  82916. * @param onError The callback when import fails
  82917. * @returns true if successful or false otherwise
  82918. */
  82919. load(scene: Scene, data: any, rootUrl: string): boolean;
  82920. /**
  82921. * Load into an asset container.
  82922. * @param scene The scene to load into
  82923. * @param data The data to import
  82924. * @param rootUrl The root url for scene and resources
  82925. * @param onError The callback when import fails
  82926. * @returns The loaded asset container
  82927. */
  82928. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  82929. private _isBinary;
  82930. private _parseBinary;
  82931. private _parseASCII;
  82932. }
  82933. }
  82934. declare module BABYLON {
  82935. /**
  82936. * Class for generating OBJ data from a Babylon scene.
  82937. */
  82938. export class OBJExport {
  82939. /**
  82940. * Exports the geometry of a Mesh array in .OBJ file format (text)
  82941. * @param mesh defines the list of meshes to serialize
  82942. * @param materials defines if materials should be exported
  82943. * @param matlibname defines the name of the associated mtl file
  82944. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  82945. * @returns the OBJ content
  82946. */
  82947. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  82948. /**
  82949. * Exports the material(s) of a mesh in .MTL file format (text)
  82950. * @param mesh defines the mesh to extract the material from
  82951. * @returns the mtl content
  82952. */
  82953. static MTL(mesh: Mesh): string;
  82954. }
  82955. }
  82956. declare module BABYLON {
  82957. /** @hidden */
  82958. export var __IGLTFExporterExtension: number;
  82959. /**
  82960. * Interface for extending the exporter
  82961. * @hidden
  82962. */
  82963. export interface IGLTFExporterExtension {
  82964. /**
  82965. * The name of this extension
  82966. */
  82967. readonly name: string;
  82968. /**
  82969. * Defines whether this extension is enabled
  82970. */
  82971. enabled: boolean;
  82972. /**
  82973. * Defines whether this extension is required
  82974. */
  82975. required: boolean;
  82976. }
  82977. }
  82978. declare module BABYLON.GLTF2.Exporter {
  82979. /** @hidden */
  82980. export var __IGLTFExporterExtensionV2: number;
  82981. /**
  82982. * Interface for a glTF exporter extension
  82983. * @hidden
  82984. */
  82985. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  82986. /**
  82987. * Define this method to modify the default behavior before exporting a texture
  82988. * @param context The context when loading the asset
  82989. * @param babylonTexture The Babylon.js texture
  82990. * @param mimeType The mime-type of the generated image
  82991. * @returns A promise that resolves with the exported texture
  82992. */
  82993. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  82994. /**
  82995. * Define this method to get notified when a texture info is created
  82996. * @param context The context when loading the asset
  82997. * @param textureInfo The glTF texture info
  82998. * @param babylonTexture The Babylon.js texture
  82999. */
  83000. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83001. /**
  83002. * Define this method to modify the default behavior when exporting texture info
  83003. * @param context The context when loading the asset
  83004. * @param meshPrimitive glTF mesh primitive
  83005. * @param babylonSubMesh Babylon submesh
  83006. * @param binaryWriter glTF serializer binary writer instance
  83007. * @returns nullable IMeshPrimitive promise
  83008. */
  83009. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  83010. /**
  83011. * Define this method to modify the default behavior when exporting a node
  83012. * @param context The context when exporting the node
  83013. * @param node glTF node
  83014. * @param babylonNode BabylonJS node
  83015. * @returns nullable INode promise
  83016. */
  83017. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83018. [key: number]: number;
  83019. }): Promise<Nullable<INode>>;
  83020. /**
  83021. * Define this method to modify the default behavior when exporting a material
  83022. * @param material glTF material
  83023. * @param babylonMaterial BabylonJS material
  83024. * @returns nullable IMaterial promise
  83025. */
  83026. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  83027. /**
  83028. * Define this method to return additional textures to export from a material
  83029. * @param material glTF material
  83030. * @param babylonMaterial BabylonJS material
  83031. * @returns List of textures
  83032. */
  83033. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83034. /** Gets a boolean indicating that this extension was used */
  83035. wasUsed: boolean;
  83036. /** Gets a boolean indicating that this extension is required for the file to work */
  83037. required: boolean;
  83038. /**
  83039. * Called after the exporter state changes to EXPORTING
  83040. */
  83041. onExporting?(): void;
  83042. }
  83043. }
  83044. declare module BABYLON.GLTF2.Exporter {
  83045. /**
  83046. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  83047. * @hidden
  83048. */
  83049. export class _GLTFMaterialExporter {
  83050. /**
  83051. * Represents the dielectric specular values for R, G and B
  83052. */
  83053. private static readonly _DielectricSpecular;
  83054. /**
  83055. * Allows the maximum specular power to be defined for material calculations
  83056. */
  83057. private static readonly _MaxSpecularPower;
  83058. /**
  83059. * Mapping to store textures
  83060. */
  83061. private _textureMap;
  83062. /**
  83063. * Numeric tolerance value
  83064. */
  83065. private static readonly _Epsilon;
  83066. /**
  83067. * Reference to the glTF Exporter
  83068. */
  83069. private _exporter;
  83070. constructor(exporter: _Exporter);
  83071. /**
  83072. * Specifies if two colors are approximately equal in value
  83073. * @param color1 first color to compare to
  83074. * @param color2 second color to compare to
  83075. * @param epsilon threshold value
  83076. */
  83077. private static FuzzyEquals;
  83078. /**
  83079. * Gets the materials from a Babylon scene and converts them to glTF materials
  83080. * @param scene babylonjs scene
  83081. * @param mimeType texture mime type
  83082. * @param images array of images
  83083. * @param textures array of textures
  83084. * @param materials array of materials
  83085. * @param imageData mapping of texture names to base64 textures
  83086. * @param hasTextureCoords specifies if texture coordinates are present on the material
  83087. */
  83088. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  83089. /**
  83090. * Makes a copy of the glTF material without the texture parameters
  83091. * @param originalMaterial original glTF material
  83092. * @returns glTF material without texture parameters
  83093. */
  83094. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  83095. /**
  83096. * Specifies if the material has any texture parameters present
  83097. * @param material glTF Material
  83098. * @returns boolean specifying if texture parameters are present
  83099. */
  83100. _hasTexturesPresent(material: IMaterial): boolean;
  83101. /**
  83102. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  83103. * @param babylonStandardMaterial
  83104. * @returns glTF Metallic Roughness Material representation
  83105. */
  83106. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  83107. /**
  83108. * Computes the metallic factor
  83109. * @param diffuse diffused value
  83110. * @param specular specular value
  83111. * @param oneMinusSpecularStrength one minus the specular strength
  83112. * @returns metallic value
  83113. */
  83114. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  83115. /**
  83116. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  83117. * @param glTFMaterial glTF material
  83118. * @param babylonMaterial Babylon material
  83119. */
  83120. private static _SetAlphaMode;
  83121. /**
  83122. * Converts a Babylon Standard Material to a glTF Material
  83123. * @param babylonStandardMaterial BJS Standard Material
  83124. * @param mimeType mime type to use for the textures
  83125. * @param images array of glTF image interfaces
  83126. * @param textures array of glTF texture interfaces
  83127. * @param materials array of glTF material interfaces
  83128. * @param imageData map of image file name to data
  83129. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83130. */
  83131. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83132. private _finishMaterial;
  83133. /**
  83134. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83135. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  83136. * @param mimeType mime type to use for the textures
  83137. * @param images array of glTF image interfaces
  83138. * @param textures array of glTF texture interfaces
  83139. * @param materials array of glTF material interfaces
  83140. * @param imageData map of image file name to data
  83141. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83142. */
  83143. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83144. /**
  83145. * Converts an image typed array buffer to a base64 image
  83146. * @param buffer typed array buffer
  83147. * @param width width of the image
  83148. * @param height height of the image
  83149. * @param mimeType mimetype of the image
  83150. * @returns base64 image string
  83151. */
  83152. private _createBase64FromCanvasAsync;
  83153. /**
  83154. * Generates a white texture based on the specified width and height
  83155. * @param width width of the texture in pixels
  83156. * @param height height of the texture in pixels
  83157. * @param scene babylonjs scene
  83158. * @returns white texture
  83159. */
  83160. private _createWhiteTexture;
  83161. /**
  83162. * 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
  83163. * @param texture1 first texture to resize
  83164. * @param texture2 second texture to resize
  83165. * @param scene babylonjs scene
  83166. * @returns resized textures or null
  83167. */
  83168. private _resizeTexturesToSameDimensions;
  83169. /**
  83170. * Converts an array of pixels to a Float32Array
  83171. * Throws an error if the pixel format is not supported
  83172. * @param pixels - array buffer containing pixel values
  83173. * @returns Float32 of pixels
  83174. */
  83175. private _convertPixelArrayToFloat32;
  83176. /**
  83177. * Convert Specular Glossiness Textures to Metallic Roughness
  83178. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  83179. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  83180. * @param diffuseTexture texture used to store diffuse information
  83181. * @param specularGlossinessTexture texture used to store specular and glossiness information
  83182. * @param factors specular glossiness material factors
  83183. * @param mimeType the mime type to use for the texture
  83184. * @returns pbr metallic roughness interface or null
  83185. */
  83186. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  83187. /**
  83188. * Converts specular glossiness material properties to metallic roughness
  83189. * @param specularGlossiness interface with specular glossiness material properties
  83190. * @returns interface with metallic roughness material properties
  83191. */
  83192. private _convertSpecularGlossinessToMetallicRoughness;
  83193. /**
  83194. * Calculates the surface reflectance, independent of lighting conditions
  83195. * @param color Color source to calculate brightness from
  83196. * @returns number representing the perceived brightness, or zero if color is undefined
  83197. */
  83198. private _getPerceivedBrightness;
  83199. /**
  83200. * Returns the maximum color component value
  83201. * @param color
  83202. * @returns maximum color component value, or zero if color is null or undefined
  83203. */
  83204. private _getMaxComponent;
  83205. /**
  83206. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  83207. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83208. * @param mimeType mime type to use for the textures
  83209. * @param images array of glTF image interfaces
  83210. * @param textures array of glTF texture interfaces
  83211. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83212. * @param imageData map of image file name to data
  83213. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83214. * @returns glTF PBR Metallic Roughness factors
  83215. */
  83216. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  83217. private _getGLTFTextureSampler;
  83218. private _getGLTFTextureWrapMode;
  83219. private _getGLTFTextureWrapModesSampler;
  83220. /**
  83221. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  83222. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83223. * @param mimeType mime type to use for the textures
  83224. * @param images array of glTF image interfaces
  83225. * @param textures array of glTF texture interfaces
  83226. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83227. * @param imageData map of image file name to data
  83228. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83229. * @returns glTF PBR Metallic Roughness factors
  83230. */
  83231. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  83232. /**
  83233. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83234. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83235. * @param mimeType mime type to use for the textures
  83236. * @param images array of glTF image interfaces
  83237. * @param textures array of glTF texture interfaces
  83238. * @param materials array of glTF material interfaces
  83239. * @param imageData map of image file name to data
  83240. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83241. */
  83242. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83243. private setMetallicRoughnessPbrMaterial;
  83244. private getPixelsFromTexture;
  83245. /**
  83246. * Extracts a texture from a Babylon texture into file data and glTF data
  83247. * @param babylonTexture Babylon texture to extract
  83248. * @param mimeType Mime Type of the babylonTexture
  83249. * @return glTF texture info, or null if the texture format is not supported
  83250. */
  83251. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83252. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83253. /**
  83254. * Builds a texture from base64 string
  83255. * @param base64Texture base64 texture string
  83256. * @param baseTextureName Name to use for the texture
  83257. * @param mimeType image mime type for the texture
  83258. * @param images array of images
  83259. * @param textures array of textures
  83260. * @param imageData map of image data
  83261. * @returns glTF texture info, or null if the texture format is not supported
  83262. */
  83263. private _getTextureInfoFromBase64;
  83264. }
  83265. }
  83266. declare module BABYLON {
  83267. /**
  83268. * Class for holding and downloading glTF file data
  83269. */
  83270. export class GLTFData {
  83271. /**
  83272. * Object which contains the file name as the key and its data as the value
  83273. */
  83274. glTFFiles: {
  83275. [fileName: string]: string | Blob;
  83276. };
  83277. /**
  83278. * Initializes the glTF file object
  83279. */
  83280. constructor();
  83281. /**
  83282. * Downloads the glTF data as files based on their names and data
  83283. */
  83284. downloadFiles(): void;
  83285. }
  83286. }
  83287. declare module BABYLON {
  83288. /**
  83289. * Holds a collection of exporter options and parameters
  83290. */
  83291. export interface IExportOptions {
  83292. /**
  83293. * Function which indicates whether a babylon node should be exported or not
  83294. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  83295. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  83296. */
  83297. shouldExportNode?(node: Node): boolean;
  83298. /**
  83299. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  83300. * @param metadata source metadata to read from
  83301. * @returns the data to store to glTF node extras
  83302. */
  83303. metadataSelector?(metadata: any): any;
  83304. /**
  83305. * The sample rate to bake animation curves
  83306. */
  83307. animationSampleRate?: number;
  83308. /**
  83309. * Begin serialization without waiting for the scene to be ready
  83310. */
  83311. exportWithoutWaitingForScene?: boolean;
  83312. /**
  83313. * Indicates if coordinate system swapping root nodes should be included in export
  83314. */
  83315. includeCoordinateSystemConversionNodes?: boolean;
  83316. }
  83317. /**
  83318. * Class for generating glTF data from a Babylon scene.
  83319. */
  83320. export class GLTF2Export {
  83321. /**
  83322. * Exports the geometry of the scene to .gltf file format asynchronously
  83323. * @param scene Babylon scene with scene hierarchy information
  83324. * @param filePrefix File prefix to use when generating the glTF file
  83325. * @param options Exporter options
  83326. * @returns Returns an object with a .gltf file and associates texture names
  83327. * as keys and their data and paths as values
  83328. */
  83329. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83330. private static _PreExportAsync;
  83331. private static _PostExportAsync;
  83332. /**
  83333. * Exports the geometry of the scene to .glb file format asychronously
  83334. * @param scene Babylon scene with scene hierarchy information
  83335. * @param filePrefix File prefix to use when generating glb file
  83336. * @param options Exporter options
  83337. * @returns Returns an object with a .glb filename as key and data as value
  83338. */
  83339. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83340. }
  83341. }
  83342. declare module BABYLON.GLTF2.Exporter {
  83343. /**
  83344. * @hidden
  83345. */
  83346. export class _GLTFUtilities {
  83347. /**
  83348. * Creates a buffer view based on the supplied arguments
  83349. * @param bufferIndex index value of the specified buffer
  83350. * @param byteOffset byte offset value
  83351. * @param byteLength byte length of the bufferView
  83352. * @param byteStride byte distance between conequential elements
  83353. * @param name name of the buffer view
  83354. * @returns bufferView for glTF
  83355. */
  83356. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  83357. /**
  83358. * Creates an accessor based on the supplied arguments
  83359. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  83360. * @param name The name of the accessor
  83361. * @param type The type of the accessor
  83362. * @param componentType The datatype of components in the attribute
  83363. * @param count The number of attributes referenced by this accessor
  83364. * @param byteOffset The offset relative to the start of the bufferView in bytes
  83365. * @param min Minimum value of each component in this attribute
  83366. * @param max Maximum value of each component in this attribute
  83367. * @returns accessor for glTF
  83368. */
  83369. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  83370. /**
  83371. * Calculates the minimum and maximum values of an array of position floats
  83372. * @param positions Positions array of a mesh
  83373. * @param vertexStart Starting vertex offset to calculate min and max values
  83374. * @param vertexCount Number of vertices to check for min and max values
  83375. * @returns min number array and max number array
  83376. */
  83377. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  83378. min: number[];
  83379. max: number[];
  83380. };
  83381. /**
  83382. * Converts a new right-handed Vector3
  83383. * @param vector vector3 array
  83384. * @returns right-handed Vector3
  83385. */
  83386. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  83387. /**
  83388. * Converts a Vector3 to right-handed
  83389. * @param vector Vector3 to convert to right-handed
  83390. */
  83391. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  83392. /**
  83393. * Converts a three element number array to right-handed
  83394. * @param vector number array to convert to right-handed
  83395. */
  83396. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  83397. /**
  83398. * Converts a new right-handed Vector3
  83399. * @param vector vector3 array
  83400. * @returns right-handed Vector3
  83401. */
  83402. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  83403. /**
  83404. * Converts a Vector3 to right-handed
  83405. * @param vector Vector3 to convert to right-handed
  83406. */
  83407. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  83408. /**
  83409. * Converts a three element number array to right-handed
  83410. * @param vector number array to convert to right-handed
  83411. */
  83412. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  83413. /**
  83414. * Converts a Vector4 to right-handed
  83415. * @param vector Vector4 to convert to right-handed
  83416. */
  83417. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  83418. /**
  83419. * Converts a Vector4 to right-handed
  83420. * @param vector Vector4 to convert to right-handed
  83421. */
  83422. static _GetRightHandedArray4FromRef(vector: number[]): void;
  83423. /**
  83424. * Converts a Quaternion to right-handed
  83425. * @param quaternion Source quaternion to convert to right-handed
  83426. */
  83427. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  83428. /**
  83429. * Converts a Quaternion to right-handed
  83430. * @param quaternion Source quaternion to convert to right-handed
  83431. */
  83432. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  83433. static _NormalizeTangentFromRef(tangent: Vector4): void;
  83434. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  83435. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  83436. }
  83437. }
  83438. declare module BABYLON.GLTF2.Exporter {
  83439. /**
  83440. * Converts Babylon Scene into glTF 2.0.
  83441. * @hidden
  83442. */
  83443. export class _Exporter {
  83444. /**
  83445. * Stores the glTF to export
  83446. */
  83447. _glTF: IGLTF;
  83448. /**
  83449. * Stores all generated buffer views, which represents views into the main glTF buffer data
  83450. */
  83451. _bufferViews: IBufferView[];
  83452. /**
  83453. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  83454. */
  83455. _accessors: IAccessor[];
  83456. /**
  83457. * Stores all the generated nodes, which contains transform and/or mesh information per node
  83458. */
  83459. _nodes: INode[];
  83460. /**
  83461. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  83462. */
  83463. private _scenes;
  83464. /**
  83465. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  83466. */
  83467. private _meshes;
  83468. /**
  83469. * Stores all the generated material information, which represents the appearance of each primitive
  83470. */
  83471. _materials: IMaterial[];
  83472. _materialMap: {
  83473. [materialID: number]: number;
  83474. };
  83475. /**
  83476. * Stores all the generated texture information, which is referenced by glTF materials
  83477. */
  83478. _textures: ITexture[];
  83479. /**
  83480. * Stores all the generated image information, which is referenced by glTF textures
  83481. */
  83482. _images: IImage[];
  83483. /**
  83484. * Stores all the texture samplers
  83485. */
  83486. _samplers: ISampler[];
  83487. /**
  83488. * Stores all the generated glTF skins
  83489. */
  83490. _skins: ISkin[];
  83491. /**
  83492. * Stores all the generated animation samplers, which is referenced by glTF animations
  83493. */
  83494. /**
  83495. * Stores the animations for glTF models
  83496. */
  83497. private _animations;
  83498. /**
  83499. * Stores the total amount of bytes stored in the glTF buffer
  83500. */
  83501. private _totalByteLength;
  83502. /**
  83503. * Stores a reference to the Babylon scene containing the source geometry and material information
  83504. */
  83505. _babylonScene: Scene;
  83506. /**
  83507. * Stores a map of the image data, where the key is the file name and the value
  83508. * is the image data
  83509. */
  83510. _imageData: {
  83511. [fileName: string]: {
  83512. data: Uint8Array;
  83513. mimeType: ImageMimeType;
  83514. };
  83515. };
  83516. protected _orderedImageData: Array<{
  83517. data: Uint8Array;
  83518. mimeType: ImageMimeType;
  83519. }>;
  83520. /**
  83521. * Stores a map of the unique id of a node to its index in the node array
  83522. */
  83523. _nodeMap: {
  83524. [key: number]: number;
  83525. };
  83526. /**
  83527. * Specifies if the source Babylon scene was left handed, and needed conversion.
  83528. */
  83529. _convertToRightHandedSystem: boolean;
  83530. /**
  83531. * Specifies if a Babylon node should be converted to right-handed on export
  83532. */
  83533. _convertToRightHandedSystemMap: {
  83534. [nodeId: number]: boolean;
  83535. };
  83536. _includeCoordinateSystemConversionNodes: boolean;
  83537. /**
  83538. * Baked animation sample rate
  83539. */
  83540. private _animationSampleRate;
  83541. private _options;
  83542. private _localEngine;
  83543. _glTFMaterialExporter: _GLTFMaterialExporter;
  83544. private _extensions;
  83545. private static _ExtensionNames;
  83546. private static _ExtensionFactories;
  83547. private _applyExtension;
  83548. private _applyExtensions;
  83549. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  83550. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  83551. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83552. [key: number]: number;
  83553. }): Promise<Nullable<INode>>;
  83554. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  83555. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  83556. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83557. private _forEachExtensions;
  83558. private _extensionsOnExporting;
  83559. /**
  83560. * Load glTF serializer extensions
  83561. */
  83562. private _loadExtensions;
  83563. /**
  83564. * Creates a glTF Exporter instance, which can accept optional exporter options
  83565. * @param babylonScene Babylon scene object
  83566. * @param options Options to modify the behavior of the exporter
  83567. */
  83568. constructor(babylonScene: Scene, options?: IExportOptions);
  83569. dispose(): void;
  83570. /**
  83571. * Registers a glTF exporter extension
  83572. * @param name Name of the extension to export
  83573. * @param factory The factory function that creates the exporter extension
  83574. */
  83575. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  83576. /**
  83577. * Un-registers an exporter extension
  83578. * @param name The name fo the exporter extension
  83579. * @returns A boolean indicating whether the extension has been un-registered
  83580. */
  83581. static UnregisterExtension(name: string): boolean;
  83582. /**
  83583. * Lazy load a local engine
  83584. */
  83585. _getLocalEngine(): Engine;
  83586. private reorderIndicesBasedOnPrimitiveMode;
  83587. /**
  83588. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  83589. * clock-wise during export to glTF
  83590. * @param submesh BabylonJS submesh
  83591. * @param primitiveMode Primitive mode of the mesh
  83592. * @param sideOrientation the winding order of the submesh
  83593. * @param vertexBufferKind The type of vertex attribute
  83594. * @param meshAttributeArray The vertex attribute data
  83595. * @param byteOffset The offset to the binary data
  83596. * @param binaryWriter The binary data for the glTF file
  83597. * @param convertToRightHandedSystem Converts the values to right-handed
  83598. */
  83599. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  83600. /**
  83601. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  83602. * clock-wise during export to glTF
  83603. * @param submesh BabylonJS submesh
  83604. * @param primitiveMode Primitive mode of the mesh
  83605. * @param sideOrientation the winding order of the submesh
  83606. * @param vertexBufferKind The type of vertex attribute
  83607. * @param meshAttributeArray The vertex attribute data
  83608. * @param byteOffset The offset to the binary data
  83609. * @param binaryWriter The binary data for the glTF file
  83610. * @param convertToRightHandedSystem Converts the values to right-handed
  83611. */
  83612. private reorderTriangleFillMode;
  83613. /**
  83614. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  83615. * clock-wise during export to glTF
  83616. * @param submesh BabylonJS submesh
  83617. * @param primitiveMode Primitive mode of the mesh
  83618. * @param sideOrientation the winding order of the submesh
  83619. * @param vertexBufferKind The type of vertex attribute
  83620. * @param meshAttributeArray The vertex attribute data
  83621. * @param byteOffset The offset to the binary data
  83622. * @param binaryWriter The binary data for the glTF file
  83623. * @param convertToRightHandedSystem Converts the values to right-handed
  83624. */
  83625. private reorderTriangleStripDrawMode;
  83626. /**
  83627. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  83628. * clock-wise during export to glTF
  83629. * @param submesh BabylonJS submesh
  83630. * @param primitiveMode Primitive mode of the mesh
  83631. * @param sideOrientation the winding order of the submesh
  83632. * @param vertexBufferKind The type of vertex attribute
  83633. * @param meshAttributeArray The vertex attribute data
  83634. * @param byteOffset The offset to the binary data
  83635. * @param binaryWriter The binary data for the glTF file
  83636. * @param convertToRightHandedSystem Converts the values to right-handed
  83637. */
  83638. private reorderTriangleFanMode;
  83639. /**
  83640. * Writes the vertex attribute data to binary
  83641. * @param vertices The vertices to write to the binary writer
  83642. * @param byteOffset The offset into the binary writer to overwrite binary data
  83643. * @param vertexAttributeKind The vertex attribute type
  83644. * @param meshAttributeArray The vertex attribute data
  83645. * @param binaryWriter The writer containing the binary data
  83646. * @param convertToRightHandedSystem Converts the values to right-handed
  83647. */
  83648. private writeVertexAttributeData;
  83649. /**
  83650. * Writes mesh attribute data to a data buffer
  83651. * Returns the bytelength of the data
  83652. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  83653. * @param meshAttributeArray Array containing the attribute data
  83654. * @param byteStride Specifies the space between data
  83655. * @param binaryWriter The buffer to write the binary data to
  83656. * @param convertToRightHandedSystem Converts the values to right-handed
  83657. */
  83658. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  83659. /**
  83660. * Writes mesh attribute data to a data buffer
  83661. * Returns the bytelength of the data
  83662. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  83663. * @param meshAttributeArray Array containing the attribute data
  83664. * @param byteStride Specifies the space between data
  83665. * @param binaryWriter The buffer to write the binary data to
  83666. * @param convertToRightHandedSystem Converts the values to right-handed
  83667. */
  83668. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  83669. /**
  83670. * Generates glTF json data
  83671. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  83672. * @param glTFPrefix Text to use when prefixing a glTF file
  83673. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  83674. * @returns json data as string
  83675. */
  83676. private generateJSON;
  83677. /**
  83678. * Generates data for .gltf and .bin files based on the glTF prefix string
  83679. * @param glTFPrefix Text to use when prefixing a glTF file
  83680. * @param dispose Dispose the exporter
  83681. * @returns GLTFData with glTF file data
  83682. */
  83683. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83684. /**
  83685. * Creates a binary buffer for glTF
  83686. * @returns array buffer for binary data
  83687. */
  83688. private _generateBinaryAsync;
  83689. /**
  83690. * Pads the number to a multiple of 4
  83691. * @param num number to pad
  83692. * @returns padded number
  83693. */
  83694. private _getPadding;
  83695. /**
  83696. * @hidden
  83697. */
  83698. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83699. /**
  83700. * Sets the TRS for each node
  83701. * @param node glTF Node for storing the transformation data
  83702. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  83703. * @param convertToRightHandedSystem Converts the values to right-handed
  83704. */
  83705. private setNodeTransformation;
  83706. private getVertexBufferFromMesh;
  83707. /**
  83708. * Creates a bufferview based on the vertices type for the Babylon mesh
  83709. * @param kind Indicates the type of vertices data
  83710. * @param componentType Indicates the numerical type used to store the data
  83711. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  83712. * @param binaryWriter The buffer to write the bufferview data to
  83713. * @param convertToRightHandedSystem Converts the values to right-handed
  83714. */
  83715. private createBufferViewKind;
  83716. /**
  83717. * Creates a bufferview based on the vertices type for the Babylon mesh
  83718. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  83719. * @param babylonMorphTarget the morph target to be exported
  83720. * @param binaryWriter The buffer to write the bufferview data to
  83721. * @param convertToRightHandedSystem Converts the values to right-handed
  83722. */
  83723. private setMorphTargetAttributes;
  83724. /**
  83725. * The primitive mode of the Babylon mesh
  83726. * @param babylonMesh The BabylonJS mesh
  83727. */
  83728. private getMeshPrimitiveMode;
  83729. /**
  83730. * Sets the primitive mode of the glTF mesh primitive
  83731. * @param meshPrimitive glTF mesh primitive
  83732. * @param primitiveMode The primitive mode
  83733. */
  83734. private setPrimitiveMode;
  83735. /**
  83736. * Sets the vertex attribute accessor based of the glTF mesh primitive
  83737. * @param meshPrimitive glTF mesh primitive
  83738. * @param attributeKind vertex attribute
  83739. * @returns boolean specifying if uv coordinates are present
  83740. */
  83741. private setAttributeKind;
  83742. /**
  83743. * Sets data for the primitive attributes of each submesh
  83744. * @param mesh glTF Mesh object to store the primitive attribute information
  83745. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  83746. * @param binaryWriter Buffer to write the attribute data to
  83747. * @param convertToRightHandedSystem Converts the values to right-handed
  83748. */
  83749. private setPrimitiveAttributesAsync;
  83750. /**
  83751. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  83752. * @param node The node to check
  83753. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  83754. */
  83755. private isBabylonCoordinateSystemConvertingNode;
  83756. /**
  83757. * Creates a glTF scene based on the array of meshes
  83758. * Returns the the total byte offset
  83759. * @param babylonScene Babylon scene to get the mesh data from
  83760. * @param binaryWriter Buffer to write binary data to
  83761. */
  83762. private createSceneAsync;
  83763. /**
  83764. * Creates a mapping of Node unique id to node index and handles animations
  83765. * @param babylonScene Babylon Scene
  83766. * @param nodes Babylon transform nodes
  83767. * @param binaryWriter Buffer to write binary data to
  83768. * @returns Node mapping of unique id to index
  83769. */
  83770. private createNodeMapAndAnimationsAsync;
  83771. /**
  83772. * Creates a glTF node from a Babylon mesh
  83773. * @param babylonMesh Source Babylon mesh
  83774. * @param binaryWriter Buffer for storing geometry data
  83775. * @param convertToRightHandedSystem Converts the values to right-handed
  83776. * @param nodeMap Node mapping of unique id to glTF node index
  83777. * @returns glTF node
  83778. */
  83779. private createNodeAsync;
  83780. /**
  83781. * Creates a glTF skin from a Babylon skeleton
  83782. * @param babylonScene Babylon Scene
  83783. * @param nodes Babylon transform nodes
  83784. * @param binaryWriter Buffer to write binary data to
  83785. * @returns Node mapping of unique id to index
  83786. */
  83787. private createSkinsAsync;
  83788. }
  83789. /**
  83790. * @hidden
  83791. *
  83792. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  83793. */
  83794. export class _BinaryWriter {
  83795. /**
  83796. * Array buffer which stores all binary data
  83797. */
  83798. private _arrayBuffer;
  83799. /**
  83800. * View of the array buffer
  83801. */
  83802. private _dataView;
  83803. /**
  83804. * byte offset of data in array buffer
  83805. */
  83806. private _byteOffset;
  83807. /**
  83808. * Initialize binary writer with an initial byte length
  83809. * @param byteLength Initial byte length of the array buffer
  83810. */
  83811. constructor(byteLength: number);
  83812. /**
  83813. * Resize the array buffer to the specified byte length
  83814. * @param byteLength
  83815. */
  83816. private resizeBuffer;
  83817. /**
  83818. * Get an array buffer with the length of the byte offset
  83819. * @returns ArrayBuffer resized to the byte offset
  83820. */
  83821. getArrayBuffer(): ArrayBuffer;
  83822. /**
  83823. * Get the byte offset of the array buffer
  83824. * @returns byte offset
  83825. */
  83826. getByteOffset(): number;
  83827. /**
  83828. * Stores an UInt8 in the array buffer
  83829. * @param entry
  83830. * @param byteOffset If defined, specifies where to set the value as an offset.
  83831. */
  83832. setUInt8(entry: number, byteOffset?: number): void;
  83833. /**
  83834. * Stores an UInt16 in the array buffer
  83835. * @param entry
  83836. * @param byteOffset If defined, specifies where to set the value as an offset.
  83837. */
  83838. setUInt16(entry: number, byteOffset?: number): void;
  83839. /**
  83840. * Gets an UInt32 in the array buffer
  83841. * @param entry
  83842. * @param byteOffset If defined, specifies where to set the value as an offset.
  83843. */
  83844. getUInt32(byteOffset: number): number;
  83845. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83846. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83847. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83848. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83849. /**
  83850. * Stores a Float32 in the array buffer
  83851. * @param entry
  83852. */
  83853. setFloat32(entry: number, byteOffset?: number): void;
  83854. /**
  83855. * Stores an UInt32 in the array buffer
  83856. * @param entry
  83857. * @param byteOffset If defined, specifies where to set the value as an offset.
  83858. */
  83859. setUInt32(entry: number, byteOffset?: number): void;
  83860. }
  83861. }
  83862. declare module BABYLON.GLTF2.Exporter {
  83863. /**
  83864. * @hidden
  83865. * Interface to store animation data.
  83866. */
  83867. export interface _IAnimationData {
  83868. /**
  83869. * Keyframe data.
  83870. */
  83871. inputs: number[];
  83872. /**
  83873. * Value data.
  83874. */
  83875. outputs: number[][];
  83876. /**
  83877. * Animation interpolation data.
  83878. */
  83879. samplerInterpolation: AnimationSamplerInterpolation;
  83880. /**
  83881. * Minimum keyframe value.
  83882. */
  83883. inputsMin: number;
  83884. /**
  83885. * Maximum keyframe value.
  83886. */
  83887. inputsMax: number;
  83888. }
  83889. /**
  83890. * @hidden
  83891. */
  83892. export interface _IAnimationInfo {
  83893. /**
  83894. * The target channel for the animation
  83895. */
  83896. animationChannelTargetPath: AnimationChannelTargetPath;
  83897. /**
  83898. * The glTF accessor type for the data.
  83899. */
  83900. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  83901. /**
  83902. * Specifies if quaternions should be used.
  83903. */
  83904. useQuaternion: boolean;
  83905. }
  83906. /**
  83907. * @hidden
  83908. * Utility class for generating glTF animation data from BabylonJS.
  83909. */
  83910. export class _GLTFAnimation {
  83911. /**
  83912. * @ignore
  83913. *
  83914. * Creates glTF channel animation from BabylonJS animation.
  83915. * @param babylonTransformNode - BabylonJS mesh.
  83916. * @param animation - animation.
  83917. * @param animationChannelTargetPath - The target animation channel.
  83918. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  83919. * @param useQuaternion - Specifies if quaternions are used.
  83920. * @returns nullable IAnimationData
  83921. */
  83922. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  83923. private static _DeduceAnimationInfo;
  83924. /**
  83925. * @ignore
  83926. * Create node animations from the transform node animations
  83927. * @param babylonNode
  83928. * @param runtimeGLTFAnimation
  83929. * @param idleGLTFAnimations
  83930. * @param nodeMap
  83931. * @param nodes
  83932. * @param binaryWriter
  83933. * @param bufferViews
  83934. * @param accessors
  83935. * @param convertToRightHandedSystem
  83936. * @param animationSampleRate
  83937. */
  83938. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83939. [key: number]: number;
  83940. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83941. /**
  83942. * @ignore
  83943. * Create individual morph animations from the mesh's morph target animation tracks
  83944. * @param babylonNode
  83945. * @param runtimeGLTFAnimation
  83946. * @param idleGLTFAnimations
  83947. * @param nodeMap
  83948. * @param nodes
  83949. * @param binaryWriter
  83950. * @param bufferViews
  83951. * @param accessors
  83952. * @param convertToRightHandedSystem
  83953. * @param animationSampleRate
  83954. */
  83955. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83956. [key: number]: number;
  83957. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83958. /**
  83959. * @ignore
  83960. * Create node and morph animations from the animation groups
  83961. * @param babylonScene
  83962. * @param glTFAnimations
  83963. * @param nodeMap
  83964. * @param nodes
  83965. * @param binaryWriter
  83966. * @param bufferViews
  83967. * @param accessors
  83968. * @param convertToRightHandedSystemMap
  83969. * @param animationSampleRate
  83970. */
  83971. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  83972. [key: number]: number;
  83973. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  83974. [nodeId: number]: boolean;
  83975. }, animationSampleRate: number): void;
  83976. private static AddAnimation;
  83977. /**
  83978. * Create a baked animation
  83979. * @param babylonTransformNode BabylonJS mesh
  83980. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  83981. * @param animationChannelTargetPath animation target channel
  83982. * @param minFrame minimum animation frame
  83983. * @param maxFrame maximum animation frame
  83984. * @param fps frames per second of the animation
  83985. * @param inputs input key frames of the animation
  83986. * @param outputs output key frame data of the animation
  83987. * @param convertToRightHandedSystem converts the values to right-handed
  83988. * @param useQuaternion specifies if quaternions should be used
  83989. */
  83990. private static _CreateBakedAnimation;
  83991. private static _ConvertFactorToVector3OrQuaternion;
  83992. private static _SetInterpolatedValue;
  83993. /**
  83994. * Creates linear animation from the animation key frames
  83995. * @param babylonTransformNode BabylonJS mesh
  83996. * @param animation BabylonJS animation
  83997. * @param animationChannelTargetPath The target animation channel
  83998. * @param frameDelta The difference between the last and first frame of the animation
  83999. * @param inputs Array to store the key frame times
  84000. * @param outputs Array to store the key frame data
  84001. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84002. * @param useQuaternion Specifies if quaternions are used in the animation
  84003. */
  84004. private static _CreateLinearOrStepAnimation;
  84005. /**
  84006. * Creates cubic spline animation from the animation key frames
  84007. * @param babylonTransformNode BabylonJS mesh
  84008. * @param animation BabylonJS animation
  84009. * @param animationChannelTargetPath The target animation channel
  84010. * @param frameDelta The difference between the last and first frame of the animation
  84011. * @param inputs Array to store the key frame times
  84012. * @param outputs Array to store the key frame data
  84013. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84014. * @param useQuaternion Specifies if quaternions are used in the animation
  84015. */
  84016. private static _CreateCubicSplineAnimation;
  84017. private static _GetBasePositionRotationOrScale;
  84018. /**
  84019. * Adds a key frame value
  84020. * @param keyFrame
  84021. * @param animation
  84022. * @param outputs
  84023. * @param animationChannelTargetPath
  84024. * @param basePositionRotationOrScale
  84025. * @param convertToRightHandedSystem
  84026. * @param useQuaternion
  84027. */
  84028. private static _AddKeyframeValue;
  84029. /**
  84030. * Determine the interpolation based on the key frames
  84031. * @param keyFrames
  84032. * @param animationChannelTargetPath
  84033. * @param useQuaternion
  84034. */
  84035. private static _DeduceInterpolation;
  84036. /**
  84037. * Adds an input tangent or output tangent to the output data
  84038. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  84039. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  84040. * @param outputs The animation data by keyframe
  84041. * @param animationChannelTargetPath The target animation channel
  84042. * @param interpolation The interpolation type
  84043. * @param keyFrame The key frame with the animation data
  84044. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  84045. * @param useQuaternion Specifies if quaternions are used
  84046. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  84047. */
  84048. private static AddSplineTangent;
  84049. /**
  84050. * Get the minimum and maximum key frames' frame values
  84051. * @param keyFrames animation key frames
  84052. * @returns the minimum and maximum key frame value
  84053. */
  84054. private static calculateMinMaxKeyFrames;
  84055. }
  84056. }
  84057. declare module BABYLON.GLTF2.Exporter {
  84058. /** @hidden */
  84059. export var textureTransformPixelShader: {
  84060. name: string;
  84061. shader: string;
  84062. };
  84063. }
  84064. declare module BABYLON.GLTF2.Exporter.Extensions {
  84065. /**
  84066. * @hidden
  84067. */
  84068. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  84069. private _recordedTextures;
  84070. /** Name of this extension */
  84071. readonly name: string;
  84072. /** Defines whether this extension is enabled */
  84073. enabled: boolean;
  84074. /** Defines whether this extension is required */
  84075. required: boolean;
  84076. /** Reference to the glTF exporter */
  84077. private _wasUsed;
  84078. constructor(exporter: _Exporter);
  84079. dispose(): void;
  84080. /** @hidden */
  84081. get wasUsed(): boolean;
  84082. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84083. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  84084. /**
  84085. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  84086. * @param babylonTexture
  84087. * @param offset
  84088. * @param rotation
  84089. * @param scale
  84090. * @param scene
  84091. */
  84092. private _textureTransformTextureAsync;
  84093. }
  84094. }
  84095. declare module BABYLON.GLTF2.Exporter.Extensions {
  84096. /**
  84097. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  84098. */
  84099. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  84100. /** The name of this extension. */
  84101. readonly name: string;
  84102. /** Defines whether this extension is enabled. */
  84103. enabled: boolean;
  84104. /** Defines whether this extension is required */
  84105. required: boolean;
  84106. /** Reference to the glTF exporter */
  84107. private _exporter;
  84108. private _lights;
  84109. /** @hidden */
  84110. constructor(exporter: _Exporter);
  84111. /** @hidden */
  84112. dispose(): void;
  84113. /** @hidden */
  84114. get wasUsed(): boolean;
  84115. /** @hidden */
  84116. onExporting(): void;
  84117. /**
  84118. * Define this method to modify the default behavior when exporting a node
  84119. * @param context The context when exporting the node
  84120. * @param node glTF node
  84121. * @param babylonNode BabylonJS node
  84122. * @param nodeMap Node mapping of unique id to glTF node index
  84123. * @returns nullable INode promise
  84124. */
  84125. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84126. [key: number]: number;
  84127. }): Promise<Nullable<INode>>;
  84128. }
  84129. }
  84130. declare module BABYLON.GLTF2.Exporter.Extensions {
  84131. /**
  84132. * @hidden
  84133. */
  84134. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  84135. /** Name of this extension */
  84136. readonly name: string;
  84137. /** Defines whether this extension is enabled */
  84138. enabled: boolean;
  84139. /** Defines whether this extension is required */
  84140. required: boolean;
  84141. /** Reference to the glTF exporter */
  84142. private _textureInfos;
  84143. private _exportedTextures;
  84144. private _wasUsed;
  84145. constructor(exporter: _Exporter);
  84146. dispose(): void;
  84147. /** @hidden */
  84148. get wasUsed(): boolean;
  84149. private _getTextureIndex;
  84150. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84151. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84152. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84153. }
  84154. }
  84155. declare module BABYLON.GLTF2.Exporter.Extensions {
  84156. /**
  84157. * @hidden
  84158. */
  84159. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  84160. /** Name of this extension */
  84161. readonly name: string;
  84162. /** Defines whether this extension is enabled */
  84163. enabled: boolean;
  84164. /** Defines whether this extension is required */
  84165. required: boolean;
  84166. private _wasUsed;
  84167. constructor(exporter: _Exporter);
  84168. /** @hidden */
  84169. get wasUsed(): boolean;
  84170. dispose(): void;
  84171. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84172. }
  84173. }
  84174. declare module BABYLON {
  84175. /**
  84176. * Class for generating STL data from a Babylon scene.
  84177. */
  84178. export class STLExport {
  84179. /**
  84180. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  84181. * @param meshes list defines the mesh to serialize
  84182. * @param download triggers the automatic download of the file.
  84183. * @param fileName changes the downloads fileName.
  84184. * @param binary changes the STL to a binary type.
  84185. * @param isLittleEndian toggle for binary type exporter.
  84186. * @returns the STL as UTF8 string
  84187. */
  84188. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  84189. }
  84190. }
  84191. declare module "babylonjs-gltf2interface" {
  84192. export = BABYLON.GLTF2;
  84193. }
  84194. /**
  84195. * Module for glTF 2.0 Interface
  84196. */
  84197. declare module BABYLON.GLTF2 {
  84198. /**
  84199. * The datatype of the components in the attribute
  84200. */
  84201. const enum AccessorComponentType {
  84202. /**
  84203. * Byte
  84204. */
  84205. BYTE = 5120,
  84206. /**
  84207. * Unsigned Byte
  84208. */
  84209. UNSIGNED_BYTE = 5121,
  84210. /**
  84211. * Short
  84212. */
  84213. SHORT = 5122,
  84214. /**
  84215. * Unsigned Short
  84216. */
  84217. UNSIGNED_SHORT = 5123,
  84218. /**
  84219. * Unsigned Int
  84220. */
  84221. UNSIGNED_INT = 5125,
  84222. /**
  84223. * Float
  84224. */
  84225. FLOAT = 5126,
  84226. }
  84227. /**
  84228. * Specifies if the attirbute is a scalar, vector, or matrix
  84229. */
  84230. const enum AccessorType {
  84231. /**
  84232. * Scalar
  84233. */
  84234. SCALAR = "SCALAR",
  84235. /**
  84236. * Vector2
  84237. */
  84238. VEC2 = "VEC2",
  84239. /**
  84240. * Vector3
  84241. */
  84242. VEC3 = "VEC3",
  84243. /**
  84244. * Vector4
  84245. */
  84246. VEC4 = "VEC4",
  84247. /**
  84248. * Matrix2x2
  84249. */
  84250. MAT2 = "MAT2",
  84251. /**
  84252. * Matrix3x3
  84253. */
  84254. MAT3 = "MAT3",
  84255. /**
  84256. * Matrix4x4
  84257. */
  84258. MAT4 = "MAT4",
  84259. }
  84260. /**
  84261. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84262. */
  84263. const enum AnimationChannelTargetPath {
  84264. /**
  84265. * Translation
  84266. */
  84267. TRANSLATION = "translation",
  84268. /**
  84269. * Rotation
  84270. */
  84271. ROTATION = "rotation",
  84272. /**
  84273. * Scale
  84274. */
  84275. SCALE = "scale",
  84276. /**
  84277. * Weights
  84278. */
  84279. WEIGHTS = "weights",
  84280. }
  84281. /**
  84282. * Interpolation algorithm
  84283. */
  84284. const enum AnimationSamplerInterpolation {
  84285. /**
  84286. * The animated values are linearly interpolated between keyframes
  84287. */
  84288. LINEAR = "LINEAR",
  84289. /**
  84290. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  84291. */
  84292. STEP = "STEP",
  84293. /**
  84294. * The animation's interpolation is computed using a cubic spline with specified tangents
  84295. */
  84296. CUBICSPLINE = "CUBICSPLINE",
  84297. }
  84298. /**
  84299. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84300. */
  84301. const enum CameraType {
  84302. /**
  84303. * A perspective camera containing properties to create a perspective projection matrix
  84304. */
  84305. PERSPECTIVE = "perspective",
  84306. /**
  84307. * An orthographic camera containing properties to create an orthographic projection matrix
  84308. */
  84309. ORTHOGRAPHIC = "orthographic",
  84310. }
  84311. /**
  84312. * The mime-type of the image
  84313. */
  84314. const enum ImageMimeType {
  84315. /**
  84316. * JPEG Mime-type
  84317. */
  84318. JPEG = "image/jpeg",
  84319. /**
  84320. * PNG Mime-type
  84321. */
  84322. PNG = "image/png",
  84323. }
  84324. /**
  84325. * The alpha rendering mode of the material
  84326. */
  84327. const enum MaterialAlphaMode {
  84328. /**
  84329. * The alpha value is ignored and the rendered output is fully opaque
  84330. */
  84331. OPAQUE = "OPAQUE",
  84332. /**
  84333. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  84334. */
  84335. MASK = "MASK",
  84336. /**
  84337. * 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)
  84338. */
  84339. BLEND = "BLEND",
  84340. }
  84341. /**
  84342. * The type of the primitives to render
  84343. */
  84344. const enum MeshPrimitiveMode {
  84345. /**
  84346. * Points
  84347. */
  84348. POINTS = 0,
  84349. /**
  84350. * Lines
  84351. */
  84352. LINES = 1,
  84353. /**
  84354. * Line Loop
  84355. */
  84356. LINE_LOOP = 2,
  84357. /**
  84358. * Line Strip
  84359. */
  84360. LINE_STRIP = 3,
  84361. /**
  84362. * Triangles
  84363. */
  84364. TRIANGLES = 4,
  84365. /**
  84366. * Triangle Strip
  84367. */
  84368. TRIANGLE_STRIP = 5,
  84369. /**
  84370. * Triangle Fan
  84371. */
  84372. TRIANGLE_FAN = 6,
  84373. }
  84374. /**
  84375. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84376. */
  84377. const enum TextureMagFilter {
  84378. /**
  84379. * Nearest
  84380. */
  84381. NEAREST = 9728,
  84382. /**
  84383. * Linear
  84384. */
  84385. LINEAR = 9729,
  84386. }
  84387. /**
  84388. * Minification filter. All valid values correspond to WebGL enums
  84389. */
  84390. const enum TextureMinFilter {
  84391. /**
  84392. * Nearest
  84393. */
  84394. NEAREST = 9728,
  84395. /**
  84396. * Linear
  84397. */
  84398. LINEAR = 9729,
  84399. /**
  84400. * Nearest Mip-Map Nearest
  84401. */
  84402. NEAREST_MIPMAP_NEAREST = 9984,
  84403. /**
  84404. * Linear Mipmap Nearest
  84405. */
  84406. LINEAR_MIPMAP_NEAREST = 9985,
  84407. /**
  84408. * Nearest Mipmap Linear
  84409. */
  84410. NEAREST_MIPMAP_LINEAR = 9986,
  84411. /**
  84412. * Linear Mipmap Linear
  84413. */
  84414. LINEAR_MIPMAP_LINEAR = 9987,
  84415. }
  84416. /**
  84417. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84418. */
  84419. const enum TextureWrapMode {
  84420. /**
  84421. * Clamp to Edge
  84422. */
  84423. CLAMP_TO_EDGE = 33071,
  84424. /**
  84425. * Mirrored Repeat
  84426. */
  84427. MIRRORED_REPEAT = 33648,
  84428. /**
  84429. * Repeat
  84430. */
  84431. REPEAT = 10497,
  84432. }
  84433. /**
  84434. * glTF Property
  84435. */
  84436. interface IProperty {
  84437. /**
  84438. * Dictionary object with extension-specific objects
  84439. */
  84440. extensions?: {
  84441. [key: string]: any;
  84442. };
  84443. /**
  84444. * Application-Specific data
  84445. */
  84446. extras?: any;
  84447. }
  84448. /**
  84449. * glTF Child of Root Property
  84450. */
  84451. interface IChildRootProperty extends IProperty {
  84452. /**
  84453. * The user-defined name of this object
  84454. */
  84455. name?: string;
  84456. }
  84457. /**
  84458. * Indices of those attributes that deviate from their initialization value
  84459. */
  84460. interface IAccessorSparseIndices extends IProperty {
  84461. /**
  84462. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84463. */
  84464. bufferView: number;
  84465. /**
  84466. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84467. */
  84468. byteOffset?: number;
  84469. /**
  84470. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  84471. */
  84472. componentType: AccessorComponentType;
  84473. }
  84474. /**
  84475. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  84476. */
  84477. interface IAccessorSparseValues extends IProperty {
  84478. /**
  84479. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84480. */
  84481. bufferView: number;
  84482. /**
  84483. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84484. */
  84485. byteOffset?: number;
  84486. }
  84487. /**
  84488. * Sparse storage of attributes that deviate from their initialization value
  84489. */
  84490. interface IAccessorSparse extends IProperty {
  84491. /**
  84492. * The number of attributes encoded in this sparse accessor
  84493. */
  84494. count: number;
  84495. /**
  84496. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  84497. */
  84498. indices: IAccessorSparseIndices;
  84499. /**
  84500. * 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
  84501. */
  84502. values: IAccessorSparseValues;
  84503. }
  84504. /**
  84505. * 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
  84506. */
  84507. interface IAccessor extends IChildRootProperty {
  84508. /**
  84509. * The index of the bufferview
  84510. */
  84511. bufferView?: number;
  84512. /**
  84513. * The offset relative to the start of the bufferView in bytes
  84514. */
  84515. byteOffset?: number;
  84516. /**
  84517. * The datatype of components in the attribute
  84518. */
  84519. componentType: AccessorComponentType;
  84520. /**
  84521. * Specifies whether integer data values should be normalized
  84522. */
  84523. normalized?: boolean;
  84524. /**
  84525. * The number of attributes referenced by this accessor
  84526. */
  84527. count: number;
  84528. /**
  84529. * Specifies if the attribute is a scalar, vector, or matrix
  84530. */
  84531. type: AccessorType;
  84532. /**
  84533. * Maximum value of each component in this attribute
  84534. */
  84535. max?: number[];
  84536. /**
  84537. * Minimum value of each component in this attribute
  84538. */
  84539. min?: number[];
  84540. /**
  84541. * Sparse storage of attributes that deviate from their initialization value
  84542. */
  84543. sparse?: IAccessorSparse;
  84544. }
  84545. /**
  84546. * Targets an animation's sampler at a node's property
  84547. */
  84548. interface IAnimationChannel extends IProperty {
  84549. /**
  84550. * The index of a sampler in this animation used to compute the value for the target
  84551. */
  84552. sampler: number;
  84553. /**
  84554. * The index of the node and TRS property to target
  84555. */
  84556. target: IAnimationChannelTarget;
  84557. }
  84558. /**
  84559. * The index of the node and TRS property that an animation channel targets
  84560. */
  84561. interface IAnimationChannelTarget extends IProperty {
  84562. /**
  84563. * The index of the node to target
  84564. */
  84565. node: number;
  84566. /**
  84567. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84568. */
  84569. path: AnimationChannelTargetPath;
  84570. }
  84571. /**
  84572. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84573. */
  84574. interface IAnimationSampler extends IProperty {
  84575. /**
  84576. * The index of an accessor containing keyframe input values, e.g., time
  84577. */
  84578. input: number;
  84579. /**
  84580. * Interpolation algorithm
  84581. */
  84582. interpolation?: AnimationSamplerInterpolation;
  84583. /**
  84584. * The index of an accessor, containing keyframe output values
  84585. */
  84586. output: number;
  84587. }
  84588. /**
  84589. * A keyframe animation
  84590. */
  84591. interface IAnimation extends IChildRootProperty {
  84592. /**
  84593. * An array of channels, each of which targets an animation's sampler at a node's property
  84594. */
  84595. channels: IAnimationChannel[];
  84596. /**
  84597. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84598. */
  84599. samplers: IAnimationSampler[];
  84600. }
  84601. /**
  84602. * Metadata about the glTF asset
  84603. */
  84604. interface IAsset extends IChildRootProperty {
  84605. /**
  84606. * A copyright message suitable for display to credit the content creator
  84607. */
  84608. copyright?: string;
  84609. /**
  84610. * Tool that generated this glTF model. Useful for debugging
  84611. */
  84612. generator?: string;
  84613. /**
  84614. * The glTF version that this asset targets
  84615. */
  84616. version: string;
  84617. /**
  84618. * The minimum glTF version that this asset targets
  84619. */
  84620. minVersion?: string;
  84621. }
  84622. /**
  84623. * A buffer points to binary geometry, animation, or skins
  84624. */
  84625. interface IBuffer extends IChildRootProperty {
  84626. /**
  84627. * 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
  84628. */
  84629. uri?: string;
  84630. /**
  84631. * The length of the buffer in bytes
  84632. */
  84633. byteLength: number;
  84634. }
  84635. /**
  84636. * A view into a buffer generally representing a subset of the buffer
  84637. */
  84638. interface IBufferView extends IChildRootProperty {
  84639. /**
  84640. * The index of the buffer
  84641. */
  84642. buffer: number;
  84643. /**
  84644. * The offset into the buffer in bytes
  84645. */
  84646. byteOffset?: number;
  84647. /**
  84648. * The lenth of the bufferView in bytes
  84649. */
  84650. byteLength: number;
  84651. /**
  84652. * The stride, in bytes
  84653. */
  84654. byteStride?: number;
  84655. }
  84656. /**
  84657. * An orthographic camera containing properties to create an orthographic projection matrix
  84658. */
  84659. interface ICameraOrthographic extends IProperty {
  84660. /**
  84661. * The floating-point horizontal magnification of the view. Must not be zero
  84662. */
  84663. xmag: number;
  84664. /**
  84665. * The floating-point vertical magnification of the view. Must not be zero
  84666. */
  84667. ymag: number;
  84668. /**
  84669. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  84670. */
  84671. zfar: number;
  84672. /**
  84673. * The floating-point distance to the near clipping plane
  84674. */
  84675. znear: number;
  84676. }
  84677. /**
  84678. * A perspective camera containing properties to create a perspective projection matrix
  84679. */
  84680. interface ICameraPerspective extends IProperty {
  84681. /**
  84682. * The floating-point aspect ratio of the field of view
  84683. */
  84684. aspectRatio?: number;
  84685. /**
  84686. * The floating-point vertical field of view in radians
  84687. */
  84688. yfov: number;
  84689. /**
  84690. * The floating-point distance to the far clipping plane
  84691. */
  84692. zfar?: number;
  84693. /**
  84694. * The floating-point distance to the near clipping plane
  84695. */
  84696. znear: number;
  84697. }
  84698. /**
  84699. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84700. */
  84701. interface ICamera extends IChildRootProperty {
  84702. /**
  84703. * An orthographic camera containing properties to create an orthographic projection matrix
  84704. */
  84705. orthographic?: ICameraOrthographic;
  84706. /**
  84707. * A perspective camera containing properties to create a perspective projection matrix
  84708. */
  84709. perspective?: ICameraPerspective;
  84710. /**
  84711. * Specifies if the camera uses a perspective or orthographic projection
  84712. */
  84713. type: CameraType;
  84714. }
  84715. /**
  84716. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  84717. */
  84718. interface IImage extends IChildRootProperty {
  84719. /**
  84720. * 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
  84721. */
  84722. uri?: string;
  84723. /**
  84724. * The image's MIME type
  84725. */
  84726. mimeType?: ImageMimeType;
  84727. /**
  84728. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  84729. */
  84730. bufferView?: number;
  84731. }
  84732. /**
  84733. * Material Normal Texture Info
  84734. */
  84735. interface IMaterialNormalTextureInfo extends ITextureInfo {
  84736. /**
  84737. * The scalar multiplier applied to each normal vector of the normal texture
  84738. */
  84739. scale?: number;
  84740. }
  84741. /**
  84742. * Material Occlusion Texture Info
  84743. */
  84744. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  84745. /**
  84746. * A scalar multiplier controlling the amount of occlusion applied
  84747. */
  84748. strength?: number;
  84749. }
  84750. /**
  84751. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  84752. */
  84753. interface IMaterialPbrMetallicRoughness {
  84754. /**
  84755. * The material's base color factor
  84756. */
  84757. baseColorFactor?: number[];
  84758. /**
  84759. * The base color texture
  84760. */
  84761. baseColorTexture?: ITextureInfo;
  84762. /**
  84763. * The metalness of the material
  84764. */
  84765. metallicFactor?: number;
  84766. /**
  84767. * The roughness of the material
  84768. */
  84769. roughnessFactor?: number;
  84770. /**
  84771. * The metallic-roughness texture
  84772. */
  84773. metallicRoughnessTexture?: ITextureInfo;
  84774. }
  84775. /**
  84776. * The material appearance of a primitive
  84777. */
  84778. interface IMaterial extends IChildRootProperty {
  84779. /**
  84780. * 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
  84781. */
  84782. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  84783. /**
  84784. * The normal map texture
  84785. */
  84786. normalTexture?: IMaterialNormalTextureInfo;
  84787. /**
  84788. * The occlusion map texture
  84789. */
  84790. occlusionTexture?: IMaterialOcclusionTextureInfo;
  84791. /**
  84792. * The emissive map texture
  84793. */
  84794. emissiveTexture?: ITextureInfo;
  84795. /**
  84796. * 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
  84797. */
  84798. emissiveFactor?: number[];
  84799. /**
  84800. * The alpha rendering mode of the material
  84801. */
  84802. alphaMode?: MaterialAlphaMode;
  84803. /**
  84804. * The alpha cutoff value of the material
  84805. */
  84806. alphaCutoff?: number;
  84807. /**
  84808. * Specifies whether the material is double sided
  84809. */
  84810. doubleSided?: boolean;
  84811. }
  84812. /**
  84813. * Geometry to be rendered with the given material
  84814. */
  84815. interface IMeshPrimitive extends IProperty {
  84816. /**
  84817. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  84818. */
  84819. attributes: {
  84820. [name: string]: number;
  84821. };
  84822. /**
  84823. * The index of the accessor that contains the indices
  84824. */
  84825. indices?: number;
  84826. /**
  84827. * The index of the material to apply to this primitive when rendering
  84828. */
  84829. material?: number;
  84830. /**
  84831. * The type of primitives to render. All valid values correspond to WebGL enums
  84832. */
  84833. mode?: MeshPrimitiveMode;
  84834. /**
  84835. * 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
  84836. */
  84837. targets?: {
  84838. [name: string]: number;
  84839. }[];
  84840. }
  84841. /**
  84842. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  84843. */
  84844. interface IMesh extends IChildRootProperty {
  84845. /**
  84846. * An array of primitives, each defining geometry to be rendered with a material
  84847. */
  84848. primitives: IMeshPrimitive[];
  84849. /**
  84850. * Array of weights to be applied to the Morph Targets
  84851. */
  84852. weights?: number[];
  84853. }
  84854. /**
  84855. * A node in the node hierarchy
  84856. */
  84857. interface INode extends IChildRootProperty {
  84858. /**
  84859. * The index of the camera referenced by this node
  84860. */
  84861. camera?: number;
  84862. /**
  84863. * The indices of this node's children
  84864. */
  84865. children?: number[];
  84866. /**
  84867. * The index of the skin referenced by this node
  84868. */
  84869. skin?: number;
  84870. /**
  84871. * A floating-point 4x4 transformation matrix stored in column-major order
  84872. */
  84873. matrix?: number[];
  84874. /**
  84875. * The index of the mesh in this node
  84876. */
  84877. mesh?: number;
  84878. /**
  84879. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  84880. */
  84881. rotation?: number[];
  84882. /**
  84883. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  84884. */
  84885. scale?: number[];
  84886. /**
  84887. * The node's translation along the x, y, and z axes
  84888. */
  84889. translation?: number[];
  84890. /**
  84891. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  84892. */
  84893. weights?: number[];
  84894. }
  84895. /**
  84896. * Texture sampler properties for filtering and wrapping modes
  84897. */
  84898. interface ISampler extends IChildRootProperty {
  84899. /**
  84900. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84901. */
  84902. magFilter?: TextureMagFilter;
  84903. /**
  84904. * Minification filter. All valid values correspond to WebGL enums
  84905. */
  84906. minFilter?: TextureMinFilter;
  84907. /**
  84908. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84909. */
  84910. wrapS?: TextureWrapMode;
  84911. /**
  84912. * T (V) wrapping mode. All valid values correspond to WebGL enums
  84913. */
  84914. wrapT?: TextureWrapMode;
  84915. }
  84916. /**
  84917. * The root nodes of a scene
  84918. */
  84919. interface IScene extends IChildRootProperty {
  84920. /**
  84921. * The indices of each root node
  84922. */
  84923. nodes: number[];
  84924. }
  84925. /**
  84926. * Joints and matrices defining a skin
  84927. */
  84928. interface ISkin extends IChildRootProperty {
  84929. /**
  84930. * 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
  84931. */
  84932. inverseBindMatrices?: number;
  84933. /**
  84934. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  84935. */
  84936. skeleton?: number;
  84937. /**
  84938. * 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)
  84939. */
  84940. joints: number[];
  84941. }
  84942. /**
  84943. * A texture and its sampler
  84944. */
  84945. interface ITexture extends IChildRootProperty {
  84946. /**
  84947. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  84948. */
  84949. sampler?: number;
  84950. /**
  84951. * The index of the image used by this texture
  84952. */
  84953. source: number;
  84954. }
  84955. /**
  84956. * Reference to a texture
  84957. */
  84958. interface ITextureInfo extends IProperty {
  84959. /**
  84960. * The index of the texture
  84961. */
  84962. index: number;
  84963. /**
  84964. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  84965. */
  84966. texCoord?: number;
  84967. }
  84968. /**
  84969. * The root object for a glTF asset
  84970. */
  84971. interface IGLTF extends IProperty {
  84972. /**
  84973. * An array of accessors. An accessor is a typed view into a bufferView
  84974. */
  84975. accessors?: IAccessor[];
  84976. /**
  84977. * An array of keyframe animations
  84978. */
  84979. animations?: IAnimation[];
  84980. /**
  84981. * Metadata about the glTF asset
  84982. */
  84983. asset: IAsset;
  84984. /**
  84985. * An array of buffers. A buffer points to binary geometry, animation, or skins
  84986. */
  84987. buffers?: IBuffer[];
  84988. /**
  84989. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  84990. */
  84991. bufferViews?: IBufferView[];
  84992. /**
  84993. * An array of cameras
  84994. */
  84995. cameras?: ICamera[];
  84996. /**
  84997. * Names of glTF extensions used somewhere in this asset
  84998. */
  84999. extensionsUsed?: string[];
  85000. /**
  85001. * Names of glTF extensions required to properly load this asset
  85002. */
  85003. extensionsRequired?: string[];
  85004. /**
  85005. * An array of images. An image defines data used to create a texture
  85006. */
  85007. images?: IImage[];
  85008. /**
  85009. * An array of materials. A material defines the appearance of a primitive
  85010. */
  85011. materials?: IMaterial[];
  85012. /**
  85013. * An array of meshes. A mesh is a set of primitives to be rendered
  85014. */
  85015. meshes?: IMesh[];
  85016. /**
  85017. * An array of nodes
  85018. */
  85019. nodes?: INode[];
  85020. /**
  85021. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  85022. */
  85023. samplers?: ISampler[];
  85024. /**
  85025. * The index of the default scene
  85026. */
  85027. scene?: number;
  85028. /**
  85029. * An array of scenes
  85030. */
  85031. scenes?: IScene[];
  85032. /**
  85033. * An array of skins. A skin is defined by joints and matrices
  85034. */
  85035. skins?: ISkin[];
  85036. /**
  85037. * An array of textures
  85038. */
  85039. textures?: ITexture[];
  85040. }
  85041. /**
  85042. * The glTF validation results
  85043. * @ignore
  85044. */
  85045. interface IGLTFValidationResults {
  85046. info: {
  85047. generator: string;
  85048. hasAnimations: boolean;
  85049. hasDefaultScene: boolean;
  85050. hasMaterials: boolean;
  85051. hasMorphTargets: boolean;
  85052. hasSkins: boolean;
  85053. hasTextures: boolean;
  85054. maxAttributesUsed: number;
  85055. primitivesCount: number
  85056. };
  85057. issues: {
  85058. messages: Array<string>;
  85059. numErrors: number;
  85060. numHints: number;
  85061. numInfos: number;
  85062. numWarnings: number;
  85063. truncated: boolean
  85064. };
  85065. mimeType: string;
  85066. uri: string;
  85067. validatedAt: string;
  85068. validatorVersion: string;
  85069. }
  85070. /**
  85071. * The glTF validation options
  85072. */
  85073. interface IGLTFValidationOptions {
  85074. /** Uri to use */
  85075. uri?: string;
  85076. /** Function used to load external resources */
  85077. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  85078. /** Boolean indicating that we need to validate accessor data */
  85079. validateAccessorData?: boolean;
  85080. /** max number of issues allowed */
  85081. maxIssues?: number;
  85082. /** Ignored issues */
  85083. ignoredIssues?: Array<string>;
  85084. /** Value to override severy settings */
  85085. severityOverrides?: Object;
  85086. }
  85087. /**
  85088. * The glTF validator object
  85089. * @ignore
  85090. */
  85091. interface IGLTFValidator {
  85092. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85093. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85094. }
  85095. /**
  85096. * Interfaces from the EXT_lights_image_based extension
  85097. */
  85098. /** @hidden */
  85099. interface IEXTLightsImageBased_LightReferenceImageBased {
  85100. light: number;
  85101. }
  85102. /** @hidden */
  85103. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  85104. intensity: number;
  85105. rotation: number[];
  85106. specularImageSize: number;
  85107. specularImages: number[][];
  85108. irradianceCoefficients: number[][];
  85109. }
  85110. /** @hidden */
  85111. interface IEXTLightsImageBased {
  85112. lights: IEXTLightsImageBased_LightImageBased[];
  85113. }
  85114. /**
  85115. * Interfaces from the EXT_mesh_gpu_instancing extension
  85116. * !!! Experimental Extension Subject to Changes !!!
  85117. */
  85118. /** @hidden */
  85119. interface IEXTMeshGpuInstancing {
  85120. mesh?: number;
  85121. attributes: { [name: string]: number };
  85122. }
  85123. /**
  85124. * Interfaces from the KHR_draco_mesh_compression extension
  85125. */
  85126. /** @hidden */
  85127. interface IKHRDracoMeshCompression {
  85128. bufferView: number;
  85129. attributes: { [name: string]: number };
  85130. }
  85131. /**
  85132. * Interfaces from the KHR_lights_punctual extension
  85133. */
  85134. /** @hidden */
  85135. const enum IKHRLightsPunctual_LightType {
  85136. DIRECTIONAL = "directional",
  85137. POINT = "point",
  85138. SPOT = "spot"
  85139. }
  85140. /** @hidden */
  85141. interface IKHRLightsPunctual_LightReference {
  85142. light: number;
  85143. }
  85144. /** @hidden */
  85145. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  85146. type: IKHRLightsPunctual_LightType;
  85147. color?: number[];
  85148. intensity?: number;
  85149. range?: number;
  85150. spot?: {
  85151. innerConeAngle?: number;
  85152. outerConeAngle?: number;
  85153. };
  85154. }
  85155. /** @hidden */
  85156. interface IKHRLightsPunctual {
  85157. lights: IKHRLightsPunctual_Light[];
  85158. }
  85159. /**
  85160. * Interfaces from the KHR_materials_clearcoat extension
  85161. * !!! Experimental Extension Subject to Changes !!!
  85162. */
  85163. /** @hidden */
  85164. interface IKHRMaterialsClearcoat {
  85165. clearcoatFactor: number;
  85166. clearcoatTexture: ITextureInfo;
  85167. clearcoatRoughnessFactor: number;
  85168. clearcoatRoughnessTexture: ITextureInfo;
  85169. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  85170. }
  85171. /**
  85172. * Interfaces from the KHR_materials_ior extension
  85173. * !!! Experimental Extension Subject to Changes !!!
  85174. */
  85175. /** @hidden */
  85176. interface IKHRMaterialsIor {
  85177. ior: number;
  85178. }
  85179. /**
  85180. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  85181. */
  85182. /** @hidden */
  85183. interface IKHRMaterialsPbrSpecularGlossiness {
  85184. diffuseFactor: number[];
  85185. diffuseTexture: ITextureInfo;
  85186. specularFactor: number[];
  85187. glossinessFactor: number;
  85188. specularGlossinessTexture: ITextureInfo;
  85189. }
  85190. /**
  85191. * Interfaces from the KHR_materials_sheen extension
  85192. * !!! Experimental Extension Subject to Changes !!!
  85193. */
  85194. /** @hidden */
  85195. interface IKHRMaterialsSheen {
  85196. sheenColorFactor?: number[];
  85197. sheenTexture?: ITextureInfo;
  85198. sheenRoughnessFactor?: number;
  85199. }
  85200. /**
  85201. * Interfaces from the KHR_materials_specular extension
  85202. * !!! Experimental Extension Subject to Changes !!!
  85203. */
  85204. /** @hidden */
  85205. interface IKHRMaterialsSpecular {
  85206. specularFactor: number;
  85207. specularColorFactor: number[];
  85208. specularTexture: ITextureInfo;
  85209. }
  85210. /**
  85211. * Interfaces from the KHR_materials_transmission extension
  85212. * !!! Experimental Extension Subject to Changes !!!
  85213. */
  85214. /** @hidden */
  85215. interface IKHRMaterialsTransmission {
  85216. transmissionFactor?: number;
  85217. transmissionTexture?: ITextureInfo;
  85218. }
  85219. /**
  85220. * Interfaces from the KHR_materials_variants extension
  85221. * !!! Experimental Extension Subject to Changes !!!
  85222. */
  85223. /** @hidden */
  85224. interface IKHRMaterialVariants_Mapping extends IProperty {
  85225. mappings: Array<{
  85226. variants: number[];
  85227. material: number;
  85228. }>;
  85229. }
  85230. /** @hidden */
  85231. interface IKHRMaterialVariants_Variant extends IProperty {
  85232. name: string;
  85233. }
  85234. /** @hidden */
  85235. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  85236. variants: Array<IKHRMaterialVariants_Variant>;
  85237. }
  85238. /**
  85239. * Interfaces from the KHR_texture_basisu extension
  85240. * !!! Experimental Extension Subject to Changes !!!
  85241. */
  85242. /** @hidden */
  85243. interface IKHRTextureBasisU {
  85244. source: number;
  85245. }
  85246. /**
  85247. * Interfaces from the EXT_texture_webp extension
  85248. */
  85249. /** @hidden */
  85250. interface IEXTTextureWebP {
  85251. source: number;
  85252. }
  85253. /**
  85254. * Interfaces from the KHR_texture_transform extension
  85255. */
  85256. /** @hidden */
  85257. interface IKHRTextureTransform {
  85258. offset?: number[];
  85259. rotation?: number;
  85260. scale?: number[];
  85261. texCoord?: number;
  85262. }
  85263. /**
  85264. * Interfaces from the KHR_xmp extension
  85265. * !!! Experimental Extension Subject to Changes !!!
  85266. */
  85267. /** @hidden */
  85268. interface IKHRXmp_Data {
  85269. [key: string]: unknown;
  85270. }
  85271. /** @hidden */
  85272. interface IKHRXmp_Gltf {
  85273. packets: IKHRXmp_Data[];
  85274. }
  85275. /** @hidden */
  85276. interface IKHRXmp_Node {
  85277. packet: number;
  85278. }
  85279. /**
  85280. * Interfaces from the MSFT_audio_emitter extension
  85281. */
  85282. /** @hidden */
  85283. interface IMSFTAudioEmitter_ClipReference {
  85284. clip: number;
  85285. weight?: number;
  85286. }
  85287. /** @hidden */
  85288. interface IMSFTAudioEmitter_EmittersReference {
  85289. emitters: number[];
  85290. }
  85291. /** @hidden */
  85292. const enum IMSFTAudioEmitter_DistanceModel {
  85293. linear = "linear",
  85294. inverse = "inverse",
  85295. exponential = "exponential",
  85296. }
  85297. /** @hidden */
  85298. interface IMSFTAudioEmitter_Emitter {
  85299. name?: string;
  85300. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  85301. refDistance?: number;
  85302. maxDistance?: number;
  85303. rolloffFactor?: number;
  85304. innerAngle?: number;
  85305. outerAngle?: number;
  85306. loop?: boolean;
  85307. volume?: number;
  85308. clips: IMSFTAudioEmitter_ClipReference[];
  85309. }
  85310. /** @hidden */
  85311. const enum IMSFTAudioEmitter_AudioMimeType {
  85312. WAV = "audio/wav",
  85313. }
  85314. /** @hidden */
  85315. interface IMSFTAudioEmitter_Clip extends IProperty {
  85316. uri?: string;
  85317. bufferView?: number;
  85318. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  85319. }
  85320. /** @hidden */
  85321. const enum IMSFTAudioEmitter_AnimationEventAction {
  85322. play = "play",
  85323. pause = "pause",
  85324. stop = "stop",
  85325. }
  85326. /** @hidden */
  85327. interface IMSFTAudioEmitter_AnimationEvent {
  85328. action: IMSFTAudioEmitter_AnimationEventAction;
  85329. emitter: number;
  85330. time: number;
  85331. startOffset?: number;
  85332. }
  85333. /**
  85334. * Interfaces from the MSFT_lod extension
  85335. */
  85336. /** @hidden */
  85337. interface IMSFTLOD {
  85338. ids: number[];
  85339. }
  85340. }
  85341. declare module BABYLON {
  85342. /** @hidden */
  85343. export var cellPixelShader: {
  85344. name: string;
  85345. shader: string;
  85346. };
  85347. }
  85348. declare module BABYLON {
  85349. /** @hidden */
  85350. export var cellVertexShader: {
  85351. name: string;
  85352. shader: string;
  85353. };
  85354. }
  85355. declare module BABYLON {
  85356. export class CellMaterial extends BABYLON.PushMaterial {
  85357. private _diffuseTexture;
  85358. diffuseTexture: BABYLON.BaseTexture;
  85359. diffuseColor: BABYLON.Color3;
  85360. _computeHighLevel: boolean;
  85361. computeHighLevel: boolean;
  85362. private _disableLighting;
  85363. disableLighting: boolean;
  85364. private _maxSimultaneousLights;
  85365. maxSimultaneousLights: number;
  85366. constructor(name: string, scene: BABYLON.Scene);
  85367. needAlphaBlending(): boolean;
  85368. needAlphaTesting(): boolean;
  85369. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85370. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85371. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85372. getAnimatables(): BABYLON.IAnimatable[];
  85373. getActiveTextures(): BABYLON.BaseTexture[];
  85374. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85375. dispose(forceDisposeEffect?: boolean): void;
  85376. getClassName(): string;
  85377. clone(name: string): CellMaterial;
  85378. serialize(): any;
  85379. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  85380. }
  85381. }
  85382. declare module BABYLON {
  85383. export class CustomShaderStructure {
  85384. FragmentStore: string;
  85385. VertexStore: string;
  85386. constructor();
  85387. }
  85388. export class ShaderSpecialParts {
  85389. constructor();
  85390. Fragment_Begin: string;
  85391. Fragment_Definitions: string;
  85392. Fragment_MainBegin: string;
  85393. Fragment_Custom_Diffuse: string;
  85394. Fragment_Before_Lights: string;
  85395. Fragment_Before_Fog: string;
  85396. Fragment_Custom_Alpha: string;
  85397. Fragment_Before_FragColor: string;
  85398. Vertex_Begin: string;
  85399. Vertex_Definitions: string;
  85400. Vertex_MainBegin: string;
  85401. Vertex_Before_PositionUpdated: string;
  85402. Vertex_Before_NormalUpdated: string;
  85403. Vertex_After_WorldPosComputed: string;
  85404. Vertex_MainEnd: string;
  85405. }
  85406. export class CustomMaterial extends BABYLON.StandardMaterial {
  85407. static ShaderIndexer: number;
  85408. CustomParts: ShaderSpecialParts;
  85409. _isCreatedShader: boolean;
  85410. _createdShaderName: string;
  85411. _customUniform: string[];
  85412. _newUniforms: string[];
  85413. _newUniformInstances: {
  85414. [name: string]: any;
  85415. };
  85416. _newSamplerInstances: {
  85417. [name: string]: BABYLON.Texture;
  85418. };
  85419. _customAttributes: string[];
  85420. FragmentShader: string;
  85421. VertexShader: string;
  85422. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85423. ReviewUniform(name: string, arr: string[]): string[];
  85424. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85425. constructor(name: string, scene: BABYLON.Scene);
  85426. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  85427. AddAttribute(name: string): CustomMaterial;
  85428. Fragment_Begin(shaderPart: string): CustomMaterial;
  85429. Fragment_Definitions(shaderPart: string): CustomMaterial;
  85430. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  85431. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  85432. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  85433. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  85434. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  85435. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  85436. Vertex_Begin(shaderPart: string): CustomMaterial;
  85437. Vertex_Definitions(shaderPart: string): CustomMaterial;
  85438. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  85439. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  85440. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  85441. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  85442. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  85443. }
  85444. }
  85445. declare module BABYLON {
  85446. export class ShaderAlebdoParts {
  85447. constructor();
  85448. Fragment_Begin: string;
  85449. Fragment_Definitions: string;
  85450. Fragment_MainBegin: string;
  85451. Fragment_Custom_Albedo: string;
  85452. Fragment_Before_Lights: string;
  85453. Fragment_Custom_MetallicRoughness: string;
  85454. Fragment_Custom_MicroSurface: string;
  85455. Fragment_Before_Fog: string;
  85456. Fragment_Custom_Alpha: string;
  85457. Fragment_Before_FragColor: string;
  85458. Vertex_Begin: string;
  85459. Vertex_Definitions: string;
  85460. Vertex_MainBegin: string;
  85461. Vertex_Before_PositionUpdated: string;
  85462. Vertex_Before_NormalUpdated: string;
  85463. Vertex_After_WorldPosComputed: string;
  85464. Vertex_MainEnd: string;
  85465. }
  85466. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  85467. static ShaderIndexer: number;
  85468. CustomParts: ShaderAlebdoParts;
  85469. _isCreatedShader: boolean;
  85470. _createdShaderName: string;
  85471. _customUniform: string[];
  85472. _newUniforms: string[];
  85473. _newUniformInstances: {
  85474. [name: string]: any;
  85475. };
  85476. _newSamplerInstances: {
  85477. [name: string]: BABYLON.Texture;
  85478. };
  85479. _customAttributes: string[];
  85480. FragmentShader: string;
  85481. VertexShader: string;
  85482. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85483. ReviewUniform(name: string, arr: string[]): string[];
  85484. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85485. constructor(name: string, scene: BABYLON.Scene);
  85486. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  85487. AddAttribute(name: string): PBRCustomMaterial;
  85488. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  85489. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  85490. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  85491. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  85492. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  85493. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  85494. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  85495. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  85496. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  85497. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  85498. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  85499. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  85500. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  85501. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  85502. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  85503. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  85504. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  85505. }
  85506. }
  85507. declare module BABYLON {
  85508. /** @hidden */
  85509. export var firePixelShader: {
  85510. name: string;
  85511. shader: string;
  85512. };
  85513. }
  85514. declare module BABYLON {
  85515. /** @hidden */
  85516. export var fireVertexShader: {
  85517. name: string;
  85518. shader: string;
  85519. };
  85520. }
  85521. declare module BABYLON {
  85522. export class FireMaterial extends BABYLON.PushMaterial {
  85523. private _diffuseTexture;
  85524. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85525. private _distortionTexture;
  85526. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85527. private _opacityTexture;
  85528. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85529. diffuseColor: BABYLON.Color3;
  85530. speed: number;
  85531. private _scaledDiffuse;
  85532. private _lastTime;
  85533. constructor(name: string, scene: BABYLON.Scene);
  85534. needAlphaBlending(): boolean;
  85535. needAlphaTesting(): boolean;
  85536. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85537. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85538. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85539. getAnimatables(): BABYLON.IAnimatable[];
  85540. getActiveTextures(): BABYLON.BaseTexture[];
  85541. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85542. getClassName(): string;
  85543. dispose(forceDisposeEffect?: boolean): void;
  85544. clone(name: string): FireMaterial;
  85545. serialize(): any;
  85546. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  85547. }
  85548. }
  85549. declare module BABYLON {
  85550. /** @hidden */
  85551. export var furPixelShader: {
  85552. name: string;
  85553. shader: string;
  85554. };
  85555. }
  85556. declare module BABYLON {
  85557. /** @hidden */
  85558. export var furVertexShader: {
  85559. name: string;
  85560. shader: string;
  85561. };
  85562. }
  85563. declare module BABYLON {
  85564. export class FurMaterial extends BABYLON.PushMaterial {
  85565. private _diffuseTexture;
  85566. diffuseTexture: BABYLON.BaseTexture;
  85567. private _heightTexture;
  85568. heightTexture: BABYLON.BaseTexture;
  85569. diffuseColor: BABYLON.Color3;
  85570. furLength: number;
  85571. furAngle: number;
  85572. furColor: BABYLON.Color3;
  85573. furOffset: number;
  85574. furSpacing: number;
  85575. furGravity: BABYLON.Vector3;
  85576. furSpeed: number;
  85577. furDensity: number;
  85578. furOcclusion: number;
  85579. furTexture: BABYLON.DynamicTexture;
  85580. private _disableLighting;
  85581. disableLighting: boolean;
  85582. private _maxSimultaneousLights;
  85583. maxSimultaneousLights: number;
  85584. highLevelFur: boolean;
  85585. _meshes: BABYLON.AbstractMesh[];
  85586. private _furTime;
  85587. constructor(name: string, scene: BABYLON.Scene);
  85588. get furTime(): number;
  85589. set furTime(furTime: number);
  85590. needAlphaBlending(): boolean;
  85591. needAlphaTesting(): boolean;
  85592. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85593. updateFur(): void;
  85594. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85595. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85596. getAnimatables(): BABYLON.IAnimatable[];
  85597. getActiveTextures(): BABYLON.BaseTexture[];
  85598. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85599. dispose(forceDisposeEffect?: boolean): void;
  85600. clone(name: string): FurMaterial;
  85601. serialize(): any;
  85602. getClassName(): string;
  85603. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  85604. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  85605. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  85606. }
  85607. }
  85608. declare module BABYLON {
  85609. /** @hidden */
  85610. export var gradientPixelShader: {
  85611. name: string;
  85612. shader: string;
  85613. };
  85614. }
  85615. declare module BABYLON {
  85616. /** @hidden */
  85617. export var gradientVertexShader: {
  85618. name: string;
  85619. shader: string;
  85620. };
  85621. }
  85622. declare module BABYLON {
  85623. export class GradientMaterial extends BABYLON.PushMaterial {
  85624. private _maxSimultaneousLights;
  85625. maxSimultaneousLights: number;
  85626. topColor: BABYLON.Color3;
  85627. topColorAlpha: number;
  85628. bottomColor: BABYLON.Color3;
  85629. bottomColorAlpha: number;
  85630. offset: number;
  85631. scale: number;
  85632. smoothness: number;
  85633. private _disableLighting;
  85634. disableLighting: boolean;
  85635. constructor(name: string, scene: BABYLON.Scene);
  85636. needAlphaBlending(): boolean;
  85637. needAlphaTesting(): boolean;
  85638. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85639. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85640. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85641. getAnimatables(): BABYLON.IAnimatable[];
  85642. dispose(forceDisposeEffect?: boolean): void;
  85643. clone(name: string): GradientMaterial;
  85644. serialize(): any;
  85645. getClassName(): string;
  85646. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  85647. }
  85648. }
  85649. declare module BABYLON {
  85650. /** @hidden */
  85651. export var gridPixelShader: {
  85652. name: string;
  85653. shader: string;
  85654. };
  85655. }
  85656. declare module BABYLON {
  85657. /** @hidden */
  85658. export var gridVertexShader: {
  85659. name: string;
  85660. shader: string;
  85661. };
  85662. }
  85663. declare module BABYLON {
  85664. /**
  85665. * The grid materials allows you to wrap any shape with a grid.
  85666. * Colors are customizable.
  85667. */
  85668. export class GridMaterial extends BABYLON.PushMaterial {
  85669. /**
  85670. * Main color of the grid (e.g. between lines)
  85671. */
  85672. mainColor: BABYLON.Color3;
  85673. /**
  85674. * Color of the grid lines.
  85675. */
  85676. lineColor: BABYLON.Color3;
  85677. /**
  85678. * The scale of the grid compared to unit.
  85679. */
  85680. gridRatio: number;
  85681. /**
  85682. * Allows setting an offset for the grid lines.
  85683. */
  85684. gridOffset: BABYLON.Vector3;
  85685. /**
  85686. * The frequency of thicker lines.
  85687. */
  85688. majorUnitFrequency: number;
  85689. /**
  85690. * The visibility of minor units in the grid.
  85691. */
  85692. minorUnitVisibility: number;
  85693. /**
  85694. * The grid opacity outside of the lines.
  85695. */
  85696. opacity: number;
  85697. /**
  85698. * Determine RBG output is premultiplied by alpha value.
  85699. */
  85700. preMultiplyAlpha: boolean;
  85701. private _opacityTexture;
  85702. opacityTexture: BABYLON.BaseTexture;
  85703. private _gridControl;
  85704. /**
  85705. * constructor
  85706. * @param name The name given to the material in order to identify it afterwards.
  85707. * @param scene The scene the material is used in.
  85708. */
  85709. constructor(name: string, scene: BABYLON.Scene);
  85710. /**
  85711. * Returns wehter or not the grid requires alpha blending.
  85712. */
  85713. needAlphaBlending(): boolean;
  85714. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85715. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85716. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85717. /**
  85718. * Dispose the material and its associated resources.
  85719. * @param forceDisposeEffect will also dispose the used effect when true
  85720. */
  85721. dispose(forceDisposeEffect?: boolean): void;
  85722. clone(name: string): GridMaterial;
  85723. serialize(): any;
  85724. getClassName(): string;
  85725. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  85726. }
  85727. }
  85728. declare module BABYLON {
  85729. /** @hidden */
  85730. export var lavaPixelShader: {
  85731. name: string;
  85732. shader: string;
  85733. };
  85734. }
  85735. declare module BABYLON {
  85736. /** @hidden */
  85737. export var lavaVertexShader: {
  85738. name: string;
  85739. shader: string;
  85740. };
  85741. }
  85742. declare module BABYLON {
  85743. export class LavaMaterial extends BABYLON.PushMaterial {
  85744. private _diffuseTexture;
  85745. diffuseTexture: BABYLON.BaseTexture;
  85746. noiseTexture: BABYLON.BaseTexture;
  85747. fogColor: BABYLON.Color3;
  85748. speed: number;
  85749. movingSpeed: number;
  85750. lowFrequencySpeed: number;
  85751. fogDensity: number;
  85752. private _lastTime;
  85753. diffuseColor: BABYLON.Color3;
  85754. private _disableLighting;
  85755. disableLighting: boolean;
  85756. private _unlit;
  85757. unlit: boolean;
  85758. private _maxSimultaneousLights;
  85759. maxSimultaneousLights: number;
  85760. private _scaledDiffuse;
  85761. constructor(name: string, scene: BABYLON.Scene);
  85762. needAlphaBlending(): boolean;
  85763. needAlphaTesting(): boolean;
  85764. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85765. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85766. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85767. getAnimatables(): BABYLON.IAnimatable[];
  85768. getActiveTextures(): BABYLON.BaseTexture[];
  85769. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85770. dispose(forceDisposeEffect?: boolean): void;
  85771. clone(name: string): LavaMaterial;
  85772. serialize(): any;
  85773. getClassName(): string;
  85774. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  85775. }
  85776. }
  85777. declare module BABYLON {
  85778. /** @hidden */
  85779. export var mixPixelShader: {
  85780. name: string;
  85781. shader: string;
  85782. };
  85783. }
  85784. declare module BABYLON {
  85785. /** @hidden */
  85786. export var mixVertexShader: {
  85787. name: string;
  85788. shader: string;
  85789. };
  85790. }
  85791. declare module BABYLON {
  85792. export class MixMaterial extends BABYLON.PushMaterial {
  85793. /**
  85794. * Mix textures
  85795. */
  85796. private _mixTexture1;
  85797. mixTexture1: BABYLON.BaseTexture;
  85798. private _mixTexture2;
  85799. mixTexture2: BABYLON.BaseTexture;
  85800. /**
  85801. * Diffuse textures
  85802. */
  85803. private _diffuseTexture1;
  85804. diffuseTexture1: BABYLON.Texture;
  85805. private _diffuseTexture2;
  85806. diffuseTexture2: BABYLON.Texture;
  85807. private _diffuseTexture3;
  85808. diffuseTexture3: BABYLON.Texture;
  85809. private _diffuseTexture4;
  85810. diffuseTexture4: BABYLON.Texture;
  85811. private _diffuseTexture5;
  85812. diffuseTexture5: BABYLON.Texture;
  85813. private _diffuseTexture6;
  85814. diffuseTexture6: BABYLON.Texture;
  85815. private _diffuseTexture7;
  85816. diffuseTexture7: BABYLON.Texture;
  85817. private _diffuseTexture8;
  85818. diffuseTexture8: BABYLON.Texture;
  85819. /**
  85820. * Uniforms
  85821. */
  85822. diffuseColor: BABYLON.Color3;
  85823. specularColor: BABYLON.Color3;
  85824. specularPower: number;
  85825. private _disableLighting;
  85826. disableLighting: boolean;
  85827. private _maxSimultaneousLights;
  85828. maxSimultaneousLights: number;
  85829. constructor(name: string, scene: BABYLON.Scene);
  85830. needAlphaBlending(): boolean;
  85831. needAlphaTesting(): boolean;
  85832. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85833. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85834. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85835. getAnimatables(): BABYLON.IAnimatable[];
  85836. getActiveTextures(): BABYLON.BaseTexture[];
  85837. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85838. dispose(forceDisposeEffect?: boolean): void;
  85839. clone(name: string): MixMaterial;
  85840. serialize(): any;
  85841. getClassName(): string;
  85842. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  85843. }
  85844. }
  85845. declare module BABYLON {
  85846. /** @hidden */
  85847. export var normalPixelShader: {
  85848. name: string;
  85849. shader: string;
  85850. };
  85851. }
  85852. declare module BABYLON {
  85853. /** @hidden */
  85854. export var normalVertexShader: {
  85855. name: string;
  85856. shader: string;
  85857. };
  85858. }
  85859. declare module BABYLON {
  85860. export class NormalMaterial extends BABYLON.PushMaterial {
  85861. private _diffuseTexture;
  85862. diffuseTexture: BABYLON.BaseTexture;
  85863. diffuseColor: BABYLON.Color3;
  85864. private _disableLighting;
  85865. disableLighting: boolean;
  85866. private _maxSimultaneousLights;
  85867. maxSimultaneousLights: number;
  85868. constructor(name: string, scene: BABYLON.Scene);
  85869. needAlphaBlending(): boolean;
  85870. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85871. needAlphaTesting(): boolean;
  85872. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85873. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85874. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85875. getAnimatables(): BABYLON.IAnimatable[];
  85876. getActiveTextures(): BABYLON.BaseTexture[];
  85877. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85878. dispose(forceDisposeEffect?: boolean): void;
  85879. clone(name: string): NormalMaterial;
  85880. serialize(): any;
  85881. getClassName(): string;
  85882. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  85883. }
  85884. }
  85885. declare module BABYLON {
  85886. /** @hidden */
  85887. export var shadowOnlyPixelShader: {
  85888. name: string;
  85889. shader: string;
  85890. };
  85891. }
  85892. declare module BABYLON {
  85893. /** @hidden */
  85894. export var shadowOnlyVertexShader: {
  85895. name: string;
  85896. shader: string;
  85897. };
  85898. }
  85899. declare module BABYLON {
  85900. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  85901. private _activeLight;
  85902. private _needAlphaBlending;
  85903. constructor(name: string, scene: BABYLON.Scene);
  85904. shadowColor: BABYLON.Color3;
  85905. needAlphaBlending(): boolean;
  85906. needAlphaTesting(): boolean;
  85907. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85908. get activeLight(): BABYLON.IShadowLight;
  85909. set activeLight(light: BABYLON.IShadowLight);
  85910. private _getFirstShadowLightForMesh;
  85911. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85912. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85913. clone(name: string): ShadowOnlyMaterial;
  85914. serialize(): any;
  85915. getClassName(): string;
  85916. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  85917. }
  85918. }
  85919. declare module BABYLON {
  85920. /** @hidden */
  85921. export var simplePixelShader: {
  85922. name: string;
  85923. shader: string;
  85924. };
  85925. }
  85926. declare module BABYLON {
  85927. /** @hidden */
  85928. export var simpleVertexShader: {
  85929. name: string;
  85930. shader: string;
  85931. };
  85932. }
  85933. declare module BABYLON {
  85934. export class SimpleMaterial extends BABYLON.PushMaterial {
  85935. private _diffuseTexture;
  85936. diffuseTexture: BABYLON.BaseTexture;
  85937. diffuseColor: BABYLON.Color3;
  85938. private _disableLighting;
  85939. disableLighting: boolean;
  85940. private _maxSimultaneousLights;
  85941. maxSimultaneousLights: number;
  85942. constructor(name: string, scene: BABYLON.Scene);
  85943. needAlphaBlending(): boolean;
  85944. needAlphaTesting(): boolean;
  85945. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85946. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85947. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85948. getAnimatables(): BABYLON.IAnimatable[];
  85949. getActiveTextures(): BABYLON.BaseTexture[];
  85950. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85951. dispose(forceDisposeEffect?: boolean): void;
  85952. clone(name: string): SimpleMaterial;
  85953. serialize(): any;
  85954. getClassName(): string;
  85955. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  85956. }
  85957. }
  85958. declare module BABYLON {
  85959. /** @hidden */
  85960. export var skyPixelShader: {
  85961. name: string;
  85962. shader: string;
  85963. };
  85964. }
  85965. declare module BABYLON {
  85966. /** @hidden */
  85967. export var skyVertexShader: {
  85968. name: string;
  85969. shader: string;
  85970. };
  85971. }
  85972. declare module BABYLON {
  85973. /**
  85974. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  85975. * @see https://doc.babylonjs.com/extensions/sky
  85976. */
  85977. export class SkyMaterial extends BABYLON.PushMaterial {
  85978. /**
  85979. * Defines the overall luminance of sky in interval ]0, 1[.
  85980. */
  85981. luminance: number;
  85982. /**
  85983. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  85984. */
  85985. turbidity: number;
  85986. /**
  85987. * Defines the sky appearance (light intensity).
  85988. */
  85989. rayleigh: number;
  85990. /**
  85991. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  85992. */
  85993. mieCoefficient: number;
  85994. /**
  85995. * Defines the amount of haze particles following the Mie scattering theory.
  85996. */
  85997. mieDirectionalG: number;
  85998. /**
  85999. * Defines the distance of the sun according to the active scene camera.
  86000. */
  86001. distance: number;
  86002. /**
  86003. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  86004. * "inclined".
  86005. */
  86006. inclination: number;
  86007. /**
  86008. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  86009. * an object direction and a reference direction.
  86010. */
  86011. azimuth: number;
  86012. /**
  86013. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  86014. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  86015. */
  86016. sunPosition: BABYLON.Vector3;
  86017. /**
  86018. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  86019. * .sunPosition property.
  86020. */
  86021. useSunPosition: boolean;
  86022. /**
  86023. * Defines an offset vector used to get a horizon offset.
  86024. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  86025. */
  86026. cameraOffset: BABYLON.Vector3;
  86027. private _cameraPosition;
  86028. /**
  86029. * Instantiates a new sky material.
  86030. * This material allows to create dynamic and texture free
  86031. * effects for skyboxes by taking care of the atmosphere state.
  86032. * @see https://doc.babylonjs.com/extensions/sky
  86033. * @param name Define the name of the material in the scene
  86034. * @param scene Define the scene the material belong to
  86035. */
  86036. constructor(name: string, scene: BABYLON.Scene);
  86037. /**
  86038. * Specifies if the material will require alpha blending
  86039. * @returns a boolean specifying if alpha blending is needed
  86040. */
  86041. needAlphaBlending(): boolean;
  86042. /**
  86043. * Specifies if this material should be rendered in alpha test mode
  86044. * @returns false as the sky material doesn't need alpha testing.
  86045. */
  86046. needAlphaTesting(): boolean;
  86047. /**
  86048. * Get the texture used for alpha test purpose.
  86049. * @returns null as the sky material has no texture.
  86050. */
  86051. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86052. /**
  86053. * Get if the submesh is ready to be used and all its information available.
  86054. * Child classes can use it to update shaders
  86055. * @param mesh defines the mesh to check
  86056. * @param subMesh defines which submesh to check
  86057. * @param useInstances specifies that instances should be used
  86058. * @returns a boolean indicating that the submesh is ready or not
  86059. */
  86060. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86061. /**
  86062. * Binds the submesh to this material by preparing the effect and shader to draw
  86063. * @param world defines the world transformation matrix
  86064. * @param mesh defines the mesh containing the submesh
  86065. * @param subMesh defines the submesh to bind the material to
  86066. */
  86067. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86068. /**
  86069. * Get the list of animatables in the material.
  86070. * @returns the list of animatables object used in the material
  86071. */
  86072. getAnimatables(): BABYLON.IAnimatable[];
  86073. /**
  86074. * Disposes the material
  86075. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86076. */
  86077. dispose(forceDisposeEffect?: boolean): void;
  86078. /**
  86079. * Makes a duplicate of the material, and gives it a new name
  86080. * @param name defines the new name for the duplicated material
  86081. * @returns the cloned material
  86082. */
  86083. clone(name: string): SkyMaterial;
  86084. /**
  86085. * Serializes this material in a JSON representation
  86086. * @returns the serialized material object
  86087. */
  86088. serialize(): any;
  86089. /**
  86090. * Gets the current class name of the material e.g. "SkyMaterial"
  86091. * Mainly use in serialization.
  86092. * @returns the class name
  86093. */
  86094. getClassName(): string;
  86095. /**
  86096. * Creates a sky material from parsed material data
  86097. * @param source defines the JSON representation of the material
  86098. * @param scene defines the hosting scene
  86099. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86100. * @returns a new sky material
  86101. */
  86102. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  86103. }
  86104. }
  86105. declare module BABYLON {
  86106. /** @hidden */
  86107. export var terrainPixelShader: {
  86108. name: string;
  86109. shader: string;
  86110. };
  86111. }
  86112. declare module BABYLON {
  86113. /** @hidden */
  86114. export var terrainVertexShader: {
  86115. name: string;
  86116. shader: string;
  86117. };
  86118. }
  86119. declare module BABYLON {
  86120. export class TerrainMaterial extends BABYLON.PushMaterial {
  86121. private _mixTexture;
  86122. mixTexture: BABYLON.BaseTexture;
  86123. private _diffuseTexture1;
  86124. diffuseTexture1: BABYLON.Texture;
  86125. private _diffuseTexture2;
  86126. diffuseTexture2: BABYLON.Texture;
  86127. private _diffuseTexture3;
  86128. diffuseTexture3: BABYLON.Texture;
  86129. private _bumpTexture1;
  86130. bumpTexture1: BABYLON.Texture;
  86131. private _bumpTexture2;
  86132. bumpTexture2: BABYLON.Texture;
  86133. private _bumpTexture3;
  86134. bumpTexture3: BABYLON.Texture;
  86135. diffuseColor: BABYLON.Color3;
  86136. specularColor: BABYLON.Color3;
  86137. specularPower: number;
  86138. private _disableLighting;
  86139. disableLighting: boolean;
  86140. private _maxSimultaneousLights;
  86141. maxSimultaneousLights: number;
  86142. constructor(name: string, scene: BABYLON.Scene);
  86143. needAlphaBlending(): boolean;
  86144. needAlphaTesting(): boolean;
  86145. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86146. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86147. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86148. getAnimatables(): BABYLON.IAnimatable[];
  86149. getActiveTextures(): BABYLON.BaseTexture[];
  86150. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86151. dispose(forceDisposeEffect?: boolean): void;
  86152. clone(name: string): TerrainMaterial;
  86153. serialize(): any;
  86154. getClassName(): string;
  86155. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  86156. }
  86157. }
  86158. declare module BABYLON {
  86159. /** @hidden */
  86160. export var triplanarPixelShader: {
  86161. name: string;
  86162. shader: string;
  86163. };
  86164. }
  86165. declare module BABYLON {
  86166. /** @hidden */
  86167. export var triplanarVertexShader: {
  86168. name: string;
  86169. shader: string;
  86170. };
  86171. }
  86172. declare module BABYLON {
  86173. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  86174. mixTexture: BABYLON.BaseTexture;
  86175. private _diffuseTextureX;
  86176. diffuseTextureX: BABYLON.BaseTexture;
  86177. private _diffuseTextureY;
  86178. diffuseTextureY: BABYLON.BaseTexture;
  86179. private _diffuseTextureZ;
  86180. diffuseTextureZ: BABYLON.BaseTexture;
  86181. private _normalTextureX;
  86182. normalTextureX: BABYLON.BaseTexture;
  86183. private _normalTextureY;
  86184. normalTextureY: BABYLON.BaseTexture;
  86185. private _normalTextureZ;
  86186. normalTextureZ: BABYLON.BaseTexture;
  86187. tileSize: number;
  86188. diffuseColor: BABYLON.Color3;
  86189. specularColor: BABYLON.Color3;
  86190. specularPower: number;
  86191. private _disableLighting;
  86192. disableLighting: boolean;
  86193. private _maxSimultaneousLights;
  86194. maxSimultaneousLights: number;
  86195. constructor(name: string, scene: BABYLON.Scene);
  86196. needAlphaBlending(): boolean;
  86197. needAlphaTesting(): boolean;
  86198. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86199. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86200. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86201. getAnimatables(): BABYLON.IAnimatable[];
  86202. getActiveTextures(): BABYLON.BaseTexture[];
  86203. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86204. dispose(forceDisposeEffect?: boolean): void;
  86205. clone(name: string): TriPlanarMaterial;
  86206. serialize(): any;
  86207. getClassName(): string;
  86208. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  86209. }
  86210. }
  86211. declare module BABYLON {
  86212. /** @hidden */
  86213. export var waterPixelShader: {
  86214. name: string;
  86215. shader: string;
  86216. };
  86217. }
  86218. declare module BABYLON {
  86219. /** @hidden */
  86220. export var waterVertexShader: {
  86221. name: string;
  86222. shader: string;
  86223. };
  86224. }
  86225. declare module BABYLON {
  86226. export class WaterMaterial extends BABYLON.PushMaterial {
  86227. renderTargetSize: BABYLON.Vector2;
  86228. private _bumpTexture;
  86229. bumpTexture: BABYLON.BaseTexture;
  86230. diffuseColor: BABYLON.Color3;
  86231. specularColor: BABYLON.Color3;
  86232. specularPower: number;
  86233. private _disableLighting;
  86234. disableLighting: boolean;
  86235. private _maxSimultaneousLights;
  86236. maxSimultaneousLights: number;
  86237. /**
  86238. * @param {number}: Represents the wind force
  86239. */
  86240. windForce: number;
  86241. /**
  86242. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  86243. */
  86244. windDirection: BABYLON.Vector2;
  86245. /**
  86246. * @param {number}: Wave height, represents the height of the waves
  86247. */
  86248. waveHeight: number;
  86249. /**
  86250. * @param {number}: Bump height, represents the bump height related to the bump map
  86251. */
  86252. bumpHeight: number;
  86253. /**
  86254. * @param {boolean}: Add a smaller moving bump to less steady waves.
  86255. */
  86256. private _bumpSuperimpose;
  86257. bumpSuperimpose: boolean;
  86258. /**
  86259. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  86260. */
  86261. private _fresnelSeparate;
  86262. fresnelSeparate: boolean;
  86263. /**
  86264. * @param {boolean}: bump Waves modify the reflection.
  86265. */
  86266. private _bumpAffectsReflection;
  86267. bumpAffectsReflection: boolean;
  86268. /**
  86269. * @param {number}: The water color blended with the refraction (near)
  86270. */
  86271. waterColor: BABYLON.Color3;
  86272. /**
  86273. * @param {number}: The blend factor related to the water color
  86274. */
  86275. colorBlendFactor: number;
  86276. /**
  86277. * @param {number}: The water color blended with the reflection (far)
  86278. */
  86279. waterColor2: BABYLON.Color3;
  86280. /**
  86281. * @param {number}: The blend factor related to the water color (reflection, far)
  86282. */
  86283. colorBlendFactor2: number;
  86284. /**
  86285. * @param {number}: Represents the maximum length of a wave
  86286. */
  86287. waveLength: number;
  86288. /**
  86289. * @param {number}: Defines the waves speed
  86290. */
  86291. waveSpeed: number;
  86292. /**
  86293. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  86294. * will avoid calculating useless pixels in the pixel shader of the water material.
  86295. */
  86296. disableClipPlane: boolean;
  86297. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  86298. private _mesh;
  86299. private _refractionRTT;
  86300. private _reflectionRTT;
  86301. private _reflectionTransform;
  86302. private _lastTime;
  86303. private _lastDeltaTime;
  86304. private _useLogarithmicDepth;
  86305. private _waitingRenderList;
  86306. private _imageProcessingConfiguration;
  86307. private _imageProcessingObserver;
  86308. /**
  86309. * Gets a boolean indicating that current material needs to register RTT
  86310. */
  86311. get hasRenderTargetTextures(): boolean;
  86312. /**
  86313. * Constructor
  86314. */
  86315. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  86316. get useLogarithmicDepth(): boolean;
  86317. set useLogarithmicDepth(value: boolean);
  86318. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86319. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86320. addToRenderList(node: any): void;
  86321. enableRenderTargets(enable: boolean): void;
  86322. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  86323. get renderTargetsEnabled(): boolean;
  86324. needAlphaBlending(): boolean;
  86325. needAlphaTesting(): boolean;
  86326. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86327. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86328. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86329. private _createRenderTargets;
  86330. getAnimatables(): BABYLON.IAnimatable[];
  86331. getActiveTextures(): BABYLON.BaseTexture[];
  86332. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86333. dispose(forceDisposeEffect?: boolean): void;
  86334. clone(name: string): WaterMaterial;
  86335. serialize(): any;
  86336. getClassName(): string;
  86337. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  86338. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  86339. }
  86340. }
  86341. declare module BABYLON {
  86342. /** @hidden */
  86343. export var asciiartPixelShader: {
  86344. name: string;
  86345. shader: string;
  86346. };
  86347. }
  86348. declare module BABYLON {
  86349. /**
  86350. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  86351. *
  86352. * It basically takes care rendering the font front the given font size to a texture.
  86353. * This is used later on in the postprocess.
  86354. */
  86355. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  86356. private _font;
  86357. private _text;
  86358. private _charSize;
  86359. /**
  86360. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86361. */
  86362. get charSize(): number;
  86363. /**
  86364. * Create a new instance of the Ascii Art FontTexture class
  86365. * @param name the name of the texture
  86366. * @param font the font to use, use the W3C CSS notation
  86367. * @param text the caracter set to use in the rendering.
  86368. * @param scene the scene that owns the texture
  86369. */
  86370. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86371. /**
  86372. * Gets the max char width of a font.
  86373. * @param font the font to use, use the W3C CSS notation
  86374. * @return the max char width
  86375. */
  86376. private getFontWidth;
  86377. /**
  86378. * Gets the max char height of a font.
  86379. * @param font the font to use, use the W3C CSS notation
  86380. * @return the max char height
  86381. */
  86382. private getFontHeight;
  86383. /**
  86384. * Clones the current AsciiArtTexture.
  86385. * @return the clone of the texture.
  86386. */
  86387. clone(): AsciiArtFontTexture;
  86388. /**
  86389. * Parses a json object representing the texture and returns an instance of it.
  86390. * @param source the source JSON representation
  86391. * @param scene the scene to create the texture for
  86392. * @return the parsed texture
  86393. */
  86394. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  86395. }
  86396. /**
  86397. * Option available in the Ascii Art Post Process.
  86398. */
  86399. export interface IAsciiArtPostProcessOptions {
  86400. /**
  86401. * The font to use following the w3c font definition.
  86402. */
  86403. font?: string;
  86404. /**
  86405. * The character set to use in the postprocess.
  86406. */
  86407. characterSet?: string;
  86408. /**
  86409. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86410. * This number is defined between 0 and 1;
  86411. */
  86412. mixToTile?: number;
  86413. /**
  86414. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86415. * This number is defined between 0 and 1;
  86416. */
  86417. mixToNormal?: number;
  86418. }
  86419. /**
  86420. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  86421. *
  86422. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86423. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  86424. */
  86425. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  86426. /**
  86427. * The font texture used to render the char in the post process.
  86428. */
  86429. private _asciiArtFontTexture;
  86430. /**
  86431. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86432. * This number is defined between 0 and 1;
  86433. */
  86434. mixToTile: number;
  86435. /**
  86436. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86437. * This number is defined between 0 and 1;
  86438. */
  86439. mixToNormal: number;
  86440. /**
  86441. * Instantiates a new Ascii Art Post Process.
  86442. * @param name the name to give to the postprocess
  86443. * @camera the camera to apply the post process to.
  86444. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  86445. */
  86446. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  86447. }
  86448. }
  86449. declare module BABYLON {
  86450. /** @hidden */
  86451. export var digitalrainPixelShader: {
  86452. name: string;
  86453. shader: string;
  86454. };
  86455. }
  86456. declare module BABYLON {
  86457. /**
  86458. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  86459. *
  86460. * It basically takes care rendering the font front the given font size to a texture.
  86461. * This is used later on in the postprocess.
  86462. */
  86463. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  86464. private _font;
  86465. private _text;
  86466. private _charSize;
  86467. /**
  86468. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86469. */
  86470. get charSize(): number;
  86471. /**
  86472. * Create a new instance of the Digital Rain FontTexture class
  86473. * @param name the name of the texture
  86474. * @param font the font to use, use the W3C CSS notation
  86475. * @param text the caracter set to use in the rendering.
  86476. * @param scene the scene that owns the texture
  86477. */
  86478. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86479. /**
  86480. * Gets the max char width of a font.
  86481. * @param font the font to use, use the W3C CSS notation
  86482. * @return the max char width
  86483. */
  86484. private getFontWidth;
  86485. /**
  86486. * Gets the max char height of a font.
  86487. * @param font the font to use, use the W3C CSS notation
  86488. * @return the max char height
  86489. */
  86490. private getFontHeight;
  86491. /**
  86492. * Clones the current DigitalRainFontTexture.
  86493. * @return the clone of the texture.
  86494. */
  86495. clone(): DigitalRainFontTexture;
  86496. /**
  86497. * Parses a json object representing the texture and returns an instance of it.
  86498. * @param source the source JSON representation
  86499. * @param scene the scene to create the texture for
  86500. * @return the parsed texture
  86501. */
  86502. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  86503. }
  86504. /**
  86505. * Option available in the Digital Rain Post Process.
  86506. */
  86507. export interface IDigitalRainPostProcessOptions {
  86508. /**
  86509. * The font to use following the w3c font definition.
  86510. */
  86511. font?: string;
  86512. /**
  86513. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86514. * This number is defined between 0 and 1;
  86515. */
  86516. mixToTile?: number;
  86517. /**
  86518. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86519. * This number is defined between 0 and 1;
  86520. */
  86521. mixToNormal?: number;
  86522. }
  86523. /**
  86524. * DigitalRainPostProcess helps rendering everithing in digital rain.
  86525. *
  86526. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86527. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  86528. */
  86529. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  86530. /**
  86531. * The font texture used to render the char in the post process.
  86532. */
  86533. private _digitalRainFontTexture;
  86534. /**
  86535. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86536. * This number is defined between 0 and 1;
  86537. */
  86538. mixToTile: number;
  86539. /**
  86540. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86541. * This number is defined between 0 and 1;
  86542. */
  86543. mixToNormal: number;
  86544. /**
  86545. * Instantiates a new Digital Rain Post Process.
  86546. * @param name the name to give to the postprocess
  86547. * @camera the camera to apply the post process to.
  86548. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  86549. */
  86550. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  86551. }
  86552. }
  86553. declare module BABYLON {
  86554. /** @hidden */
  86555. export var brickProceduralTexturePixelShader: {
  86556. name: string;
  86557. shader: string;
  86558. };
  86559. }
  86560. declare module BABYLON {
  86561. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  86562. private _numberOfBricksHeight;
  86563. private _numberOfBricksWidth;
  86564. private _jointColor;
  86565. private _brickColor;
  86566. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86567. updateShaderUniforms(): void;
  86568. get numberOfBricksHeight(): number;
  86569. set numberOfBricksHeight(value: number);
  86570. get numberOfBricksWidth(): number;
  86571. set numberOfBricksWidth(value: number);
  86572. get jointColor(): BABYLON.Color3;
  86573. set jointColor(value: BABYLON.Color3);
  86574. get brickColor(): BABYLON.Color3;
  86575. set brickColor(value: BABYLON.Color3);
  86576. /**
  86577. * Serializes this brick procedural texture
  86578. * @returns a serialized brick procedural texture object
  86579. */
  86580. serialize(): any;
  86581. /**
  86582. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  86583. * @param parsedTexture defines parsed texture data
  86584. * @param scene defines the current scene
  86585. * @param rootUrl defines the root URL containing brick procedural texture information
  86586. * @returns a parsed Brick Procedural BABYLON.Texture
  86587. */
  86588. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  86589. }
  86590. }
  86591. declare module BABYLON {
  86592. /** @hidden */
  86593. export var cloudProceduralTexturePixelShader: {
  86594. name: string;
  86595. shader: string;
  86596. };
  86597. }
  86598. declare module BABYLON {
  86599. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  86600. private _skyColor;
  86601. private _cloudColor;
  86602. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86603. updateShaderUniforms(): void;
  86604. get skyColor(): BABYLON.Color4;
  86605. set skyColor(value: BABYLON.Color4);
  86606. get cloudColor(): BABYLON.Color4;
  86607. set cloudColor(value: BABYLON.Color4);
  86608. /**
  86609. * Serializes this cloud procedural texture
  86610. * @returns a serialized cloud procedural texture object
  86611. */
  86612. serialize(): any;
  86613. /**
  86614. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud 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 cloud procedural texture information
  86618. * @returns a parsed Cloud Procedural BABYLON.Texture
  86619. */
  86620. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  86621. }
  86622. }
  86623. declare module BABYLON {
  86624. /** @hidden */
  86625. export var fireProceduralTexturePixelShader: {
  86626. name: string;
  86627. shader: string;
  86628. };
  86629. }
  86630. declare module BABYLON {
  86631. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  86632. private _time;
  86633. private _speed;
  86634. private _autoGenerateTime;
  86635. private _fireColors;
  86636. private _alphaThreshold;
  86637. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86638. updateShaderUniforms(): void;
  86639. render(useCameraPostProcess?: boolean): void;
  86640. static get PurpleFireColors(): BABYLON.Color3[];
  86641. static get GreenFireColors(): BABYLON.Color3[];
  86642. static get RedFireColors(): BABYLON.Color3[];
  86643. static get BlueFireColors(): BABYLON.Color3[];
  86644. get autoGenerateTime(): boolean;
  86645. set autoGenerateTime(value: boolean);
  86646. get fireColors(): BABYLON.Color3[];
  86647. set fireColors(value: BABYLON.Color3[]);
  86648. get time(): number;
  86649. set time(value: number);
  86650. get speed(): BABYLON.Vector2;
  86651. set speed(value: BABYLON.Vector2);
  86652. get alphaThreshold(): number;
  86653. set alphaThreshold(value: number);
  86654. /**
  86655. * Serializes this fire procedural texture
  86656. * @returns a serialized fire procedural texture object
  86657. */
  86658. serialize(): any;
  86659. /**
  86660. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  86661. * @param parsedTexture defines parsed texture data
  86662. * @param scene defines the current scene
  86663. * @param rootUrl defines the root URL containing fire procedural texture information
  86664. * @returns a parsed Fire Procedural BABYLON.Texture
  86665. */
  86666. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  86667. }
  86668. }
  86669. declare module BABYLON {
  86670. /** @hidden */
  86671. export var grassProceduralTexturePixelShader: {
  86672. name: string;
  86673. shader: string;
  86674. };
  86675. }
  86676. declare module BABYLON {
  86677. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  86678. private _grassColors;
  86679. private _groundColor;
  86680. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86681. updateShaderUniforms(): void;
  86682. get grassColors(): BABYLON.Color3[];
  86683. set grassColors(value: BABYLON.Color3[]);
  86684. get groundColor(): BABYLON.Color3;
  86685. set groundColor(value: BABYLON.Color3);
  86686. /**
  86687. * Serializes this grass procedural texture
  86688. * @returns a serialized grass procedural texture object
  86689. */
  86690. serialize(): any;
  86691. /**
  86692. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  86693. * @param parsedTexture defines parsed texture data
  86694. * @param scene defines the current scene
  86695. * @param rootUrl defines the root URL containing grass procedural texture information
  86696. * @returns a parsed Grass Procedural BABYLON.Texture
  86697. */
  86698. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  86699. }
  86700. }
  86701. declare module BABYLON {
  86702. /** @hidden */
  86703. export var marbleProceduralTexturePixelShader: {
  86704. name: string;
  86705. shader: string;
  86706. };
  86707. }
  86708. declare module BABYLON {
  86709. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  86710. private _numberOfTilesHeight;
  86711. private _numberOfTilesWidth;
  86712. private _amplitude;
  86713. private _jointColor;
  86714. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86715. updateShaderUniforms(): void;
  86716. get numberOfTilesHeight(): number;
  86717. set numberOfTilesHeight(value: number);
  86718. get amplitude(): number;
  86719. set amplitude(value: number);
  86720. get numberOfTilesWidth(): number;
  86721. set numberOfTilesWidth(value: number);
  86722. get jointColor(): BABYLON.Color3;
  86723. set jointColor(value: BABYLON.Color3);
  86724. /**
  86725. * Serializes this marble procedural texture
  86726. * @returns a serialized marble procedural texture object
  86727. */
  86728. serialize(): any;
  86729. /**
  86730. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  86731. * @param parsedTexture defines parsed texture data
  86732. * @param scene defines the current scene
  86733. * @param rootUrl defines the root URL containing marble procedural texture information
  86734. * @returns a parsed Marble Procedural BABYLON.Texture
  86735. */
  86736. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  86737. }
  86738. }
  86739. declare module BABYLON {
  86740. /** @hidden */
  86741. export var normalMapProceduralTexturePixelShader: {
  86742. name: string;
  86743. shader: string;
  86744. };
  86745. }
  86746. declare module BABYLON {
  86747. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  86748. private _baseTexture;
  86749. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86750. updateShaderUniforms(): void;
  86751. render(useCameraPostProcess?: boolean): void;
  86752. resize(size: any, generateMipMaps: any): void;
  86753. get baseTexture(): BABYLON.Texture;
  86754. set baseTexture(texture: BABYLON.Texture);
  86755. /**
  86756. * Serializes this normal map procedural texture
  86757. * @returns a serialized normal map procedural texture object
  86758. */
  86759. serialize(): any;
  86760. /**
  86761. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  86762. * @param parsedTexture defines parsed texture data
  86763. * @param scene defines the current scene
  86764. * @param rootUrl defines the root URL containing normal map procedural texture information
  86765. * @returns a parsed Normal Map Procedural BABYLON.Texture
  86766. */
  86767. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  86768. }
  86769. }
  86770. declare module BABYLON {
  86771. /** @hidden */
  86772. export var perlinNoiseProceduralTexturePixelShader: {
  86773. name: string;
  86774. shader: string;
  86775. };
  86776. }
  86777. declare module BABYLON {
  86778. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  86779. time: number;
  86780. timeScale: number;
  86781. translationSpeed: number;
  86782. private _currentTranslation;
  86783. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86784. updateShaderUniforms(): void;
  86785. render(useCameraPostProcess?: boolean): void;
  86786. resize(size: any, generateMipMaps: any): void;
  86787. /**
  86788. * Serializes this perlin noise procedural texture
  86789. * @returns a serialized perlin noise procedural texture object
  86790. */
  86791. serialize(): any;
  86792. /**
  86793. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  86794. * @param parsedTexture defines parsed texture data
  86795. * @param scene defines the current scene
  86796. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  86797. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  86798. */
  86799. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  86800. }
  86801. }
  86802. declare module BABYLON {
  86803. /** @hidden */
  86804. export var roadProceduralTexturePixelShader: {
  86805. name: string;
  86806. shader: string;
  86807. };
  86808. }
  86809. declare module BABYLON {
  86810. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  86811. private _roadColor;
  86812. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86813. updateShaderUniforms(): void;
  86814. get roadColor(): BABYLON.Color3;
  86815. set roadColor(value: BABYLON.Color3);
  86816. /**
  86817. * Serializes this road procedural texture
  86818. * @returns a serialized road procedural texture object
  86819. */
  86820. serialize(): any;
  86821. /**
  86822. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  86823. * @param parsedTexture defines parsed texture data
  86824. * @param scene defines the current scene
  86825. * @param rootUrl defines the root URL containing road procedural texture information
  86826. * @returns a parsed Road Procedural BABYLON.Texture
  86827. */
  86828. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  86829. }
  86830. }
  86831. declare module BABYLON {
  86832. /** @hidden */
  86833. export var starfieldProceduralTexturePixelShader: {
  86834. name: string;
  86835. shader: string;
  86836. };
  86837. }
  86838. declare module BABYLON {
  86839. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  86840. private _time;
  86841. private _alpha;
  86842. private _beta;
  86843. private _zoom;
  86844. private _formuparam;
  86845. private _stepsize;
  86846. private _tile;
  86847. private _brightness;
  86848. private _darkmatter;
  86849. private _distfading;
  86850. private _saturation;
  86851. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86852. updateShaderUniforms(): void;
  86853. get time(): number;
  86854. set time(value: number);
  86855. get alpha(): number;
  86856. set alpha(value: number);
  86857. get beta(): number;
  86858. set beta(value: number);
  86859. get formuparam(): number;
  86860. set formuparam(value: number);
  86861. get stepsize(): number;
  86862. set stepsize(value: number);
  86863. get zoom(): number;
  86864. set zoom(value: number);
  86865. get tile(): number;
  86866. set tile(value: number);
  86867. get brightness(): number;
  86868. set brightness(value: number);
  86869. get darkmatter(): number;
  86870. set darkmatter(value: number);
  86871. get distfading(): number;
  86872. set distfading(value: number);
  86873. get saturation(): number;
  86874. set saturation(value: number);
  86875. /**
  86876. * Serializes this starfield procedural texture
  86877. * @returns a serialized starfield procedural texture object
  86878. */
  86879. serialize(): any;
  86880. /**
  86881. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  86882. * @param parsedTexture defines parsed texture data
  86883. * @param scene defines the current scene
  86884. * @param rootUrl defines the root URL containing startfield procedural texture information
  86885. * @returns a parsed Starfield Procedural BABYLON.Texture
  86886. */
  86887. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  86888. }
  86889. }
  86890. declare module BABYLON {
  86891. /** @hidden */
  86892. export var woodProceduralTexturePixelShader: {
  86893. name: string;
  86894. shader: string;
  86895. };
  86896. }
  86897. declare module BABYLON {
  86898. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  86899. private _ampScale;
  86900. private _woodColor;
  86901. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86902. updateShaderUniforms(): void;
  86903. get ampScale(): number;
  86904. set ampScale(value: number);
  86905. get woodColor(): BABYLON.Color3;
  86906. set woodColor(value: BABYLON.Color3);
  86907. /**
  86908. * Serializes this wood procedural texture
  86909. * @returns a serialized wood procedural texture object
  86910. */
  86911. serialize(): any;
  86912. /**
  86913. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  86914. * @param parsedTexture defines parsed texture data
  86915. * @param scene defines the current scene
  86916. * @param rootUrl defines the root URL containing wood procedural texture information
  86917. * @returns a parsed Wood Procedural BABYLON.Texture
  86918. */
  86919. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  86920. }
  86921. }