documentation.d.ts 3.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. /**
  1053. * Prepass texture index for color
  1054. */
  1055. static readonly PREPASS_COLOR_INDEX: number;
  1056. /**
  1057. * Prepass texture index for irradiance
  1058. */
  1059. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1060. /**
  1061. * Prepass texture index for depth + normal
  1062. */
  1063. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1064. /**
  1065. * Prepass texture index for albedo
  1066. */
  1067. static readonly PREPASS_ALBEDO_INDEX: number;
  1068. }
  1069. }
  1070. declare module BABYLON {
  1071. /**
  1072. * This represents the required contract to create a new type of texture loader.
  1073. */
  1074. export interface IInternalTextureLoader {
  1075. /**
  1076. * Defines wether the loader supports cascade loading the different faces.
  1077. */
  1078. supportCascades: boolean;
  1079. /**
  1080. * This returns if the loader support the current file information.
  1081. * @param extension defines the file extension of the file being loaded
  1082. * @param mimeType defines the optional mime type of the file being loaded
  1083. * @returns true if the loader can load the specified file
  1084. */
  1085. canLoad(extension: string, mimeType?: string): boolean;
  1086. /**
  1087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1088. * @param data contains the texture data
  1089. * @param texture defines the BabylonJS internal texture
  1090. * @param createPolynomials will be true if polynomials have been requested
  1091. * @param onLoad defines the callback to trigger once the texture is ready
  1092. * @param onError defines the callback to trigger in case of error
  1093. */
  1094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1095. /**
  1096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1097. * @param data contains the texture data
  1098. * @param texture defines the BabylonJS internal texture
  1099. * @param callback defines the method to call once ready to upload
  1100. */
  1101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1102. }
  1103. }
  1104. declare module BABYLON {
  1105. /**
  1106. * Class used to store and describe the pipeline context associated with an effect
  1107. */
  1108. export interface IPipelineContext {
  1109. /**
  1110. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1111. */
  1112. isAsync: boolean;
  1113. /**
  1114. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1115. */
  1116. isReady: boolean;
  1117. /** @hidden */
  1118. _getVertexShaderCode(): string | null;
  1119. /** @hidden */
  1120. _getFragmentShaderCode(): string | null;
  1121. /** @hidden */
  1122. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Class used to store gfx data (like WebGLBuffer)
  1128. */
  1129. export class DataBuffer {
  1130. /**
  1131. * Gets or sets the number of objects referencing this buffer
  1132. */
  1133. references: number;
  1134. /** Gets or sets the size of the underlying buffer */
  1135. capacity: number;
  1136. /**
  1137. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1138. */
  1139. is32Bits: boolean;
  1140. /**
  1141. * Gets the underlying buffer
  1142. */
  1143. get underlyingResource(): any;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /** @hidden */
  1148. export interface IShaderProcessor {
  1149. attributeProcessor?: (attribute: string) => string;
  1150. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1151. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1152. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1153. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1154. lineProcessor?: (line: string, isFragment: boolean) => string;
  1155. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1156. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1157. }
  1158. }
  1159. declare module BABYLON {
  1160. /** @hidden */
  1161. export interface ProcessingOptions {
  1162. defines: string[];
  1163. indexParameters: any;
  1164. isFragment: boolean;
  1165. shouldUseHighPrecisionShader: boolean;
  1166. supportsUniformBuffers: boolean;
  1167. shadersRepository: string;
  1168. includesShadersStore: {
  1169. [key: string]: string;
  1170. };
  1171. processor?: IShaderProcessor;
  1172. version: string;
  1173. platformName: string;
  1174. lookForClosingBracketForUniformBuffer?: boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeNode {
  1180. line: string;
  1181. children: ShaderCodeNode[];
  1182. additionalDefineKey?: string;
  1183. additionalDefineValue?: string;
  1184. isValid(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. process(preprocessors: {
  1188. [key: string]: string;
  1189. }, options: ProcessingOptions): string;
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeCursor {
  1195. private _lines;
  1196. lineIndex: number;
  1197. get currentLine(): string;
  1198. get canRead(): boolean;
  1199. set lines(value: string[]);
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1205. process(preprocessors: {
  1206. [key: string]: string;
  1207. }, options: ProcessingOptions): string;
  1208. }
  1209. }
  1210. declare module BABYLON {
  1211. /** @hidden */
  1212. export class ShaderDefineExpression {
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. private static _OperatorPriority;
  1217. private static _Stack;
  1218. static postfixToInfix(postfix: string[]): string;
  1219. static infixToPostfix(infix: string): string[];
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderCodeTestNode extends ShaderCodeNode {
  1225. testExpression: ShaderDefineExpression;
  1226. isValid(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1234. define: string;
  1235. not: boolean;
  1236. constructor(define: string, not?: boolean);
  1237. isTrue(preprocessors: {
  1238. [key: string]: string;
  1239. }): boolean;
  1240. }
  1241. }
  1242. declare module BABYLON {
  1243. /** @hidden */
  1244. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module BABYLON {
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module BABYLON {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module BABYLON {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module BABYLON {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1492. }
  1493. }
  1494. declare module BABYLON {
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IColor4Like {
  1499. r: float;
  1500. g: float;
  1501. b: float;
  1502. a: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IColor3Like {
  1508. r: float;
  1509. g: float;
  1510. b: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector4Like {
  1516. x: float;
  1517. y: float;
  1518. z: float;
  1519. w: float;
  1520. }
  1521. /**
  1522. * @hidden
  1523. */
  1524. export interface IVector3Like {
  1525. x: float;
  1526. y: float;
  1527. z: float;
  1528. }
  1529. /**
  1530. * @hidden
  1531. */
  1532. export interface IVector2Like {
  1533. x: float;
  1534. y: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IMatrixLike {
  1540. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1541. updateFlag: int;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IViewportLike {
  1547. x: float;
  1548. y: float;
  1549. width: float;
  1550. height: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IPlaneLike {
  1556. normal: IVector3Like;
  1557. d: float;
  1558. normalize(): void;
  1559. }
  1560. }
  1561. declare module BABYLON {
  1562. /**
  1563. * Interface used to define common properties for effect fallbacks
  1564. */
  1565. export interface IEffectFallbacks {
  1566. /**
  1567. * Removes the defines that should be removed when falling back.
  1568. * @param currentDefines defines the current define statements for the shader.
  1569. * @param effect defines the current effect we try to compile
  1570. * @returns The resulting defines with defines of the current rank removed.
  1571. */
  1572. reduce(currentDefines: string, effect: Effect): string;
  1573. /**
  1574. * Removes the fallback from the bound mesh.
  1575. */
  1576. unBindMesh(): void;
  1577. /**
  1578. * Checks to see if more fallbacks are still availible.
  1579. */
  1580. hasMoreFallbacks: boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to evalaute queries containing `and` and `or` operators
  1586. */
  1587. export class AndOrNotEvaluator {
  1588. /**
  1589. * Evaluate a query
  1590. * @param query defines the query to evaluate
  1591. * @param evaluateCallback defines the callback used to filter result
  1592. * @returns true if the query matches
  1593. */
  1594. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1595. private static _HandleParenthesisContent;
  1596. private static _SimplifyNegation;
  1597. }
  1598. }
  1599. declare module BABYLON {
  1600. /**
  1601. * Class used to store custom tags
  1602. */
  1603. export class Tags {
  1604. /**
  1605. * Adds support for tags on the given object
  1606. * @param obj defines the object to use
  1607. */
  1608. static EnableFor(obj: any): void;
  1609. /**
  1610. * Removes tags support
  1611. * @param obj defines the object to use
  1612. */
  1613. static DisableFor(obj: any): void;
  1614. /**
  1615. * Gets a boolean indicating if the given object has tags
  1616. * @param obj defines the object to use
  1617. * @returns a boolean
  1618. */
  1619. static HasTags(obj: any): boolean;
  1620. /**
  1621. * Gets the tags available on a given object
  1622. * @param obj defines the object to use
  1623. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1624. * @returns the tags
  1625. */
  1626. static GetTags(obj: any, asString?: boolean): any;
  1627. /**
  1628. * Adds tags to an object
  1629. * @param obj defines the object to use
  1630. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1631. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1632. */
  1633. static AddTagsTo(obj: any, tagsString: string): void;
  1634. /**
  1635. * @hidden
  1636. */
  1637. static _AddTagTo(obj: any, tag: string): void;
  1638. /**
  1639. * Removes specific tags from a specific object
  1640. * @param obj defines the object to use
  1641. * @param tagsString defines the tags to remove
  1642. */
  1643. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1644. /**
  1645. * @hidden
  1646. */
  1647. static _RemoveTagFrom(obj: any, tag: string): void;
  1648. /**
  1649. * Defines if tags hosted on an object match a given query
  1650. * @param obj defines the object to use
  1651. * @param tagsQuery defines the tag query
  1652. * @returns a boolean
  1653. */
  1654. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1655. }
  1656. }
  1657. declare module BABYLON {
  1658. /**
  1659. * Scalar computation library
  1660. */
  1661. export class Scalar {
  1662. /**
  1663. * Two pi constants convenient for computation.
  1664. */
  1665. static TwoPi: number;
  1666. /**
  1667. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. * @param a number
  1669. * @param b number
  1670. * @param epsilon (default = 1.401298E-45)
  1671. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. */
  1673. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1674. /**
  1675. * Returns a string : the upper case translation of the number i to hexadecimal.
  1676. * @param i number
  1677. * @returns the upper case translation of the number i to hexadecimal.
  1678. */
  1679. static ToHex(i: number): string;
  1680. /**
  1681. * Returns -1 if value is negative and +1 is value is positive.
  1682. * @param value the value
  1683. * @returns the value itself if it's equal to zero.
  1684. */
  1685. static Sign(value: number): number;
  1686. /**
  1687. * Returns the value itself if it's between min and max.
  1688. * Returns min if the value is lower than min.
  1689. * Returns max if the value is greater than max.
  1690. * @param value the value to clmap
  1691. * @param min the min value to clamp to (default: 0)
  1692. * @param max the max value to clamp to (default: 1)
  1693. * @returns the clamped value
  1694. */
  1695. static Clamp(value: number, min?: number, max?: number): number;
  1696. /**
  1697. * the log2 of value.
  1698. * @param value the value to compute log2 of
  1699. * @returns the log2 of value.
  1700. */
  1701. static Log2(value: number): number;
  1702. /**
  1703. * Loops the value, so that it is never larger than length and never smaller than 0.
  1704. *
  1705. * This is similar to the modulo operator but it works with floating point numbers.
  1706. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1707. * With t = 5 and length = 2.5, the result would be 0.0.
  1708. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1709. * @param value the value
  1710. * @param length the length
  1711. * @returns the looped value
  1712. */
  1713. static Repeat(value: number, length: number): number;
  1714. /**
  1715. * Normalize the value between 0.0 and 1.0 using min and max values
  1716. * @param value value to normalize
  1717. * @param min max to normalize between
  1718. * @param max min to normalize between
  1719. * @returns the normalized value
  1720. */
  1721. static Normalize(value: number, min: number, max: number): number;
  1722. /**
  1723. * Denormalize the value from 0.0 and 1.0 using min and max values
  1724. * @param normalized value to denormalize
  1725. * @param min max to denormalize between
  1726. * @param max min to denormalize between
  1727. * @returns the denormalized value
  1728. */
  1729. static Denormalize(normalized: number, min: number, max: number): number;
  1730. /**
  1731. * Calculates the shortest difference between two given angles given in degrees.
  1732. * @param current current angle in degrees
  1733. * @param target target angle in degrees
  1734. * @returns the delta
  1735. */
  1736. static DeltaAngle(current: number, target: number): number;
  1737. /**
  1738. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1739. * @param tx value
  1740. * @param length length
  1741. * @returns The returned value will move back and forth between 0 and length
  1742. */
  1743. static PingPong(tx: number, length: number): number;
  1744. /**
  1745. * Interpolates between min and max with smoothing at the limits.
  1746. *
  1747. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1748. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1749. * @param from from
  1750. * @param to to
  1751. * @param tx value
  1752. * @returns the smooth stepped value
  1753. */
  1754. static SmoothStep(from: number, to: number, tx: number): number;
  1755. /**
  1756. * Moves a value current towards target.
  1757. *
  1758. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1759. * Negative values of maxDelta pushes the value away from target.
  1760. * @param current current value
  1761. * @param target target value
  1762. * @param maxDelta max distance to move
  1763. * @returns resulting value
  1764. */
  1765. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1766. /**
  1767. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1768. *
  1769. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1770. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1771. * @param current current value
  1772. * @param target target value
  1773. * @param maxDelta max distance to move
  1774. * @returns resulting angle
  1775. */
  1776. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1777. /**
  1778. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static Lerp(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1788. * @param start start value
  1789. * @param end target value
  1790. * @param amount amount to lerp between
  1791. * @returns the lerped value
  1792. */
  1793. static LerpAngle(start: number, end: number, amount: number): number;
  1794. /**
  1795. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1796. * @param a start value
  1797. * @param b target value
  1798. * @param value value between a and b
  1799. * @returns the inverseLerp value
  1800. */
  1801. static InverseLerp(a: number, b: number, value: number): number;
  1802. /**
  1803. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1804. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1805. * @param value1 spline value
  1806. * @param tangent1 spline value
  1807. * @param value2 spline value
  1808. * @param tangent2 spline value
  1809. * @param amount input value
  1810. * @returns hermite result
  1811. */
  1812. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1813. /**
  1814. * Returns a random float number between and min and max values
  1815. * @param min min value of random
  1816. * @param max max value of random
  1817. * @returns random value
  1818. */
  1819. static RandomRange(min: number, max: number): number;
  1820. /**
  1821. * This function returns percentage of a number in a given range.
  1822. *
  1823. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1824. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1825. * @param number to convert to percentage
  1826. * @param min min range
  1827. * @param max max range
  1828. * @returns the percentage
  1829. */
  1830. static RangeToPercent(number: number, min: number, max: number): number;
  1831. /**
  1832. * This function returns number that corresponds to the percentage in a given range.
  1833. *
  1834. * PercentToRange(0.34,0,100) will return 34.
  1835. * @param percent to convert to number
  1836. * @param min min range
  1837. * @param max max range
  1838. * @returns the number
  1839. */
  1840. static PercentToRange(percent: number, min: number, max: number): number;
  1841. /**
  1842. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1843. * @param angle The angle to normalize in radian.
  1844. * @return The converted angle.
  1845. */
  1846. static NormalizeRadians(angle: number): number;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Constant used to convert a value to gamma space
  1852. * @ignorenaming
  1853. */
  1854. export const ToGammaSpace: number;
  1855. /**
  1856. * Constant used to convert a value to linear space
  1857. * @ignorenaming
  1858. */
  1859. export const ToLinearSpace = 2.2;
  1860. /**
  1861. * Constant used to define the minimal number value in Babylon.js
  1862. * @ignorenaming
  1863. */
  1864. let Epsilon: number;
  1865. }
  1866. declare module BABYLON {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module BABYLON {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module BABYLON {
  1932. /**
  1933. * Represents a plane by the equation ax + by + cz + d = 0
  1934. */
  1935. export class Plane {
  1936. private static _TmpMatrix;
  1937. /**
  1938. * Normal of the plane (a,b,c)
  1939. */
  1940. normal: Vector3;
  1941. /**
  1942. * d component of the plane
  1943. */
  1944. d: number;
  1945. /**
  1946. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1947. * @param a a component of the plane
  1948. * @param b b component of the plane
  1949. * @param c c component of the plane
  1950. * @param d d component of the plane
  1951. */
  1952. constructor(a: number, b: number, c: number, d: number);
  1953. /**
  1954. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1955. */
  1956. asArray(): number[];
  1957. /**
  1958. * @returns a new plane copied from the current Plane.
  1959. */
  1960. clone(): Plane;
  1961. /**
  1962. * @returns the string "Plane".
  1963. */
  1964. getClassName(): string;
  1965. /**
  1966. * @returns the Plane hash code.
  1967. */
  1968. getHashCode(): number;
  1969. /**
  1970. * Normalize the current Plane in place.
  1971. * @returns the updated Plane.
  1972. */
  1973. normalize(): Plane;
  1974. /**
  1975. * Applies a transformation the plane and returns the result
  1976. * @param transformation the transformation matrix to be applied to the plane
  1977. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1978. */
  1979. transform(transformation: DeepImmutable<Matrix>): Plane;
  1980. /**
  1981. * Compute the dot product between the point and the plane normal
  1982. * @param point point to calculate the dot product with
  1983. * @returns the dot product (float) of the point coordinates and the plane normal.
  1984. */
  1985. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1986. /**
  1987. * Updates the current Plane from the plane defined by the three given points.
  1988. * @param point1 one of the points used to contruct the plane
  1989. * @param point2 one of the points used to contruct the plane
  1990. * @param point3 one of the points used to contruct the plane
  1991. * @returns the updated Plane.
  1992. */
  1993. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1994. /**
  1995. * Checks if the plane is facing a given direction
  1996. * @param direction the direction to check if the plane is facing
  1997. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1998. * @returns True is the vector "direction" is the same side than the plane normal.
  1999. */
  2000. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2001. /**
  2002. * Calculates the distance to a point
  2003. * @param point point to calculate distance to
  2004. * @returns the signed distance (float) from the given point to the Plane.
  2005. */
  2006. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2007. /**
  2008. * Creates a plane from an array
  2009. * @param array the array to create a plane from
  2010. * @returns a new Plane from the given array.
  2011. */
  2012. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2013. /**
  2014. * Creates a plane from three points
  2015. * @param point1 point used to create the plane
  2016. * @param point2 point used to create the plane
  2017. * @param point3 point used to create the plane
  2018. * @returns a new Plane defined by the three given points.
  2019. */
  2020. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2021. /**
  2022. * Creates a plane from an origin point and a normal
  2023. * @param origin origin of the plane to be constructed
  2024. * @param normal normal of the plane to be constructed
  2025. * @returns a new Plane the normal vector to this plane at the given origin point.
  2026. * Note : the vector "normal" is updated because normalized.
  2027. */
  2028. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2029. /**
  2030. * Calculates the distance from a plane and a point
  2031. * @param origin origin of the plane to be constructed
  2032. * @param normal normal of the plane to be constructed
  2033. * @param point point to calculate distance to
  2034. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2035. */
  2036. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2037. }
  2038. }
  2039. declare module BABYLON {
  2040. /** @hidden */
  2041. export class PerformanceConfigurator {
  2042. /** @hidden */
  2043. static MatrixUse64Bits: boolean;
  2044. /** @hidden */
  2045. static MatrixTrackPrecisionChange: boolean;
  2046. /** @hidden */
  2047. static MatrixCurrentType: any;
  2048. /** @hidden */
  2049. static MatrixTrackedMatrices: Array<any> | null;
  2050. /** @hidden */
  2051. static SetMatrixPrecision(use64bits: boolean): void;
  2052. }
  2053. }
  2054. declare module BABYLON {
  2055. /**
  2056. * Class representing a vector containing 2 coordinates
  2057. */
  2058. export class Vector2 {
  2059. /** defines the first coordinate */
  2060. x: number;
  2061. /** defines the second coordinate */
  2062. y: number;
  2063. /**
  2064. * Creates a new Vector2 from the given x and y coordinates
  2065. * @param x defines the first coordinate
  2066. * @param y defines the second coordinate
  2067. */
  2068. constructor(
  2069. /** defines the first coordinate */
  2070. x?: number,
  2071. /** defines the second coordinate */
  2072. y?: number);
  2073. /**
  2074. * Gets a string with the Vector2 coordinates
  2075. * @returns a string with the Vector2 coordinates
  2076. */
  2077. toString(): string;
  2078. /**
  2079. * Gets class name
  2080. * @returns the string "Vector2"
  2081. */
  2082. getClassName(): string;
  2083. /**
  2084. * Gets current vector hash code
  2085. * @returns the Vector2 hash code as a number
  2086. */
  2087. getHashCode(): number;
  2088. /**
  2089. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2090. * @param array defines the source array
  2091. * @param index defines the offset in source array
  2092. * @returns the current Vector2
  2093. */
  2094. toArray(array: FloatArray, index?: number): Vector2;
  2095. /**
  2096. * Update the current vector from an array
  2097. * @param array defines the destination array
  2098. * @param index defines the offset in the destination array
  2099. * @returns the current Vector3
  2100. */
  2101. fromArray(array: FloatArray, index?: number): Vector2;
  2102. /**
  2103. * Copy the current vector to an array
  2104. * @returns a new array with 2 elements: the Vector2 coordinates.
  2105. */
  2106. asArray(): number[];
  2107. /**
  2108. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2109. * @param source defines the source Vector2
  2110. * @returns the current updated Vector2
  2111. */
  2112. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2113. /**
  2114. * Sets the Vector2 coordinates with the given floats
  2115. * @param x defines the first coordinate
  2116. * @param y defines the second coordinate
  2117. * @returns the current updated Vector2
  2118. */
  2119. copyFromFloats(x: number, y: number): Vector2;
  2120. /**
  2121. * Sets the Vector2 coordinates with the given floats
  2122. * @param x defines the first coordinate
  2123. * @param y defines the second coordinate
  2124. * @returns the current updated Vector2
  2125. */
  2126. set(x: number, y: number): Vector2;
  2127. /**
  2128. * Add another vector with the current one
  2129. * @param otherVector defines the other vector
  2130. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2131. */
  2132. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2133. /**
  2134. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2135. * @param otherVector defines the other vector
  2136. * @param result defines the target vector
  2137. * @returns the unmodified current Vector2
  2138. */
  2139. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2140. /**
  2141. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2142. * @param otherVector defines the other vector
  2143. * @returns the current updated Vector2
  2144. */
  2145. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2146. /**
  2147. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2148. * @param otherVector defines the other vector
  2149. * @returns a new Vector2
  2150. */
  2151. addVector3(otherVector: Vector3): Vector2;
  2152. /**
  2153. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2154. * @param otherVector defines the other vector
  2155. * @returns a new Vector2
  2156. */
  2157. subtract(otherVector: Vector2): Vector2;
  2158. /**
  2159. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2160. * @param otherVector defines the other vector
  2161. * @param result defines the target vector
  2162. * @returns the unmodified current Vector2
  2163. */
  2164. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2165. /**
  2166. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2167. * @param otherVector defines the other vector
  2168. * @returns the current updated Vector2
  2169. */
  2170. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2171. /**
  2172. * Multiplies in place the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2183. /**
  2184. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2185. * @param otherVector defines the other vector
  2186. * @param result defines the target vector
  2187. * @returns the unmodified current Vector2
  2188. */
  2189. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2190. /**
  2191. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2192. * @param x defines the first coordinate
  2193. * @param y defines the second coordinate
  2194. * @returns a new Vector2
  2195. */
  2196. multiplyByFloats(x: number, y: number): Vector2;
  2197. /**
  2198. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2199. * @param otherVector defines the other vector
  2200. * @returns a new Vector2
  2201. */
  2202. divide(otherVector: Vector2): Vector2;
  2203. /**
  2204. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2205. * @param otherVector defines the other vector
  2206. * @param result defines the target vector
  2207. * @returns the unmodified current Vector2
  2208. */
  2209. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2210. /**
  2211. * Divides the current Vector2 coordinates by the given ones
  2212. * @param otherVector defines the other vector
  2213. * @returns the current updated Vector2
  2214. */
  2215. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2216. /**
  2217. * Gets a new Vector2 with current Vector2 negated coordinates
  2218. * @returns a new Vector2
  2219. */
  2220. negate(): Vector2;
  2221. /**
  2222. * Negate this vector in place
  2223. * @returns this
  2224. */
  2225. negateInPlace(): Vector2;
  2226. /**
  2227. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2228. * @param result defines the Vector3 object where to store the result
  2229. * @returns the current Vector2
  2230. */
  2231. negateToRef(result: Vector2): Vector2;
  2232. /**
  2233. * Multiply the Vector2 coordinates by scale
  2234. * @param scale defines the scaling factor
  2235. * @returns the current updated Vector2
  2236. */
  2237. scaleInPlace(scale: number): Vector2;
  2238. /**
  2239. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2240. * @param scale defines the scaling factor
  2241. * @returns a new Vector2
  2242. */
  2243. scale(scale: number): Vector2;
  2244. /**
  2245. * Scale the current Vector2 values by a factor to a given Vector2
  2246. * @param scale defines the scale factor
  2247. * @param result defines the Vector2 object where to store the result
  2248. * @returns the unmodified current Vector2
  2249. */
  2250. scaleToRef(scale: number, result: Vector2): Vector2;
  2251. /**
  2252. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2253. * @param scale defines the scale factor
  2254. * @param result defines the Vector2 object where to store the result
  2255. * @returns the unmodified current Vector2
  2256. */
  2257. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2258. /**
  2259. * Gets a boolean if two vectors are equals
  2260. * @param otherVector defines the other vector
  2261. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2262. */
  2263. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2264. /**
  2265. * Gets a boolean if two vectors are equals (using an epsilon value)
  2266. * @param otherVector defines the other vector
  2267. * @param epsilon defines the minimal distance to consider equality
  2268. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2269. */
  2270. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2271. /**
  2272. * Gets a new Vector2 from current Vector2 floored values
  2273. * @returns a new Vector2
  2274. */
  2275. floor(): Vector2;
  2276. /**
  2277. * Gets a new Vector2 from current Vector2 floored values
  2278. * @returns a new Vector2
  2279. */
  2280. fract(): Vector2;
  2281. /**
  2282. * Gets the length of the vector
  2283. * @returns the vector length (float)
  2284. */
  2285. length(): number;
  2286. /**
  2287. * Gets the vector squared length
  2288. * @returns the vector squared length (float)
  2289. */
  2290. lengthSquared(): number;
  2291. /**
  2292. * Normalize the vector
  2293. * @returns the current updated Vector2
  2294. */
  2295. normalize(): Vector2;
  2296. /**
  2297. * Gets a new Vector2 copied from the Vector2
  2298. * @returns a new Vector2
  2299. */
  2300. clone(): Vector2;
  2301. /**
  2302. * Gets a new Vector2(0, 0)
  2303. * @returns a new Vector2
  2304. */
  2305. static Zero(): Vector2;
  2306. /**
  2307. * Gets a new Vector2(1, 1)
  2308. * @returns a new Vector2
  2309. */
  2310. static One(): Vector2;
  2311. /**
  2312. * Gets a new Vector2 set from the given index element of the given array
  2313. * @param array defines the data source
  2314. * @param offset defines the offset in the data source
  2315. * @returns a new Vector2
  2316. */
  2317. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2318. /**
  2319. * Sets "result" from the given index element of the given array
  2320. * @param array defines the data source
  2321. * @param offset defines the offset in the data source
  2322. * @param result defines the target vector
  2323. */
  2324. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2325. /**
  2326. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2327. * @param value1 defines 1st point of control
  2328. * @param value2 defines 2nd point of control
  2329. * @param value3 defines 3rd point of control
  2330. * @param value4 defines 4th point of control
  2331. * @param amount defines the interpolation factor
  2332. * @returns a new Vector2
  2333. */
  2334. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2335. /**
  2336. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2337. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2338. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2339. * @param value defines the value to clamp
  2340. * @param min defines the lower limit
  2341. * @param max defines the upper limit
  2342. * @returns a new Vector2
  2343. */
  2344. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2345. /**
  2346. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2347. * @param value1 defines the 1st control point
  2348. * @param tangent1 defines the outgoing tangent
  2349. * @param value2 defines the 2nd control point
  2350. * @param tangent2 defines the incoming tangent
  2351. * @param amount defines the interpolation factor
  2352. * @returns a new Vector2
  2353. */
  2354. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2355. /**
  2356. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2357. * @param start defines the start vector
  2358. * @param end defines the end vector
  2359. * @param amount defines the interpolation factor
  2360. * @returns a new Vector2
  2361. */
  2362. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2363. /**
  2364. * Gets the dot product of the vector "left" and the vector "right"
  2365. * @param left defines first vector
  2366. * @param right defines second vector
  2367. * @returns the dot product (float)
  2368. */
  2369. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2370. /**
  2371. * Returns a new Vector2 equal to the normalized given vector
  2372. * @param vector defines the vector to normalize
  2373. * @returns a new Vector2
  2374. */
  2375. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2378. * @param left defines 1st vector
  2379. * @param right defines 2nd vector
  2380. * @returns a new Vector2
  2381. */
  2382. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2383. /**
  2384. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2385. * @param left defines 1st vector
  2386. * @param right defines 2nd vector
  2387. * @returns a new Vector2
  2388. */
  2389. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2390. /**
  2391. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2392. * @param vector defines the vector to transform
  2393. * @param transformation defines the matrix to apply
  2394. * @returns a new Vector2
  2395. */
  2396. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2397. /**
  2398. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2399. * @param vector defines the vector to transform
  2400. * @param transformation defines the matrix to apply
  2401. * @param result defines the target vector
  2402. */
  2403. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2404. /**
  2405. * Determines if a given vector is included in a triangle
  2406. * @param p defines the vector to test
  2407. * @param p0 defines 1st triangle point
  2408. * @param p1 defines 2nd triangle point
  2409. * @param p2 defines 3rd triangle point
  2410. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2411. */
  2412. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2413. /**
  2414. * Gets the distance between the vectors "value1" and "value2"
  2415. * @param value1 defines first vector
  2416. * @param value2 defines second vector
  2417. * @returns the distance between vectors
  2418. */
  2419. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2420. /**
  2421. * Returns the squared distance between the vectors "value1" and "value2"
  2422. * @param value1 defines first vector
  2423. * @param value2 defines second vector
  2424. * @returns the squared distance between vectors
  2425. */
  2426. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2427. /**
  2428. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2429. * @param value1 defines first vector
  2430. * @param value2 defines second vector
  2431. * @returns a new Vector2
  2432. */
  2433. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2434. /**
  2435. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2436. * @param p defines the middle point
  2437. * @param segA defines one point of the segment
  2438. * @param segB defines the other point of the segment
  2439. * @returns the shortest distance
  2440. */
  2441. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2442. }
  2443. /**
  2444. * Class used to store (x,y,z) vector representation
  2445. * A Vector3 is the main object used in 3D geometry
  2446. * It can represent etiher the coordinates of a point the space, either a direction
  2447. * Reminder: js uses a left handed forward facing system
  2448. */
  2449. export class Vector3 {
  2450. private static _UpReadOnly;
  2451. private static _ZeroReadOnly;
  2452. /** @hidden */
  2453. _x: number;
  2454. /** @hidden */
  2455. _y: number;
  2456. /** @hidden */
  2457. _z: number;
  2458. /** @hidden */
  2459. _isDirty: boolean;
  2460. /** Gets or sets the x coordinate */
  2461. get x(): number;
  2462. set x(value: number);
  2463. /** Gets or sets the y coordinate */
  2464. get y(): number;
  2465. set y(value: number);
  2466. /** Gets or sets the z coordinate */
  2467. get z(): number;
  2468. set z(value: number);
  2469. /**
  2470. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2471. * @param x defines the first coordinates (on X axis)
  2472. * @param y defines the second coordinates (on Y axis)
  2473. * @param z defines the third coordinates (on Z axis)
  2474. */
  2475. constructor(x?: number, y?: number, z?: number);
  2476. /**
  2477. * Creates a string representation of the Vector3
  2478. * @returns a string with the Vector3 coordinates.
  2479. */
  2480. toString(): string;
  2481. /**
  2482. * Gets the class name
  2483. * @returns the string "Vector3"
  2484. */
  2485. getClassName(): string;
  2486. /**
  2487. * Creates the Vector3 hash code
  2488. * @returns a number which tends to be unique between Vector3 instances
  2489. */
  2490. getHashCode(): number;
  2491. /**
  2492. * Creates an array containing three elements : the coordinates of the Vector3
  2493. * @returns a new array of numbers
  2494. */
  2495. asArray(): number[];
  2496. /**
  2497. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2498. * @param array defines the destination array
  2499. * @param index defines the offset in the destination array
  2500. * @returns the current Vector3
  2501. */
  2502. toArray(array: FloatArray, index?: number): Vector3;
  2503. /**
  2504. * Update the current vector from an array
  2505. * @param array defines the destination array
  2506. * @param index defines the offset in the destination array
  2507. * @returns the current Vector3
  2508. */
  2509. fromArray(array: FloatArray, index?: number): Vector3;
  2510. /**
  2511. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2512. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2513. */
  2514. toQuaternion(): Quaternion;
  2515. /**
  2516. * Adds the given vector to the current Vector3
  2517. * @param otherVector defines the second operand
  2518. * @returns the current updated Vector3
  2519. */
  2520. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2521. /**
  2522. * Adds the given coordinates to the current Vector3
  2523. * @param x defines the x coordinate of the operand
  2524. * @param y defines the y coordinate of the operand
  2525. * @param z defines the z coordinate of the operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2529. /**
  2530. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2531. * @param otherVector defines the second operand
  2532. * @returns the resulting Vector3
  2533. */
  2534. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2537. * @param otherVector defines the second operand
  2538. * @param result defines the Vector3 object where to store the result
  2539. * @returns the current Vector3
  2540. */
  2541. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2542. /**
  2543. * Subtract the given vector from the current Vector3
  2544. * @param otherVector defines the second operand
  2545. * @returns the current updated Vector3
  2546. */
  2547. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2548. /**
  2549. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2550. * @param otherVector defines the second operand
  2551. * @returns the resulting Vector3
  2552. */
  2553. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2554. /**
  2555. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2556. * @param otherVector defines the second operand
  2557. * @param result defines the Vector3 object where to store the result
  2558. * @returns the current Vector3
  2559. */
  2560. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2563. * @param x defines the x coordinate of the operand
  2564. * @param y defines the y coordinate of the operand
  2565. * @param z defines the z coordinate of the operand
  2566. * @returns the resulting Vector3
  2567. */
  2568. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2569. /**
  2570. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2571. * @param x defines the x coordinate of the operand
  2572. * @param y defines the y coordinate of the operand
  2573. * @param z defines the z coordinate of the operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2578. /**
  2579. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2580. * @returns a new Vector3
  2581. */
  2582. negate(): Vector3;
  2583. /**
  2584. * Negate this vector in place
  2585. * @returns this
  2586. */
  2587. negateInPlace(): Vector3;
  2588. /**
  2589. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2590. * @param result defines the Vector3 object where to store the result
  2591. * @returns the current Vector3
  2592. */
  2593. negateToRef(result: Vector3): Vector3;
  2594. /**
  2595. * Multiplies the Vector3 coordinates by the float "scale"
  2596. * @param scale defines the multiplier factor
  2597. * @returns the current updated Vector3
  2598. */
  2599. scaleInPlace(scale: number): Vector3;
  2600. /**
  2601. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2602. * @param scale defines the multiplier factor
  2603. * @returns a new Vector3
  2604. */
  2605. scale(scale: number): Vector3;
  2606. /**
  2607. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2608. * @param scale defines the multiplier factor
  2609. * @param result defines the Vector3 object where to store the result
  2610. * @returns the current Vector3
  2611. */
  2612. scaleToRef(scale: number, result: Vector3): Vector3;
  2613. /**
  2614. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2615. * @param scale defines the scale factor
  2616. * @param result defines the Vector3 object where to store the result
  2617. * @returns the unmodified current Vector3
  2618. */
  2619. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2620. /**
  2621. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2622. * @param origin defines the origin of the projection ray
  2623. * @param plane defines the plane to project to
  2624. * @returns the projected vector3
  2625. */
  2626. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2627. /**
  2628. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2629. * @param origin defines the origin of the projection ray
  2630. * @param plane defines the plane to project to
  2631. * @param result defines the Vector3 where to store the result
  2632. */
  2633. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2634. /**
  2635. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2636. * @param otherVector defines the second operand
  2637. * @returns true if both vectors are equals
  2638. */
  2639. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2640. /**
  2641. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2642. * @param otherVector defines the second operand
  2643. * @param epsilon defines the minimal distance to define values as equals
  2644. * @returns true if both vectors are distant less than epsilon
  2645. */
  2646. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2647. /**
  2648. * Returns true if the current Vector3 coordinates equals the given floats
  2649. * @param x defines the x coordinate of the operand
  2650. * @param y defines the y coordinate of the operand
  2651. * @param z defines the z coordinate of the operand
  2652. * @returns true if both vectors are equals
  2653. */
  2654. equalsToFloats(x: number, y: number, z: number): boolean;
  2655. /**
  2656. * Multiplies the current Vector3 coordinates by the given ones
  2657. * @param otherVector defines the second operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2661. /**
  2662. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2663. * @param otherVector defines the second operand
  2664. * @returns the new Vector3
  2665. */
  2666. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2669. * @param otherVector defines the second operand
  2670. * @param result defines the Vector3 object where to store the result
  2671. * @returns the current Vector3
  2672. */
  2673. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2674. /**
  2675. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the new Vector3
  2680. */
  2681. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2684. * @param otherVector defines the second operand
  2685. * @returns the new Vector3
  2686. */
  2687. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2688. /**
  2689. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2690. * @param otherVector defines the second operand
  2691. * @param result defines the Vector3 object where to store the result
  2692. * @returns the current Vector3
  2693. */
  2694. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2695. /**
  2696. * Divides the current Vector3 coordinates by the given ones.
  2697. * @param otherVector defines the second operand
  2698. * @returns the current updated Vector3
  2699. */
  2700. divideInPlace(otherVector: Vector3): Vector3;
  2701. /**
  2702. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2707. /**
  2708. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2709. * @param other defines the second operand
  2710. * @returns the current updated Vector3
  2711. */
  2712. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2713. /**
  2714. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2715. * @param x defines the x coordinate of the operand
  2716. * @param y defines the y coordinate of the operand
  2717. * @param z defines the z coordinate of the operand
  2718. * @returns the current updated Vector3
  2719. */
  2720. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2721. /**
  2722. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2723. * @param x defines the x coordinate of the operand
  2724. * @param y defines the y coordinate of the operand
  2725. * @param z defines the z coordinate of the operand
  2726. * @returns the current updated Vector3
  2727. */
  2728. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2729. /**
  2730. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2731. * Check if is non uniform within a certain amount of decimal places to account for this
  2732. * @param epsilon the amount the values can differ
  2733. * @returns if the the vector is non uniform to a certain number of decimal places
  2734. */
  2735. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2736. /**
  2737. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2738. */
  2739. get isNonUniform(): boolean;
  2740. /**
  2741. * Gets a new Vector3 from current Vector3 floored values
  2742. * @returns a new Vector3
  2743. */
  2744. floor(): Vector3;
  2745. /**
  2746. * Gets a new Vector3 from current Vector3 floored values
  2747. * @returns a new Vector3
  2748. */
  2749. fract(): Vector3;
  2750. /**
  2751. * Gets the length of the Vector3
  2752. * @returns the length of the Vector3
  2753. */
  2754. length(): number;
  2755. /**
  2756. * Gets the squared length of the Vector3
  2757. * @returns squared length of the Vector3
  2758. */
  2759. lengthSquared(): number;
  2760. /**
  2761. * Normalize the current Vector3.
  2762. * Please note that this is an in place operation.
  2763. * @returns the current updated Vector3
  2764. */
  2765. normalize(): Vector3;
  2766. /**
  2767. * Reorders the x y z properties of the vector in place
  2768. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2769. * @returns the current updated vector
  2770. */
  2771. reorderInPlace(order: string): this;
  2772. /**
  2773. * Rotates the vector around 0,0,0 by a quaternion
  2774. * @param quaternion the rotation quaternion
  2775. * @param result vector to store the result
  2776. * @returns the resulting vector
  2777. */
  2778. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2779. /**
  2780. * Rotates a vector around a given point
  2781. * @param quaternion the rotation quaternion
  2782. * @param point the point to rotate around
  2783. * @param result vector to store the result
  2784. * @returns the resulting vector
  2785. */
  2786. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2787. /**
  2788. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2789. * The cross product is then orthogonal to both current and "other"
  2790. * @param other defines the right operand
  2791. * @returns the cross product
  2792. */
  2793. cross(other: Vector3): Vector3;
  2794. /**
  2795. * Normalize the current Vector3 with the given input length.
  2796. * Please note that this is an in place operation.
  2797. * @param len the length of the vector
  2798. * @returns the current updated Vector3
  2799. */
  2800. normalizeFromLength(len: number): Vector3;
  2801. /**
  2802. * Normalize the current Vector3 to a new vector
  2803. * @returns the new Vector3
  2804. */
  2805. normalizeToNew(): Vector3;
  2806. /**
  2807. * Normalize the current Vector3 to the reference
  2808. * @param reference define the Vector3 to update
  2809. * @returns the updated Vector3
  2810. */
  2811. normalizeToRef(reference: Vector3): Vector3;
  2812. /**
  2813. * Creates a new Vector3 copied from the current Vector3
  2814. * @returns the new Vector3
  2815. */
  2816. clone(): Vector3;
  2817. /**
  2818. * Copies the given vector coordinates to the current Vector3 ones
  2819. * @param source defines the source Vector3
  2820. * @returns the current updated Vector3
  2821. */
  2822. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2823. /**
  2824. * Copies the given floats to the current Vector3 coordinates
  2825. * @param x defines the x coordinate of the operand
  2826. * @param y defines the y coordinate of the operand
  2827. * @param z defines the z coordinate of the operand
  2828. * @returns the current updated Vector3
  2829. */
  2830. copyFromFloats(x: number, y: number, z: number): Vector3;
  2831. /**
  2832. * Copies the given floats to the current Vector3 coordinates
  2833. * @param x defines the x coordinate of the operand
  2834. * @param y defines the y coordinate of the operand
  2835. * @param z defines the z coordinate of the operand
  2836. * @returns the current updated Vector3
  2837. */
  2838. set(x: number, y: number, z: number): Vector3;
  2839. /**
  2840. * Copies the given float to the current Vector3 coordinates
  2841. * @param v defines the x, y and z coordinates of the operand
  2842. * @returns the current updated Vector3
  2843. */
  2844. setAll(v: number): Vector3;
  2845. /**
  2846. * Get the clip factor between two vectors
  2847. * @param vector0 defines the first operand
  2848. * @param vector1 defines the second operand
  2849. * @param axis defines the axis to use
  2850. * @param size defines the size along the axis
  2851. * @returns the clip factor
  2852. */
  2853. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2854. /**
  2855. * Get angle between two vectors
  2856. * @param vector0 angle between vector0 and vector1
  2857. * @param vector1 angle between vector0 and vector1
  2858. * @param normal direction of the normal
  2859. * @return the angle between vector0 and vector1
  2860. */
  2861. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2862. /**
  2863. * Returns a new Vector3 set from the index "offset" of the given array
  2864. * @param array defines the source array
  2865. * @param offset defines the offset in the source array
  2866. * @returns the new Vector3
  2867. */
  2868. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2871. * @param array defines the source array
  2872. * @param offset defines the offset in the source array
  2873. * @returns the new Vector3
  2874. * @deprecated Please use FromArray instead.
  2875. */
  2876. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2879. * @param array defines the source array
  2880. * @param offset defines the offset in the source array
  2881. * @param result defines the Vector3 where to store the result
  2882. */
  2883. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2884. /**
  2885. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2886. * @param array defines the source array
  2887. * @param offset defines the offset in the source array
  2888. * @param result defines the Vector3 where to store the result
  2889. * @deprecated Please use FromArrayToRef instead.
  2890. */
  2891. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2892. /**
  2893. * Sets the given vector "result" with the given floats.
  2894. * @param x defines the x coordinate of the source
  2895. * @param y defines the y coordinate of the source
  2896. * @param z defines the z coordinate of the source
  2897. * @param result defines the Vector3 where to store the result
  2898. */
  2899. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2900. /**
  2901. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2902. * @returns a new empty Vector3
  2903. */
  2904. static Zero(): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2907. * @returns a new unit Vector3
  2908. */
  2909. static One(): Vector3;
  2910. /**
  2911. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2912. * @returns a new up Vector3
  2913. */
  2914. static Up(): Vector3;
  2915. /**
  2916. * Gets a up Vector3 that must not be updated
  2917. */
  2918. static get UpReadOnly(): DeepImmutable<Vector3>;
  2919. /**
  2920. * Gets a zero Vector3 that must not be updated
  2921. */
  2922. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2925. * @returns a new down Vector3
  2926. */
  2927. static Down(): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2930. * @param rightHandedSystem is the scene right-handed (negative z)
  2931. * @returns a new forward Vector3
  2932. */
  2933. static Forward(rightHandedSystem?: boolean): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2936. * @param rightHandedSystem is the scene right-handed (negative-z)
  2937. * @returns a new forward Vector3
  2938. */
  2939. static Backward(rightHandedSystem?: boolean): Vector3;
  2940. /**
  2941. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2942. * @returns a new right Vector3
  2943. */
  2944. static Right(): Vector3;
  2945. /**
  2946. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2947. * @returns a new left Vector3
  2948. */
  2949. static Left(): Vector3;
  2950. /**
  2951. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2952. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2953. * @param vector defines the Vector3 to transform
  2954. * @param transformation defines the transformation matrix
  2955. * @returns the transformed Vector3
  2956. */
  2957. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2958. /**
  2959. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2960. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2961. * @param vector defines the Vector3 to transform
  2962. * @param transformation defines the transformation matrix
  2963. * @param result defines the Vector3 where to store the result
  2964. */
  2965. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2968. * This method computes tranformed coordinates only, not transformed direction vectors
  2969. * @param x define the x coordinate of the source vector
  2970. * @param y define the y coordinate of the source vector
  2971. * @param z define the z coordinate of the source vector
  2972. * @param transformation defines the transformation matrix
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2978. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2979. * @param vector defines the Vector3 to transform
  2980. * @param transformation defines the transformation matrix
  2981. * @returns the new Vector3
  2982. */
  2983. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2984. /**
  2985. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2986. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2987. * @param vector defines the Vector3 to transform
  2988. * @param transformation defines the transformation matrix
  2989. * @param result defines the Vector3 where to store the result
  2990. */
  2991. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2992. /**
  2993. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2994. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2995. * @param x define the x coordinate of the source vector
  2996. * @param y define the y coordinate of the source vector
  2997. * @param z define the z coordinate of the source vector
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3004. * @param value1 defines the first control point
  3005. * @param value2 defines the second control point
  3006. * @param value3 defines the third control point
  3007. * @param value4 defines the fourth control point
  3008. * @param amount defines the amount on the spline to use
  3009. * @returns the new Vector3
  3010. */
  3011. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3012. /**
  3013. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3014. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3015. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3016. * @param value defines the current value
  3017. * @param min defines the lower range value
  3018. * @param max defines the upper range value
  3019. * @returns the new Vector3
  3020. */
  3021. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3024. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3025. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3026. * @param value defines the current value
  3027. * @param min defines the lower range value
  3028. * @param max defines the upper range value
  3029. * @param result defines the Vector3 where to store the result
  3030. */
  3031. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3032. /**
  3033. * Checks if a given vector is inside a specific range
  3034. * @param v defines the vector to test
  3035. * @param min defines the minimum range
  3036. * @param max defines the maximum range
  3037. */
  3038. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3039. /**
  3040. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3041. * @param value1 defines the first control point
  3042. * @param tangent1 defines the first tangent vector
  3043. * @param value2 defines the second control point
  3044. * @param tangent2 defines the second tangent vector
  3045. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3046. * @returns the new Vector3
  3047. */
  3048. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3049. /**
  3050. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3051. * @param start defines the start value
  3052. * @param end defines the end value
  3053. * @param amount max defines amount between both (between 0 and 1)
  3054. * @returns the new Vector3
  3055. */
  3056. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3057. /**
  3058. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3059. * @param start defines the start value
  3060. * @param end defines the end value
  3061. * @param amount max defines amount between both (between 0 and 1)
  3062. * @param result defines the Vector3 where to store the result
  3063. */
  3064. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3065. /**
  3066. * Returns the dot product (float) between the vectors "left" and "right"
  3067. * @param left defines the left operand
  3068. * @param right defines the right operand
  3069. * @returns the dot product
  3070. */
  3071. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3072. /**
  3073. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3074. * The cross product is then orthogonal to both "left" and "right"
  3075. * @param left defines the left operand
  3076. * @param right defines the right operand
  3077. * @returns the cross product
  3078. */
  3079. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3080. /**
  3081. * Sets the given vector "result" with the cross product of "left" and "right"
  3082. * The cross product is then orthogonal to both "left" and "right"
  3083. * @param left defines the left operand
  3084. * @param right defines the right operand
  3085. * @param result defines the Vector3 where to store the result
  3086. */
  3087. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3088. /**
  3089. * Returns a new Vector3 as the normalization of the given vector
  3090. * @param vector defines the Vector3 to normalize
  3091. * @returns the new Vector3
  3092. */
  3093. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3094. /**
  3095. * Sets the given vector "result" with the normalization of the given first vector
  3096. * @param vector defines the Vector3 to normalize
  3097. * @param result defines the Vector3 where to store the result
  3098. */
  3099. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3100. /**
  3101. * Project a Vector3 onto screen space
  3102. * @param vector defines the Vector3 to project
  3103. * @param world defines the world matrix to use
  3104. * @param transform defines the transform (view x projection) matrix to use
  3105. * @param viewport defines the screen viewport to use
  3106. * @returns the new Vector3
  3107. */
  3108. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3109. /** @hidden */
  3110. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3111. /**
  3112. * Unproject from screen space to object space
  3113. * @param source defines the screen space Vector3 to use
  3114. * @param viewportWidth defines the current width of the viewport
  3115. * @param viewportHeight defines the current height of the viewport
  3116. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3117. * @param transform defines the transform (view x projection) matrix to use
  3118. * @returns the new Vector3
  3119. */
  3120. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3121. /**
  3122. * Unproject from screen space to object space
  3123. * @param source defines the screen space Vector3 to use
  3124. * @param viewportWidth defines the current width of the viewport
  3125. * @param viewportHeight defines the current height of the viewport
  3126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3127. * @param view defines the view matrix to use
  3128. * @param projection defines the projection matrix to use
  3129. * @returns the new Vector3
  3130. */
  3131. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3132. /**
  3133. * Unproject from screen space to object space
  3134. * @param source defines the screen space Vector3 to use
  3135. * @param viewportWidth defines the current width of the viewport
  3136. * @param viewportHeight defines the current height of the viewport
  3137. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3138. * @param view defines the view matrix to use
  3139. * @param projection defines the projection matrix to use
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3143. /**
  3144. * Unproject from screen space to object space
  3145. * @param sourceX defines the screen space x coordinate to use
  3146. * @param sourceY defines the screen space y coordinate to use
  3147. * @param sourceZ defines the screen space z coordinate to use
  3148. * @param viewportWidth defines the current width of the viewport
  3149. * @param viewportHeight defines the current height of the viewport
  3150. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3151. * @param view defines the view matrix to use
  3152. * @param projection defines the projection matrix to use
  3153. * @param result defines the Vector3 where to store the result
  3154. */
  3155. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3156. /**
  3157. * Gets the minimal coordinate values between two Vector3
  3158. * @param left defines the first operand
  3159. * @param right defines the second operand
  3160. * @returns the new Vector3
  3161. */
  3162. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * Gets the maximal coordinate values between two Vector3
  3165. * @param left defines the first operand
  3166. * @param right defines the second operand
  3167. * @returns the new Vector3
  3168. */
  3169. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3170. /**
  3171. * Returns the distance between the vectors "value1" and "value2"
  3172. * @param value1 defines the first operand
  3173. * @param value2 defines the second operand
  3174. * @returns the distance
  3175. */
  3176. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3177. /**
  3178. * Returns the squared distance between the vectors "value1" and "value2"
  3179. * @param value1 defines the first operand
  3180. * @param value2 defines the second operand
  3181. * @returns the squared distance
  3182. */
  3183. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3184. /**
  3185. * Returns a new Vector3 located at the center between "value1" and "value2"
  3186. * @param value1 defines the first operand
  3187. * @param value2 defines the second operand
  3188. * @returns the new Vector3
  3189. */
  3190. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3191. /**
  3192. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3193. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3194. * to something in order to rotate it from its local system to the given target system
  3195. * Note: axis1, axis2 and axis3 are normalized during this operation
  3196. * @param axis1 defines the first axis
  3197. * @param axis2 defines the second axis
  3198. * @param axis3 defines the third axis
  3199. * @returns a new Vector3
  3200. */
  3201. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3204. * @param axis1 defines the first axis
  3205. * @param axis2 defines the second axis
  3206. * @param axis3 defines the third axis
  3207. * @param ref defines the Vector3 where to store the result
  3208. */
  3209. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3210. }
  3211. /**
  3212. * Vector4 class created for EulerAngle class conversion to Quaternion
  3213. */
  3214. export class Vector4 {
  3215. /** x value of the vector */
  3216. x: number;
  3217. /** y value of the vector */
  3218. y: number;
  3219. /** z value of the vector */
  3220. z: number;
  3221. /** w value of the vector */
  3222. w: number;
  3223. /**
  3224. * Creates a Vector4 object from the given floats.
  3225. * @param x x value of the vector
  3226. * @param y y value of the vector
  3227. * @param z z value of the vector
  3228. * @param w w value of the vector
  3229. */
  3230. constructor(
  3231. /** x value of the vector */
  3232. x: number,
  3233. /** y value of the vector */
  3234. y: number,
  3235. /** z value of the vector */
  3236. z: number,
  3237. /** w value of the vector */
  3238. w: number);
  3239. /**
  3240. * Returns the string with the Vector4 coordinates.
  3241. * @returns a string containing all the vector values
  3242. */
  3243. toString(): string;
  3244. /**
  3245. * Returns the string "Vector4".
  3246. * @returns "Vector4"
  3247. */
  3248. getClassName(): string;
  3249. /**
  3250. * Returns the Vector4 hash code.
  3251. * @returns a unique hash code
  3252. */
  3253. getHashCode(): number;
  3254. /**
  3255. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3256. * @returns the resulting array
  3257. */
  3258. asArray(): number[];
  3259. /**
  3260. * Populates the given array from the given index with the Vector4 coordinates.
  3261. * @param array array to populate
  3262. * @param index index of the array to start at (default: 0)
  3263. * @returns the Vector4.
  3264. */
  3265. toArray(array: FloatArray, index?: number): Vector4;
  3266. /**
  3267. * Update the current vector from an array
  3268. * @param array defines the destination array
  3269. * @param index defines the offset in the destination array
  3270. * @returns the current Vector3
  3271. */
  3272. fromArray(array: FloatArray, index?: number): Vector4;
  3273. /**
  3274. * Adds the given vector to the current Vector4.
  3275. * @param otherVector the vector to add
  3276. * @returns the updated Vector4.
  3277. */
  3278. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3281. * @param otherVector the vector to add
  3282. * @returns the resulting vector
  3283. */
  3284. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3287. * @param otherVector the vector to add
  3288. * @param result the vector to store the result
  3289. * @returns the current Vector4.
  3290. */
  3291. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3292. /**
  3293. * Subtract in place the given vector from the current Vector4.
  3294. * @param otherVector the vector to subtract
  3295. * @returns the updated Vector4.
  3296. */
  3297. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3298. /**
  3299. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3300. * @param otherVector the vector to add
  3301. * @returns the new vector with the result
  3302. */
  3303. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3304. /**
  3305. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3306. * @param otherVector the vector to subtract
  3307. * @param result the vector to store the result
  3308. * @returns the current Vector4.
  3309. */
  3310. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3311. /**
  3312. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3313. */
  3314. /**
  3315. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3316. * @param x value to subtract
  3317. * @param y value to subtract
  3318. * @param z value to subtract
  3319. * @param w value to subtract
  3320. * @returns new vector containing the result
  3321. */
  3322. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3323. /**
  3324. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3325. * @param x value to subtract
  3326. * @param y value to subtract
  3327. * @param z value to subtract
  3328. * @param w value to subtract
  3329. * @param result the vector to store the result in
  3330. * @returns the current Vector4.
  3331. */
  3332. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3333. /**
  3334. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3335. * @returns a new vector with the negated values
  3336. */
  3337. negate(): Vector4;
  3338. /**
  3339. * Negate this vector in place
  3340. * @returns this
  3341. */
  3342. negateInPlace(): Vector4;
  3343. /**
  3344. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3345. * @param result defines the Vector3 object where to store the result
  3346. * @returns the current Vector4
  3347. */
  3348. negateToRef(result: Vector4): Vector4;
  3349. /**
  3350. * Multiplies the current Vector4 coordinates by scale (float).
  3351. * @param scale the number to scale with
  3352. * @returns the updated Vector4.
  3353. */
  3354. scaleInPlace(scale: number): Vector4;
  3355. /**
  3356. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3357. * @param scale the number to scale with
  3358. * @returns a new vector with the result
  3359. */
  3360. scale(scale: number): Vector4;
  3361. /**
  3362. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3363. * @param scale the number to scale with
  3364. * @param result a vector to store the result in
  3365. * @returns the current Vector4.
  3366. */
  3367. scaleToRef(scale: number, result: Vector4): Vector4;
  3368. /**
  3369. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3370. * @param scale defines the scale factor
  3371. * @param result defines the Vector4 object where to store the result
  3372. * @returns the unmodified current Vector4
  3373. */
  3374. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3375. /**
  3376. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3377. * @param otherVector the vector to compare against
  3378. * @returns true if they are equal
  3379. */
  3380. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3381. /**
  3382. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3383. * @param otherVector vector to compare against
  3384. * @param epsilon (Default: very small number)
  3385. * @returns true if they are equal
  3386. */
  3387. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3388. /**
  3389. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3390. * @param x x value to compare against
  3391. * @param y y value to compare against
  3392. * @param z z value to compare against
  3393. * @param w w value to compare against
  3394. * @returns true if equal
  3395. */
  3396. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3397. /**
  3398. * Multiplies in place the current Vector4 by the given one.
  3399. * @param otherVector vector to multiple with
  3400. * @returns the updated Vector4.
  3401. */
  3402. multiplyInPlace(otherVector: Vector4): Vector4;
  3403. /**
  3404. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3405. * @param otherVector vector to multiple with
  3406. * @returns resulting new vector
  3407. */
  3408. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3411. * @param otherVector vector to multiple with
  3412. * @param result vector to store the result
  3413. * @returns the current Vector4.
  3414. */
  3415. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3416. /**
  3417. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3418. * @param x x value multiply with
  3419. * @param y y value multiply with
  3420. * @param z z value multiply with
  3421. * @param w w value multiply with
  3422. * @returns resulting new vector
  3423. */
  3424. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3425. /**
  3426. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3427. * @param otherVector vector to devide with
  3428. * @returns resulting new vector
  3429. */
  3430. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3431. /**
  3432. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3433. * @param otherVector vector to devide with
  3434. * @param result vector to store the result
  3435. * @returns the current Vector4.
  3436. */
  3437. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3438. /**
  3439. * Divides the current Vector3 coordinates by the given ones.
  3440. * @param otherVector vector to devide with
  3441. * @returns the updated Vector3.
  3442. */
  3443. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3446. * @param other defines the second operand
  3447. * @returns the current updated Vector4
  3448. */
  3449. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3452. * @param other defines the second operand
  3453. * @returns the current updated Vector4
  3454. */
  3455. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3456. /**
  3457. * Gets a new Vector4 from current Vector4 floored values
  3458. * @returns a new Vector4
  3459. */
  3460. floor(): Vector4;
  3461. /**
  3462. * Gets a new Vector4 from current Vector3 floored values
  3463. * @returns a new Vector4
  3464. */
  3465. fract(): Vector4;
  3466. /**
  3467. * Returns the Vector4 length (float).
  3468. * @returns the length
  3469. */
  3470. length(): number;
  3471. /**
  3472. * Returns the Vector4 squared length (float).
  3473. * @returns the length squared
  3474. */
  3475. lengthSquared(): number;
  3476. /**
  3477. * Normalizes in place the Vector4.
  3478. * @returns the updated Vector4.
  3479. */
  3480. normalize(): Vector4;
  3481. /**
  3482. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3483. * @returns this converted to a new vector3
  3484. */
  3485. toVector3(): Vector3;
  3486. /**
  3487. * Returns a new Vector4 copied from the current one.
  3488. * @returns the new cloned vector
  3489. */
  3490. clone(): Vector4;
  3491. /**
  3492. * Updates the current Vector4 with the given one coordinates.
  3493. * @param source the source vector to copy from
  3494. * @returns the updated Vector4.
  3495. */
  3496. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Updates the current Vector4 coordinates with the given floats.
  3499. * @param x float to copy from
  3500. * @param y float to copy from
  3501. * @param z float to copy from
  3502. * @param w float to copy from
  3503. * @returns the updated Vector4.
  3504. */
  3505. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3506. /**
  3507. * Updates the current Vector4 coordinates with the given floats.
  3508. * @param x float to set from
  3509. * @param y float to set from
  3510. * @param z float to set from
  3511. * @param w float to set from
  3512. * @returns the updated Vector4.
  3513. */
  3514. set(x: number, y: number, z: number, w: number): Vector4;
  3515. /**
  3516. * Copies the given float to the current Vector3 coordinates
  3517. * @param v defines the x, y, z and w coordinates of the operand
  3518. * @returns the current updated Vector3
  3519. */
  3520. setAll(v: number): Vector4;
  3521. /**
  3522. * Returns a new Vector4 set from the starting index of the given array.
  3523. * @param array the array to pull values from
  3524. * @param offset the offset into the array to start at
  3525. * @returns the new vector
  3526. */
  3527. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3528. /**
  3529. * Updates the given vector "result" from the starting index of the given array.
  3530. * @param array the array to pull values from
  3531. * @param offset the offset into the array to start at
  3532. * @param result the vector to store the result in
  3533. */
  3534. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3535. /**
  3536. * Updates the given vector "result" from the starting index of the given Float32Array.
  3537. * @param array the array to pull values from
  3538. * @param offset the offset into the array to start at
  3539. * @param result the vector to store the result in
  3540. */
  3541. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3542. /**
  3543. * Updates the given vector "result" coordinates from the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @param result the vector to the floats in
  3549. */
  3550. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3551. /**
  3552. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3553. * @returns the new vector
  3554. */
  3555. static Zero(): Vector4;
  3556. /**
  3557. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3558. * @returns the new vector
  3559. */
  3560. static One(): Vector4;
  3561. /**
  3562. * Returns a new normalized Vector4 from the given one.
  3563. * @param vector the vector to normalize
  3564. * @returns the vector
  3565. */
  3566. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3567. /**
  3568. * Updates the given vector "result" from the normalization of the given one.
  3569. * @param vector the vector to normalize
  3570. * @param result the vector to store the result in
  3571. */
  3572. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3573. /**
  3574. * Returns a vector with the minimum values from the left and right vectors
  3575. * @param left left vector to minimize
  3576. * @param right right vector to minimize
  3577. * @returns a new vector with the minimum of the left and right vector values
  3578. */
  3579. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3580. /**
  3581. * Returns a vector with the maximum values from the left and right vectors
  3582. * @param left left vector to maximize
  3583. * @param right right vector to maximize
  3584. * @returns a new vector with the maximum of the left and right vector values
  3585. */
  3586. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3587. /**
  3588. * Returns the distance (float) between the vectors "value1" and "value2".
  3589. * @param value1 value to calulate the distance between
  3590. * @param value2 value to calulate the distance between
  3591. * @return the distance between the two vectors
  3592. */
  3593. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3594. /**
  3595. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3596. * @param value1 value to calulate the distance between
  3597. * @param value2 value to calulate the distance between
  3598. * @return the distance between the two vectors squared
  3599. */
  3600. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3601. /**
  3602. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3603. * @param value1 value to calulate the center between
  3604. * @param value2 value to calulate the center between
  3605. * @return the center between the two vectors
  3606. */
  3607. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3610. * This methods computes transformed normalized direction vectors only.
  3611. * @param vector the vector to transform
  3612. * @param transformation the transformation matrix to apply
  3613. * @returns the new vector
  3614. */
  3615. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3616. /**
  3617. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3618. * This methods computes transformed normalized direction vectors only.
  3619. * @param vector the vector to transform
  3620. * @param transformation the transformation matrix to apply
  3621. * @param result the vector to store the result in
  3622. */
  3623. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3624. /**
  3625. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3626. * This methods computes transformed normalized direction vectors only.
  3627. * @param x value to transform
  3628. * @param y value to transform
  3629. * @param z value to transform
  3630. * @param w value to transform
  3631. * @param transformation the transformation matrix to apply
  3632. * @param result the vector to store the results in
  3633. */
  3634. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3635. /**
  3636. * Creates a new Vector4 from a Vector3
  3637. * @param source defines the source data
  3638. * @param w defines the 4th component (default is 0)
  3639. * @returns a new Vector4
  3640. */
  3641. static FromVector3(source: Vector3, w?: number): Vector4;
  3642. }
  3643. /**
  3644. * Class used to store quaternion data
  3645. * @see https://en.wikipedia.org/wiki/Quaternion
  3646. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3647. */
  3648. export class Quaternion {
  3649. /** @hidden */
  3650. _x: number;
  3651. /** @hidden */
  3652. _y: number;
  3653. /** @hidden */
  3654. _z: number;
  3655. /** @hidden */
  3656. _w: number;
  3657. /** @hidden */
  3658. _isDirty: boolean;
  3659. /** Gets or sets the x coordinate */
  3660. get x(): number;
  3661. set x(value: number);
  3662. /** Gets or sets the y coordinate */
  3663. get y(): number;
  3664. set y(value: number);
  3665. /** Gets or sets the z coordinate */
  3666. get z(): number;
  3667. set z(value: number);
  3668. /** Gets or sets the w coordinate */
  3669. get w(): number;
  3670. set w(value: number);
  3671. /**
  3672. * Creates a new Quaternion from the given floats
  3673. * @param x defines the first component (0 by default)
  3674. * @param y defines the second component (0 by default)
  3675. * @param z defines the third component (0 by default)
  3676. * @param w defines the fourth component (1.0 by default)
  3677. */
  3678. constructor(x?: number, y?: number, z?: number, w?: number);
  3679. /**
  3680. * Gets a string representation for the current quaternion
  3681. * @returns a string with the Quaternion coordinates
  3682. */
  3683. toString(): string;
  3684. /**
  3685. * Gets the class name of the quaternion
  3686. * @returns the string "Quaternion"
  3687. */
  3688. getClassName(): string;
  3689. /**
  3690. * Gets a hash code for this quaternion
  3691. * @returns the quaternion hash code
  3692. */
  3693. getHashCode(): number;
  3694. /**
  3695. * Copy the quaternion to an array
  3696. * @returns a new array populated with 4 elements from the quaternion coordinates
  3697. */
  3698. asArray(): number[];
  3699. /**
  3700. * Check if two quaternions are equals
  3701. * @param otherQuaternion defines the second operand
  3702. * @return true if the current quaternion and the given one coordinates are strictly equals
  3703. */
  3704. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3705. /**
  3706. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3707. * @param otherQuaternion defines the other quaternion
  3708. * @param epsilon defines the minimal distance to consider equality
  3709. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3710. */
  3711. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3712. /**
  3713. * Clone the current quaternion
  3714. * @returns a new quaternion copied from the current one
  3715. */
  3716. clone(): Quaternion;
  3717. /**
  3718. * Copy a quaternion to the current one
  3719. * @param other defines the other quaternion
  3720. * @returns the updated current quaternion
  3721. */
  3722. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Updates the current quaternion with the given float coordinates
  3725. * @param x defines the x coordinate
  3726. * @param y defines the y coordinate
  3727. * @param z defines the z coordinate
  3728. * @param w defines the w coordinate
  3729. * @returns the updated current quaternion
  3730. */
  3731. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3732. /**
  3733. * Updates the current quaternion from the given float coordinates
  3734. * @param x defines the x coordinate
  3735. * @param y defines the y coordinate
  3736. * @param z defines the z coordinate
  3737. * @param w defines the w coordinate
  3738. * @returns the updated current quaternion
  3739. */
  3740. set(x: number, y: number, z: number, w: number): Quaternion;
  3741. /**
  3742. * Adds two quaternions
  3743. * @param other defines the second operand
  3744. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3745. */
  3746. add(other: DeepImmutable<Quaternion>): Quaternion;
  3747. /**
  3748. * Add a quaternion to the current one
  3749. * @param other defines the quaternion to add
  3750. * @returns the current quaternion
  3751. */
  3752. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3753. /**
  3754. * Subtract two quaternions
  3755. * @param other defines the second operand
  3756. * @returns a new quaternion as the subtraction result of the given one from the current one
  3757. */
  3758. subtract(other: Quaternion): Quaternion;
  3759. /**
  3760. * Multiplies the current quaternion by a scale factor
  3761. * @param value defines the scale factor
  3762. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3763. */
  3764. scale(value: number): Quaternion;
  3765. /**
  3766. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3767. * @param scale defines the scale factor
  3768. * @param result defines the Quaternion object where to store the result
  3769. * @returns the unmodified current quaternion
  3770. */
  3771. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Multiplies in place the current quaternion by a scale factor
  3774. * @param value defines the scale factor
  3775. * @returns the current modified quaternion
  3776. */
  3777. scaleInPlace(value: number): Quaternion;
  3778. /**
  3779. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3780. * @param scale defines the scale factor
  3781. * @param result defines the Quaternion object where to store the result
  3782. * @returns the unmodified current quaternion
  3783. */
  3784. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3785. /**
  3786. * Multiplies two quaternions
  3787. * @param q1 defines the second operand
  3788. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3789. */
  3790. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3791. /**
  3792. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3793. * @param q1 defines the second operand
  3794. * @param result defines the target quaternion
  3795. * @returns the current quaternion
  3796. */
  3797. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3798. /**
  3799. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3800. * @param q1 defines the second operand
  3801. * @returns the currentupdated quaternion
  3802. */
  3803. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3804. /**
  3805. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3806. * @param ref defines the target quaternion
  3807. * @returns the current quaternion
  3808. */
  3809. conjugateToRef(ref: Quaternion): Quaternion;
  3810. /**
  3811. * Conjugates in place (1-q) the current quaternion
  3812. * @returns the current updated quaternion
  3813. */
  3814. conjugateInPlace(): Quaternion;
  3815. /**
  3816. * Conjugates in place (1-q) the current quaternion
  3817. * @returns a new quaternion
  3818. */
  3819. conjugate(): Quaternion;
  3820. /**
  3821. * Gets length of current quaternion
  3822. * @returns the quaternion length (float)
  3823. */
  3824. length(): number;
  3825. /**
  3826. * Normalize in place the current quaternion
  3827. * @returns the current updated quaternion
  3828. */
  3829. normalize(): Quaternion;
  3830. /**
  3831. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3832. * @param order is a reserved parameter and is ignore for now
  3833. * @returns a new Vector3 containing the Euler angles
  3834. */
  3835. toEulerAngles(order?: string): Vector3;
  3836. /**
  3837. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3838. * @param result defines the vector which will be filled with the Euler angles
  3839. * @param order is a reserved parameter and is ignore for now
  3840. * @returns the current unchanged quaternion
  3841. */
  3842. toEulerAnglesToRef(result: Vector3): Quaternion;
  3843. /**
  3844. * Updates the given rotation matrix with the current quaternion values
  3845. * @param result defines the target matrix
  3846. * @returns the current unchanged quaternion
  3847. */
  3848. toRotationMatrix(result: Matrix): Quaternion;
  3849. /**
  3850. * Updates the current quaternion from the given rotation matrix values
  3851. * @param matrix defines the source matrix
  3852. * @returns the current updated quaternion
  3853. */
  3854. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3855. /**
  3856. * Creates a new quaternion from a rotation matrix
  3857. * @param matrix defines the source matrix
  3858. * @returns a new quaternion created from the given rotation matrix values
  3859. */
  3860. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3861. /**
  3862. * Updates the given quaternion with the given rotation matrix values
  3863. * @param matrix defines the source matrix
  3864. * @param result defines the target quaternion
  3865. */
  3866. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3867. /**
  3868. * Returns the dot product (float) between the quaternions "left" and "right"
  3869. * @param left defines the left operand
  3870. * @param right defines the right operand
  3871. * @returns the dot product
  3872. */
  3873. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3874. /**
  3875. * Checks if the two quaternions are close to each other
  3876. * @param quat0 defines the first quaternion to check
  3877. * @param quat1 defines the second quaternion to check
  3878. * @returns true if the two quaternions are close to each other
  3879. */
  3880. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3881. /**
  3882. * Creates an empty quaternion
  3883. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3884. */
  3885. static Zero(): Quaternion;
  3886. /**
  3887. * Inverse a given quaternion
  3888. * @param q defines the source quaternion
  3889. * @returns a new quaternion as the inverted current quaternion
  3890. */
  3891. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3892. /**
  3893. * Inverse a given quaternion
  3894. * @param q defines the source quaternion
  3895. * @param result the quaternion the result will be stored in
  3896. * @returns the result quaternion
  3897. */
  3898. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3899. /**
  3900. * Creates an identity quaternion
  3901. * @returns the identity quaternion
  3902. */
  3903. static Identity(): Quaternion;
  3904. /**
  3905. * Gets a boolean indicating if the given quaternion is identity
  3906. * @param quaternion defines the quaternion to check
  3907. * @returns true if the quaternion is identity
  3908. */
  3909. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3910. /**
  3911. * Creates a quaternion from a rotation around an axis
  3912. * @param axis defines the axis to use
  3913. * @param angle defines the angle to use
  3914. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3915. */
  3916. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3917. /**
  3918. * Creates a rotation around an axis and stores it into the given quaternion
  3919. * @param axis defines the axis to use
  3920. * @param angle defines the angle to use
  3921. * @param result defines the target quaternion
  3922. * @returns the target quaternion
  3923. */
  3924. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3925. /**
  3926. * Creates a new quaternion from data stored into an array
  3927. * @param array defines the data source
  3928. * @param offset defines the offset in the source array where the data starts
  3929. * @returns a new quaternion
  3930. */
  3931. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3932. /**
  3933. * Updates the given quaternion "result" from the starting index of the given array.
  3934. * @param array the array to pull values from
  3935. * @param offset the offset into the array to start at
  3936. * @param result the quaternion to store the result in
  3937. */
  3938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3939. /**
  3940. * Create a quaternion from Euler rotation angles
  3941. * @param x Pitch
  3942. * @param y Yaw
  3943. * @param z Roll
  3944. * @returns the new Quaternion
  3945. */
  3946. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3947. /**
  3948. * Updates a quaternion from Euler rotation angles
  3949. * @param x Pitch
  3950. * @param y Yaw
  3951. * @param z Roll
  3952. * @param result the quaternion to store the result
  3953. * @returns the updated quaternion
  3954. */
  3955. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3956. /**
  3957. * Create a quaternion from Euler rotation vector
  3958. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3959. * @returns the new Quaternion
  3960. */
  3961. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3962. /**
  3963. * Updates a quaternion from Euler rotation vector
  3964. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3965. * @param result the quaternion to store the result
  3966. * @returns the updated quaternion
  3967. */
  3968. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3971. * @param yaw defines the rotation around Y axis
  3972. * @param pitch defines the rotation around X axis
  3973. * @param roll defines the rotation around Z axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3977. /**
  3978. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3979. * @param yaw defines the rotation around Y axis
  3980. * @param pitch defines the rotation around X axis
  3981. * @param roll defines the rotation around Z axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3985. /**
  3986. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3987. * @param alpha defines the rotation around first axis
  3988. * @param beta defines the rotation around second axis
  3989. * @param gamma defines the rotation around third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3993. /**
  3994. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3995. * @param alpha defines the rotation around first axis
  3996. * @param beta defines the rotation around second axis
  3997. * @param gamma defines the rotation around third axis
  3998. * @param result defines the target quaternion
  3999. */
  4000. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4001. /**
  4002. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4003. * @param axis1 defines the first axis
  4004. * @param axis2 defines the second axis
  4005. * @param axis3 defines the third axis
  4006. * @returns the new quaternion
  4007. */
  4008. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4009. /**
  4010. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4011. * @param axis1 defines the first axis
  4012. * @param axis2 defines the second axis
  4013. * @param axis3 defines the third axis
  4014. * @param ref defines the target quaternion
  4015. */
  4016. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4017. /**
  4018. * Interpolates between two quaternions
  4019. * @param left defines first quaternion
  4020. * @param right defines second quaternion
  4021. * @param amount defines the gradient to use
  4022. * @returns the new interpolated quaternion
  4023. */
  4024. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4025. /**
  4026. * Interpolates between two quaternions and stores it into a target quaternion
  4027. * @param left defines first quaternion
  4028. * @param right defines second quaternion
  4029. * @param amount defines the gradient to use
  4030. * @param result defines the target quaternion
  4031. */
  4032. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4033. /**
  4034. * Interpolate between two quaternions using Hermite interpolation
  4035. * @param value1 defines first quaternion
  4036. * @param tangent1 defines the incoming tangent
  4037. * @param value2 defines second quaternion
  4038. * @param tangent2 defines the outgoing tangent
  4039. * @param amount defines the target quaternion
  4040. * @returns the new interpolated quaternion
  4041. */
  4042. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4043. }
  4044. /**
  4045. * Class used to store matrix data (4x4)
  4046. */
  4047. export class Matrix {
  4048. /**
  4049. * Gets the precision of matrix computations
  4050. */
  4051. static get Use64Bits(): boolean;
  4052. private static _updateFlagSeed;
  4053. private static _identityReadOnly;
  4054. private _isIdentity;
  4055. private _isIdentityDirty;
  4056. private _isIdentity3x2;
  4057. private _isIdentity3x2Dirty;
  4058. /**
  4059. * Gets the update flag of the matrix which is an unique number for the matrix.
  4060. * It will be incremented every time the matrix data change.
  4061. * You can use it to speed the comparison between two versions of the same matrix.
  4062. */
  4063. updateFlag: number;
  4064. private readonly _m;
  4065. /**
  4066. * Gets the internal data of the matrix
  4067. */
  4068. get m(): DeepImmutable<Float32Array | Array<number>>;
  4069. /** @hidden */
  4070. _markAsUpdated(): void;
  4071. /** @hidden */
  4072. private _updateIdentityStatus;
  4073. /**
  4074. * Creates an empty matrix (filled with zeros)
  4075. */
  4076. constructor();
  4077. /**
  4078. * Check if the current matrix is identity
  4079. * @returns true is the matrix is the identity matrix
  4080. */
  4081. isIdentity(): boolean;
  4082. /**
  4083. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4084. * @returns true is the matrix is the identity matrix
  4085. */
  4086. isIdentityAs3x2(): boolean;
  4087. /**
  4088. * Gets the determinant of the matrix
  4089. * @returns the matrix determinant
  4090. */
  4091. determinant(): number;
  4092. /**
  4093. * Returns the matrix as a Float32Array or Array<number>
  4094. * @returns the matrix underlying array
  4095. */
  4096. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4097. /**
  4098. * Returns the matrix as a Float32Array or Array<number>
  4099. * @returns the matrix underlying array.
  4100. */
  4101. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4102. /**
  4103. * Inverts the current matrix in place
  4104. * @returns the current inverted matrix
  4105. */
  4106. invert(): Matrix;
  4107. /**
  4108. * Sets all the matrix elements to zero
  4109. * @returns the current matrix
  4110. */
  4111. reset(): Matrix;
  4112. /**
  4113. * Adds the current matrix with a second one
  4114. * @param other defines the matrix to add
  4115. * @returns a new matrix as the addition of the current matrix and the given one
  4116. */
  4117. add(other: DeepImmutable<Matrix>): Matrix;
  4118. /**
  4119. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4120. * @param other defines the matrix to add
  4121. * @param result defines the target matrix
  4122. * @returns the current matrix
  4123. */
  4124. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4125. /**
  4126. * Adds in place the given matrix to the current matrix
  4127. * @param other defines the second operand
  4128. * @returns the current updated matrix
  4129. */
  4130. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Sets the given matrix to the current inverted Matrix
  4133. * @param other defines the target matrix
  4134. * @returns the unmodified current matrix
  4135. */
  4136. invertToRef(other: Matrix): Matrix;
  4137. /**
  4138. * add a value at the specified position in the current Matrix
  4139. * @param index the index of the value within the matrix. between 0 and 15.
  4140. * @param value the value to be added
  4141. * @returns the current updated matrix
  4142. */
  4143. addAtIndex(index: number, value: number): Matrix;
  4144. /**
  4145. * mutiply the specified position in the current Matrix by a value
  4146. * @param index the index of the value within the matrix. between 0 and 15.
  4147. * @param value the value to be added
  4148. * @returns the current updated matrix
  4149. */
  4150. multiplyAtIndex(index: number, value: number): Matrix;
  4151. /**
  4152. * Inserts the translation vector (using 3 floats) in the current matrix
  4153. * @param x defines the 1st component of the translation
  4154. * @param y defines the 2nd component of the translation
  4155. * @param z defines the 3rd component of the translation
  4156. * @returns the current updated matrix
  4157. */
  4158. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4159. /**
  4160. * Adds the translation vector (using 3 floats) in the current matrix
  4161. * @param x defines the 1st component of the translation
  4162. * @param y defines the 2nd component of the translation
  4163. * @param z defines the 3rd component of the translation
  4164. * @returns the current updated matrix
  4165. */
  4166. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4167. /**
  4168. * Inserts the translation vector in the current matrix
  4169. * @param vector3 defines the translation to insert
  4170. * @returns the current updated matrix
  4171. */
  4172. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4173. /**
  4174. * Gets the translation value of the current matrix
  4175. * @returns a new Vector3 as the extracted translation from the matrix
  4176. */
  4177. getTranslation(): Vector3;
  4178. /**
  4179. * Fill a Vector3 with the extracted translation from the matrix
  4180. * @param result defines the Vector3 where to store the translation
  4181. * @returns the current matrix
  4182. */
  4183. getTranslationToRef(result: Vector3): Matrix;
  4184. /**
  4185. * Remove rotation and scaling part from the matrix
  4186. * @returns the updated matrix
  4187. */
  4188. removeRotationAndScaling(): Matrix;
  4189. /**
  4190. * Multiply two matrices
  4191. * @param other defines the second operand
  4192. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4193. */
  4194. multiply(other: DeepImmutable<Matrix>): Matrix;
  4195. /**
  4196. * Copy the current matrix from the given one
  4197. * @param other defines the source matrix
  4198. * @returns the current updated matrix
  4199. */
  4200. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4201. /**
  4202. * Populates the given array from the starting index with the current matrix values
  4203. * @param array defines the target array
  4204. * @param offset defines the offset in the target array where to start storing values
  4205. * @returns the current matrix
  4206. */
  4207. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4208. /**
  4209. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4210. * @param other defines the second operand
  4211. * @param result defines the matrix where to store the multiplication
  4212. * @returns the current matrix
  4213. */
  4214. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4215. /**
  4216. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4217. * @param other defines the second operand
  4218. * @param result defines the array where to store the multiplication
  4219. * @param offset defines the offset in the target array where to start storing values
  4220. * @returns the current matrix
  4221. */
  4222. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4223. /**
  4224. * Check equality between this matrix and a second one
  4225. * @param value defines the second matrix to compare
  4226. * @returns true is the current matrix and the given one values are strictly equal
  4227. */
  4228. equals(value: DeepImmutable<Matrix>): boolean;
  4229. /**
  4230. * Clone the current matrix
  4231. * @returns a new matrix from the current matrix
  4232. */
  4233. clone(): Matrix;
  4234. /**
  4235. * Returns the name of the current matrix class
  4236. * @returns the string "Matrix"
  4237. */
  4238. getClassName(): string;
  4239. /**
  4240. * Gets the hash code of the current matrix
  4241. * @returns the hash code
  4242. */
  4243. getHashCode(): number;
  4244. /**
  4245. * Decomposes the current Matrix into a translation, rotation and scaling components
  4246. * @param scale defines the scale vector3 given as a reference to update
  4247. * @param rotation defines the rotation quaternion given as a reference to update
  4248. * @param translation defines the translation vector3 given as a reference to update
  4249. * @returns true if operation was successful
  4250. */
  4251. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4252. /**
  4253. * Gets specific row of the matrix
  4254. * @param index defines the number of the row to get
  4255. * @returns the index-th row of the current matrix as a new Vector4
  4256. */
  4257. getRow(index: number): Nullable<Vector4>;
  4258. /**
  4259. * Sets the index-th row of the current matrix to the vector4 values
  4260. * @param index defines the number of the row to set
  4261. * @param row defines the target vector4
  4262. * @returns the updated current matrix
  4263. */
  4264. setRow(index: number, row: Vector4): Matrix;
  4265. /**
  4266. * Compute the transpose of the matrix
  4267. * @returns the new transposed matrix
  4268. */
  4269. transpose(): Matrix;
  4270. /**
  4271. * Compute the transpose of the matrix and store it in a given matrix
  4272. * @param result defines the target matrix
  4273. * @returns the current matrix
  4274. */
  4275. transposeToRef(result: Matrix): Matrix;
  4276. /**
  4277. * Sets the index-th row of the current matrix with the given 4 x float values
  4278. * @param index defines the row index
  4279. * @param x defines the x component to set
  4280. * @param y defines the y component to set
  4281. * @param z defines the z component to set
  4282. * @param w defines the w component to set
  4283. * @returns the updated current matrix
  4284. */
  4285. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4286. /**
  4287. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4288. * @param scale defines the scale factor
  4289. * @returns a new matrix
  4290. */
  4291. scale(scale: number): Matrix;
  4292. /**
  4293. * Scale the current matrix values by a factor to a given result matrix
  4294. * @param scale defines the scale factor
  4295. * @param result defines the matrix to store the result
  4296. * @returns the current matrix
  4297. */
  4298. scaleToRef(scale: number, result: Matrix): Matrix;
  4299. /**
  4300. * Scale the current matrix values by a factor and add the result to a given matrix
  4301. * @param scale defines the scale factor
  4302. * @param result defines the Matrix to store the result
  4303. * @returns the current matrix
  4304. */
  4305. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4306. /**
  4307. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4308. * @param ref matrix to store the result
  4309. */
  4310. toNormalMatrix(ref: Matrix): void;
  4311. /**
  4312. * Gets only rotation part of the current matrix
  4313. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4314. */
  4315. getRotationMatrix(): Matrix;
  4316. /**
  4317. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4318. * @param result defines the target matrix to store data to
  4319. * @returns the current matrix
  4320. */
  4321. getRotationMatrixToRef(result: Matrix): Matrix;
  4322. /**
  4323. * Toggles model matrix from being right handed to left handed in place and vice versa
  4324. */
  4325. toggleModelMatrixHandInPlace(): void;
  4326. /**
  4327. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4328. */
  4329. toggleProjectionMatrixHandInPlace(): void;
  4330. /**
  4331. * Creates a matrix from an array
  4332. * @param array defines the source array
  4333. * @param offset defines an offset in the source array
  4334. * @returns a new Matrix set from the starting index of the given array
  4335. */
  4336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4337. /**
  4338. * Copy the content of an array into a given matrix
  4339. * @param array defines the source array
  4340. * @param offset defines an offset in the source array
  4341. * @param result defines the target matrix
  4342. */
  4343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4344. /**
  4345. * Stores an array into a matrix after having multiplied each component by a given factor
  4346. * @param array defines the source array
  4347. * @param offset defines the offset in the source array
  4348. * @param scale defines the scaling factor
  4349. * @param result defines the target matrix
  4350. */
  4351. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4352. /**
  4353. * Gets an identity matrix that must not be updated
  4354. */
  4355. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4356. /**
  4357. * Stores a list of values (16) inside a given matrix
  4358. * @param initialM11 defines 1st value of 1st row
  4359. * @param initialM12 defines 2nd value of 1st row
  4360. * @param initialM13 defines 3rd value of 1st row
  4361. * @param initialM14 defines 4th value of 1st row
  4362. * @param initialM21 defines 1st value of 2nd row
  4363. * @param initialM22 defines 2nd value of 2nd row
  4364. * @param initialM23 defines 3rd value of 2nd row
  4365. * @param initialM24 defines 4th value of 2nd row
  4366. * @param initialM31 defines 1st value of 3rd row
  4367. * @param initialM32 defines 2nd value of 3rd row
  4368. * @param initialM33 defines 3rd value of 3rd row
  4369. * @param initialM34 defines 4th value of 3rd row
  4370. * @param initialM41 defines 1st value of 4th row
  4371. * @param initialM42 defines 2nd value of 4th row
  4372. * @param initialM43 defines 3rd value of 4th row
  4373. * @param initialM44 defines 4th value of 4th row
  4374. * @param result defines the target matrix
  4375. */
  4376. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4377. /**
  4378. * Creates new matrix from a list of values (16)
  4379. * @param initialM11 defines 1st value of 1st row
  4380. * @param initialM12 defines 2nd value of 1st row
  4381. * @param initialM13 defines 3rd value of 1st row
  4382. * @param initialM14 defines 4th value of 1st row
  4383. * @param initialM21 defines 1st value of 2nd row
  4384. * @param initialM22 defines 2nd value of 2nd row
  4385. * @param initialM23 defines 3rd value of 2nd row
  4386. * @param initialM24 defines 4th value of 2nd row
  4387. * @param initialM31 defines 1st value of 3rd row
  4388. * @param initialM32 defines 2nd value of 3rd row
  4389. * @param initialM33 defines 3rd value of 3rd row
  4390. * @param initialM34 defines 4th value of 3rd row
  4391. * @param initialM41 defines 1st value of 4th row
  4392. * @param initialM42 defines 2nd value of 4th row
  4393. * @param initialM43 defines 3rd value of 4th row
  4394. * @param initialM44 defines 4th value of 4th row
  4395. * @returns the new matrix
  4396. */
  4397. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4398. /**
  4399. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4400. * @param scale defines the scale vector3
  4401. * @param rotation defines the rotation quaternion
  4402. * @param translation defines the translation vector3
  4403. * @returns a new matrix
  4404. */
  4405. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4408. * @param scale defines the scale vector3
  4409. * @param rotation defines the rotation quaternion
  4410. * @param translation defines the translation vector3
  4411. * @param result defines the target matrix
  4412. */
  4413. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4414. /**
  4415. * Creates a new identity matrix
  4416. * @returns a new identity matrix
  4417. */
  4418. static Identity(): Matrix;
  4419. /**
  4420. * Creates a new identity matrix and stores the result in a given matrix
  4421. * @param result defines the target matrix
  4422. */
  4423. static IdentityToRef(result: Matrix): void;
  4424. /**
  4425. * Creates a new zero matrix
  4426. * @returns a new zero matrix
  4427. */
  4428. static Zero(): Matrix;
  4429. /**
  4430. * Creates a new rotation matrix for "angle" radians around the X axis
  4431. * @param angle defines the angle (in radians) to use
  4432. * @return the new matrix
  4433. */
  4434. static RotationX(angle: number): Matrix;
  4435. /**
  4436. * Creates a new matrix as the invert of a given matrix
  4437. * @param source defines the source matrix
  4438. * @returns the new matrix
  4439. */
  4440. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4441. /**
  4442. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4443. * @param angle defines the angle (in radians) to use
  4444. * @param result defines the target matrix
  4445. */
  4446. static RotationXToRef(angle: number, result: Matrix): void;
  4447. /**
  4448. * Creates a new rotation matrix for "angle" radians around the Y axis
  4449. * @param angle defines the angle (in radians) to use
  4450. * @return the new matrix
  4451. */
  4452. static RotationY(angle: number): Matrix;
  4453. /**
  4454. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4455. * @param angle defines the angle (in radians) to use
  4456. * @param result defines the target matrix
  4457. */
  4458. static RotationYToRef(angle: number, result: Matrix): void;
  4459. /**
  4460. * Creates a new rotation matrix for "angle" radians around the Z axis
  4461. * @param angle defines the angle (in radians) to use
  4462. * @return the new matrix
  4463. */
  4464. static RotationZ(angle: number): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4467. * @param angle defines the angle (in radians) to use
  4468. * @param result defines the target matrix
  4469. */
  4470. static RotationZToRef(angle: number, result: Matrix): void;
  4471. /**
  4472. * Creates a new rotation matrix for "angle" radians around the given axis
  4473. * @param axis defines the axis to use
  4474. * @param angle defines the angle (in radians) to use
  4475. * @return the new matrix
  4476. */
  4477. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4478. /**
  4479. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4480. * @param axis defines the axis to use
  4481. * @param angle defines the angle (in radians) to use
  4482. * @param result defines the target matrix
  4483. */
  4484. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4485. /**
  4486. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4487. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4488. * @param from defines the vector to align
  4489. * @param to defines the vector to align to
  4490. * @param result defines the target matrix
  4491. */
  4492. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4493. /**
  4494. * Creates a rotation matrix
  4495. * @param yaw defines the yaw angle in radians (Y axis)
  4496. * @param pitch defines the pitch angle in radians (X axis)
  4497. * @param roll defines the roll angle in radians (Z axis)
  4498. * @returns the new rotation matrix
  4499. */
  4500. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4501. /**
  4502. * Creates a rotation matrix and stores it in a given matrix
  4503. * @param yaw defines the yaw angle in radians (Y axis)
  4504. * @param pitch defines the pitch angle in radians (X axis)
  4505. * @param roll defines the roll angle in radians (Z axis)
  4506. * @param result defines the target matrix
  4507. */
  4508. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4509. /**
  4510. * Creates a scaling matrix
  4511. * @param x defines the scale factor on X axis
  4512. * @param y defines the scale factor on Y axis
  4513. * @param z defines the scale factor on Z axis
  4514. * @returns the new matrix
  4515. */
  4516. static Scaling(x: number, y: number, z: number): Matrix;
  4517. /**
  4518. * Creates a scaling matrix and stores it in a given matrix
  4519. * @param x defines the scale factor on X axis
  4520. * @param y defines the scale factor on Y axis
  4521. * @param z defines the scale factor on Z axis
  4522. * @param result defines the target matrix
  4523. */
  4524. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4525. /**
  4526. * Creates a translation matrix
  4527. * @param x defines the translation on X axis
  4528. * @param y defines the translation on Y axis
  4529. * @param z defines the translationon Z axis
  4530. * @returns the new matrix
  4531. */
  4532. static Translation(x: number, y: number, z: number): Matrix;
  4533. /**
  4534. * Creates a translation matrix and stores it in a given matrix
  4535. * @param x defines the translation on X axis
  4536. * @param y defines the translation on Y axis
  4537. * @param z defines the translationon Z axis
  4538. * @param result defines the target matrix
  4539. */
  4540. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4541. /**
  4542. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4543. * @param startValue defines the start value
  4544. * @param endValue defines the end value
  4545. * @param gradient defines the gradient factor
  4546. * @returns the new matrix
  4547. */
  4548. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4549. /**
  4550. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4551. * @param startValue defines the start value
  4552. * @param endValue defines the end value
  4553. * @param gradient defines the gradient factor
  4554. * @param result defines the Matrix object where to store data
  4555. */
  4556. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4557. /**
  4558. * Builds a new matrix whose values are computed by:
  4559. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4560. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4561. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4562. * @param startValue defines the first matrix
  4563. * @param endValue defines the second matrix
  4564. * @param gradient defines the gradient between the two matrices
  4565. * @returns the new matrix
  4566. */
  4567. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4568. /**
  4569. * Update a matrix to values which are computed by:
  4570. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4571. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4572. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4573. * @param startValue defines the first matrix
  4574. * @param endValue defines the second matrix
  4575. * @param gradient defines the gradient between the two matrices
  4576. * @param result defines the target matrix
  4577. */
  4578. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4579. /**
  4580. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4581. * This function works in left handed mode
  4582. * @param eye defines the final position of the entity
  4583. * @param target defines where the entity should look at
  4584. * @param up defines the up vector for the entity
  4585. * @returns the new matrix
  4586. */
  4587. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4588. /**
  4589. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4590. * This function works in left handed mode
  4591. * @param eye defines the final position of the entity
  4592. * @param target defines where the entity should look at
  4593. * @param up defines the up vector for the entity
  4594. * @param result defines the target matrix
  4595. */
  4596. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4597. /**
  4598. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4599. * This function works in right handed mode
  4600. * @param eye defines the final position of the entity
  4601. * @param target defines where the entity should look at
  4602. * @param up defines the up vector for the entity
  4603. * @returns the new matrix
  4604. */
  4605. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4606. /**
  4607. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4608. * This function works in right handed mode
  4609. * @param eye defines the final position of the entity
  4610. * @param target defines where the entity should look at
  4611. * @param up defines the up vector for the entity
  4612. * @param result defines the target matrix
  4613. */
  4614. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4615. /**
  4616. * Create a left-handed orthographic projection matrix
  4617. * @param width defines the viewport width
  4618. * @param height defines the viewport height
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Store a left-handed orthographic projection to a given matrix
  4626. * @param width defines the viewport width
  4627. * @param height defines the viewport height
  4628. * @param znear defines the near clip plane
  4629. * @param zfar defines the far clip plane
  4630. * @param result defines the target matrix
  4631. */
  4632. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4633. /**
  4634. * Create a left-handed orthographic projection matrix
  4635. * @param left defines the viewport left coordinate
  4636. * @param right defines the viewport right coordinate
  4637. * @param bottom defines the viewport bottom coordinate
  4638. * @param top defines the viewport top coordinate
  4639. * @param znear defines the near clip plane
  4640. * @param zfar defines the far clip plane
  4641. * @returns a new matrix as a left-handed orthographic projection matrix
  4642. */
  4643. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4644. /**
  4645. * Stores a left-handed orthographic projection into a given matrix
  4646. * @param left defines the viewport left coordinate
  4647. * @param right defines the viewport right coordinate
  4648. * @param bottom defines the viewport bottom coordinate
  4649. * @param top defines the viewport top coordinate
  4650. * @param znear defines the near clip plane
  4651. * @param zfar defines the far clip plane
  4652. * @param result defines the target matrix
  4653. */
  4654. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4655. /**
  4656. * Creates a right-handed orthographic projection matrix
  4657. * @param left defines the viewport left coordinate
  4658. * @param right defines the viewport right coordinate
  4659. * @param bottom defines the viewport bottom coordinate
  4660. * @param top defines the viewport top coordinate
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a right-handed orthographic projection matrix
  4664. */
  4665. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Stores a right-handed orthographic projection into a given matrix
  4668. * @param left defines the viewport left coordinate
  4669. * @param right defines the viewport right coordinate
  4670. * @param bottom defines the viewport bottom coordinate
  4671. * @param top defines the viewport top coordinate
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. */
  4676. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4677. /**
  4678. * Creates a left-handed perspective projection matrix
  4679. * @param width defines the viewport width
  4680. * @param height defines the viewport height
  4681. * @param znear defines the near clip plane
  4682. * @param zfar defines the far clip plane
  4683. * @returns a new matrix as a left-handed perspective projection matrix
  4684. */
  4685. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4686. /**
  4687. * Creates a left-handed perspective projection matrix
  4688. * @param fov defines the horizontal field of view
  4689. * @param aspect defines the aspect ratio
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @returns a new matrix as a left-handed perspective projection matrix
  4693. */
  4694. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4695. /**
  4696. * Stores a left-handed perspective projection into a given matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @param result defines the target matrix
  4702. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4703. */
  4704. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4705. /**
  4706. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4707. * @param fov defines the horizontal field of view
  4708. * @param aspect defines the aspect ratio
  4709. * @param znear defines the near clip plane
  4710. * @param zfar not used as infinity is used as far clip
  4711. * @param result defines the target matrix
  4712. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4713. */
  4714. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4715. /**
  4716. * Creates a right-handed perspective projection matrix
  4717. * @param fov defines the horizontal field of view
  4718. * @param aspect defines the aspect ratio
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a right-handed perspective projection matrix
  4722. */
  4723. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Stores a right-handed perspective projection into a given matrix
  4726. * @param fov defines the horizontal field of view
  4727. * @param aspect defines the aspect ratio
  4728. * @param znear defines the near clip plane
  4729. * @param zfar defines the far clip plane
  4730. * @param result defines the target matrix
  4731. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4732. */
  4733. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4734. /**
  4735. * Stores a right-handed perspective projection into a given matrix
  4736. * @param fov defines the horizontal field of view
  4737. * @param aspect defines the aspect ratio
  4738. * @param znear defines the near clip plane
  4739. * @param zfar not used as infinity is used as far clip
  4740. * @param result defines the target matrix
  4741. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4742. */
  4743. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4744. /**
  4745. * Stores a perspective projection for WebVR info a given matrix
  4746. * @param fov defines the field of view
  4747. * @param znear defines the near clip plane
  4748. * @param zfar defines the far clip plane
  4749. * @param result defines the target matrix
  4750. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4751. */
  4752. static PerspectiveFovWebVRToRef(fov: {
  4753. upDegrees: number;
  4754. downDegrees: number;
  4755. leftDegrees: number;
  4756. rightDegrees: number;
  4757. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4758. /**
  4759. * Computes a complete transformation matrix
  4760. * @param viewport defines the viewport to use
  4761. * @param world defines the world matrix
  4762. * @param view defines the view matrix
  4763. * @param projection defines the projection matrix
  4764. * @param zmin defines the near clip plane
  4765. * @param zmax defines the far clip plane
  4766. * @returns the transformation matrix
  4767. */
  4768. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4769. /**
  4770. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4771. * @param matrix defines the matrix to use
  4772. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4773. */
  4774. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4775. /**
  4776. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4777. * @param matrix defines the matrix to use
  4778. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4779. */
  4780. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4781. /**
  4782. * Compute the transpose of a given matrix
  4783. * @param matrix defines the matrix to transpose
  4784. * @returns the new matrix
  4785. */
  4786. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4787. /**
  4788. * Compute the transpose of a matrix and store it in a target matrix
  4789. * @param matrix defines the matrix to transpose
  4790. * @param result defines the target matrix
  4791. */
  4792. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4793. /**
  4794. * Computes a reflection matrix from a plane
  4795. * @param plane defines the reflection plane
  4796. * @returns a new matrix
  4797. */
  4798. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4799. /**
  4800. * Computes a reflection matrix from a plane
  4801. * @param plane defines the reflection plane
  4802. * @param result defines the target matrix
  4803. */
  4804. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4805. /**
  4806. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4807. * @param xaxis defines the value of the 1st axis
  4808. * @param yaxis defines the value of the 2nd axis
  4809. * @param zaxis defines the value of the 3rd axis
  4810. * @param result defines the target matrix
  4811. */
  4812. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4813. /**
  4814. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4815. * @param quat defines the quaternion to use
  4816. * @param result defines the target matrix
  4817. */
  4818. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4819. }
  4820. /**
  4821. * @hidden
  4822. */
  4823. export class TmpVectors {
  4824. static Vector2: Vector2[];
  4825. static Vector3: Vector3[];
  4826. static Vector4: Vector4[];
  4827. static Quaternion: Quaternion[];
  4828. static Matrix: Matrix[];
  4829. }
  4830. }
  4831. declare module BABYLON {
  4832. /**
  4833. * Defines potential orientation for back face culling
  4834. */
  4835. export enum Orientation {
  4836. /**
  4837. * Clockwise
  4838. */
  4839. CW = 0,
  4840. /** Counter clockwise */
  4841. CCW = 1
  4842. }
  4843. /** Class used to represent a Bezier curve */
  4844. export class BezierCurve {
  4845. /**
  4846. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4847. * @param t defines the time
  4848. * @param x1 defines the left coordinate on X axis
  4849. * @param y1 defines the left coordinate on Y axis
  4850. * @param x2 defines the right coordinate on X axis
  4851. * @param y2 defines the right coordinate on Y axis
  4852. * @returns the interpolated value
  4853. */
  4854. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4855. }
  4856. /**
  4857. * Defines angle representation
  4858. */
  4859. export class Angle {
  4860. private _radians;
  4861. /**
  4862. * Creates an Angle object of "radians" radians (float).
  4863. * @param radians the angle in radians
  4864. */
  4865. constructor(radians: number);
  4866. /**
  4867. * Get value in degrees
  4868. * @returns the Angle value in degrees (float)
  4869. */
  4870. degrees(): number;
  4871. /**
  4872. * Get value in radians
  4873. * @returns the Angle value in radians (float)
  4874. */
  4875. radians(): number;
  4876. /**
  4877. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4878. * @param a defines first point as the origin
  4879. * @param b defines point
  4880. * @returns a new Angle
  4881. */
  4882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4883. /**
  4884. * Gets a new Angle object from the given float in radians
  4885. * @param radians defines the angle value in radians
  4886. * @returns a new Angle
  4887. */
  4888. static FromRadians(radians: number): Angle;
  4889. /**
  4890. * Gets a new Angle object from the given float in degrees
  4891. * @param degrees defines the angle value in degrees
  4892. * @returns a new Angle
  4893. */
  4894. static FromDegrees(degrees: number): Angle;
  4895. }
  4896. /**
  4897. * This represents an arc in a 2d space.
  4898. */
  4899. export class Arc2 {
  4900. /** Defines the start point of the arc */
  4901. startPoint: Vector2;
  4902. /** Defines the mid point of the arc */
  4903. midPoint: Vector2;
  4904. /** Defines the end point of the arc */
  4905. endPoint: Vector2;
  4906. /**
  4907. * Defines the center point of the arc.
  4908. */
  4909. centerPoint: Vector2;
  4910. /**
  4911. * Defines the radius of the arc.
  4912. */
  4913. radius: number;
  4914. /**
  4915. * Defines the angle of the arc (from mid point to end point).
  4916. */
  4917. angle: Angle;
  4918. /**
  4919. * Defines the start angle of the arc (from start point to middle point).
  4920. */
  4921. startAngle: Angle;
  4922. /**
  4923. * Defines the orientation of the arc (clock wise/counter clock wise).
  4924. */
  4925. orientation: Orientation;
  4926. /**
  4927. * Creates an Arc object from the three given points : start, middle and end.
  4928. * @param startPoint Defines the start point of the arc
  4929. * @param midPoint Defines the midlle point of the arc
  4930. * @param endPoint Defines the end point of the arc
  4931. */
  4932. constructor(
  4933. /** Defines the start point of the arc */
  4934. startPoint: Vector2,
  4935. /** Defines the mid point of the arc */
  4936. midPoint: Vector2,
  4937. /** Defines the end point of the arc */
  4938. endPoint: Vector2);
  4939. }
  4940. /**
  4941. * Represents a 2D path made up of multiple 2D points
  4942. */
  4943. export class Path2 {
  4944. private _points;
  4945. private _length;
  4946. /**
  4947. * If the path start and end point are the same
  4948. */
  4949. closed: boolean;
  4950. /**
  4951. * Creates a Path2 object from the starting 2D coordinates x and y.
  4952. * @param x the starting points x value
  4953. * @param y the starting points y value
  4954. */
  4955. constructor(x: number, y: number);
  4956. /**
  4957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4958. * @param x the added points x value
  4959. * @param y the added points y value
  4960. * @returns the updated Path2.
  4961. */
  4962. addLineTo(x: number, y: number): Path2;
  4963. /**
  4964. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4965. * @param midX middle point x value
  4966. * @param midY middle point y value
  4967. * @param endX end point x value
  4968. * @param endY end point y value
  4969. * @param numberOfSegments (default: 36)
  4970. * @returns the updated Path2.
  4971. */
  4972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4973. /**
  4974. * Closes the Path2.
  4975. * @returns the Path2.
  4976. */
  4977. close(): Path2;
  4978. /**
  4979. * Gets the sum of the distance between each sequential point in the path
  4980. * @returns the Path2 total length (float).
  4981. */
  4982. length(): number;
  4983. /**
  4984. * Gets the points which construct the path
  4985. * @returns the Path2 internal array of points.
  4986. */
  4987. getPoints(): Vector2[];
  4988. /**
  4989. * Retreives the point at the distance aways from the starting point
  4990. * @param normalizedLengthPosition the length along the path to retreive the point from
  4991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4992. */
  4993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4994. /**
  4995. * Creates a new path starting from an x and y position
  4996. * @param x starting x value
  4997. * @param y starting y value
  4998. * @returns a new Path2 starting at the coordinates (x, y).
  4999. */
  5000. static StartingAt(x: number, y: number): Path2;
  5001. }
  5002. /**
  5003. * Represents a 3D path made up of multiple 3D points
  5004. */
  5005. export class Path3D {
  5006. /**
  5007. * an array of Vector3, the curve axis of the Path3D
  5008. */
  5009. path: Vector3[];
  5010. private _curve;
  5011. private _distances;
  5012. private _tangents;
  5013. private _normals;
  5014. private _binormals;
  5015. private _raw;
  5016. private _alignTangentsWithPath;
  5017. private readonly _pointAtData;
  5018. /**
  5019. * new Path3D(path, normal, raw)
  5020. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5021. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5022. * @param path an array of Vector3, the curve axis of the Path3D
  5023. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5024. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5025. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5026. */
  5027. constructor(
  5028. /**
  5029. * an array of Vector3, the curve axis of the Path3D
  5030. */
  5031. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5032. /**
  5033. * Returns the Path3D array of successive Vector3 designing its curve.
  5034. * @returns the Path3D array of successive Vector3 designing its curve.
  5035. */
  5036. getCurve(): Vector3[];
  5037. /**
  5038. * Returns the Path3D array of successive Vector3 designing its curve.
  5039. * @returns the Path3D array of successive Vector3 designing its curve.
  5040. */
  5041. getPoints(): Vector3[];
  5042. /**
  5043. * @returns the computed length (float) of the path.
  5044. */
  5045. length(): number;
  5046. /**
  5047. * Returns an array populated with tangent vectors on each Path3D curve point.
  5048. * @returns an array populated with tangent vectors on each Path3D curve point.
  5049. */
  5050. getTangents(): Vector3[];
  5051. /**
  5052. * Returns an array populated with normal vectors on each Path3D curve point.
  5053. * @returns an array populated with normal vectors on each Path3D curve point.
  5054. */
  5055. getNormals(): Vector3[];
  5056. /**
  5057. * Returns an array populated with binormal vectors on each Path3D curve point.
  5058. * @returns an array populated with binormal vectors on each Path3D curve point.
  5059. */
  5060. getBinormals(): Vector3[];
  5061. /**
  5062. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5063. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5064. */
  5065. getDistances(): number[];
  5066. /**
  5067. * Returns an interpolated point along this path
  5068. * @param position the position of the point along this path, from 0.0 to 1.0
  5069. * @returns a new Vector3 as the point
  5070. */
  5071. getPointAt(position: number): Vector3;
  5072. /**
  5073. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5074. * @param position the position of the point along this path, from 0.0 to 1.0
  5075. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5076. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5077. */
  5078. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5079. /**
  5080. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5081. * @param position the position of the point along this path, from 0.0 to 1.0
  5082. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5083. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5084. */
  5085. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5086. /**
  5087. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5088. * @param position the position of the point along this path, from 0.0 to 1.0
  5089. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5090. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5091. */
  5092. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5093. /**
  5094. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5095. * @param position the position of the point along this path, from 0.0 to 1.0
  5096. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5097. */
  5098. getDistanceAt(position: number): number;
  5099. /**
  5100. * Returns the array index of the previous point of an interpolated point along this path
  5101. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5102. * @returns the array index
  5103. */
  5104. getPreviousPointIndexAt(position: number): number;
  5105. /**
  5106. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5107. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5108. * @returns the sub position
  5109. */
  5110. getSubPositionAt(position: number): number;
  5111. /**
  5112. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5113. * @param target the vector of which to get the closest position to
  5114. * @returns the position of the closest virtual point on this path to the target vector
  5115. */
  5116. getClosestPositionTo(target: Vector3): number;
  5117. /**
  5118. * Returns a sub path (slice) of this path
  5119. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5120. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5121. * @returns a sub path (slice) of this path
  5122. */
  5123. slice(start?: number, end?: number): Path3D;
  5124. /**
  5125. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5126. * @param path path which all values are copied into the curves points
  5127. * @param firstNormal which should be projected onto the curve
  5128. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5129. * @returns the same object updated.
  5130. */
  5131. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5132. private _compute;
  5133. private _getFirstNonNullVector;
  5134. private _getLastNonNullVector;
  5135. private _normalVector;
  5136. /**
  5137. * Updates the point at data for an interpolated point along this curve
  5138. * @param position the position of the point along this curve, from 0.0 to 1.0
  5139. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5140. * @returns the (updated) point at data
  5141. */
  5142. private _updatePointAtData;
  5143. /**
  5144. * Updates the point at data from the specified parameters
  5145. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5146. * @param point the interpolated point
  5147. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5148. */
  5149. private _setPointAtData;
  5150. /**
  5151. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5152. */
  5153. private _updateInterpolationMatrix;
  5154. }
  5155. /**
  5156. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5157. * A Curve3 is designed from a series of successive Vector3.
  5158. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5159. */
  5160. export class Curve3 {
  5161. private _points;
  5162. private _length;
  5163. /**
  5164. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5165. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5166. * @param v1 (Vector3) the control point
  5167. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5168. * @param nbPoints (integer) the wanted number of points in the curve
  5169. * @returns the created Curve3
  5170. */
  5171. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5172. /**
  5173. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5174. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5175. * @param v1 (Vector3) the first control point
  5176. * @param v2 (Vector3) the second control point
  5177. * @param v3 (Vector3) the end point of the Cubic Bezier
  5178. * @param nbPoints (integer) the wanted number of points in the curve
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5182. /**
  5183. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5184. * @param p1 (Vector3) the origin point of the Hermite Spline
  5185. * @param t1 (Vector3) the tangent vector at the origin point
  5186. * @param p2 (Vector3) the end point of the Hermite Spline
  5187. * @param t2 (Vector3) the tangent vector at the end point
  5188. * @param nbPoints (integer) the wanted number of points in the curve
  5189. * @returns the created Curve3
  5190. */
  5191. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5192. /**
  5193. * Returns a Curve3 object along a CatmullRom Spline curve :
  5194. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5195. * @param nbPoints (integer) the wanted number of points between each curve control points
  5196. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5197. * @returns the created Curve3
  5198. */
  5199. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5200. /**
  5201. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5202. * A Curve3 is designed from a series of successive Vector3.
  5203. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5204. * @param points points which make up the curve
  5205. */
  5206. constructor(points: Vector3[]);
  5207. /**
  5208. * @returns the Curve3 stored array of successive Vector3
  5209. */
  5210. getPoints(): Vector3[];
  5211. /**
  5212. * @returns the computed length (float) of the curve.
  5213. */
  5214. length(): number;
  5215. /**
  5216. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5217. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5218. * curveA and curveB keep unchanged.
  5219. * @param curve the curve to continue from this curve
  5220. * @returns the newly constructed curve
  5221. */
  5222. continue(curve: DeepImmutable<Curve3>): Curve3;
  5223. private _computeLength;
  5224. }
  5225. }
  5226. declare module BABYLON {
  5227. /**
  5228. * This represents the main contract an easing function should follow.
  5229. * Easing functions are used throughout the animation system.
  5230. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export interface IEasingFunction {
  5233. /**
  5234. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5235. * of the easing function.
  5236. * The link below provides some of the most common examples of easing functions.
  5237. * @see https://easings.net/
  5238. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5239. * @returns the corresponding value on the curve defined by the easing function
  5240. */
  5241. ease(gradient: number): number;
  5242. }
  5243. /**
  5244. * Base class used for every default easing function.
  5245. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5246. */
  5247. export class EasingFunction implements IEasingFunction {
  5248. /**
  5249. * Interpolation follows the mathematical formula associated with the easing function.
  5250. */
  5251. static readonly EASINGMODE_EASEIN: number;
  5252. /**
  5253. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5254. */
  5255. static readonly EASINGMODE_EASEOUT: number;
  5256. /**
  5257. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5258. */
  5259. static readonly EASINGMODE_EASEINOUT: number;
  5260. private _easingMode;
  5261. /**
  5262. * Sets the easing mode of the current function.
  5263. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5264. */
  5265. setEasingMode(easingMode: number): void;
  5266. /**
  5267. * Gets the current easing mode.
  5268. * @returns the easing mode
  5269. */
  5270. getEasingMode(): number;
  5271. /**
  5272. * @hidden
  5273. */
  5274. easeInCore(gradient: number): number;
  5275. /**
  5276. * Given an input gradient between 0 and 1, this returns the corresponding value
  5277. * of the easing function.
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Easing function with a circle shape (see link below).
  5285. * @see https://easings.net/#easeInCirc
  5286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export class CircleEase extends EasingFunction implements IEasingFunction {
  5289. /** @hidden */
  5290. easeInCore(gradient: number): number;
  5291. }
  5292. /**
  5293. * Easing function with a ease back shape (see link below).
  5294. * @see https://easings.net/#easeInBack
  5295. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5296. */
  5297. export class BackEase extends EasingFunction implements IEasingFunction {
  5298. /** Defines the amplitude of the function */
  5299. amplitude: number;
  5300. /**
  5301. * Instantiates a back ease easing
  5302. * @see https://easings.net/#easeInBack
  5303. * @param amplitude Defines the amplitude of the function
  5304. */
  5305. constructor(
  5306. /** Defines the amplitude of the function */
  5307. amplitude?: number);
  5308. /** @hidden */
  5309. easeInCore(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with a bouncing shape (see link below).
  5313. * @see https://easings.net/#easeInBounce
  5314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class BounceEase extends EasingFunction implements IEasingFunction {
  5317. /** Defines the number of bounces */
  5318. bounces: number;
  5319. /** Defines the amplitude of the bounce */
  5320. bounciness: number;
  5321. /**
  5322. * Instantiates a bounce easing
  5323. * @see https://easings.net/#easeInBounce
  5324. * @param bounces Defines the number of bounces
  5325. * @param bounciness Defines the amplitude of the bounce
  5326. */
  5327. constructor(
  5328. /** Defines the number of bounces */
  5329. bounces?: number,
  5330. /** Defines the amplitude of the bounce */
  5331. bounciness?: number);
  5332. /** @hidden */
  5333. easeInCore(gradient: number): number;
  5334. }
  5335. /**
  5336. * Easing function with a power of 3 shape (see link below).
  5337. * @see https://easings.net/#easeInCubic
  5338. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5339. */
  5340. export class CubicEase extends EasingFunction implements IEasingFunction {
  5341. /** @hidden */
  5342. easeInCore(gradient: number): number;
  5343. }
  5344. /**
  5345. * Easing function with an elastic shape (see link below).
  5346. * @see https://easings.net/#easeInElastic
  5347. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5348. */
  5349. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5350. /** Defines the number of oscillations*/
  5351. oscillations: number;
  5352. /** Defines the amplitude of the oscillations*/
  5353. springiness: number;
  5354. /**
  5355. * Instantiates an elastic easing function
  5356. * @see https://easings.net/#easeInElastic
  5357. * @param oscillations Defines the number of oscillations
  5358. * @param springiness Defines the amplitude of the oscillations
  5359. */
  5360. constructor(
  5361. /** Defines the number of oscillations*/
  5362. oscillations?: number,
  5363. /** Defines the amplitude of the oscillations*/
  5364. springiness?: number);
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with an exponential shape (see link below).
  5370. * @see https://easings.net/#easeInExpo
  5371. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5374. /** Defines the exponent of the function */
  5375. exponent: number;
  5376. /**
  5377. * Instantiates an exponential easing function
  5378. * @see https://easings.net/#easeInExpo
  5379. * @param exponent Defines the exponent of the function
  5380. */
  5381. constructor(
  5382. /** Defines the exponent of the function */
  5383. exponent?: number);
  5384. /** @hidden */
  5385. easeInCore(gradient: number): number;
  5386. }
  5387. /**
  5388. * Easing function with a power shape (see link below).
  5389. * @see https://easings.net/#easeInQuad
  5390. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5391. */
  5392. export class PowerEase extends EasingFunction implements IEasingFunction {
  5393. /** Defines the power of the function */
  5394. power: number;
  5395. /**
  5396. * Instantiates an power base easing function
  5397. * @see https://easings.net/#easeInQuad
  5398. * @param power Defines the power of the function
  5399. */
  5400. constructor(
  5401. /** Defines the power of the function */
  5402. power?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 2 shape (see link below).
  5408. * @see https://easings.net/#easeInQuad
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power of 4 shape (see link below).
  5417. * @see https://easings.net/#easeInQuart
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a power of 5 shape (see link below).
  5426. * @see https://easings.net/#easeInQuint
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5430. /** @hidden */
  5431. easeInCore(gradient: number): number;
  5432. }
  5433. /**
  5434. * Easing function with a sin shape (see link below).
  5435. * @see https://easings.net/#easeInSine
  5436. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5437. */
  5438. export class SineEase extends EasingFunction implements IEasingFunction {
  5439. /** @hidden */
  5440. easeInCore(gradient: number): number;
  5441. }
  5442. /**
  5443. * Easing function with a bezier shape (see link below).
  5444. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5445. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5446. */
  5447. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5448. /** Defines the x component of the start tangent in the bezier curve */
  5449. x1: number;
  5450. /** Defines the y component of the start tangent in the bezier curve */
  5451. y1: number;
  5452. /** Defines the x component of the end tangent in the bezier curve */
  5453. x2: number;
  5454. /** Defines the y component of the end tangent in the bezier curve */
  5455. y2: number;
  5456. /**
  5457. * Instantiates a bezier function
  5458. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5459. * @param x1 Defines the x component of the start tangent in the bezier curve
  5460. * @param y1 Defines the y component of the start tangent in the bezier curve
  5461. * @param x2 Defines the x component of the end tangent in the bezier curve
  5462. * @param y2 Defines the y component of the end tangent in the bezier curve
  5463. */
  5464. constructor(
  5465. /** Defines the x component of the start tangent in the bezier curve */
  5466. x1?: number,
  5467. /** Defines the y component of the start tangent in the bezier curve */
  5468. y1?: number,
  5469. /** Defines the x component of the end tangent in the bezier curve */
  5470. x2?: number,
  5471. /** Defines the y component of the end tangent in the bezier curve */
  5472. y2?: number);
  5473. /** @hidden */
  5474. easeInCore(gradient: number): number;
  5475. }
  5476. }
  5477. declare module BABYLON {
  5478. /**
  5479. * Class used to hold a RBG color
  5480. */
  5481. export class Color3 {
  5482. /**
  5483. * Defines the red component (between 0 and 1, default is 0)
  5484. */
  5485. r: number;
  5486. /**
  5487. * Defines the green component (between 0 and 1, default is 0)
  5488. */
  5489. g: number;
  5490. /**
  5491. * Defines the blue component (between 0 and 1, default is 0)
  5492. */
  5493. b: number;
  5494. /**
  5495. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5496. * @param r defines the red component (between 0 and 1, default is 0)
  5497. * @param g defines the green component (between 0 and 1, default is 0)
  5498. * @param b defines the blue component (between 0 and 1, default is 0)
  5499. */
  5500. constructor(
  5501. /**
  5502. * Defines the red component (between 0 and 1, default is 0)
  5503. */
  5504. r?: number,
  5505. /**
  5506. * Defines the green component (between 0 and 1, default is 0)
  5507. */
  5508. g?: number,
  5509. /**
  5510. * Defines the blue component (between 0 and 1, default is 0)
  5511. */
  5512. b?: number);
  5513. /**
  5514. * Creates a string with the Color3 current values
  5515. * @returns the string representation of the Color3 object
  5516. */
  5517. toString(): string;
  5518. /**
  5519. * Returns the string "Color3"
  5520. * @returns "Color3"
  5521. */
  5522. getClassName(): string;
  5523. /**
  5524. * Compute the Color3 hash code
  5525. * @returns an unique number that can be used to hash Color3 objects
  5526. */
  5527. getHashCode(): number;
  5528. /**
  5529. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5530. * @param array defines the array where to store the r,g,b components
  5531. * @param index defines an optional index in the target array to define where to start storing values
  5532. * @returns the current Color3 object
  5533. */
  5534. toArray(array: FloatArray, index?: number): Color3;
  5535. /**
  5536. * Update the current color with values stored in an array from the starting index of the given array
  5537. * @param array defines the source array
  5538. * @param offset defines an offset in the source array
  5539. * @returns the current Color3 object
  5540. */
  5541. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5542. /**
  5543. * Returns a new Color4 object from the current Color3 and the given alpha
  5544. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5545. * @returns a new Color4 object
  5546. */
  5547. toColor4(alpha?: number): Color4;
  5548. /**
  5549. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5550. * @returns the new array
  5551. */
  5552. asArray(): number[];
  5553. /**
  5554. * Returns the luminance value
  5555. * @returns a float value
  5556. */
  5557. toLuminance(): number;
  5558. /**
  5559. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5560. * @param otherColor defines the second operand
  5561. * @returns the new Color3 object
  5562. */
  5563. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5564. /**
  5565. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5566. * @param otherColor defines the second operand
  5567. * @param result defines the Color3 object where to store the result
  5568. * @returns the current Color3
  5569. */
  5570. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5571. /**
  5572. * Determines equality between Color3 objects
  5573. * @param otherColor defines the second operand
  5574. * @returns true if the rgb values are equal to the given ones
  5575. */
  5576. equals(otherColor: DeepImmutable<Color3>): boolean;
  5577. /**
  5578. * Determines equality between the current Color3 object and a set of r,b,g values
  5579. * @param r defines the red component to check
  5580. * @param g defines the green component to check
  5581. * @param b defines the blue component to check
  5582. * @returns true if the rgb values are equal to the given ones
  5583. */
  5584. equalsFloats(r: number, g: number, b: number): boolean;
  5585. /**
  5586. * Multiplies in place each rgb value by scale
  5587. * @param scale defines the scaling factor
  5588. * @returns the updated Color3
  5589. */
  5590. scale(scale: number): Color3;
  5591. /**
  5592. * Multiplies the rgb values by scale and stores the result into "result"
  5593. * @param scale defines the scaling factor
  5594. * @param result defines the Color3 object where to store the result
  5595. * @returns the unmodified current Color3
  5596. */
  5597. scaleToRef(scale: number, result: Color3): Color3;
  5598. /**
  5599. * Scale the current Color3 values by a factor and add the result to a given Color3
  5600. * @param scale defines the scale factor
  5601. * @param result defines color to store the result into
  5602. * @returns the unmodified current Color3
  5603. */
  5604. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5605. /**
  5606. * Clamps the rgb values by the min and max values and stores the result into "result"
  5607. * @param min defines minimum clamping value (default is 0)
  5608. * @param max defines maximum clamping value (default is 1)
  5609. * @param result defines color to store the result into
  5610. * @returns the original Color3
  5611. */
  5612. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5613. /**
  5614. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5615. * @param otherColor defines the second operand
  5616. * @returns the new Color3
  5617. */
  5618. add(otherColor: DeepImmutable<Color3>): Color3;
  5619. /**
  5620. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5621. * @param otherColor defines the second operand
  5622. * @param result defines Color3 object to store the result into
  5623. * @returns the unmodified current Color3
  5624. */
  5625. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5626. /**
  5627. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5628. * @param otherColor defines the second operand
  5629. * @returns the new Color3
  5630. */
  5631. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5632. /**
  5633. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5634. * @param otherColor defines the second operand
  5635. * @param result defines Color3 object to store the result into
  5636. * @returns the unmodified current Color3
  5637. */
  5638. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5639. /**
  5640. * Copy the current object
  5641. * @returns a new Color3 copied the current one
  5642. */
  5643. clone(): Color3;
  5644. /**
  5645. * Copies the rgb values from the source in the current Color3
  5646. * @param source defines the source Color3 object
  5647. * @returns the updated Color3 object
  5648. */
  5649. copyFrom(source: DeepImmutable<Color3>): Color3;
  5650. /**
  5651. * Updates the Color3 rgb values from the given floats
  5652. * @param r defines the red component to read from
  5653. * @param g defines the green component to read from
  5654. * @param b defines the blue component to read from
  5655. * @returns the current Color3 object
  5656. */
  5657. copyFromFloats(r: number, g: number, b: number): Color3;
  5658. /**
  5659. * Updates the Color3 rgb values from the given floats
  5660. * @param r defines the red component to read from
  5661. * @param g defines the green component to read from
  5662. * @param b defines the blue component to read from
  5663. * @returns the current Color3 object
  5664. */
  5665. set(r: number, g: number, b: number): Color3;
  5666. /**
  5667. * Compute the Color3 hexadecimal code as a string
  5668. * @returns a string containing the hexadecimal representation of the Color3 object
  5669. */
  5670. toHexString(): string;
  5671. /**
  5672. * Computes a new Color3 converted from the current one to linear space
  5673. * @returns a new Color3 object
  5674. */
  5675. toLinearSpace(): Color3;
  5676. /**
  5677. * Converts current color in rgb space to HSV values
  5678. * @returns a new color3 representing the HSV values
  5679. */
  5680. toHSV(): Color3;
  5681. /**
  5682. * Converts current color in rgb space to HSV values
  5683. * @param result defines the Color3 where to store the HSV values
  5684. */
  5685. toHSVToRef(result: Color3): void;
  5686. /**
  5687. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5688. * @param convertedColor defines the Color3 object where to store the linear space version
  5689. * @returns the unmodified Color3
  5690. */
  5691. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5692. /**
  5693. * Computes a new Color3 converted from the current one to gamma space
  5694. * @returns a new Color3 object
  5695. */
  5696. toGammaSpace(): Color3;
  5697. /**
  5698. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5699. * @param convertedColor defines the Color3 object where to store the gamma space version
  5700. * @returns the unmodified Color3
  5701. */
  5702. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5703. private static _BlackReadOnly;
  5704. /**
  5705. * Convert Hue, saturation and value to a Color3 (RGB)
  5706. * @param hue defines the hue
  5707. * @param saturation defines the saturation
  5708. * @param value defines the value
  5709. * @param result defines the Color3 where to store the RGB values
  5710. */
  5711. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5712. /**
  5713. * Creates a new Color3 from the string containing valid hexadecimal values
  5714. * @param hex defines a string containing valid hexadecimal values
  5715. * @returns a new Color3 object
  5716. */
  5717. static FromHexString(hex: string): Color3;
  5718. /**
  5719. * Creates a new Color3 from the starting index of the given array
  5720. * @param array defines the source array
  5721. * @param offset defines an offset in the source array
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5725. /**
  5726. * Creates a new Color3 from the starting index element of the given array
  5727. * @param array defines the source array to read from
  5728. * @param offset defines the offset in the source array
  5729. * @param result defines the target Color3 object
  5730. */
  5731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5732. /**
  5733. * Creates a new Color3 from integer values (< 256)
  5734. * @param r defines the red component to read from (value between 0 and 255)
  5735. * @param g defines the green component to read from (value between 0 and 255)
  5736. * @param b defines the blue component to read from (value between 0 and 255)
  5737. * @returns a new Color3 object
  5738. */
  5739. static FromInts(r: number, g: number, b: number): Color3;
  5740. /**
  5741. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5742. * @param start defines the start Color3 value
  5743. * @param end defines the end Color3 value
  5744. * @param amount defines the gradient value between start and end
  5745. * @returns a new Color3 object
  5746. */
  5747. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5748. /**
  5749. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5750. * @param left defines the start value
  5751. * @param right defines the end value
  5752. * @param amount defines the gradient factor
  5753. * @param result defines the Color3 object where to store the result
  5754. */
  5755. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5756. /**
  5757. * Returns a Color3 value containing a red color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Red(): Color3;
  5761. /**
  5762. * Returns a Color3 value containing a green color
  5763. * @returns a new Color3 object
  5764. */
  5765. static Green(): Color3;
  5766. /**
  5767. * Returns a Color3 value containing a blue color
  5768. * @returns a new Color3 object
  5769. */
  5770. static Blue(): Color3;
  5771. /**
  5772. * Returns a Color3 value containing a black color
  5773. * @returns a new Color3 object
  5774. */
  5775. static Black(): Color3;
  5776. /**
  5777. * Gets a Color3 value containing a black color that must not be updated
  5778. */
  5779. static get BlackReadOnly(): DeepImmutable<Color3>;
  5780. /**
  5781. * Returns a Color3 value containing a white color
  5782. * @returns a new Color3 object
  5783. */
  5784. static White(): Color3;
  5785. /**
  5786. * Returns a Color3 value containing a purple color
  5787. * @returns a new Color3 object
  5788. */
  5789. static Purple(): Color3;
  5790. /**
  5791. * Returns a Color3 value containing a magenta color
  5792. * @returns a new Color3 object
  5793. */
  5794. static Magenta(): Color3;
  5795. /**
  5796. * Returns a Color3 value containing a yellow color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Yellow(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a gray color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Gray(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a teal color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Teal(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a random color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Random(): Color3;
  5815. }
  5816. /**
  5817. * Class used to hold a RBGA color
  5818. */
  5819. export class Color4 {
  5820. /**
  5821. * Defines the red component (between 0 and 1, default is 0)
  5822. */
  5823. r: number;
  5824. /**
  5825. * Defines the green component (between 0 and 1, default is 0)
  5826. */
  5827. g: number;
  5828. /**
  5829. * Defines the blue component (between 0 and 1, default is 0)
  5830. */
  5831. b: number;
  5832. /**
  5833. * Defines the alpha component (between 0 and 1, default is 1)
  5834. */
  5835. a: number;
  5836. /**
  5837. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5838. * @param r defines the red component (between 0 and 1, default is 0)
  5839. * @param g defines the green component (between 0 and 1, default is 0)
  5840. * @param b defines the blue component (between 0 and 1, default is 0)
  5841. * @param a defines the alpha component (between 0 and 1, default is 1)
  5842. */
  5843. constructor(
  5844. /**
  5845. * Defines the red component (between 0 and 1, default is 0)
  5846. */
  5847. r?: number,
  5848. /**
  5849. * Defines the green component (between 0 and 1, default is 0)
  5850. */
  5851. g?: number,
  5852. /**
  5853. * Defines the blue component (between 0 and 1, default is 0)
  5854. */
  5855. b?: number,
  5856. /**
  5857. * Defines the alpha component (between 0 and 1, default is 1)
  5858. */
  5859. a?: number);
  5860. /**
  5861. * Adds in place the given Color4 values to the current Color4 object
  5862. * @param right defines the second operand
  5863. * @returns the current updated Color4 object
  5864. */
  5865. addInPlace(right: DeepImmutable<Color4>): Color4;
  5866. /**
  5867. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5868. * @returns the new array
  5869. */
  5870. asArray(): number[];
  5871. /**
  5872. * Stores from the starting index in the given array the Color4 successive values
  5873. * @param array defines the array where to store the r,g,b components
  5874. * @param index defines an optional index in the target array to define where to start storing values
  5875. * @returns the current Color4 object
  5876. */
  5877. toArray(array: number[], index?: number): Color4;
  5878. /**
  5879. * Update the current color with values stored in an array from the starting index of the given array
  5880. * @param array defines the source array
  5881. * @param offset defines an offset in the source array
  5882. * @returns the current Color4 object
  5883. */
  5884. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5885. /**
  5886. * Determines equality between Color4 objects
  5887. * @param otherColor defines the second operand
  5888. * @returns true if the rgba values are equal to the given ones
  5889. */
  5890. equals(otherColor: DeepImmutable<Color4>): boolean;
  5891. /**
  5892. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5893. * @param right defines the second operand
  5894. * @returns a new Color4 object
  5895. */
  5896. add(right: DeepImmutable<Color4>): Color4;
  5897. /**
  5898. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5899. * @param right defines the second operand
  5900. * @returns a new Color4 object
  5901. */
  5902. subtract(right: DeepImmutable<Color4>): Color4;
  5903. /**
  5904. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5905. * @param right defines the second operand
  5906. * @param result defines the Color4 object where to store the result
  5907. * @returns the current Color4 object
  5908. */
  5909. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5910. /**
  5911. * Creates a new Color4 with the current Color4 values multiplied by scale
  5912. * @param scale defines the scaling factor to apply
  5913. * @returns a new Color4 object
  5914. */
  5915. scale(scale: number): Color4;
  5916. /**
  5917. * Multiplies the current Color4 values by scale and stores the result in "result"
  5918. * @param scale defines the scaling factor to apply
  5919. * @param result defines the Color4 object where to store the result
  5920. * @returns the current unmodified Color4
  5921. */
  5922. scaleToRef(scale: number, result: Color4): Color4;
  5923. /**
  5924. * Scale the current Color4 values by a factor and add the result to a given Color4
  5925. * @param scale defines the scale factor
  5926. * @param result defines the Color4 object where to store the result
  5927. * @returns the unmodified current Color4
  5928. */
  5929. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5930. /**
  5931. * Clamps the rgb values by the min and max values and stores the result into "result"
  5932. * @param min defines minimum clamping value (default is 0)
  5933. * @param max defines maximum clamping value (default is 1)
  5934. * @param result defines color to store the result into.
  5935. * @returns the cuurent Color4
  5936. */
  5937. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5938. /**
  5939. * Multipy an Color4 value by another and return a new Color4 object
  5940. * @param color defines the Color4 value to multiply by
  5941. * @returns a new Color4 object
  5942. */
  5943. multiply(color: Color4): Color4;
  5944. /**
  5945. * Multipy a Color4 value by another and push the result in a reference value
  5946. * @param color defines the Color4 value to multiply by
  5947. * @param result defines the Color4 to fill the result in
  5948. * @returns the result Color4
  5949. */
  5950. multiplyToRef(color: Color4, result: Color4): Color4;
  5951. /**
  5952. * Creates a string with the Color4 current values
  5953. * @returns the string representation of the Color4 object
  5954. */
  5955. toString(): string;
  5956. /**
  5957. * Returns the string "Color4"
  5958. * @returns "Color4"
  5959. */
  5960. getClassName(): string;
  5961. /**
  5962. * Compute the Color4 hash code
  5963. * @returns an unique number that can be used to hash Color4 objects
  5964. */
  5965. getHashCode(): number;
  5966. /**
  5967. * Creates a new Color4 copied from the current one
  5968. * @returns a new Color4 object
  5969. */
  5970. clone(): Color4;
  5971. /**
  5972. * Copies the given Color4 values into the current one
  5973. * @param source defines the source Color4 object
  5974. * @returns the current updated Color4 object
  5975. */
  5976. copyFrom(source: Color4): Color4;
  5977. /**
  5978. * Copies the given float values into the current one
  5979. * @param r defines the red component to read from
  5980. * @param g defines the green component to read from
  5981. * @param b defines the blue component to read from
  5982. * @param a defines the alpha component to read from
  5983. * @returns the current updated Color4 object
  5984. */
  5985. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5986. /**
  5987. * Copies the given float values into the current one
  5988. * @param r defines the red component to read from
  5989. * @param g defines the green component to read from
  5990. * @param b defines the blue component to read from
  5991. * @param a defines the alpha component to read from
  5992. * @returns the current updated Color4 object
  5993. */
  5994. set(r: number, g: number, b: number, a: number): Color4;
  5995. /**
  5996. * Compute the Color4 hexadecimal code as a string
  5997. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5998. * @returns a string containing the hexadecimal representation of the Color4 object
  5999. */
  6000. toHexString(returnAsColor3?: boolean): string;
  6001. /**
  6002. * Computes a new Color4 converted from the current one to linear space
  6003. * @returns a new Color4 object
  6004. */
  6005. toLinearSpace(): Color4;
  6006. /**
  6007. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6008. * @param convertedColor defines the Color4 object where to store the linear space version
  6009. * @returns the unmodified Color4
  6010. */
  6011. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6012. /**
  6013. * Computes a new Color4 converted from the current one to gamma space
  6014. * @returns a new Color4 object
  6015. */
  6016. toGammaSpace(): Color4;
  6017. /**
  6018. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6019. * @param convertedColor defines the Color4 object where to store the gamma space version
  6020. * @returns the unmodified Color4
  6021. */
  6022. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6023. /**
  6024. * Creates a new Color4 from the string containing valid hexadecimal values
  6025. * @param hex defines a string containing valid hexadecimal values
  6026. * @returns a new Color4 object
  6027. */
  6028. static FromHexString(hex: string): Color4;
  6029. /**
  6030. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6031. * @param left defines the start value
  6032. * @param right defines the end value
  6033. * @param amount defines the gradient factor
  6034. * @returns a new Color4 object
  6035. */
  6036. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6037. /**
  6038. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6039. * @param left defines the start value
  6040. * @param right defines the end value
  6041. * @param amount defines the gradient factor
  6042. * @param result defines the Color4 object where to store data
  6043. */
  6044. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6045. /**
  6046. * Creates a new Color4 from a Color3 and an alpha value
  6047. * @param color3 defines the source Color3 to read from
  6048. * @param alpha defines the alpha component (1.0 by default)
  6049. * @returns a new Color4 object
  6050. */
  6051. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6052. /**
  6053. * Creates a new Color4 from the starting index element of the given array
  6054. * @param array defines the source array to read from
  6055. * @param offset defines the offset in the source array
  6056. * @returns a new Color4 object
  6057. */
  6058. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6059. /**
  6060. * Creates a new Color4 from the starting index element of the given array
  6061. * @param array defines the source array to read from
  6062. * @param offset defines the offset in the source array
  6063. * @param result defines the target Color4 object
  6064. */
  6065. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6066. /**
  6067. * Creates a new Color3 from integer values (< 256)
  6068. * @param r defines the red component to read from (value between 0 and 255)
  6069. * @param g defines the green component to read from (value between 0 and 255)
  6070. * @param b defines the blue component to read from (value between 0 and 255)
  6071. * @param a defines the alpha component to read from (value between 0 and 255)
  6072. * @returns a new Color3 object
  6073. */
  6074. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6075. /**
  6076. * Check the content of a given array and convert it to an array containing RGBA data
  6077. * If the original array was already containing count * 4 values then it is returned directly
  6078. * @param colors defines the array to check
  6079. * @param count defines the number of RGBA data to expect
  6080. * @returns an array containing count * 4 values (RGBA)
  6081. */
  6082. static CheckColors4(colors: number[], count: number): number[];
  6083. }
  6084. /**
  6085. * @hidden
  6086. */
  6087. export class TmpColors {
  6088. static Color3: Color3[];
  6089. static Color4: Color4[];
  6090. }
  6091. }
  6092. declare module BABYLON {
  6093. /**
  6094. * Defines an interface which represents an animation key frame
  6095. */
  6096. export interface IAnimationKey {
  6097. /**
  6098. * Frame of the key frame
  6099. */
  6100. frame: number;
  6101. /**
  6102. * Value at the specifies key frame
  6103. */
  6104. value: any;
  6105. /**
  6106. * The input tangent for the cubic hermite spline
  6107. */
  6108. inTangent?: any;
  6109. /**
  6110. * The output tangent for the cubic hermite spline
  6111. */
  6112. outTangent?: any;
  6113. /**
  6114. * The animation interpolation type
  6115. */
  6116. interpolation?: AnimationKeyInterpolation;
  6117. }
  6118. /**
  6119. * Enum for the animation key frame interpolation type
  6120. */
  6121. export enum AnimationKeyInterpolation {
  6122. /**
  6123. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6124. */
  6125. STEP = 1
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. /**
  6130. * Represents the range of an animation
  6131. */
  6132. export class AnimationRange {
  6133. /**The name of the animation range**/
  6134. name: string;
  6135. /**The starting frame of the animation */
  6136. from: number;
  6137. /**The ending frame of the animation*/
  6138. to: number;
  6139. /**
  6140. * Initializes the range of an animation
  6141. * @param name The name of the animation range
  6142. * @param from The starting frame of the animation
  6143. * @param to The ending frame of the animation
  6144. */
  6145. constructor(
  6146. /**The name of the animation range**/
  6147. name: string,
  6148. /**The starting frame of the animation */
  6149. from: number,
  6150. /**The ending frame of the animation*/
  6151. to: number);
  6152. /**
  6153. * Makes a copy of the animation range
  6154. * @returns A copy of the animation range
  6155. */
  6156. clone(): AnimationRange;
  6157. }
  6158. }
  6159. declare module BABYLON {
  6160. /**
  6161. * Composed of a frame, and an action function
  6162. */
  6163. export class AnimationEvent {
  6164. /** The frame for which the event is triggered **/
  6165. frame: number;
  6166. /** The event to perform when triggered **/
  6167. action: (currentFrame: number) => void;
  6168. /** Specifies if the event should be triggered only once**/
  6169. onlyOnce?: boolean | undefined;
  6170. /**
  6171. * Specifies if the animation event is done
  6172. */
  6173. isDone: boolean;
  6174. /**
  6175. * Initializes the animation event
  6176. * @param frame The frame for which the event is triggered
  6177. * @param action The event to perform when triggered
  6178. * @param onlyOnce Specifies if the event should be triggered only once
  6179. */
  6180. constructor(
  6181. /** The frame for which the event is triggered **/
  6182. frame: number,
  6183. /** The event to perform when triggered **/
  6184. action: (currentFrame: number) => void,
  6185. /** Specifies if the event should be triggered only once**/
  6186. onlyOnce?: boolean | undefined);
  6187. /** @hidden */
  6188. _clone(): AnimationEvent;
  6189. }
  6190. }
  6191. declare module BABYLON {
  6192. /**
  6193. * Interface used to define a behavior
  6194. */
  6195. export interface Behavior<T> {
  6196. /** gets or sets behavior's name */
  6197. name: string;
  6198. /**
  6199. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6200. */
  6201. init(): void;
  6202. /**
  6203. * Called when the behavior is attached to a target
  6204. * @param target defines the target where the behavior is attached to
  6205. */
  6206. attach(target: T): void;
  6207. /**
  6208. * Called when the behavior is detached from its target
  6209. */
  6210. detach(): void;
  6211. }
  6212. /**
  6213. * Interface implemented by classes supporting behaviors
  6214. */
  6215. export interface IBehaviorAware<T> {
  6216. /**
  6217. * Attach a behavior
  6218. * @param behavior defines the behavior to attach
  6219. * @returns the current host
  6220. */
  6221. addBehavior(behavior: Behavior<T>): T;
  6222. /**
  6223. * Remove a behavior from the current object
  6224. * @param behavior defines the behavior to detach
  6225. * @returns the current host
  6226. */
  6227. removeBehavior(behavior: Behavior<T>): T;
  6228. /**
  6229. * Gets a behavior using its name to search
  6230. * @param name defines the name to search
  6231. * @returns the behavior or null if not found
  6232. */
  6233. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6234. }
  6235. }
  6236. declare module BABYLON {
  6237. /**
  6238. * Defines an array and its length.
  6239. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6240. */
  6241. export interface ISmartArrayLike<T> {
  6242. /**
  6243. * The data of the array.
  6244. */
  6245. data: Array<T>;
  6246. /**
  6247. * The active length of the array.
  6248. */
  6249. length: number;
  6250. }
  6251. /**
  6252. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6253. */
  6254. export class SmartArray<T> implements ISmartArrayLike<T> {
  6255. /**
  6256. * The full set of data from the array.
  6257. */
  6258. data: Array<T>;
  6259. /**
  6260. * The active length of the array.
  6261. */
  6262. length: number;
  6263. protected _id: number;
  6264. /**
  6265. * Instantiates a Smart Array.
  6266. * @param capacity defines the default capacity of the array.
  6267. */
  6268. constructor(capacity: number);
  6269. /**
  6270. * Pushes a value at the end of the active data.
  6271. * @param value defines the object to push in the array.
  6272. */
  6273. push(value: T): void;
  6274. /**
  6275. * Iterates over the active data and apply the lambda to them.
  6276. * @param func defines the action to apply on each value.
  6277. */
  6278. forEach(func: (content: T) => void): void;
  6279. /**
  6280. * Sorts the full sets of data.
  6281. * @param compareFn defines the comparison function to apply.
  6282. */
  6283. sort(compareFn: (a: T, b: T) => number): void;
  6284. /**
  6285. * Resets the active data to an empty array.
  6286. */
  6287. reset(): void;
  6288. /**
  6289. * Releases all the data from the array as well as the array.
  6290. */
  6291. dispose(): void;
  6292. /**
  6293. * Concats the active data with a given array.
  6294. * @param array defines the data to concatenate with.
  6295. */
  6296. concat(array: any): void;
  6297. /**
  6298. * Returns the position of a value in the active data.
  6299. * @param value defines the value to find the index for
  6300. * @returns the index if found in the active data otherwise -1
  6301. */
  6302. indexOf(value: T): number;
  6303. /**
  6304. * Returns whether an element is part of the active data.
  6305. * @param value defines the value to look for
  6306. * @returns true if found in the active data otherwise false
  6307. */
  6308. contains(value: T): boolean;
  6309. private static _GlobalId;
  6310. }
  6311. /**
  6312. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6313. * The data in this array can only be present once
  6314. */
  6315. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6316. private _duplicateId;
  6317. /**
  6318. * Pushes a value at the end of the active data.
  6319. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6320. * @param value defines the object to push in the array.
  6321. */
  6322. push(value: T): void;
  6323. /**
  6324. * Pushes a value at the end of the active data.
  6325. * If the data is already present, it won t be added again
  6326. * @param value defines the object to push in the array.
  6327. * @returns true if added false if it was already present
  6328. */
  6329. pushNoDuplicate(value: T): boolean;
  6330. /**
  6331. * Resets the active data to an empty array.
  6332. */
  6333. reset(): void;
  6334. /**
  6335. * Concats the active data with a given array.
  6336. * This ensures no dupplicate will be present in the result.
  6337. * @param array defines the data to concatenate with.
  6338. */
  6339. concatWithNoDuplicate(array: any): void;
  6340. }
  6341. }
  6342. declare module BABYLON {
  6343. /**
  6344. * @ignore
  6345. * This is a list of all the different input types that are available in the application.
  6346. * Fo instance: ArcRotateCameraGamepadInput...
  6347. */
  6348. export var CameraInputTypes: {};
  6349. /**
  6350. * This is the contract to implement in order to create a new input class.
  6351. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6352. */
  6353. export interface ICameraInput<TCamera extends Camera> {
  6354. /**
  6355. * Defines the camera the input is attached to.
  6356. */
  6357. camera: Nullable<TCamera>;
  6358. /**
  6359. * Gets the class name of the current intput.
  6360. * @returns the class name
  6361. */
  6362. getClassName(): string;
  6363. /**
  6364. * Get the friendly name associated with the input class.
  6365. * @returns the input friendly name
  6366. */
  6367. getSimpleName(): string;
  6368. /**
  6369. * Attach the input controls to a specific dom element to get the input from.
  6370. * @param element Defines the element the controls should be listened from
  6371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6372. */
  6373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6374. /**
  6375. * Detach the current controls from the specified dom element.
  6376. * @param element Defines the element to stop listening the inputs from
  6377. */
  6378. detachControl(element: Nullable<HTMLElement>): void;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs?: () => void;
  6384. }
  6385. /**
  6386. * Represents a map of input types to input instance or input index to input instance.
  6387. */
  6388. export interface CameraInputsMap<TCamera extends Camera> {
  6389. /**
  6390. * Accessor to the input by input type.
  6391. */
  6392. [name: string]: ICameraInput<TCamera>;
  6393. /**
  6394. * Accessor to the input by input index.
  6395. */
  6396. [idx: number]: ICameraInput<TCamera>;
  6397. }
  6398. /**
  6399. * This represents the input manager used within a camera.
  6400. * It helps dealing with all the different kind of input attached to a camera.
  6401. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6402. */
  6403. export class CameraInputsManager<TCamera extends Camera> {
  6404. /**
  6405. * Defines the list of inputs attahed to the camera.
  6406. */
  6407. attached: CameraInputsMap<TCamera>;
  6408. /**
  6409. * Defines the dom element the camera is collecting inputs from.
  6410. * This is null if the controls have not been attached.
  6411. */
  6412. attachedElement: Nullable<HTMLElement>;
  6413. /**
  6414. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6415. */
  6416. noPreventDefault: boolean;
  6417. /**
  6418. * Defined the camera the input manager belongs to.
  6419. */
  6420. camera: TCamera;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs: () => void;
  6426. /**
  6427. * Instantiate a new Camera Input Manager.
  6428. * @param camera Defines the camera the input manager blongs to
  6429. */
  6430. constructor(camera: TCamera);
  6431. /**
  6432. * Add an input method to a camera
  6433. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6434. * @param input camera input method
  6435. */
  6436. add(input: ICameraInput<TCamera>): void;
  6437. /**
  6438. * Remove a specific input method from a camera
  6439. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6440. * @param inputToRemove camera input method
  6441. */
  6442. remove(inputToRemove: ICameraInput<TCamera>): void;
  6443. /**
  6444. * Remove a specific input type from a camera
  6445. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6446. * @param inputType the type of the input to remove
  6447. */
  6448. removeByType(inputType: string): void;
  6449. private _addCheckInputs;
  6450. /**
  6451. * Attach the input controls to the currently attached dom element to listen the events from.
  6452. * @param input Defines the input to attach
  6453. */
  6454. attachInput(input: ICameraInput<TCamera>): void;
  6455. /**
  6456. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6457. * @param element Defines the dom element to collect the events from
  6458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6459. */
  6460. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6461. /**
  6462. * Detach the current manager inputs controls from a specific dom element.
  6463. * @param element Defines the dom element to collect the events from
  6464. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6465. */
  6466. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6467. /**
  6468. * Rebuild the dynamic inputCheck function from the current list of
  6469. * defined inputs in the manager.
  6470. */
  6471. rebuildInputCheck(): void;
  6472. /**
  6473. * Remove all attached input methods from a camera
  6474. */
  6475. clear(): void;
  6476. /**
  6477. * Serialize the current input manager attached to a camera.
  6478. * This ensures than once parsed,
  6479. * the input associated to the camera will be identical to the current ones
  6480. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6481. */
  6482. serialize(serializedCamera: any): void;
  6483. /**
  6484. * Parses an input manager serialized JSON to restore the previous list of inputs
  6485. * and states associated to a camera.
  6486. * @param parsedCamera Defines the JSON to parse
  6487. */
  6488. parse(parsedCamera: any): void;
  6489. }
  6490. }
  6491. declare module BABYLON {
  6492. /**
  6493. * Class used to store data that will be store in GPU memory
  6494. */
  6495. export class Buffer {
  6496. private _engine;
  6497. private _buffer;
  6498. /** @hidden */
  6499. _data: Nullable<DataArray>;
  6500. private _updatable;
  6501. private _instanced;
  6502. private _divisor;
  6503. /**
  6504. * Gets the byte stride.
  6505. */
  6506. readonly byteStride: number;
  6507. /**
  6508. * Constructor
  6509. * @param engine the engine
  6510. * @param data the data to use for this buffer
  6511. * @param updatable whether the data is updatable
  6512. * @param stride the stride (optional)
  6513. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6514. * @param instanced whether the buffer is instanced (optional)
  6515. * @param useBytes set to true if the stride in in bytes (optional)
  6516. * @param divisor sets an optional divisor for instances (1 by default)
  6517. */
  6518. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6519. /**
  6520. * Create a new VertexBuffer based on the current buffer
  6521. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6522. * @param offset defines offset in the buffer (0 by default)
  6523. * @param size defines the size in floats of attributes (position is 3 for instance)
  6524. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6525. * @param instanced defines if the vertex buffer contains indexed data
  6526. * @param useBytes defines if the offset and stride are in bytes *
  6527. * @param divisor sets an optional divisor for instances (1 by default)
  6528. * @returns the new vertex buffer
  6529. */
  6530. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6531. /**
  6532. * Gets a boolean indicating if the Buffer is updatable?
  6533. * @returns true if the buffer is updatable
  6534. */
  6535. isUpdatable(): boolean;
  6536. /**
  6537. * Gets current buffer's data
  6538. * @returns a DataArray or null
  6539. */
  6540. getData(): Nullable<DataArray>;
  6541. /**
  6542. * Gets underlying native buffer
  6543. * @returns underlying native buffer
  6544. */
  6545. getBuffer(): Nullable<DataBuffer>;
  6546. /**
  6547. * Gets the stride in float32 units (i.e. byte stride / 4).
  6548. * May not be an integer if the byte stride is not divisible by 4.
  6549. * @returns the stride in float32 units
  6550. * @deprecated Please use byteStride instead.
  6551. */
  6552. getStrideSize(): number;
  6553. /**
  6554. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6555. * @param data defines the data to store
  6556. */
  6557. create(data?: Nullable<DataArray>): void;
  6558. /** @hidden */
  6559. _rebuild(): void;
  6560. /**
  6561. * Update current buffer data
  6562. * @param data defines the data to store
  6563. */
  6564. update(data: DataArray): void;
  6565. /**
  6566. * Updates the data directly.
  6567. * @param data the new data
  6568. * @param offset the new offset
  6569. * @param vertexCount the vertex count (optional)
  6570. * @param useBytes set to true if the offset is in bytes
  6571. */
  6572. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6573. /**
  6574. * Release all resources
  6575. */
  6576. dispose(): void;
  6577. }
  6578. /**
  6579. * Specialized buffer used to store vertex data
  6580. */
  6581. export class VertexBuffer {
  6582. /** @hidden */
  6583. _buffer: Buffer;
  6584. private _kind;
  6585. private _size;
  6586. private _ownsBuffer;
  6587. private _instanced;
  6588. private _instanceDivisor;
  6589. /**
  6590. * The byte type.
  6591. */
  6592. static readonly BYTE: number;
  6593. /**
  6594. * The unsigned byte type.
  6595. */
  6596. static readonly UNSIGNED_BYTE: number;
  6597. /**
  6598. * The short type.
  6599. */
  6600. static readonly SHORT: number;
  6601. /**
  6602. * The unsigned short type.
  6603. */
  6604. static readonly UNSIGNED_SHORT: number;
  6605. /**
  6606. * The integer type.
  6607. */
  6608. static readonly INT: number;
  6609. /**
  6610. * The unsigned integer type.
  6611. */
  6612. static readonly UNSIGNED_INT: number;
  6613. /**
  6614. * The float type.
  6615. */
  6616. static readonly FLOAT: number;
  6617. /**
  6618. * Gets or sets the instance divisor when in instanced mode
  6619. */
  6620. get instanceDivisor(): number;
  6621. set instanceDivisor(value: number);
  6622. /**
  6623. * Gets the byte stride.
  6624. */
  6625. readonly byteStride: number;
  6626. /**
  6627. * Gets the byte offset.
  6628. */
  6629. readonly byteOffset: number;
  6630. /**
  6631. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6632. */
  6633. readonly normalized: boolean;
  6634. /**
  6635. * Gets the data type of each component in the array.
  6636. */
  6637. readonly type: number;
  6638. /**
  6639. * Constructor
  6640. * @param engine the engine
  6641. * @param data the data to use for this vertex buffer
  6642. * @param kind the vertex buffer kind
  6643. * @param updatable whether the data is updatable
  6644. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6645. * @param stride the stride (optional)
  6646. * @param instanced whether the buffer is instanced (optional)
  6647. * @param offset the offset of the data (optional)
  6648. * @param size the number of components (optional)
  6649. * @param type the type of the component (optional)
  6650. * @param normalized whether the data contains normalized data (optional)
  6651. * @param useBytes set to true if stride and offset are in bytes (optional)
  6652. * @param divisor defines the instance divisor to use (1 by default)
  6653. */
  6654. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6655. /** @hidden */
  6656. _rebuild(): void;
  6657. /**
  6658. * Returns the kind of the VertexBuffer (string)
  6659. * @returns a string
  6660. */
  6661. getKind(): string;
  6662. /**
  6663. * Gets a boolean indicating if the VertexBuffer is updatable?
  6664. * @returns true if the buffer is updatable
  6665. */
  6666. isUpdatable(): boolean;
  6667. /**
  6668. * Gets current buffer's data
  6669. * @returns a DataArray or null
  6670. */
  6671. getData(): Nullable<DataArray>;
  6672. /**
  6673. * Gets underlying native buffer
  6674. * @returns underlying native buffer
  6675. */
  6676. getBuffer(): Nullable<DataBuffer>;
  6677. /**
  6678. * Gets the stride in float32 units (i.e. byte stride / 4).
  6679. * May not be an integer if the byte stride is not divisible by 4.
  6680. * @returns the stride in float32 units
  6681. * @deprecated Please use byteStride instead.
  6682. */
  6683. getStrideSize(): number;
  6684. /**
  6685. * Returns the offset as a multiple of the type byte length.
  6686. * @returns the offset in bytes
  6687. * @deprecated Please use byteOffset instead.
  6688. */
  6689. getOffset(): number;
  6690. /**
  6691. * Returns the number of components per vertex attribute (integer)
  6692. * @returns the size in float
  6693. */
  6694. getSize(): number;
  6695. /**
  6696. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6697. * @returns true if this buffer is instanced
  6698. */
  6699. getIsInstanced(): boolean;
  6700. /**
  6701. * Returns the instancing divisor, zero for non-instanced (integer).
  6702. * @returns a number
  6703. */
  6704. getInstanceDivisor(): number;
  6705. /**
  6706. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6707. * @param data defines the data to store
  6708. */
  6709. create(data?: DataArray): void;
  6710. /**
  6711. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6712. * This function will create a new buffer if the current one is not updatable
  6713. * @param data defines the data to store
  6714. */
  6715. update(data: DataArray): void;
  6716. /**
  6717. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6718. * Returns the directly updated WebGLBuffer.
  6719. * @param data the new data
  6720. * @param offset the new offset
  6721. * @param useBytes set to true if the offset is in bytes
  6722. */
  6723. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6724. /**
  6725. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6726. */
  6727. dispose(): void;
  6728. /**
  6729. * Enumerates each value of this vertex buffer as numbers.
  6730. * @param count the number of values to enumerate
  6731. * @param callback the callback function called for each value
  6732. */
  6733. forEach(count: number, callback: (value: number, index: number) => void): void;
  6734. /**
  6735. * Positions
  6736. */
  6737. static readonly PositionKind: string;
  6738. /**
  6739. * Normals
  6740. */
  6741. static readonly NormalKind: string;
  6742. /**
  6743. * Tangents
  6744. */
  6745. static readonly TangentKind: string;
  6746. /**
  6747. * Texture coordinates
  6748. */
  6749. static readonly UVKind: string;
  6750. /**
  6751. * Texture coordinates 2
  6752. */
  6753. static readonly UV2Kind: string;
  6754. /**
  6755. * Texture coordinates 3
  6756. */
  6757. static readonly UV3Kind: string;
  6758. /**
  6759. * Texture coordinates 4
  6760. */
  6761. static readonly UV4Kind: string;
  6762. /**
  6763. * Texture coordinates 5
  6764. */
  6765. static readonly UV5Kind: string;
  6766. /**
  6767. * Texture coordinates 6
  6768. */
  6769. static readonly UV6Kind: string;
  6770. /**
  6771. * Colors
  6772. */
  6773. static readonly ColorKind: string;
  6774. /**
  6775. * Matrix indices (for bones)
  6776. */
  6777. static readonly MatricesIndicesKind: string;
  6778. /**
  6779. * Matrix weights (for bones)
  6780. */
  6781. static readonly MatricesWeightsKind: string;
  6782. /**
  6783. * Additional matrix indices (for bones)
  6784. */
  6785. static readonly MatricesIndicesExtraKind: string;
  6786. /**
  6787. * Additional matrix weights (for bones)
  6788. */
  6789. static readonly MatricesWeightsExtraKind: string;
  6790. /**
  6791. * Deduces the stride given a kind.
  6792. * @param kind The kind string to deduce
  6793. * @returns The deduced stride
  6794. */
  6795. static DeduceStride(kind: string): number;
  6796. /**
  6797. * Gets the byte length of the given type.
  6798. * @param type the type
  6799. * @returns the number of bytes
  6800. */
  6801. static GetTypeByteLength(type: number): number;
  6802. /**
  6803. * Enumerates each value of the given parameters as numbers.
  6804. * @param data the data to enumerate
  6805. * @param byteOffset the byte offset of the data
  6806. * @param byteStride the byte stride of the data
  6807. * @param componentCount the number of components per element
  6808. * @param componentType the type of the component
  6809. * @param count the number of values to enumerate
  6810. * @param normalized whether the data is normalized
  6811. * @param callback the callback function called for each value
  6812. */
  6813. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6814. private static _GetFloatValue;
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * @hidden
  6820. */
  6821. export class IntersectionInfo {
  6822. bu: Nullable<number>;
  6823. bv: Nullable<number>;
  6824. distance: number;
  6825. faceId: number;
  6826. subMeshId: number;
  6827. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6828. }
  6829. }
  6830. declare module BABYLON {
  6831. /**
  6832. * Class used to store bounding sphere information
  6833. */
  6834. export class BoundingSphere {
  6835. /**
  6836. * Gets the center of the bounding sphere in local space
  6837. */
  6838. readonly center: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in local space
  6841. */
  6842. radius: number;
  6843. /**
  6844. * Gets the center of the bounding sphere in world space
  6845. */
  6846. readonly centerWorld: Vector3;
  6847. /**
  6848. * Radius of the bounding sphere in world space
  6849. */
  6850. radiusWorld: number;
  6851. /**
  6852. * Gets the minimum vector in local space
  6853. */
  6854. readonly minimum: Vector3;
  6855. /**
  6856. * Gets the maximum vector in local space
  6857. */
  6858. readonly maximum: Vector3;
  6859. private _worldMatrix;
  6860. private static readonly TmpVector3;
  6861. /**
  6862. * Creates a new bounding sphere
  6863. * @param min defines the minimum vector (in local space)
  6864. * @param max defines the maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6868. /**
  6869. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6870. * @param min defines the new minimum vector (in local space)
  6871. * @param max defines the new maximum vector (in local space)
  6872. * @param worldMatrix defines the new world matrix
  6873. */
  6874. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6875. /**
  6876. * Scale the current bounding sphere by applying a scale factor
  6877. * @param factor defines the scale factor to apply
  6878. * @returns the current bounding box
  6879. */
  6880. scale(factor: number): BoundingSphere;
  6881. /**
  6882. * Gets the world matrix of the bounding box
  6883. * @returns a matrix
  6884. */
  6885. getWorldMatrix(): DeepImmutable<Matrix>;
  6886. /** @hidden */
  6887. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Tests if the bounding sphere is intersecting the frustum planes
  6890. * @param frustumPlanes defines the frustum planes to test
  6891. * @returns true if there is an intersection
  6892. */
  6893. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6894. /**
  6895. * Tests if the bounding sphere center is in between the frustum planes.
  6896. * Used for optimistic fast inclusion.
  6897. * @param frustumPlanes defines the frustum planes to test
  6898. * @returns true if the sphere center is in between the frustum planes
  6899. */
  6900. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6901. /**
  6902. * Tests if a point is inside the bounding sphere
  6903. * @param point defines the point to test
  6904. * @returns true if the point is inside the bounding sphere
  6905. */
  6906. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6907. /**
  6908. * Checks if two sphere intersct
  6909. * @param sphere0 sphere 0
  6910. * @param sphere1 sphere 1
  6911. * @returns true if the speres intersect
  6912. */
  6913. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6914. }
  6915. }
  6916. declare module BABYLON {
  6917. /**
  6918. * Class used to store bounding box information
  6919. */
  6920. export class BoundingBox implements ICullable {
  6921. /**
  6922. * Gets the 8 vectors representing the bounding box in local space
  6923. */
  6924. readonly vectors: Vector3[];
  6925. /**
  6926. * Gets the center of the bounding box in local space
  6927. */
  6928. readonly center: Vector3;
  6929. /**
  6930. * Gets the center of the bounding box in world space
  6931. */
  6932. readonly centerWorld: Vector3;
  6933. /**
  6934. * Gets the extend size in local space
  6935. */
  6936. readonly extendSize: Vector3;
  6937. /**
  6938. * Gets the extend size in world space
  6939. */
  6940. readonly extendSizeWorld: Vector3;
  6941. /**
  6942. * Gets the OBB (object bounding box) directions
  6943. */
  6944. readonly directions: Vector3[];
  6945. /**
  6946. * Gets the 8 vectors representing the bounding box in world space
  6947. */
  6948. readonly vectorsWorld: Vector3[];
  6949. /**
  6950. * Gets the minimum vector in world space
  6951. */
  6952. readonly minimumWorld: Vector3;
  6953. /**
  6954. * Gets the maximum vector in world space
  6955. */
  6956. readonly maximumWorld: Vector3;
  6957. /**
  6958. * Gets the minimum vector in local space
  6959. */
  6960. readonly minimum: Vector3;
  6961. /**
  6962. * Gets the maximum vector in local space
  6963. */
  6964. readonly maximum: Vector3;
  6965. private _worldMatrix;
  6966. private static readonly TmpVector3;
  6967. /**
  6968. * @hidden
  6969. */
  6970. _tag: number;
  6971. /**
  6972. * Creates a new bounding box
  6973. * @param min defines the minimum vector (in local space)
  6974. * @param max defines the maximum vector (in local space)
  6975. * @param worldMatrix defines the new world matrix
  6976. */
  6977. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6978. /**
  6979. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6980. * @param min defines the new minimum vector (in local space)
  6981. * @param max defines the new maximum vector (in local space)
  6982. * @param worldMatrix defines the new world matrix
  6983. */
  6984. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6985. /**
  6986. * Scale the current bounding box by applying a scale factor
  6987. * @param factor defines the scale factor to apply
  6988. * @returns the current bounding box
  6989. */
  6990. scale(factor: number): BoundingBox;
  6991. /**
  6992. * Gets the world matrix of the bounding box
  6993. * @returns a matrix
  6994. */
  6995. getWorldMatrix(): DeepImmutable<Matrix>;
  6996. /** @hidden */
  6997. _update(world: DeepImmutable<Matrix>): void;
  6998. /**
  6999. * Tests if the bounding box is intersecting the frustum planes
  7000. * @param frustumPlanes defines the frustum planes to test
  7001. * @returns true if there is an intersection
  7002. */
  7003. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7004. /**
  7005. * Tests if the bounding box is entirely inside the frustum planes
  7006. * @param frustumPlanes defines the frustum planes to test
  7007. * @returns true if there is an inclusion
  7008. */
  7009. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7010. /**
  7011. * Tests if a point is inside the bounding box
  7012. * @param point defines the point to test
  7013. * @returns true if the point is inside the bounding box
  7014. */
  7015. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7016. /**
  7017. * Tests if the bounding box intersects with a bounding sphere
  7018. * @param sphere defines the sphere to test
  7019. * @returns true if there is an intersection
  7020. */
  7021. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7022. /**
  7023. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7024. * @param min defines the min vector to use
  7025. * @param max defines the max vector to use
  7026. * @returns true if there is an intersection
  7027. */
  7028. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7029. /**
  7030. * Tests if two bounding boxes are intersections
  7031. * @param box0 defines the first box to test
  7032. * @param box1 defines the second box to test
  7033. * @returns true if there is an intersection
  7034. */
  7035. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7036. /**
  7037. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7038. * @param minPoint defines the minimum vector of the bounding box
  7039. * @param maxPoint defines the maximum vector of the bounding box
  7040. * @param sphereCenter defines the sphere center
  7041. * @param sphereRadius defines the sphere radius
  7042. * @returns true if there is an intersection
  7043. */
  7044. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7045. /**
  7046. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7047. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7048. * @param frustumPlanes defines the frustum planes to test
  7049. * @return true if there is an inclusion
  7050. */
  7051. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7052. /**
  7053. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7054. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @return true if there is an intersection
  7057. */
  7058. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. }
  7060. }
  7061. declare module BABYLON {
  7062. /** @hidden */
  7063. export class Collider {
  7064. /** Define if a collision was found */
  7065. collisionFound: boolean;
  7066. /**
  7067. * Define last intersection point in local space
  7068. */
  7069. intersectionPoint: Vector3;
  7070. /**
  7071. * Define last collided mesh
  7072. */
  7073. collidedMesh: Nullable<AbstractMesh>;
  7074. private _collisionPoint;
  7075. private _planeIntersectionPoint;
  7076. private _tempVector;
  7077. private _tempVector2;
  7078. private _tempVector3;
  7079. private _tempVector4;
  7080. private _edge;
  7081. private _baseToVertex;
  7082. private _destinationPoint;
  7083. private _slidePlaneNormal;
  7084. private _displacementVector;
  7085. /** @hidden */
  7086. _radius: Vector3;
  7087. /** @hidden */
  7088. _retry: number;
  7089. private _velocity;
  7090. private _basePoint;
  7091. private _epsilon;
  7092. /** @hidden */
  7093. _velocityWorldLength: number;
  7094. /** @hidden */
  7095. _basePointWorld: Vector3;
  7096. private _velocityWorld;
  7097. private _normalizedVelocity;
  7098. /** @hidden */
  7099. _initialVelocity: Vector3;
  7100. /** @hidden */
  7101. _initialPosition: Vector3;
  7102. private _nearestDistance;
  7103. private _collisionMask;
  7104. get collisionMask(): number;
  7105. set collisionMask(mask: number);
  7106. /**
  7107. * Gets the plane normal used to compute the sliding response (in local space)
  7108. */
  7109. get slidePlaneNormal(): Vector3;
  7110. /** @hidden */
  7111. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7112. /** @hidden */
  7113. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7114. /** @hidden */
  7115. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7116. /** @hidden */
  7117. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7118. /** @hidden */
  7119. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7120. /** @hidden */
  7121. _getResponse(pos: Vector3, vel: Vector3): void;
  7122. }
  7123. }
  7124. declare module BABYLON {
  7125. /**
  7126. * Interface for cullable objects
  7127. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7128. */
  7129. export interface ICullable {
  7130. /**
  7131. * Checks if the object or part of the object is in the frustum
  7132. * @param frustumPlanes Camera near/planes
  7133. * @returns true if the object is in frustum otherwise false
  7134. */
  7135. isInFrustum(frustumPlanes: Plane[]): boolean;
  7136. /**
  7137. * Checks if a cullable object (mesh...) is in the camera frustum
  7138. * Unlike isInFrustum this cheks the full bounding box
  7139. * @param frustumPlanes Camera near/planes
  7140. * @returns true if the object is in frustum otherwise false
  7141. */
  7142. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7143. }
  7144. /**
  7145. * Info for a bounding data of a mesh
  7146. */
  7147. export class BoundingInfo implements ICullable {
  7148. /**
  7149. * Bounding box for the mesh
  7150. */
  7151. readonly boundingBox: BoundingBox;
  7152. /**
  7153. * Bounding sphere for the mesh
  7154. */
  7155. readonly boundingSphere: BoundingSphere;
  7156. private _isLocked;
  7157. private static readonly TmpVector3;
  7158. /**
  7159. * Constructs bounding info
  7160. * @param minimum min vector of the bounding box/sphere
  7161. * @param maximum max vector of the bounding box/sphere
  7162. * @param worldMatrix defines the new world matrix
  7163. */
  7164. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7165. /**
  7166. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7167. * @param min defines the new minimum vector (in local space)
  7168. * @param max defines the new maximum vector (in local space)
  7169. * @param worldMatrix defines the new world matrix
  7170. */
  7171. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7172. /**
  7173. * min vector of the bounding box/sphere
  7174. */
  7175. get minimum(): Vector3;
  7176. /**
  7177. * max vector of the bounding box/sphere
  7178. */
  7179. get maximum(): Vector3;
  7180. /**
  7181. * If the info is locked and won't be updated to avoid perf overhead
  7182. */
  7183. get isLocked(): boolean;
  7184. set isLocked(value: boolean);
  7185. /**
  7186. * Updates the bounding sphere and box
  7187. * @param world world matrix to be used to update
  7188. */
  7189. update(world: DeepImmutable<Matrix>): void;
  7190. /**
  7191. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7192. * @param center New center of the bounding info
  7193. * @param extend New extend of the bounding info
  7194. * @returns the current bounding info
  7195. */
  7196. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7197. /**
  7198. * Scale the current bounding info by applying a scale factor
  7199. * @param factor defines the scale factor to apply
  7200. * @returns the current bounding info
  7201. */
  7202. scale(factor: number): BoundingInfo;
  7203. /**
  7204. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7205. * @param frustumPlanes defines the frustum to test
  7206. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7207. * @returns true if the bounding info is in the frustum planes
  7208. */
  7209. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7210. /**
  7211. * Gets the world distance between the min and max points of the bounding box
  7212. */
  7213. get diagonalLength(): number;
  7214. /**
  7215. * Checks if a cullable object (mesh...) is in the camera frustum
  7216. * Unlike isInFrustum this cheks the full bounding box
  7217. * @param frustumPlanes Camera near/planes
  7218. * @returns true if the object is in frustum otherwise false
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7221. /** @hidden */
  7222. _checkCollision(collider: Collider): boolean;
  7223. /**
  7224. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7225. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7226. * @param point the point to check intersection with
  7227. * @returns if the point intersects
  7228. */
  7229. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7230. /**
  7231. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7232. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7233. * @param boundingInfo the bounding info to check intersection with
  7234. * @param precise if the intersection should be done using OBB
  7235. * @returns if the bounding info intersects
  7236. */
  7237. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7238. }
  7239. }
  7240. declare module BABYLON {
  7241. /**
  7242. * Extracts minimum and maximum values from a list of indexed positions
  7243. * @param positions defines the positions to use
  7244. * @param indices defines the indices to the positions
  7245. * @param indexStart defines the start index
  7246. * @param indexCount defines the end index
  7247. * @param bias defines bias value to add to the result
  7248. * @return minimum and maximum values
  7249. */
  7250. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7251. minimum: Vector3;
  7252. maximum: Vector3;
  7253. };
  7254. /**
  7255. * Extracts minimum and maximum values from a list of positions
  7256. * @param positions defines the positions to use
  7257. * @param start defines the start index in the positions array
  7258. * @param count defines the number of positions to handle
  7259. * @param bias defines bias value to add to the result
  7260. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7261. * @return minimum and maximum values
  7262. */
  7263. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7264. minimum: Vector3;
  7265. maximum: Vector3;
  7266. };
  7267. }
  7268. declare module BABYLON {
  7269. /** @hidden */
  7270. export class WebGLDataBuffer extends DataBuffer {
  7271. private _buffer;
  7272. constructor(resource: WebGLBuffer);
  7273. get underlyingResource(): any;
  7274. }
  7275. }
  7276. declare module BABYLON {
  7277. /** @hidden */
  7278. export class WebGLPipelineContext implements IPipelineContext {
  7279. engine: ThinEngine;
  7280. program: Nullable<WebGLProgram>;
  7281. context?: WebGLRenderingContext;
  7282. vertexShader?: WebGLShader;
  7283. fragmentShader?: WebGLShader;
  7284. isParallelCompiled: boolean;
  7285. onCompiled?: () => void;
  7286. transformFeedback?: WebGLTransformFeedback | null;
  7287. vertexCompilationError: Nullable<string>;
  7288. fragmentCompilationError: Nullable<string>;
  7289. programLinkError: Nullable<string>;
  7290. programValidationError: Nullable<string>;
  7291. get isAsync(): boolean;
  7292. get isReady(): boolean;
  7293. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7294. _getVertexShaderCode(): string | null;
  7295. _getFragmentShaderCode(): string | null;
  7296. }
  7297. }
  7298. declare module BABYLON {
  7299. interface ThinEngine {
  7300. /**
  7301. * Create an uniform buffer
  7302. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7303. * @param elements defines the content of the uniform buffer
  7304. * @returns the webGL uniform buffer
  7305. */
  7306. createUniformBuffer(elements: FloatArray): DataBuffer;
  7307. /**
  7308. * Create a dynamic uniform buffer
  7309. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7310. * @param elements defines the content of the uniform buffer
  7311. * @returns the webGL uniform buffer
  7312. */
  7313. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7314. /**
  7315. * Update an existing uniform buffer
  7316. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7317. * @param uniformBuffer defines the target uniform buffer
  7318. * @param elements defines the content to update
  7319. * @param offset defines the offset in the uniform buffer where update should start
  7320. * @param count defines the size of the data to update
  7321. */
  7322. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7323. /**
  7324. * Bind an uniform buffer to the current webGL context
  7325. * @param buffer defines the buffer to bind
  7326. */
  7327. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7328. /**
  7329. * Bind a buffer to the current webGL context at a given location
  7330. * @param buffer defines the buffer to bind
  7331. * @param location defines the index where to bind the buffer
  7332. */
  7333. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7334. /**
  7335. * Bind a specific block at a given index in a specific shader program
  7336. * @param pipelineContext defines the pipeline context to use
  7337. * @param blockName defines the block name
  7338. * @param index defines the index where to bind the block
  7339. */
  7340. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7341. }
  7342. }
  7343. declare module BABYLON {
  7344. /**
  7345. * Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. */
  7354. export class UniformBuffer {
  7355. private _engine;
  7356. private _buffer;
  7357. private _data;
  7358. private _bufferData;
  7359. private _dynamic?;
  7360. private _uniformLocations;
  7361. private _uniformSizes;
  7362. private _uniformLocationPointer;
  7363. private _needSync;
  7364. private _noUBO;
  7365. private _currentEffect;
  7366. /** @hidden */
  7367. _alreadyBound: boolean;
  7368. private static _MAX_UNIFORM_SIZE;
  7369. private static _tempBuffer;
  7370. /**
  7371. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7372. * This is dynamic to allow compat with webgl 1 and 2.
  7373. * You will need to pass the name of the uniform as well as the value.
  7374. */
  7375. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7376. /**
  7377. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7378. * This is dynamic to allow compat with webgl 1 and 2.
  7379. * You will need to pass the name of the uniform as well as the value.
  7380. */
  7381. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7382. /**
  7383. * Lambda to Update a single float in a uniform buffer.
  7384. * This is dynamic to allow compat with webgl 1 and 2.
  7385. * You will need to pass the name of the uniform as well as the value.
  7386. */
  7387. updateFloat: (name: string, x: number) => void;
  7388. /**
  7389. * Lambda to Update a vec2 of float in a uniform buffer.
  7390. * This is dynamic to allow compat with webgl 1 and 2.
  7391. * You will need to pass the name of the uniform as well as the value.
  7392. */
  7393. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7394. /**
  7395. * Lambda to Update a vec3 of float in a uniform buffer.
  7396. * This is dynamic to allow compat with webgl 1 and 2.
  7397. * You will need to pass the name of the uniform as well as the value.
  7398. */
  7399. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7400. /**
  7401. * Lambda to Update a vec4 of float in a uniform buffer.
  7402. * This is dynamic to allow compat with webgl 1 and 2.
  7403. * You will need to pass the name of the uniform as well as the value.
  7404. */
  7405. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7406. /**
  7407. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7408. * This is dynamic to allow compat with webgl 1 and 2.
  7409. * You will need to pass the name of the uniform as well as the value.
  7410. */
  7411. updateMatrix: (name: string, mat: Matrix) => void;
  7412. /**
  7413. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7414. * This is dynamic to allow compat with webgl 1 and 2.
  7415. * You will need to pass the name of the uniform as well as the value.
  7416. */
  7417. updateVector3: (name: string, vector: Vector3) => void;
  7418. /**
  7419. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7420. * This is dynamic to allow compat with webgl 1 and 2.
  7421. * You will need to pass the name of the uniform as well as the value.
  7422. */
  7423. updateVector4: (name: string, vector: Vector4) => void;
  7424. /**
  7425. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7426. * This is dynamic to allow compat with webgl 1 and 2.
  7427. * You will need to pass the name of the uniform as well as the value.
  7428. */
  7429. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7430. /**
  7431. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7432. * This is dynamic to allow compat with webgl 1 and 2.
  7433. * You will need to pass the name of the uniform as well as the value.
  7434. */
  7435. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7436. /**
  7437. * Instantiates a new Uniform buffer objects.
  7438. *
  7439. * Handles blocks of uniform on the GPU.
  7440. *
  7441. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7442. *
  7443. * For more information, please refer to :
  7444. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7445. * @param engine Define the engine the buffer is associated with
  7446. * @param data Define the data contained in the buffer
  7447. * @param dynamic Define if the buffer is updatable
  7448. */
  7449. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7450. /**
  7451. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7452. * or just falling back on setUniformXXX calls.
  7453. */
  7454. get useUbo(): boolean;
  7455. /**
  7456. * Indicates if the WebGL underlying uniform buffer is in sync
  7457. * with the javascript cache data.
  7458. */
  7459. get isSync(): boolean;
  7460. /**
  7461. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7462. * Also, a dynamic UniformBuffer will disable cache verification and always
  7463. * update the underlying WebGL uniform buffer to the GPU.
  7464. * @returns if Dynamic, otherwise false
  7465. */
  7466. isDynamic(): boolean;
  7467. /**
  7468. * The data cache on JS side.
  7469. * @returns the underlying data as a float array
  7470. */
  7471. getData(): Float32Array;
  7472. /**
  7473. * The underlying WebGL Uniform buffer.
  7474. * @returns the webgl buffer
  7475. */
  7476. getBuffer(): Nullable<DataBuffer>;
  7477. /**
  7478. * std140 layout specifies how to align data within an UBO structure.
  7479. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7480. * for specs.
  7481. */
  7482. private _fillAlignment;
  7483. /**
  7484. * Adds an uniform in the buffer.
  7485. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7486. * for the layout to be correct !
  7487. * @param name Name of the uniform, as used in the uniform block in the shader.
  7488. * @param size Data size, or data directly.
  7489. */
  7490. addUniform(name: string, size: number | number[]): void;
  7491. /**
  7492. * Adds a Matrix 4x4 to the uniform buffer.
  7493. * @param name Name of the uniform, as used in the uniform block in the shader.
  7494. * @param mat A 4x4 matrix.
  7495. */
  7496. addMatrix(name: string, mat: Matrix): void;
  7497. /**
  7498. * Adds a vec2 to the uniform buffer.
  7499. * @param name Name of the uniform, as used in the uniform block in the shader.
  7500. * @param x Define the x component value of the vec2
  7501. * @param y Define the y component value of the vec2
  7502. */
  7503. addFloat2(name: string, x: number, y: number): void;
  7504. /**
  7505. * Adds a vec3 to the uniform buffer.
  7506. * @param name Name of the uniform, as used in the uniform block in the shader.
  7507. * @param x Define the x component value of the vec3
  7508. * @param y Define the y component value of the vec3
  7509. * @param z Define the z component value of the vec3
  7510. */
  7511. addFloat3(name: string, x: number, y: number, z: number): void;
  7512. /**
  7513. * Adds a vec3 to the uniform buffer.
  7514. * @param name Name of the uniform, as used in the uniform block in the shader.
  7515. * @param color Define the vec3 from a Color
  7516. */
  7517. addColor3(name: string, color: Color3): void;
  7518. /**
  7519. * Adds a vec4 to the uniform buffer.
  7520. * @param name Name of the uniform, as used in the uniform block in the shader.
  7521. * @param color Define the rgb components from a Color
  7522. * @param alpha Define the a component of the vec4
  7523. */
  7524. addColor4(name: string, color: Color3, alpha: number): void;
  7525. /**
  7526. * Adds a vec3 to the uniform buffer.
  7527. * @param name Name of the uniform, as used in the uniform block in the shader.
  7528. * @param vector Define the vec3 components from a Vector
  7529. */
  7530. addVector3(name: string, vector: Vector3): void;
  7531. /**
  7532. * Adds a Matrix 3x3 to the uniform buffer.
  7533. * @param name Name of the uniform, as used in the uniform block in the shader.
  7534. */
  7535. addMatrix3x3(name: string): void;
  7536. /**
  7537. * Adds a Matrix 2x2 to the uniform buffer.
  7538. * @param name Name of the uniform, as used in the uniform block in the shader.
  7539. */
  7540. addMatrix2x2(name: string): void;
  7541. /**
  7542. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7543. */
  7544. create(): void;
  7545. /** @hidden */
  7546. _rebuild(): void;
  7547. /**
  7548. * Updates the WebGL Uniform Buffer on the GPU.
  7549. * If the `dynamic` flag is set to true, no cache comparison is done.
  7550. * Otherwise, the buffer will be updated only if the cache differs.
  7551. */
  7552. update(): void;
  7553. /**
  7554. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7556. * @param data Define the flattened data
  7557. * @param size Define the size of the data.
  7558. */
  7559. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7560. private _valueCache;
  7561. private _cacheMatrix;
  7562. private _updateMatrix3x3ForUniform;
  7563. private _updateMatrix3x3ForEffect;
  7564. private _updateMatrix2x2ForEffect;
  7565. private _updateMatrix2x2ForUniform;
  7566. private _updateFloatForEffect;
  7567. private _updateFloatForUniform;
  7568. private _updateFloat2ForEffect;
  7569. private _updateFloat2ForUniform;
  7570. private _updateFloat3ForEffect;
  7571. private _updateFloat3ForUniform;
  7572. private _updateFloat4ForEffect;
  7573. private _updateFloat4ForUniform;
  7574. private _updateMatrixForEffect;
  7575. private _updateMatrixForUniform;
  7576. private _updateVector3ForEffect;
  7577. private _updateVector3ForUniform;
  7578. private _updateVector4ForEffect;
  7579. private _updateVector4ForUniform;
  7580. private _updateColor3ForEffect;
  7581. private _updateColor3ForUniform;
  7582. private _updateColor4ForEffect;
  7583. private _updateColor4ForUniform;
  7584. /**
  7585. * Sets a sampler uniform on the effect.
  7586. * @param name Define the name of the sampler.
  7587. * @param texture Define the texture to set in the sampler
  7588. */
  7589. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7590. /**
  7591. * Directly updates the value of the uniform in the cache AND on the GPU.
  7592. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7593. * @param data Define the flattened data
  7594. */
  7595. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7596. /**
  7597. * Binds this uniform buffer to an effect.
  7598. * @param effect Define the effect to bind the buffer to
  7599. * @param name Name of the uniform block in the shader.
  7600. */
  7601. bindToEffect(effect: Effect, name: string): void;
  7602. /**
  7603. * Disposes the uniform buffer.
  7604. */
  7605. dispose(): void;
  7606. }
  7607. }
  7608. declare module BABYLON {
  7609. /**
  7610. * Enum that determines the text-wrapping mode to use.
  7611. */
  7612. export enum InspectableType {
  7613. /**
  7614. * Checkbox for booleans
  7615. */
  7616. Checkbox = 0,
  7617. /**
  7618. * Sliders for numbers
  7619. */
  7620. Slider = 1,
  7621. /**
  7622. * Vector3
  7623. */
  7624. Vector3 = 2,
  7625. /**
  7626. * Quaternions
  7627. */
  7628. Quaternion = 3,
  7629. /**
  7630. * Color3
  7631. */
  7632. Color3 = 4,
  7633. /**
  7634. * String
  7635. */
  7636. String = 5
  7637. }
  7638. /**
  7639. * Interface used to define custom inspectable properties.
  7640. * This interface is used by the inspector to display custom property grids
  7641. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7642. */
  7643. export interface IInspectable {
  7644. /**
  7645. * Gets the label to display
  7646. */
  7647. label: string;
  7648. /**
  7649. * Gets the name of the property to edit
  7650. */
  7651. propertyName: string;
  7652. /**
  7653. * Gets the type of the editor to use
  7654. */
  7655. type: InspectableType;
  7656. /**
  7657. * Gets the minimum value of the property when using in "slider" mode
  7658. */
  7659. min?: number;
  7660. /**
  7661. * Gets the maximum value of the property when using in "slider" mode
  7662. */
  7663. max?: number;
  7664. /**
  7665. * Gets the setp to use when using in "slider" mode
  7666. */
  7667. step?: number;
  7668. }
  7669. }
  7670. declare module BABYLON {
  7671. /**
  7672. * Class used to provide helper for timing
  7673. */
  7674. export class TimingTools {
  7675. /**
  7676. * Polyfill for setImmediate
  7677. * @param action defines the action to execute after the current execution block
  7678. */
  7679. static SetImmediate(action: () => void): void;
  7680. }
  7681. }
  7682. declare module BABYLON {
  7683. /**
  7684. * Class used to enable instatition of objects by class name
  7685. */
  7686. export class InstantiationTools {
  7687. /**
  7688. * Use this object to register external classes like custom textures or material
  7689. * to allow the laoders to instantiate them
  7690. */
  7691. static RegisteredExternalClasses: {
  7692. [key: string]: Object;
  7693. };
  7694. /**
  7695. * Tries to instantiate a new object from a given class name
  7696. * @param className defines the class name to instantiate
  7697. * @returns the new object or null if the system was not able to do the instantiation
  7698. */
  7699. static Instantiate(className: string): any;
  7700. }
  7701. }
  7702. declare module BABYLON {
  7703. /**
  7704. * Define options used to create a depth texture
  7705. */
  7706. export class DepthTextureCreationOptions {
  7707. /** Specifies whether or not a stencil should be allocated in the texture */
  7708. generateStencil?: boolean;
  7709. /** Specifies whether or not bilinear filtering is enable on the texture */
  7710. bilinearFiltering?: boolean;
  7711. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7712. comparisonFunction?: number;
  7713. /** Specifies if the created texture is a cube texture */
  7714. isCube?: boolean;
  7715. }
  7716. }
  7717. declare module BABYLON {
  7718. interface ThinEngine {
  7719. /**
  7720. * Creates a depth stencil cube texture.
  7721. * This is only available in WebGL 2.
  7722. * @param size The size of face edge in the cube texture.
  7723. * @param options The options defining the cube texture.
  7724. * @returns The cube texture
  7725. */
  7726. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7727. /**
  7728. * Creates a cube texture
  7729. * @param rootUrl defines the url where the files to load is located
  7730. * @param scene defines the current scene
  7731. * @param files defines the list of files to load (1 per face)
  7732. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7733. * @param onLoad defines an optional callback raised when the texture is loaded
  7734. * @param onError defines an optional callback raised if there is an issue to load the texture
  7735. * @param format defines the format of the data
  7736. * @param forcedExtension defines the extension to use to pick the right loader
  7737. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7738. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7739. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7740. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7741. * @returns the cube texture as an InternalTexture
  7742. */
  7743. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7744. /**
  7745. * Creates a cube texture
  7746. * @param rootUrl defines the url where the files to load is located
  7747. * @param scene defines the current scene
  7748. * @param files defines the list of files to load (1 per face)
  7749. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7750. * @param onLoad defines an optional callback raised when the texture is loaded
  7751. * @param onError defines an optional callback raised if there is an issue to load the texture
  7752. * @param format defines the format of the data
  7753. * @param forcedExtension defines the extension to use to pick the right loader
  7754. * @returns the cube texture as an InternalTexture
  7755. */
  7756. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7757. /**
  7758. * Creates a cube texture
  7759. * @param rootUrl defines the url where the files to load is located
  7760. * @param scene defines the current scene
  7761. * @param files defines the list of files to load (1 per face)
  7762. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7763. * @param onLoad defines an optional callback raised when the texture is loaded
  7764. * @param onError defines an optional callback raised if there is an issue to load the texture
  7765. * @param format defines the format of the data
  7766. * @param forcedExtension defines the extension to use to pick the right loader
  7767. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7768. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7769. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7770. * @returns the cube texture as an InternalTexture
  7771. */
  7772. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7773. /** @hidden */
  7774. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7775. /** @hidden */
  7776. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7777. /** @hidden */
  7778. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7779. /** @hidden */
  7780. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7781. /**
  7782. * @hidden
  7783. */
  7784. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7785. }
  7786. }
  7787. declare module BABYLON {
  7788. /**
  7789. * Class for creating a cube texture
  7790. */
  7791. export class CubeTexture extends BaseTexture {
  7792. private _delayedOnLoad;
  7793. /**
  7794. * Observable triggered once the texture has been loaded.
  7795. */
  7796. onLoadObservable: Observable<CubeTexture>;
  7797. /**
  7798. * The url of the texture
  7799. */
  7800. url: string;
  7801. /**
  7802. * Gets or sets the center of the bounding box associated with the cube texture.
  7803. * It must define where the camera used to render the texture was set
  7804. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7805. */
  7806. boundingBoxPosition: Vector3;
  7807. private _boundingBoxSize;
  7808. /**
  7809. * Gets or sets the size of the bounding box associated with the cube texture
  7810. * When defined, the cubemap will switch to local mode
  7811. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7812. * @example https://www.babylonjs-playground.com/#RNASML
  7813. */
  7814. set boundingBoxSize(value: Vector3);
  7815. /**
  7816. * Returns the bounding box size
  7817. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7818. */
  7819. get boundingBoxSize(): Vector3;
  7820. protected _rotationY: number;
  7821. /**
  7822. * Sets texture matrix rotation angle around Y axis in radians.
  7823. */
  7824. set rotationY(value: number);
  7825. /**
  7826. * Gets texture matrix rotation angle around Y axis radians.
  7827. */
  7828. get rotationY(): number;
  7829. /**
  7830. * Are mip maps generated for this texture or not.
  7831. */
  7832. get noMipmap(): boolean;
  7833. private _noMipmap;
  7834. private _files;
  7835. protected _forcedExtension: Nullable<string>;
  7836. private _extensions;
  7837. private _textureMatrix;
  7838. private _format;
  7839. private _createPolynomials;
  7840. /**
  7841. * Creates a cube texture from an array of image urls
  7842. * @param files defines an array of image urls
  7843. * @param scene defines the hosting scene
  7844. * @param noMipmap specifies if mip maps are not used
  7845. * @returns a cube texture
  7846. */
  7847. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7848. /**
  7849. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7850. * @param url defines the url of the prefiltered texture
  7851. * @param scene defines the scene the texture is attached to
  7852. * @param forcedExtension defines the extension of the file if different from the url
  7853. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7854. * @return the prefiltered texture
  7855. */
  7856. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7857. /**
  7858. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7859. * as prefiltered data.
  7860. * @param rootUrl defines the url of the texture or the root name of the six images
  7861. * @param null defines the scene or engine the texture is attached to
  7862. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7863. * @param noMipmap defines if mipmaps should be created or not
  7864. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7865. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7866. * @param onError defines a callback triggered in case of error during load
  7867. * @param format defines the internal format to use for the texture once loaded
  7868. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7869. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7870. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7871. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7872. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7873. * @return the cube texture
  7874. */
  7875. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7876. /**
  7877. * Get the current class name of the texture useful for serialization or dynamic coding.
  7878. * @returns "CubeTexture"
  7879. */
  7880. getClassName(): string;
  7881. /**
  7882. * Update the url (and optional buffer) of this texture if url was null during construction.
  7883. * @param url the url of the texture
  7884. * @param forcedExtension defines the extension to use
  7885. * @param onLoad callback called when the texture is loaded (defaults to null)
  7886. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7887. */
  7888. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7889. /**
  7890. * Delays loading of the cube texture
  7891. * @param forcedExtension defines the extension to use
  7892. */
  7893. delayLoad(forcedExtension?: string): void;
  7894. /**
  7895. * Returns the reflection texture matrix
  7896. * @returns the reflection texture matrix
  7897. */
  7898. getReflectionTextureMatrix(): Matrix;
  7899. /**
  7900. * Sets the reflection texture matrix
  7901. * @param value Reflection texture matrix
  7902. */
  7903. setReflectionTextureMatrix(value: Matrix): void;
  7904. /**
  7905. * Parses text to create a cube texture
  7906. * @param parsedTexture define the serialized text to read from
  7907. * @param scene defines the hosting scene
  7908. * @param rootUrl defines the root url of the cube texture
  7909. * @returns a cube texture
  7910. */
  7911. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7912. /**
  7913. * Makes a clone, or deep copy, of the cube texture
  7914. * @returns a new cube texture
  7915. */
  7916. clone(): CubeTexture;
  7917. }
  7918. }
  7919. declare module BABYLON {
  7920. /**
  7921. * Manages the defines for the Material
  7922. */
  7923. export class MaterialDefines {
  7924. /** @hidden */
  7925. protected _keys: string[];
  7926. private _isDirty;
  7927. /** @hidden */
  7928. _renderId: number;
  7929. /** @hidden */
  7930. _areLightsDirty: boolean;
  7931. /** @hidden */
  7932. _areLightsDisposed: boolean;
  7933. /** @hidden */
  7934. _areAttributesDirty: boolean;
  7935. /** @hidden */
  7936. _areTexturesDirty: boolean;
  7937. /** @hidden */
  7938. _areFresnelDirty: boolean;
  7939. /** @hidden */
  7940. _areMiscDirty: boolean;
  7941. /** @hidden */
  7942. _areImageProcessingDirty: boolean;
  7943. /** @hidden */
  7944. _normals: boolean;
  7945. /** @hidden */
  7946. _uvs: boolean;
  7947. /** @hidden */
  7948. _needNormals: boolean;
  7949. /** @hidden */
  7950. _needUVs: boolean;
  7951. [id: string]: any;
  7952. /**
  7953. * Specifies if the material needs to be re-calculated
  7954. */
  7955. get isDirty(): boolean;
  7956. /**
  7957. * Marks the material to indicate that it has been re-calculated
  7958. */
  7959. markAsProcessed(): void;
  7960. /**
  7961. * Marks the material to indicate that it needs to be re-calculated
  7962. */
  7963. markAsUnprocessed(): void;
  7964. /**
  7965. * Marks the material to indicate all of its defines need to be re-calculated
  7966. */
  7967. markAllAsDirty(): void;
  7968. /**
  7969. * Marks the material to indicate that image processing needs to be re-calculated
  7970. */
  7971. markAsImageProcessingDirty(): void;
  7972. /**
  7973. * Marks the material to indicate the lights need to be re-calculated
  7974. * @param disposed Defines whether the light is dirty due to dispose or not
  7975. */
  7976. markAsLightDirty(disposed?: boolean): void;
  7977. /**
  7978. * Marks the attribute state as changed
  7979. */
  7980. markAsAttributesDirty(): void;
  7981. /**
  7982. * Marks the texture state as changed
  7983. */
  7984. markAsTexturesDirty(): void;
  7985. /**
  7986. * Marks the fresnel state as changed
  7987. */
  7988. markAsFresnelDirty(): void;
  7989. /**
  7990. * Marks the misc state as changed
  7991. */
  7992. markAsMiscDirty(): void;
  7993. /**
  7994. * Rebuilds the material defines
  7995. */
  7996. rebuild(): void;
  7997. /**
  7998. * Specifies if two material defines are equal
  7999. * @param other - A material define instance to compare to
  8000. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8001. */
  8002. isEqual(other: MaterialDefines): boolean;
  8003. /**
  8004. * Clones this instance's defines to another instance
  8005. * @param other - material defines to clone values to
  8006. */
  8007. cloneTo(other: MaterialDefines): void;
  8008. /**
  8009. * Resets the material define values
  8010. */
  8011. reset(): void;
  8012. /**
  8013. * Converts the material define values to a string
  8014. * @returns - String of material define information
  8015. */
  8016. toString(): string;
  8017. }
  8018. }
  8019. declare module BABYLON {
  8020. /**
  8021. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8022. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8023. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8024. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8025. */
  8026. export class ColorCurves {
  8027. private _dirty;
  8028. private _tempColor;
  8029. private _globalCurve;
  8030. private _highlightsCurve;
  8031. private _midtonesCurve;
  8032. private _shadowsCurve;
  8033. private _positiveCurve;
  8034. private _negativeCurve;
  8035. private _globalHue;
  8036. private _globalDensity;
  8037. private _globalSaturation;
  8038. private _globalExposure;
  8039. /**
  8040. * Gets the global Hue value.
  8041. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8042. */
  8043. get globalHue(): number;
  8044. /**
  8045. * Sets the global Hue value.
  8046. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8047. */
  8048. set globalHue(value: number);
  8049. /**
  8050. * Gets the global Density value.
  8051. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8052. * Values less than zero provide a filter of opposite hue.
  8053. */
  8054. get globalDensity(): number;
  8055. /**
  8056. * Sets the global Density value.
  8057. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. set globalDensity(value: number);
  8061. /**
  8062. * Gets the global Saturation value.
  8063. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8064. */
  8065. get globalSaturation(): number;
  8066. /**
  8067. * Sets the global Saturation value.
  8068. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8069. */
  8070. set globalSaturation(value: number);
  8071. /**
  8072. * Gets the global Exposure value.
  8073. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8074. */
  8075. get globalExposure(): number;
  8076. /**
  8077. * Sets the global Exposure value.
  8078. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8079. */
  8080. set globalExposure(value: number);
  8081. private _highlightsHue;
  8082. private _highlightsDensity;
  8083. private _highlightsSaturation;
  8084. private _highlightsExposure;
  8085. /**
  8086. * Gets the highlights Hue value.
  8087. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8088. */
  8089. get highlightsHue(): number;
  8090. /**
  8091. * Sets the highlights Hue value.
  8092. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8093. */
  8094. set highlightsHue(value: number);
  8095. /**
  8096. * Gets the highlights Density value.
  8097. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. get highlightsDensity(): number;
  8101. /**
  8102. * Sets the highlights Density value.
  8103. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8104. * Values less than zero provide a filter of opposite hue.
  8105. */
  8106. set highlightsDensity(value: number);
  8107. /**
  8108. * Gets the highlights Saturation value.
  8109. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8110. */
  8111. get highlightsSaturation(): number;
  8112. /**
  8113. * Sets the highlights Saturation value.
  8114. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8115. */
  8116. set highlightsSaturation(value: number);
  8117. /**
  8118. * Gets the highlights Exposure value.
  8119. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8120. */
  8121. get highlightsExposure(): number;
  8122. /**
  8123. * Sets the highlights Exposure value.
  8124. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8125. */
  8126. set highlightsExposure(value: number);
  8127. private _midtonesHue;
  8128. private _midtonesDensity;
  8129. private _midtonesSaturation;
  8130. private _midtonesExposure;
  8131. /**
  8132. * Gets the midtones Hue value.
  8133. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8134. */
  8135. get midtonesHue(): number;
  8136. /**
  8137. * Sets the midtones Hue value.
  8138. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8139. */
  8140. set midtonesHue(value: number);
  8141. /**
  8142. * Gets the midtones Density value.
  8143. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8144. * Values less than zero provide a filter of opposite hue.
  8145. */
  8146. get midtonesDensity(): number;
  8147. /**
  8148. * Sets the midtones Density value.
  8149. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8150. * Values less than zero provide a filter of opposite hue.
  8151. */
  8152. set midtonesDensity(value: number);
  8153. /**
  8154. * Gets the midtones Saturation value.
  8155. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8156. */
  8157. get midtonesSaturation(): number;
  8158. /**
  8159. * Sets the midtones Saturation value.
  8160. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8161. */
  8162. set midtonesSaturation(value: number);
  8163. /**
  8164. * Gets the midtones Exposure value.
  8165. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8166. */
  8167. get midtonesExposure(): number;
  8168. /**
  8169. * Sets the midtones Exposure value.
  8170. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8171. */
  8172. set midtonesExposure(value: number);
  8173. private _shadowsHue;
  8174. private _shadowsDensity;
  8175. private _shadowsSaturation;
  8176. private _shadowsExposure;
  8177. /**
  8178. * Gets the shadows Hue value.
  8179. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8180. */
  8181. get shadowsHue(): number;
  8182. /**
  8183. * Sets the shadows Hue value.
  8184. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8185. */
  8186. set shadowsHue(value: number);
  8187. /**
  8188. * Gets the shadows Density value.
  8189. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8190. * Values less than zero provide a filter of opposite hue.
  8191. */
  8192. get shadowsDensity(): number;
  8193. /**
  8194. * Sets the shadows Density value.
  8195. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8196. * Values less than zero provide a filter of opposite hue.
  8197. */
  8198. set shadowsDensity(value: number);
  8199. /**
  8200. * Gets the shadows Saturation value.
  8201. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8202. */
  8203. get shadowsSaturation(): number;
  8204. /**
  8205. * Sets the shadows Saturation value.
  8206. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8207. */
  8208. set shadowsSaturation(value: number);
  8209. /**
  8210. * Gets the shadows Exposure value.
  8211. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8212. */
  8213. get shadowsExposure(): number;
  8214. /**
  8215. * Sets the shadows Exposure value.
  8216. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8217. */
  8218. set shadowsExposure(value: number);
  8219. /**
  8220. * Returns the class name
  8221. * @returns The class name
  8222. */
  8223. getClassName(): string;
  8224. /**
  8225. * Binds the color curves to the shader.
  8226. * @param colorCurves The color curve to bind
  8227. * @param effect The effect to bind to
  8228. * @param positiveUniform The positive uniform shader parameter
  8229. * @param neutralUniform The neutral uniform shader parameter
  8230. * @param negativeUniform The negative uniform shader parameter
  8231. */
  8232. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8233. /**
  8234. * Prepare the list of uniforms associated with the ColorCurves effects.
  8235. * @param uniformsList The list of uniforms used in the effect
  8236. */
  8237. static PrepareUniforms(uniformsList: string[]): void;
  8238. /**
  8239. * Returns color grading data based on a hue, density, saturation and exposure value.
  8240. * @param filterHue The hue of the color filter.
  8241. * @param filterDensity The density of the color filter.
  8242. * @param saturation The saturation.
  8243. * @param exposure The exposure.
  8244. * @param result The result data container.
  8245. */
  8246. private getColorGradingDataToRef;
  8247. /**
  8248. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8249. * @param value The input slider value in range [-100,100].
  8250. * @returns Adjusted value.
  8251. */
  8252. private static applyColorGradingSliderNonlinear;
  8253. /**
  8254. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8255. * @param hue The hue (H) input.
  8256. * @param saturation The saturation (S) input.
  8257. * @param brightness The brightness (B) input.
  8258. * @result An RGBA color represented as Vector4.
  8259. */
  8260. private static fromHSBToRef;
  8261. /**
  8262. * Returns a value clamped between min and max
  8263. * @param value The value to clamp
  8264. * @param min The minimum of value
  8265. * @param max The maximum of value
  8266. * @returns The clamped value.
  8267. */
  8268. private static clamp;
  8269. /**
  8270. * Clones the current color curve instance.
  8271. * @return The cloned curves
  8272. */
  8273. clone(): ColorCurves;
  8274. /**
  8275. * Serializes the current color curve instance to a json representation.
  8276. * @return a JSON representation
  8277. */
  8278. serialize(): any;
  8279. /**
  8280. * Parses the color curve from a json representation.
  8281. * @param source the JSON source to parse
  8282. * @return The parsed curves
  8283. */
  8284. static Parse(source: any): ColorCurves;
  8285. }
  8286. }
  8287. declare module BABYLON {
  8288. /**
  8289. * Interface to follow in your material defines to integrate easily the
  8290. * Image proccessing functions.
  8291. * @hidden
  8292. */
  8293. export interface IImageProcessingConfigurationDefines {
  8294. IMAGEPROCESSING: boolean;
  8295. VIGNETTE: boolean;
  8296. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8297. VIGNETTEBLENDMODEOPAQUE: boolean;
  8298. TONEMAPPING: boolean;
  8299. TONEMAPPING_ACES: boolean;
  8300. CONTRAST: boolean;
  8301. EXPOSURE: boolean;
  8302. COLORCURVES: boolean;
  8303. COLORGRADING: boolean;
  8304. COLORGRADING3D: boolean;
  8305. SAMPLER3DGREENDEPTH: boolean;
  8306. SAMPLER3DBGRMAP: boolean;
  8307. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8308. }
  8309. /**
  8310. * @hidden
  8311. */
  8312. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. COLORCURVES: boolean;
  8321. COLORGRADING: boolean;
  8322. COLORGRADING3D: boolean;
  8323. SAMPLER3DGREENDEPTH: boolean;
  8324. SAMPLER3DBGRMAP: boolean;
  8325. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8326. EXPOSURE: boolean;
  8327. constructor();
  8328. }
  8329. /**
  8330. * This groups together the common properties used for image processing either in direct forward pass
  8331. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8332. * or not.
  8333. */
  8334. export class ImageProcessingConfiguration {
  8335. /**
  8336. * Default tone mapping applied in BabylonJS.
  8337. */
  8338. static readonly TONEMAPPING_STANDARD: number;
  8339. /**
  8340. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8341. * to other engines rendering to increase portability.
  8342. */
  8343. static readonly TONEMAPPING_ACES: number;
  8344. /**
  8345. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8346. */
  8347. colorCurves: Nullable<ColorCurves>;
  8348. private _colorCurvesEnabled;
  8349. /**
  8350. * Gets wether the color curves effect is enabled.
  8351. */
  8352. get colorCurvesEnabled(): boolean;
  8353. /**
  8354. * Sets wether the color curves effect is enabled.
  8355. */
  8356. set colorCurvesEnabled(value: boolean);
  8357. private _colorGradingTexture;
  8358. /**
  8359. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8360. */
  8361. get colorGradingTexture(): Nullable<BaseTexture>;
  8362. /**
  8363. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8364. */
  8365. set colorGradingTexture(value: Nullable<BaseTexture>);
  8366. private _colorGradingEnabled;
  8367. /**
  8368. * Gets wether the color grading effect is enabled.
  8369. */
  8370. get colorGradingEnabled(): boolean;
  8371. /**
  8372. * Sets wether the color grading effect is enabled.
  8373. */
  8374. set colorGradingEnabled(value: boolean);
  8375. private _colorGradingWithGreenDepth;
  8376. /**
  8377. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8378. */
  8379. get colorGradingWithGreenDepth(): boolean;
  8380. /**
  8381. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8382. */
  8383. set colorGradingWithGreenDepth(value: boolean);
  8384. private _colorGradingBGR;
  8385. /**
  8386. * Gets wether the color grading texture contains BGR values.
  8387. */
  8388. get colorGradingBGR(): boolean;
  8389. /**
  8390. * Sets wether the color grading texture contains BGR values.
  8391. */
  8392. set colorGradingBGR(value: boolean);
  8393. /** @hidden */
  8394. _exposure: number;
  8395. /**
  8396. * Gets the Exposure used in the effect.
  8397. */
  8398. get exposure(): number;
  8399. /**
  8400. * Sets the Exposure used in the effect.
  8401. */
  8402. set exposure(value: number);
  8403. private _toneMappingEnabled;
  8404. /**
  8405. * Gets wether the tone mapping effect is enabled.
  8406. */
  8407. get toneMappingEnabled(): boolean;
  8408. /**
  8409. * Sets wether the tone mapping effect is enabled.
  8410. */
  8411. set toneMappingEnabled(value: boolean);
  8412. private _toneMappingType;
  8413. /**
  8414. * Gets the type of tone mapping effect.
  8415. */
  8416. get toneMappingType(): number;
  8417. /**
  8418. * Sets the type of tone mapping effect used in BabylonJS.
  8419. */
  8420. set toneMappingType(value: number);
  8421. protected _contrast: number;
  8422. /**
  8423. * Gets the contrast used in the effect.
  8424. */
  8425. get contrast(): number;
  8426. /**
  8427. * Sets the contrast used in the effect.
  8428. */
  8429. set contrast(value: number);
  8430. /**
  8431. * Vignette stretch size.
  8432. */
  8433. vignetteStretch: number;
  8434. /**
  8435. * Vignette centre X Offset.
  8436. */
  8437. vignetteCentreX: number;
  8438. /**
  8439. * Vignette centre Y Offset.
  8440. */
  8441. vignetteCentreY: number;
  8442. /**
  8443. * Vignette weight or intensity of the vignette effect.
  8444. */
  8445. vignetteWeight: number;
  8446. /**
  8447. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8448. * if vignetteEnabled is set to true.
  8449. */
  8450. vignetteColor: Color4;
  8451. /**
  8452. * Camera field of view used by the Vignette effect.
  8453. */
  8454. vignetteCameraFov: number;
  8455. private _vignetteBlendMode;
  8456. /**
  8457. * Gets the vignette blend mode allowing different kind of effect.
  8458. */
  8459. get vignetteBlendMode(): number;
  8460. /**
  8461. * Sets the vignette blend mode allowing different kind of effect.
  8462. */
  8463. set vignetteBlendMode(value: number);
  8464. private _vignetteEnabled;
  8465. /**
  8466. * Gets wether the vignette effect is enabled.
  8467. */
  8468. get vignetteEnabled(): boolean;
  8469. /**
  8470. * Sets wether the vignette effect is enabled.
  8471. */
  8472. set vignetteEnabled(value: boolean);
  8473. private _applyByPostProcess;
  8474. /**
  8475. * Gets wether the image processing is applied through a post process or not.
  8476. */
  8477. get applyByPostProcess(): boolean;
  8478. /**
  8479. * Sets wether the image processing is applied through a post process or not.
  8480. */
  8481. set applyByPostProcess(value: boolean);
  8482. private _isEnabled;
  8483. /**
  8484. * Gets wether the image processing is enabled or not.
  8485. */
  8486. get isEnabled(): boolean;
  8487. /**
  8488. * Sets wether the image processing is enabled or not.
  8489. */
  8490. set isEnabled(value: boolean);
  8491. /**
  8492. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8493. */
  8494. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8495. /**
  8496. * Method called each time the image processing information changes requires to recompile the effect.
  8497. */
  8498. protected _updateParameters(): void;
  8499. /**
  8500. * Gets the current class name.
  8501. * @return "ImageProcessingConfiguration"
  8502. */
  8503. getClassName(): string;
  8504. /**
  8505. * Prepare the list of uniforms associated with the Image Processing effects.
  8506. * @param uniforms The list of uniforms used in the effect
  8507. * @param defines the list of defines currently in use
  8508. */
  8509. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8510. /**
  8511. * Prepare the list of samplers associated with the Image Processing effects.
  8512. * @param samplersList The list of uniforms used in the effect
  8513. * @param defines the list of defines currently in use
  8514. */
  8515. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8516. /**
  8517. * Prepare the list of defines associated to the shader.
  8518. * @param defines the list of defines to complete
  8519. * @param forPostProcess Define if we are currently in post process mode or not
  8520. */
  8521. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8522. /**
  8523. * Returns true if all the image processing information are ready.
  8524. * @returns True if ready, otherwise, false
  8525. */
  8526. isReady(): boolean;
  8527. /**
  8528. * Binds the image processing to the shader.
  8529. * @param effect The effect to bind to
  8530. * @param overrideAspectRatio Override the aspect ratio of the effect
  8531. */
  8532. bind(effect: Effect, overrideAspectRatio?: number): void;
  8533. /**
  8534. * Clones the current image processing instance.
  8535. * @return The cloned image processing
  8536. */
  8537. clone(): ImageProcessingConfiguration;
  8538. /**
  8539. * Serializes the current image processing instance to a json representation.
  8540. * @return a JSON representation
  8541. */
  8542. serialize(): any;
  8543. /**
  8544. * Parses the image processing from a json representation.
  8545. * @param source the JSON source to parse
  8546. * @return The parsed image processing
  8547. */
  8548. static Parse(source: any): ImageProcessingConfiguration;
  8549. private static _VIGNETTEMODE_MULTIPLY;
  8550. private static _VIGNETTEMODE_OPAQUE;
  8551. /**
  8552. * Used to apply the vignette as a mix with the pixel color.
  8553. */
  8554. static get VIGNETTEMODE_MULTIPLY(): number;
  8555. /**
  8556. * Used to apply the vignette as a replacement of the pixel color.
  8557. */
  8558. static get VIGNETTEMODE_OPAQUE(): number;
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /** @hidden */
  8563. export var postprocessVertexShader: {
  8564. name: string;
  8565. shader: string;
  8566. };
  8567. }
  8568. declare module BABYLON {
  8569. interface ThinEngine {
  8570. /**
  8571. * Creates a new render target texture
  8572. * @param size defines the size of the texture
  8573. * @param options defines the options used to create the texture
  8574. * @returns a new render target texture stored in an InternalTexture
  8575. */
  8576. createRenderTargetTexture(size: number | {
  8577. width: number;
  8578. height: number;
  8579. layers?: number;
  8580. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8581. /**
  8582. * Creates a depth stencil texture.
  8583. * This is only available in WebGL 2 or with the depth texture extension available.
  8584. * @param size The size of face edge in the texture.
  8585. * @param options The options defining the texture.
  8586. * @returns The texture
  8587. */
  8588. createDepthStencilTexture(size: number | {
  8589. width: number;
  8590. height: number;
  8591. layers?: number;
  8592. }, options: DepthTextureCreationOptions): InternalTexture;
  8593. /** @hidden */
  8594. _createDepthStencilTexture(size: number | {
  8595. width: number;
  8596. height: number;
  8597. layers?: number;
  8598. }, options: DepthTextureCreationOptions): InternalTexture;
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /**
  8603. * Defines the kind of connection point for node based material
  8604. */
  8605. export enum NodeMaterialBlockConnectionPointTypes {
  8606. /** Float */
  8607. Float = 1,
  8608. /** Int */
  8609. Int = 2,
  8610. /** Vector2 */
  8611. Vector2 = 4,
  8612. /** Vector3 */
  8613. Vector3 = 8,
  8614. /** Vector4 */
  8615. Vector4 = 16,
  8616. /** Color3 */
  8617. Color3 = 32,
  8618. /** Color4 */
  8619. Color4 = 64,
  8620. /** Matrix */
  8621. Matrix = 128,
  8622. /** Custom object */
  8623. Object = 256,
  8624. /** Detect type based on connection */
  8625. AutoDetect = 1024,
  8626. /** Output type that will be defined by input type */
  8627. BasedOnInput = 2048
  8628. }
  8629. }
  8630. declare module BABYLON {
  8631. /**
  8632. * Enum used to define the target of a block
  8633. */
  8634. export enum NodeMaterialBlockTargets {
  8635. /** Vertex shader */
  8636. Vertex = 1,
  8637. /** Fragment shader */
  8638. Fragment = 2,
  8639. /** Neutral */
  8640. Neutral = 4,
  8641. /** Vertex and Fragment */
  8642. VertexAndFragment = 3
  8643. }
  8644. }
  8645. declare module BABYLON {
  8646. /**
  8647. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8648. */
  8649. export enum NodeMaterialBlockConnectionPointMode {
  8650. /** Value is an uniform */
  8651. Uniform = 0,
  8652. /** Value is a mesh attribute */
  8653. Attribute = 1,
  8654. /** Value is a varying between vertex and fragment shaders */
  8655. Varying = 2,
  8656. /** Mode is undefined */
  8657. Undefined = 3
  8658. }
  8659. }
  8660. declare module BABYLON {
  8661. /**
  8662. * Enum used to define system values e.g. values automatically provided by the system
  8663. */
  8664. export enum NodeMaterialSystemValues {
  8665. /** World */
  8666. World = 1,
  8667. /** View */
  8668. View = 2,
  8669. /** Projection */
  8670. Projection = 3,
  8671. /** ViewProjection */
  8672. ViewProjection = 4,
  8673. /** WorldView */
  8674. WorldView = 5,
  8675. /** WorldViewProjection */
  8676. WorldViewProjection = 6,
  8677. /** CameraPosition */
  8678. CameraPosition = 7,
  8679. /** Fog Color */
  8680. FogColor = 8,
  8681. /** Delta time */
  8682. DeltaTime = 9
  8683. }
  8684. }
  8685. declare module BABYLON {
  8686. /** Defines supported spaces */
  8687. export enum Space {
  8688. /** Local (object) space */
  8689. LOCAL = 0,
  8690. /** World space */
  8691. WORLD = 1,
  8692. /** Bone space */
  8693. BONE = 2
  8694. }
  8695. /** Defines the 3 main axes */
  8696. export class Axis {
  8697. /** X axis */
  8698. static X: Vector3;
  8699. /** Y axis */
  8700. static Y: Vector3;
  8701. /** Z axis */
  8702. static Z: Vector3;
  8703. }
  8704. }
  8705. declare module BABYLON {
  8706. /**
  8707. * Represents a camera frustum
  8708. */
  8709. export class Frustum {
  8710. /**
  8711. * Gets the planes representing the frustum
  8712. * @param transform matrix to be applied to the returned planes
  8713. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8714. */
  8715. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8716. /**
  8717. * Gets the near frustum plane transformed by the transform matrix
  8718. * @param transform transformation matrix to be applied to the resulting frustum plane
  8719. * @param frustumPlane the resuling frustum plane
  8720. */
  8721. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8722. /**
  8723. * Gets the far frustum plane transformed by the transform matrix
  8724. * @param transform transformation matrix to be applied to the resulting frustum plane
  8725. * @param frustumPlane the resuling frustum plane
  8726. */
  8727. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8728. /**
  8729. * Gets the left frustum plane transformed by the transform matrix
  8730. * @param transform transformation matrix to be applied to the resulting frustum plane
  8731. * @param frustumPlane the resuling frustum plane
  8732. */
  8733. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8734. /**
  8735. * Gets the right frustum plane transformed by the transform matrix
  8736. * @param transform transformation matrix to be applied to the resulting frustum plane
  8737. * @param frustumPlane the resuling frustum plane
  8738. */
  8739. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8740. /**
  8741. * Gets the top frustum plane transformed by the transform matrix
  8742. * @param transform transformation matrix to be applied to the resulting frustum plane
  8743. * @param frustumPlane the resuling frustum plane
  8744. */
  8745. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8746. /**
  8747. * Gets the bottom frustum plane transformed by the transform matrix
  8748. * @param transform transformation matrix to be applied to the resulting frustum plane
  8749. * @param frustumPlane the resuling frustum plane
  8750. */
  8751. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8752. /**
  8753. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8754. * @param transform transformation matrix to be applied to the resulting frustum planes
  8755. * @param frustumPlanes the resuling frustum planes
  8756. */
  8757. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8758. }
  8759. }
  8760. declare module BABYLON {
  8761. /**
  8762. * Interface for the size containing width and height
  8763. */
  8764. export interface ISize {
  8765. /**
  8766. * Width
  8767. */
  8768. width: number;
  8769. /**
  8770. * Heighht
  8771. */
  8772. height: number;
  8773. }
  8774. /**
  8775. * Size containing widht and height
  8776. */
  8777. export class Size implements ISize {
  8778. /**
  8779. * Width
  8780. */
  8781. width: number;
  8782. /**
  8783. * Height
  8784. */
  8785. height: number;
  8786. /**
  8787. * Creates a Size object from the given width and height (floats).
  8788. * @param width width of the new size
  8789. * @param height height of the new size
  8790. */
  8791. constructor(width: number, height: number);
  8792. /**
  8793. * Returns a string with the Size width and height
  8794. * @returns a string with the Size width and height
  8795. */
  8796. toString(): string;
  8797. /**
  8798. * "Size"
  8799. * @returns the string "Size"
  8800. */
  8801. getClassName(): string;
  8802. /**
  8803. * Returns the Size hash code.
  8804. * @returns a hash code for a unique width and height
  8805. */
  8806. getHashCode(): number;
  8807. /**
  8808. * Updates the current size from the given one.
  8809. * @param src the given size
  8810. */
  8811. copyFrom(src: Size): void;
  8812. /**
  8813. * Updates in place the current Size from the given floats.
  8814. * @param width width of the new size
  8815. * @param height height of the new size
  8816. * @returns the updated Size.
  8817. */
  8818. copyFromFloats(width: number, height: number): Size;
  8819. /**
  8820. * Updates in place the current Size from the given floats.
  8821. * @param width width to set
  8822. * @param height height to set
  8823. * @returns the updated Size.
  8824. */
  8825. set(width: number, height: number): Size;
  8826. /**
  8827. * Multiplies the width and height by numbers
  8828. * @param w factor to multiple the width by
  8829. * @param h factor to multiple the height by
  8830. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8831. */
  8832. multiplyByFloats(w: number, h: number): Size;
  8833. /**
  8834. * Clones the size
  8835. * @returns a new Size copied from the given one.
  8836. */
  8837. clone(): Size;
  8838. /**
  8839. * True if the current Size and the given one width and height are strictly equal.
  8840. * @param other the other size to compare against
  8841. * @returns True if the current Size and the given one width and height are strictly equal.
  8842. */
  8843. equals(other: Size): boolean;
  8844. /**
  8845. * The surface of the Size : width * height (float).
  8846. */
  8847. get surface(): number;
  8848. /**
  8849. * Create a new size of zero
  8850. * @returns a new Size set to (0.0, 0.0)
  8851. */
  8852. static Zero(): Size;
  8853. /**
  8854. * Sums the width and height of two sizes
  8855. * @param otherSize size to add to this size
  8856. * @returns a new Size set as the addition result of the current Size and the given one.
  8857. */
  8858. add(otherSize: Size): Size;
  8859. /**
  8860. * Subtracts the width and height of two
  8861. * @param otherSize size to subtract to this size
  8862. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8863. */
  8864. subtract(otherSize: Size): Size;
  8865. /**
  8866. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8867. * @param start starting size to lerp between
  8868. * @param end end size to lerp between
  8869. * @param amount amount to lerp between the start and end values
  8870. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8871. */
  8872. static Lerp(start: Size, end: Size, amount: number): Size;
  8873. }
  8874. }
  8875. declare module BABYLON {
  8876. /**
  8877. * Contains position and normal vectors for a vertex
  8878. */
  8879. export class PositionNormalVertex {
  8880. /** the position of the vertex (defaut: 0,0,0) */
  8881. position: Vector3;
  8882. /** the normal of the vertex (defaut: 0,1,0) */
  8883. normal: Vector3;
  8884. /**
  8885. * Creates a PositionNormalVertex
  8886. * @param position the position of the vertex (defaut: 0,0,0)
  8887. * @param normal the normal of the vertex (defaut: 0,1,0)
  8888. */
  8889. constructor(
  8890. /** the position of the vertex (defaut: 0,0,0) */
  8891. position?: Vector3,
  8892. /** the normal of the vertex (defaut: 0,1,0) */
  8893. normal?: Vector3);
  8894. /**
  8895. * Clones the PositionNormalVertex
  8896. * @returns the cloned PositionNormalVertex
  8897. */
  8898. clone(): PositionNormalVertex;
  8899. }
  8900. /**
  8901. * Contains position, normal and uv vectors for a vertex
  8902. */
  8903. export class PositionNormalTextureVertex {
  8904. /** the position of the vertex (defaut: 0,0,0) */
  8905. position: Vector3;
  8906. /** the normal of the vertex (defaut: 0,1,0) */
  8907. normal: Vector3;
  8908. /** the uv of the vertex (default: 0,0) */
  8909. uv: Vector2;
  8910. /**
  8911. * Creates a PositionNormalTextureVertex
  8912. * @param position the position of the vertex (defaut: 0,0,0)
  8913. * @param normal the normal of the vertex (defaut: 0,1,0)
  8914. * @param uv the uv of the vertex (default: 0,0)
  8915. */
  8916. constructor(
  8917. /** the position of the vertex (defaut: 0,0,0) */
  8918. position?: Vector3,
  8919. /** the normal of the vertex (defaut: 0,1,0) */
  8920. normal?: Vector3,
  8921. /** the uv of the vertex (default: 0,0) */
  8922. uv?: Vector2);
  8923. /**
  8924. * Clones the PositionNormalTextureVertex
  8925. * @returns the cloned PositionNormalTextureVertex
  8926. */
  8927. clone(): PositionNormalTextureVertex;
  8928. }
  8929. }
  8930. declare module BABYLON {
  8931. /**
  8932. * Enum defining the type of animations supported by InputBlock
  8933. */
  8934. export enum AnimatedInputBlockTypes {
  8935. /** No animation */
  8936. None = 0,
  8937. /** Time based animation. Will only work for floats */
  8938. Time = 1
  8939. }
  8940. }
  8941. declare module BABYLON {
  8942. /**
  8943. * Interface describing all the common properties and methods a shadow light needs to implement.
  8944. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8945. * as well as binding the different shadow properties to the effects.
  8946. */
  8947. export interface IShadowLight extends Light {
  8948. /**
  8949. * The light id in the scene (used in scene.findLighById for instance)
  8950. */
  8951. id: string;
  8952. /**
  8953. * The position the shdow will be casted from.
  8954. */
  8955. position: Vector3;
  8956. /**
  8957. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8958. */
  8959. direction: Vector3;
  8960. /**
  8961. * The transformed position. Position of the light in world space taking parenting in account.
  8962. */
  8963. transformedPosition: Vector3;
  8964. /**
  8965. * The transformed direction. Direction of the light in world space taking parenting in account.
  8966. */
  8967. transformedDirection: Vector3;
  8968. /**
  8969. * The friendly name of the light in the scene.
  8970. */
  8971. name: string;
  8972. /**
  8973. * Defines the shadow projection clipping minimum z value.
  8974. */
  8975. shadowMinZ: number;
  8976. /**
  8977. * Defines the shadow projection clipping maximum z value.
  8978. */
  8979. shadowMaxZ: number;
  8980. /**
  8981. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8982. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8983. */
  8984. computeTransformedInformation(): boolean;
  8985. /**
  8986. * Gets the scene the light belongs to.
  8987. * @returns The scene
  8988. */
  8989. getScene(): Scene;
  8990. /**
  8991. * Callback defining a custom Projection Matrix Builder.
  8992. * This can be used to override the default projection matrix computation.
  8993. */
  8994. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8995. /**
  8996. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8997. * @param matrix The materix to updated with the projection information
  8998. * @param viewMatrix The transform matrix of the light
  8999. * @param renderList The list of mesh to render in the map
  9000. * @returns The current light
  9001. */
  9002. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9003. /**
  9004. * Gets the current depth scale used in ESM.
  9005. * @returns The scale
  9006. */
  9007. getDepthScale(): number;
  9008. /**
  9009. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9010. * @returns true if a cube texture needs to be use
  9011. */
  9012. needCube(): boolean;
  9013. /**
  9014. * Detects if the projection matrix requires to be recomputed this frame.
  9015. * @returns true if it requires to be recomputed otherwise, false.
  9016. */
  9017. needProjectionMatrixCompute(): boolean;
  9018. /**
  9019. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9020. */
  9021. forceProjectionMatrixCompute(): void;
  9022. /**
  9023. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9024. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9025. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9026. */
  9027. getShadowDirection(faceIndex?: number): Vector3;
  9028. /**
  9029. * Gets the minZ used for shadow according to both the scene and the light.
  9030. * @param activeCamera The camera we are returning the min for
  9031. * @returns the depth min z
  9032. */
  9033. getDepthMinZ(activeCamera: Camera): number;
  9034. /**
  9035. * Gets the maxZ used for shadow according to both the scene and the light.
  9036. * @param activeCamera The camera we are returning the max for
  9037. * @returns the depth max z
  9038. */
  9039. getDepthMaxZ(activeCamera: Camera): number;
  9040. }
  9041. /**
  9042. * Base implementation IShadowLight
  9043. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9044. */
  9045. export abstract class ShadowLight extends Light implements IShadowLight {
  9046. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9047. protected _position: Vector3;
  9048. protected _setPosition(value: Vector3): void;
  9049. /**
  9050. * Sets the position the shadow will be casted from. Also use as the light position for both
  9051. * point and spot lights.
  9052. */
  9053. get position(): Vector3;
  9054. /**
  9055. * Sets the position the shadow will be casted from. Also use as the light position for both
  9056. * point and spot lights.
  9057. */
  9058. set position(value: Vector3);
  9059. protected _direction: Vector3;
  9060. protected _setDirection(value: Vector3): void;
  9061. /**
  9062. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9063. * Also use as the light direction on spot and directional lights.
  9064. */
  9065. get direction(): Vector3;
  9066. /**
  9067. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9068. * Also use as the light direction on spot and directional lights.
  9069. */
  9070. set direction(value: Vector3);
  9071. protected _shadowMinZ: number;
  9072. /**
  9073. * Gets the shadow projection clipping minimum z value.
  9074. */
  9075. get shadowMinZ(): number;
  9076. /**
  9077. * Sets the shadow projection clipping minimum z value.
  9078. */
  9079. set shadowMinZ(value: number);
  9080. protected _shadowMaxZ: number;
  9081. /**
  9082. * Sets the shadow projection clipping maximum z value.
  9083. */
  9084. get shadowMaxZ(): number;
  9085. /**
  9086. * Gets the shadow projection clipping maximum z value.
  9087. */
  9088. set shadowMaxZ(value: number);
  9089. /**
  9090. * Callback defining a custom Projection Matrix Builder.
  9091. * This can be used to override the default projection matrix computation.
  9092. */
  9093. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9094. /**
  9095. * The transformed position. Position of the light in world space taking parenting in account.
  9096. */
  9097. transformedPosition: Vector3;
  9098. /**
  9099. * The transformed direction. Direction of the light in world space taking parenting in account.
  9100. */
  9101. transformedDirection: Vector3;
  9102. private _needProjectionMatrixCompute;
  9103. /**
  9104. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9105. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9106. */
  9107. computeTransformedInformation(): boolean;
  9108. /**
  9109. * Return the depth scale used for the shadow map.
  9110. * @returns the depth scale.
  9111. */
  9112. getDepthScale(): number;
  9113. /**
  9114. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9115. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9116. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9117. */
  9118. getShadowDirection(faceIndex?: number): Vector3;
  9119. /**
  9120. * Returns the ShadowLight absolute position in the World.
  9121. * @returns the position vector in world space
  9122. */
  9123. getAbsolutePosition(): Vector3;
  9124. /**
  9125. * Sets the ShadowLight direction toward the passed target.
  9126. * @param target The point to target in local space
  9127. * @returns the updated ShadowLight direction
  9128. */
  9129. setDirectionToTarget(target: Vector3): Vector3;
  9130. /**
  9131. * Returns the light rotation in euler definition.
  9132. * @returns the x y z rotation in local space.
  9133. */
  9134. getRotation(): Vector3;
  9135. /**
  9136. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9137. * @returns true if a cube texture needs to be use
  9138. */
  9139. needCube(): boolean;
  9140. /**
  9141. * Detects if the projection matrix requires to be recomputed this frame.
  9142. * @returns true if it requires to be recomputed otherwise, false.
  9143. */
  9144. needProjectionMatrixCompute(): boolean;
  9145. /**
  9146. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9147. */
  9148. forceProjectionMatrixCompute(): void;
  9149. /** @hidden */
  9150. _initCache(): void;
  9151. /** @hidden */
  9152. _isSynchronized(): boolean;
  9153. /**
  9154. * Computes the world matrix of the node
  9155. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9156. * @returns the world matrix
  9157. */
  9158. computeWorldMatrix(force?: boolean): Matrix;
  9159. /**
  9160. * Gets the minZ used for shadow according to both the scene and the light.
  9161. * @param activeCamera The camera we are returning the min for
  9162. * @returns the depth min z
  9163. */
  9164. getDepthMinZ(activeCamera: Camera): number;
  9165. /**
  9166. * Gets the maxZ used for shadow according to both the scene and the light.
  9167. * @param activeCamera The camera we are returning the max for
  9168. * @returns the depth max z
  9169. */
  9170. getDepthMaxZ(activeCamera: Camera): number;
  9171. /**
  9172. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9173. * @param matrix The materix to updated with the projection information
  9174. * @param viewMatrix The transform matrix of the light
  9175. * @param renderList The list of mesh to render in the map
  9176. * @returns The current light
  9177. */
  9178. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9179. }
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var packingFunctions: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var bayerDitherFunctions: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var shadowMapFragmentDeclaration: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var clipPlaneFragmentDeclaration: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var clipPlaneFragment: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapFragment: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapPixelShader: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var bonesDeclaration: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var morphTargetsVertexGlobalDeclaration: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var morphTargetsVertexDeclaration: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var instancesDeclaration: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /** @hidden */
  9260. export var helperFunctions: {
  9261. name: string;
  9262. shader: string;
  9263. };
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var shadowMapVertexDeclaration: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var clipPlaneVertexDeclaration: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var morphTargetsVertex: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var instancesVertex: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /** @hidden */
  9295. export var bonesVertex: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var shadowMapVertexNormalBias: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var shadowMapVertexMetric: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var clipPlaneVertex: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var shadowMapVertexShader: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var depthBoxBlurPixelShader: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var shadowMapFragmentSoftTransparentShadow: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /**
  9344. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9345. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9346. */
  9347. export class EffectFallbacks implements IEffectFallbacks {
  9348. private _defines;
  9349. private _currentRank;
  9350. private _maxRank;
  9351. private _mesh;
  9352. /**
  9353. * Removes the fallback from the bound mesh.
  9354. */
  9355. unBindMesh(): void;
  9356. /**
  9357. * Adds a fallback on the specified property.
  9358. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9359. * @param define The name of the define in the shader
  9360. */
  9361. addFallback(rank: number, define: string): void;
  9362. /**
  9363. * Sets the mesh to use CPU skinning when needing to fallback.
  9364. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9365. * @param mesh The mesh to use the fallbacks.
  9366. */
  9367. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9368. /**
  9369. * Checks to see if more fallbacks are still availible.
  9370. */
  9371. get hasMoreFallbacks(): boolean;
  9372. /**
  9373. * Removes the defines that should be removed when falling back.
  9374. * @param currentDefines defines the current define statements for the shader.
  9375. * @param effect defines the current effect we try to compile
  9376. * @returns The resulting defines with defines of the current rank removed.
  9377. */
  9378. reduce(currentDefines: string, effect: Effect): string;
  9379. }
  9380. }
  9381. declare module BABYLON {
  9382. /**
  9383. * Interface used to define Action
  9384. */
  9385. export interface IAction {
  9386. /**
  9387. * Trigger for the action
  9388. */
  9389. trigger: number;
  9390. /** Options of the trigger */
  9391. triggerOptions: any;
  9392. /**
  9393. * Gets the trigger parameters
  9394. * @returns the trigger parameters
  9395. */
  9396. getTriggerParameter(): any;
  9397. /**
  9398. * Internal only - executes current action event
  9399. * @hidden
  9400. */
  9401. _executeCurrent(evt?: ActionEvent): void;
  9402. /**
  9403. * Serialize placeholder for child classes
  9404. * @param parent of child
  9405. * @returns the serialized object
  9406. */
  9407. serialize(parent: any): any;
  9408. /**
  9409. * Internal only
  9410. * @hidden
  9411. */
  9412. _prepare(): void;
  9413. /**
  9414. * Internal only - manager for action
  9415. * @hidden
  9416. */
  9417. _actionManager: Nullable<AbstractActionManager>;
  9418. /**
  9419. * Adds action to chain of actions, may be a DoNothingAction
  9420. * @param action defines the next action to execute
  9421. * @returns The action passed in
  9422. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9423. */
  9424. then(action: IAction): IAction;
  9425. }
  9426. /**
  9427. * The action to be carried out following a trigger
  9428. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9429. */
  9430. export class Action implements IAction {
  9431. /** the trigger, with or without parameters, for the action */
  9432. triggerOptions: any;
  9433. /**
  9434. * Trigger for the action
  9435. */
  9436. trigger: number;
  9437. /**
  9438. * Internal only - manager for action
  9439. * @hidden
  9440. */
  9441. _actionManager: ActionManager;
  9442. private _nextActiveAction;
  9443. private _child;
  9444. private _condition?;
  9445. private _triggerParameter;
  9446. /**
  9447. * An event triggered prior to action being executed.
  9448. */
  9449. onBeforeExecuteObservable: Observable<Action>;
  9450. /**
  9451. * Creates a new Action
  9452. * @param triggerOptions the trigger, with or without parameters, for the action
  9453. * @param condition an optional determinant of action
  9454. */
  9455. constructor(
  9456. /** the trigger, with or without parameters, for the action */
  9457. triggerOptions: any, condition?: Condition);
  9458. /**
  9459. * Internal only
  9460. * @hidden
  9461. */
  9462. _prepare(): void;
  9463. /**
  9464. * Gets the trigger parameters
  9465. * @returns the trigger parameters
  9466. */
  9467. getTriggerParameter(): any;
  9468. /**
  9469. * Internal only - executes current action event
  9470. * @hidden
  9471. */
  9472. _executeCurrent(evt?: ActionEvent): void;
  9473. /**
  9474. * Execute placeholder for child classes
  9475. * @param evt optional action event
  9476. */
  9477. execute(evt?: ActionEvent): void;
  9478. /**
  9479. * Skips to next active action
  9480. */
  9481. skipToNextActiveAction(): void;
  9482. /**
  9483. * Adds action to chain of actions, may be a DoNothingAction
  9484. * @param action defines the next action to execute
  9485. * @returns The action passed in
  9486. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9487. */
  9488. then(action: Action): Action;
  9489. /**
  9490. * Internal only
  9491. * @hidden
  9492. */
  9493. _getProperty(propertyPath: string): string;
  9494. /**
  9495. * Internal only
  9496. * @hidden
  9497. */
  9498. _getEffectiveTarget(target: any, propertyPath: string): any;
  9499. /**
  9500. * Serialize placeholder for child classes
  9501. * @param parent of child
  9502. * @returns the serialized object
  9503. */
  9504. serialize(parent: any): any;
  9505. /**
  9506. * Internal only called by serialize
  9507. * @hidden
  9508. */
  9509. protected _serialize(serializedAction: any, parent?: any): any;
  9510. /**
  9511. * Internal only
  9512. * @hidden
  9513. */
  9514. static _SerializeValueAsString: (value: any) => string;
  9515. /**
  9516. * Internal only
  9517. * @hidden
  9518. */
  9519. static _GetTargetProperty: (target: Scene | Node) => {
  9520. name: string;
  9521. targetType: string;
  9522. value: string;
  9523. };
  9524. }
  9525. }
  9526. declare module BABYLON {
  9527. /**
  9528. * A Condition applied to an Action
  9529. */
  9530. export class Condition {
  9531. /**
  9532. * Internal only - manager for action
  9533. * @hidden
  9534. */
  9535. _actionManager: ActionManager;
  9536. /**
  9537. * Internal only
  9538. * @hidden
  9539. */
  9540. _evaluationId: number;
  9541. /**
  9542. * Internal only
  9543. * @hidden
  9544. */
  9545. _currentResult: boolean;
  9546. /**
  9547. * Creates a new Condition
  9548. * @param actionManager the manager of the action the condition is applied to
  9549. */
  9550. constructor(actionManager: ActionManager);
  9551. /**
  9552. * Check if the current condition is valid
  9553. * @returns a boolean
  9554. */
  9555. isValid(): boolean;
  9556. /**
  9557. * Internal only
  9558. * @hidden
  9559. */
  9560. _getProperty(propertyPath: string): string;
  9561. /**
  9562. * Internal only
  9563. * @hidden
  9564. */
  9565. _getEffectiveTarget(target: any, propertyPath: string): any;
  9566. /**
  9567. * Serialize placeholder for child classes
  9568. * @returns the serialized object
  9569. */
  9570. serialize(): any;
  9571. /**
  9572. * Internal only
  9573. * @hidden
  9574. */
  9575. protected _serialize(serializedCondition: any): any;
  9576. }
  9577. /**
  9578. * Defines specific conditional operators as extensions of Condition
  9579. */
  9580. export class ValueCondition extends Condition {
  9581. /** path to specify the property of the target the conditional operator uses */
  9582. propertyPath: string;
  9583. /** the value compared by the conditional operator against the current value of the property */
  9584. value: any;
  9585. /** the conditional operator, default ValueCondition.IsEqual */
  9586. operator: number;
  9587. /**
  9588. * Internal only
  9589. * @hidden
  9590. */
  9591. private static _IsEqual;
  9592. /**
  9593. * Internal only
  9594. * @hidden
  9595. */
  9596. private static _IsDifferent;
  9597. /**
  9598. * Internal only
  9599. * @hidden
  9600. */
  9601. private static _IsGreater;
  9602. /**
  9603. * Internal only
  9604. * @hidden
  9605. */
  9606. private static _IsLesser;
  9607. /**
  9608. * returns the number for IsEqual
  9609. */
  9610. static get IsEqual(): number;
  9611. /**
  9612. * Returns the number for IsDifferent
  9613. */
  9614. static get IsDifferent(): number;
  9615. /**
  9616. * Returns the number for IsGreater
  9617. */
  9618. static get IsGreater(): number;
  9619. /**
  9620. * Returns the number for IsLesser
  9621. */
  9622. static get IsLesser(): number;
  9623. /**
  9624. * Internal only The action manager for the condition
  9625. * @hidden
  9626. */
  9627. _actionManager: ActionManager;
  9628. /**
  9629. * Internal only
  9630. * @hidden
  9631. */
  9632. private _target;
  9633. /**
  9634. * Internal only
  9635. * @hidden
  9636. */
  9637. private _effectiveTarget;
  9638. /**
  9639. * Internal only
  9640. * @hidden
  9641. */
  9642. private _property;
  9643. /**
  9644. * Creates a new ValueCondition
  9645. * @param actionManager manager for the action the condition applies to
  9646. * @param target for the action
  9647. * @param propertyPath path to specify the property of the target the conditional operator uses
  9648. * @param value the value compared by the conditional operator against the current value of the property
  9649. * @param operator the conditional operator, default ValueCondition.IsEqual
  9650. */
  9651. constructor(actionManager: ActionManager, target: any,
  9652. /** path to specify the property of the target the conditional operator uses */
  9653. propertyPath: string,
  9654. /** the value compared by the conditional operator against the current value of the property */
  9655. value: any,
  9656. /** the conditional operator, default ValueCondition.IsEqual */
  9657. operator?: number);
  9658. /**
  9659. * Compares the given value with the property value for the specified conditional operator
  9660. * @returns the result of the comparison
  9661. */
  9662. isValid(): boolean;
  9663. /**
  9664. * Serialize the ValueCondition into a JSON compatible object
  9665. * @returns serialization object
  9666. */
  9667. serialize(): any;
  9668. /**
  9669. * Gets the name of the conditional operator for the ValueCondition
  9670. * @param operator the conditional operator
  9671. * @returns the name
  9672. */
  9673. static GetOperatorName(operator: number): string;
  9674. }
  9675. /**
  9676. * Defines a predicate condition as an extension of Condition
  9677. */
  9678. export class PredicateCondition extends Condition {
  9679. /** defines the predicate function used to validate the condition */
  9680. predicate: () => boolean;
  9681. /**
  9682. * Internal only - manager for action
  9683. * @hidden
  9684. */
  9685. _actionManager: ActionManager;
  9686. /**
  9687. * Creates a new PredicateCondition
  9688. * @param actionManager manager for the action the condition applies to
  9689. * @param predicate defines the predicate function used to validate the condition
  9690. */
  9691. constructor(actionManager: ActionManager,
  9692. /** defines the predicate function used to validate the condition */
  9693. predicate: () => boolean);
  9694. /**
  9695. * @returns the validity of the predicate condition
  9696. */
  9697. isValid(): boolean;
  9698. }
  9699. /**
  9700. * Defines a state condition as an extension of Condition
  9701. */
  9702. export class StateCondition extends Condition {
  9703. /** Value to compare with target state */
  9704. value: string;
  9705. /**
  9706. * Internal only - manager for action
  9707. * @hidden
  9708. */
  9709. _actionManager: ActionManager;
  9710. /**
  9711. * Internal only
  9712. * @hidden
  9713. */
  9714. private _target;
  9715. /**
  9716. * Creates a new StateCondition
  9717. * @param actionManager manager for the action the condition applies to
  9718. * @param target of the condition
  9719. * @param value to compare with target state
  9720. */
  9721. constructor(actionManager: ActionManager, target: any,
  9722. /** Value to compare with target state */
  9723. value: string);
  9724. /**
  9725. * Gets a boolean indicating if the current condition is met
  9726. * @returns the validity of the state
  9727. */
  9728. isValid(): boolean;
  9729. /**
  9730. * Serialize the StateCondition into a JSON compatible object
  9731. * @returns serialization object
  9732. */
  9733. serialize(): any;
  9734. }
  9735. }
  9736. declare module BABYLON {
  9737. /**
  9738. * This defines an action responsible to toggle a boolean once triggered.
  9739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9740. */
  9741. export class SwitchBooleanAction extends Action {
  9742. /**
  9743. * The path to the boolean property in the target object
  9744. */
  9745. propertyPath: string;
  9746. private _target;
  9747. private _effectiveTarget;
  9748. private _property;
  9749. /**
  9750. * Instantiate the action
  9751. * @param triggerOptions defines the trigger options
  9752. * @param target defines the object containing the boolean
  9753. * @param propertyPath defines the path to the boolean property in the target object
  9754. * @param condition defines the trigger related conditions
  9755. */
  9756. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9757. /** @hidden */
  9758. _prepare(): void;
  9759. /**
  9760. * Execute the action toggle the boolean value.
  9761. */
  9762. execute(): void;
  9763. /**
  9764. * Serializes the actions and its related information.
  9765. * @param parent defines the object to serialize in
  9766. * @returns the serialized object
  9767. */
  9768. serialize(parent: any): any;
  9769. }
  9770. /**
  9771. * This defines an action responsible to set a the state field of the target
  9772. * to a desired value once triggered.
  9773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9774. */
  9775. export class SetStateAction extends Action {
  9776. /**
  9777. * The value to store in the state field.
  9778. */
  9779. value: string;
  9780. private _target;
  9781. /**
  9782. * Instantiate the action
  9783. * @param triggerOptions defines the trigger options
  9784. * @param target defines the object containing the state property
  9785. * @param value defines the value to store in the state field
  9786. * @param condition defines the trigger related conditions
  9787. */
  9788. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9789. /**
  9790. * Execute the action and store the value on the target state property.
  9791. */
  9792. execute(): void;
  9793. /**
  9794. * Serializes the actions and its related information.
  9795. * @param parent defines the object to serialize in
  9796. * @returns the serialized object
  9797. */
  9798. serialize(parent: any): any;
  9799. }
  9800. /**
  9801. * This defines an action responsible to set a property of the target
  9802. * to a desired value once triggered.
  9803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9804. */
  9805. export class SetValueAction extends Action {
  9806. /**
  9807. * The path of the property to set in the target.
  9808. */
  9809. propertyPath: string;
  9810. /**
  9811. * The value to set in the property
  9812. */
  9813. value: any;
  9814. private _target;
  9815. private _effectiveTarget;
  9816. private _property;
  9817. /**
  9818. * Instantiate the action
  9819. * @param triggerOptions defines the trigger options
  9820. * @param target defines the object containing the property
  9821. * @param propertyPath defines the path of the property to set in the target
  9822. * @param value defines the value to set in the property
  9823. * @param condition defines the trigger related conditions
  9824. */
  9825. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9826. /** @hidden */
  9827. _prepare(): void;
  9828. /**
  9829. * Execute the action and set the targetted property to the desired value.
  9830. */
  9831. execute(): void;
  9832. /**
  9833. * Serializes the actions and its related information.
  9834. * @param parent defines the object to serialize in
  9835. * @returns the serialized object
  9836. */
  9837. serialize(parent: any): any;
  9838. }
  9839. /**
  9840. * This defines an action responsible to increment the target value
  9841. * to a desired value once triggered.
  9842. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9843. */
  9844. export class IncrementValueAction extends Action {
  9845. /**
  9846. * The path of the property to increment in the target.
  9847. */
  9848. propertyPath: string;
  9849. /**
  9850. * The value we should increment the property by.
  9851. */
  9852. value: any;
  9853. private _target;
  9854. private _effectiveTarget;
  9855. private _property;
  9856. /**
  9857. * Instantiate the action
  9858. * @param triggerOptions defines the trigger options
  9859. * @param target defines the object containing the property
  9860. * @param propertyPath defines the path of the property to increment in the target
  9861. * @param value defines the value value we should increment the property by
  9862. * @param condition defines the trigger related conditions
  9863. */
  9864. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9865. /** @hidden */
  9866. _prepare(): void;
  9867. /**
  9868. * Execute the action and increment the target of the value amount.
  9869. */
  9870. execute(): void;
  9871. /**
  9872. * Serializes the actions and its related information.
  9873. * @param parent defines the object to serialize in
  9874. * @returns the serialized object
  9875. */
  9876. serialize(parent: any): any;
  9877. }
  9878. /**
  9879. * This defines an action responsible to start an animation once triggered.
  9880. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9881. */
  9882. export class PlayAnimationAction extends Action {
  9883. /**
  9884. * Where the animation should start (animation frame)
  9885. */
  9886. from: number;
  9887. /**
  9888. * Where the animation should stop (animation frame)
  9889. */
  9890. to: number;
  9891. /**
  9892. * Define if the animation should loop or stop after the first play.
  9893. */
  9894. loop?: boolean;
  9895. private _target;
  9896. /**
  9897. * Instantiate the action
  9898. * @param triggerOptions defines the trigger options
  9899. * @param target defines the target animation or animation name
  9900. * @param from defines from where the animation should start (animation frame)
  9901. * @param end defines where the animation should stop (animation frame)
  9902. * @param loop defines if the animation should loop or stop after the first play
  9903. * @param condition defines the trigger related conditions
  9904. */
  9905. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9906. /** @hidden */
  9907. _prepare(): void;
  9908. /**
  9909. * Execute the action and play the animation.
  9910. */
  9911. execute(): void;
  9912. /**
  9913. * Serializes the actions and its related information.
  9914. * @param parent defines the object to serialize in
  9915. * @returns the serialized object
  9916. */
  9917. serialize(parent: any): any;
  9918. }
  9919. /**
  9920. * This defines an action responsible to stop an animation once triggered.
  9921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9922. */
  9923. export class StopAnimationAction extends Action {
  9924. private _target;
  9925. /**
  9926. * Instantiate the action
  9927. * @param triggerOptions defines the trigger options
  9928. * @param target defines the target animation or animation name
  9929. * @param condition defines the trigger related conditions
  9930. */
  9931. constructor(triggerOptions: any, target: any, condition?: Condition);
  9932. /** @hidden */
  9933. _prepare(): void;
  9934. /**
  9935. * Execute the action and stop the animation.
  9936. */
  9937. execute(): void;
  9938. /**
  9939. * Serializes the actions and its related information.
  9940. * @param parent defines the object to serialize in
  9941. * @returns the serialized object
  9942. */
  9943. serialize(parent: any): any;
  9944. }
  9945. /**
  9946. * This defines an action responsible that does nothing once triggered.
  9947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9948. */
  9949. export class DoNothingAction extends Action {
  9950. /**
  9951. * Instantiate the action
  9952. * @param triggerOptions defines the trigger options
  9953. * @param condition defines the trigger related conditions
  9954. */
  9955. constructor(triggerOptions?: any, condition?: Condition);
  9956. /**
  9957. * Execute the action and do nothing.
  9958. */
  9959. execute(): void;
  9960. /**
  9961. * Serializes the actions and its related information.
  9962. * @param parent defines the object to serialize in
  9963. * @returns the serialized object
  9964. */
  9965. serialize(parent: any): any;
  9966. }
  9967. /**
  9968. * This defines an action responsible to trigger several actions once triggered.
  9969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9970. */
  9971. export class CombineAction extends Action {
  9972. /**
  9973. * The list of aggregated animations to run.
  9974. */
  9975. children: Action[];
  9976. /**
  9977. * Instantiate the action
  9978. * @param triggerOptions defines the trigger options
  9979. * @param children defines the list of aggregated animations to run
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and executes all the aggregated actions.
  9987. */
  9988. execute(evt: ActionEvent): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. /**
  9997. * This defines an action responsible to run code (external event) once triggered.
  9998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9999. */
  10000. export class ExecuteCodeAction extends Action {
  10001. /**
  10002. * The callback function to run.
  10003. */
  10004. func: (evt: ActionEvent) => void;
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param func defines the callback function to run
  10009. * @param condition defines the trigger related conditions
  10010. */
  10011. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10012. /**
  10013. * Execute the action and run the attached code.
  10014. */
  10015. execute(evt: ActionEvent): void;
  10016. }
  10017. /**
  10018. * This defines an action responsible to set the parent property of the target once triggered.
  10019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10020. */
  10021. export class SetParentAction extends Action {
  10022. private _parent;
  10023. private _target;
  10024. /**
  10025. * Instantiate the action
  10026. * @param triggerOptions defines the trigger options
  10027. * @param target defines the target containing the parent property
  10028. * @param parent defines from where the animation should start (animation frame)
  10029. * @param condition defines the trigger related conditions
  10030. */
  10031. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10032. /** @hidden */
  10033. _prepare(): void;
  10034. /**
  10035. * Execute the action and set the parent property.
  10036. */
  10037. execute(): void;
  10038. /**
  10039. * Serializes the actions and its related information.
  10040. * @param parent defines the object to serialize in
  10041. * @returns the serialized object
  10042. */
  10043. serialize(parent: any): any;
  10044. }
  10045. }
  10046. declare module BABYLON {
  10047. /**
  10048. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10049. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10050. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10051. */
  10052. export class ActionManager extends AbstractActionManager {
  10053. /**
  10054. * Nothing
  10055. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10056. */
  10057. static readonly NothingTrigger: number;
  10058. /**
  10059. * On pick
  10060. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10061. */
  10062. static readonly OnPickTrigger: number;
  10063. /**
  10064. * On left pick
  10065. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10066. */
  10067. static readonly OnLeftPickTrigger: number;
  10068. /**
  10069. * On right pick
  10070. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10071. */
  10072. static readonly OnRightPickTrigger: number;
  10073. /**
  10074. * On center pick
  10075. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10076. */
  10077. static readonly OnCenterPickTrigger: number;
  10078. /**
  10079. * On pick down
  10080. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10081. */
  10082. static readonly OnPickDownTrigger: number;
  10083. /**
  10084. * On double pick
  10085. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10086. */
  10087. static readonly OnDoublePickTrigger: number;
  10088. /**
  10089. * On pick up
  10090. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10091. */
  10092. static readonly OnPickUpTrigger: number;
  10093. /**
  10094. * On pick out.
  10095. * This trigger will only be raised if you also declared a OnPickDown
  10096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10097. */
  10098. static readonly OnPickOutTrigger: number;
  10099. /**
  10100. * On long press
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10102. */
  10103. static readonly OnLongPressTrigger: number;
  10104. /**
  10105. * On pointer over
  10106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10107. */
  10108. static readonly OnPointerOverTrigger: number;
  10109. /**
  10110. * On pointer out
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10112. */
  10113. static readonly OnPointerOutTrigger: number;
  10114. /**
  10115. * On every frame
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10117. */
  10118. static readonly OnEveryFrameTrigger: number;
  10119. /**
  10120. * On intersection enter
  10121. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10122. */
  10123. static readonly OnIntersectionEnterTrigger: number;
  10124. /**
  10125. * On intersection exit
  10126. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10127. */
  10128. static readonly OnIntersectionExitTrigger: number;
  10129. /**
  10130. * On key down
  10131. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10132. */
  10133. static readonly OnKeyDownTrigger: number;
  10134. /**
  10135. * On key up
  10136. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10137. */
  10138. static readonly OnKeyUpTrigger: number;
  10139. private _scene;
  10140. /**
  10141. * Creates a new action manager
  10142. * @param scene defines the hosting scene
  10143. */
  10144. constructor(scene: Scene);
  10145. /**
  10146. * Releases all associated resources
  10147. */
  10148. dispose(): void;
  10149. /**
  10150. * Gets hosting scene
  10151. * @returns the hosting scene
  10152. */
  10153. getScene(): Scene;
  10154. /**
  10155. * Does this action manager handles actions of any of the given triggers
  10156. * @param triggers defines the triggers to be tested
  10157. * @return a boolean indicating whether one (or more) of the triggers is handled
  10158. */
  10159. hasSpecificTriggers(triggers: number[]): boolean;
  10160. /**
  10161. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10162. * speed.
  10163. * @param triggerA defines the trigger to be tested
  10164. * @param triggerB defines the trigger to be tested
  10165. * @return a boolean indicating whether one (or more) of the triggers is handled
  10166. */
  10167. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10168. /**
  10169. * Does this action manager handles actions of a given trigger
  10170. * @param trigger defines the trigger to be tested
  10171. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10172. * @return whether the trigger is handled
  10173. */
  10174. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10175. /**
  10176. * Does this action manager has pointer triggers
  10177. */
  10178. get hasPointerTriggers(): boolean;
  10179. /**
  10180. * Does this action manager has pick triggers
  10181. */
  10182. get hasPickTriggers(): boolean;
  10183. /**
  10184. * Registers an action to this action manager
  10185. * @param action defines the action to be registered
  10186. * @return the action amended (prepared) after registration
  10187. */
  10188. registerAction(action: IAction): Nullable<IAction>;
  10189. /**
  10190. * Unregisters an action to this action manager
  10191. * @param action defines the action to be unregistered
  10192. * @return a boolean indicating whether the action has been unregistered
  10193. */
  10194. unregisterAction(action: IAction): Boolean;
  10195. /**
  10196. * Process a specific trigger
  10197. * @param trigger defines the trigger to process
  10198. * @param evt defines the event details to be processed
  10199. */
  10200. processTrigger(trigger: number, evt?: IActionEvent): void;
  10201. /** @hidden */
  10202. _getEffectiveTarget(target: any, propertyPath: string): any;
  10203. /** @hidden */
  10204. _getProperty(propertyPath: string): string;
  10205. /**
  10206. * Serialize this manager to a JSON object
  10207. * @param name defines the property name to store this manager
  10208. * @returns a JSON representation of this manager
  10209. */
  10210. serialize(name: string): any;
  10211. /**
  10212. * Creates a new ActionManager from a JSON data
  10213. * @param parsedActions defines the JSON data to read from
  10214. * @param object defines the hosting mesh
  10215. * @param scene defines the hosting scene
  10216. */
  10217. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10218. /**
  10219. * Get a trigger name by index
  10220. * @param trigger defines the trigger index
  10221. * @returns a trigger name
  10222. */
  10223. static GetTriggerName(trigger: number): string;
  10224. }
  10225. }
  10226. declare module BABYLON {
  10227. /**
  10228. * Class used to represent a sprite
  10229. * @see https://doc.babylonjs.com/babylon101/sprites
  10230. */
  10231. export class Sprite implements IAnimatable {
  10232. /** defines the name */
  10233. name: string;
  10234. /** Gets or sets the current world position */
  10235. position: Vector3;
  10236. /** Gets or sets the main color */
  10237. color: Color4;
  10238. /** Gets or sets the width */
  10239. width: number;
  10240. /** Gets or sets the height */
  10241. height: number;
  10242. /** Gets or sets rotation angle */
  10243. angle: number;
  10244. /** Gets or sets the cell index in the sprite sheet */
  10245. cellIndex: number;
  10246. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10247. cellRef: string;
  10248. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10249. invertU: boolean;
  10250. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10251. invertV: boolean;
  10252. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10253. disposeWhenFinishedAnimating: boolean;
  10254. /** Gets the list of attached animations */
  10255. animations: Nullable<Array<Animation>>;
  10256. /** Gets or sets a boolean indicating if the sprite can be picked */
  10257. isPickable: boolean;
  10258. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10259. useAlphaForPicking: boolean;
  10260. /** @hidden */
  10261. _xOffset: number;
  10262. /** @hidden */
  10263. _yOffset: number;
  10264. /** @hidden */
  10265. _xSize: number;
  10266. /** @hidden */
  10267. _ySize: number;
  10268. /**
  10269. * Gets or sets the associated action manager
  10270. */
  10271. actionManager: Nullable<ActionManager>;
  10272. /**
  10273. * An event triggered when the control has been disposed
  10274. */
  10275. onDisposeObservable: Observable<Sprite>;
  10276. private _animationStarted;
  10277. private _loopAnimation;
  10278. private _fromIndex;
  10279. private _toIndex;
  10280. private _delay;
  10281. private _direction;
  10282. private _manager;
  10283. private _time;
  10284. private _onAnimationEnd;
  10285. /**
  10286. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10287. */
  10288. isVisible: boolean;
  10289. /**
  10290. * Gets or sets the sprite size
  10291. */
  10292. get size(): number;
  10293. set size(value: number);
  10294. /**
  10295. * Returns a boolean indicating if the animation is started
  10296. */
  10297. get animationStarted(): boolean;
  10298. /**
  10299. * Gets or sets the unique id of the sprite
  10300. */
  10301. uniqueId: number;
  10302. /**
  10303. * Gets the manager of this sprite
  10304. */
  10305. get manager(): ISpriteManager;
  10306. /**
  10307. * Creates a new Sprite
  10308. * @param name defines the name
  10309. * @param manager defines the manager
  10310. */
  10311. constructor(
  10312. /** defines the name */
  10313. name: string, manager: ISpriteManager);
  10314. /**
  10315. * Returns the string "Sprite"
  10316. * @returns "Sprite"
  10317. */
  10318. getClassName(): string;
  10319. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10320. get fromIndex(): number;
  10321. set fromIndex(value: number);
  10322. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10323. get toIndex(): number;
  10324. set toIndex(value: number);
  10325. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10326. get loopAnimation(): boolean;
  10327. set loopAnimation(value: boolean);
  10328. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10329. get delay(): number;
  10330. set delay(value: number);
  10331. /**
  10332. * Starts an animation
  10333. * @param from defines the initial key
  10334. * @param to defines the end key
  10335. * @param loop defines if the animation must loop
  10336. * @param delay defines the start delay (in ms)
  10337. * @param onAnimationEnd defines a callback to call when animation ends
  10338. */
  10339. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10340. /** Stops current animation (if any) */
  10341. stopAnimation(): void;
  10342. /** @hidden */
  10343. _animate(deltaTime: number): void;
  10344. /** Release associated resources */
  10345. dispose(): void;
  10346. /**
  10347. * Serializes the sprite to a JSON object
  10348. * @returns the JSON object
  10349. */
  10350. serialize(): any;
  10351. /**
  10352. * Parses a JSON object to create a new sprite
  10353. * @param parsedSprite The JSON object to parse
  10354. * @param manager defines the hosting manager
  10355. * @returns the new sprite
  10356. */
  10357. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10358. }
  10359. }
  10360. declare module BABYLON {
  10361. /**
  10362. * Information about the result of picking within a scene
  10363. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10364. */
  10365. export class PickingInfo {
  10366. /** @hidden */
  10367. _pickingUnavailable: boolean;
  10368. /**
  10369. * If the pick collided with an object
  10370. */
  10371. hit: boolean;
  10372. /**
  10373. * Distance away where the pick collided
  10374. */
  10375. distance: number;
  10376. /**
  10377. * The location of pick collision
  10378. */
  10379. pickedPoint: Nullable<Vector3>;
  10380. /**
  10381. * The mesh corresponding the the pick collision
  10382. */
  10383. pickedMesh: Nullable<AbstractMesh>;
  10384. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10385. bu: number;
  10386. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10387. bv: number;
  10388. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10389. faceId: number;
  10390. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10391. subMeshFaceId: number;
  10392. /** Id of the the submesh that was picked */
  10393. subMeshId: number;
  10394. /** If a sprite was picked, this will be the sprite the pick collided with */
  10395. pickedSprite: Nullable<Sprite>;
  10396. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10397. thinInstanceIndex: number;
  10398. /**
  10399. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10400. */
  10401. originMesh: Nullable<AbstractMesh>;
  10402. /**
  10403. * The ray that was used to perform the picking.
  10404. */
  10405. ray: Nullable<Ray>;
  10406. /**
  10407. * Gets the normal correspodning to the face the pick collided with
  10408. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10409. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10410. * @returns The normal correspodning to the face the pick collided with
  10411. */
  10412. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10413. /**
  10414. * Gets the texture coordinates of where the pick occured
  10415. * @returns the vector containing the coordnates of the texture
  10416. */
  10417. getTextureCoordinates(): Nullable<Vector2>;
  10418. }
  10419. }
  10420. declare module BABYLON {
  10421. /**
  10422. * Class representing a ray with position and direction
  10423. */
  10424. export class Ray {
  10425. /** origin point */
  10426. origin: Vector3;
  10427. /** direction */
  10428. direction: Vector3;
  10429. /** length of the ray */
  10430. length: number;
  10431. private static readonly _TmpVector3;
  10432. private _tmpRay;
  10433. /**
  10434. * Creates a new ray
  10435. * @param origin origin point
  10436. * @param direction direction
  10437. * @param length length of the ray
  10438. */
  10439. constructor(
  10440. /** origin point */
  10441. origin: Vector3,
  10442. /** direction */
  10443. direction: Vector3,
  10444. /** length of the ray */
  10445. length?: number);
  10446. /**
  10447. * Checks if the ray intersects a box
  10448. * This does not account for the ray lenght by design to improve perfs.
  10449. * @param minimum bound of the box
  10450. * @param maximum bound of the box
  10451. * @param intersectionTreshold extra extend to be added to the box in all direction
  10452. * @returns if the box was hit
  10453. */
  10454. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10455. /**
  10456. * Checks if the ray intersects a box
  10457. * This does not account for the ray lenght by design to improve perfs.
  10458. * @param box the bounding box to check
  10459. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10460. * @returns if the box was hit
  10461. */
  10462. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10463. /**
  10464. * If the ray hits a sphere
  10465. * @param sphere the bounding sphere to check
  10466. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10467. * @returns true if it hits the sphere
  10468. */
  10469. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10470. /**
  10471. * If the ray hits a triange
  10472. * @param vertex0 triangle vertex
  10473. * @param vertex1 triangle vertex
  10474. * @param vertex2 triangle vertex
  10475. * @returns intersection information if hit
  10476. */
  10477. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10478. /**
  10479. * Checks if ray intersects a plane
  10480. * @param plane the plane to check
  10481. * @returns the distance away it was hit
  10482. */
  10483. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10484. /**
  10485. * Calculate the intercept of a ray on a given axis
  10486. * @param axis to check 'x' | 'y' | 'z'
  10487. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10488. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10489. */
  10490. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10491. /**
  10492. * Checks if ray intersects a mesh
  10493. * @param mesh the mesh to check
  10494. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10495. * @returns picking info of the intersecton
  10496. */
  10497. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10498. /**
  10499. * Checks if ray intersects a mesh
  10500. * @param meshes the meshes to check
  10501. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10502. * @param results array to store result in
  10503. * @returns Array of picking infos
  10504. */
  10505. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10506. private _comparePickingInfo;
  10507. private static smallnum;
  10508. private static rayl;
  10509. /**
  10510. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10511. * @param sega the first point of the segment to test the intersection against
  10512. * @param segb the second point of the segment to test the intersection against
  10513. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10514. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10515. */
  10516. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10517. /**
  10518. * Update the ray from viewport position
  10519. * @param x position
  10520. * @param y y position
  10521. * @param viewportWidth viewport width
  10522. * @param viewportHeight viewport height
  10523. * @param world world matrix
  10524. * @param view view matrix
  10525. * @param projection projection matrix
  10526. * @returns this ray updated
  10527. */
  10528. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10529. /**
  10530. * Creates a ray with origin and direction of 0,0,0
  10531. * @returns the new ray
  10532. */
  10533. static Zero(): Ray;
  10534. /**
  10535. * Creates a new ray from screen space and viewport
  10536. * @param x position
  10537. * @param y y position
  10538. * @param viewportWidth viewport width
  10539. * @param viewportHeight viewport height
  10540. * @param world world matrix
  10541. * @param view view matrix
  10542. * @param projection projection matrix
  10543. * @returns new ray
  10544. */
  10545. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10546. /**
  10547. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10548. * transformed to the given world matrix.
  10549. * @param origin The origin point
  10550. * @param end The end point
  10551. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10552. * @returns the new ray
  10553. */
  10554. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10555. /**
  10556. * Transforms a ray by a matrix
  10557. * @param ray ray to transform
  10558. * @param matrix matrix to apply
  10559. * @returns the resulting new ray
  10560. */
  10561. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10562. /**
  10563. * Transforms a ray by a matrix
  10564. * @param ray ray to transform
  10565. * @param matrix matrix to apply
  10566. * @param result ray to store result in
  10567. */
  10568. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10569. /**
  10570. * Unproject a ray from screen space to object space
  10571. * @param sourceX defines the screen space x coordinate to use
  10572. * @param sourceY defines the screen space y coordinate to use
  10573. * @param viewportWidth defines the current width of the viewport
  10574. * @param viewportHeight defines the current height of the viewport
  10575. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10576. * @param view defines the view matrix to use
  10577. * @param projection defines the projection matrix to use
  10578. */
  10579. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10580. }
  10581. /**
  10582. * Type used to define predicate used to select faces when a mesh intersection is detected
  10583. */
  10584. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10585. interface Scene {
  10586. /** @hidden */
  10587. _tempPickingRay: Nullable<Ray>;
  10588. /** @hidden */
  10589. _cachedRayForTransform: Ray;
  10590. /** @hidden */
  10591. _pickWithRayInverseMatrix: Matrix;
  10592. /** @hidden */
  10593. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10594. /** @hidden */
  10595. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10596. /** @hidden */
  10597. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10598. }
  10599. }
  10600. declare module BABYLON {
  10601. /**
  10602. * Groups all the scene component constants in one place to ease maintenance.
  10603. * @hidden
  10604. */
  10605. export class SceneComponentConstants {
  10606. static readonly NAME_EFFECTLAYER: string;
  10607. static readonly NAME_LAYER: string;
  10608. static readonly NAME_LENSFLARESYSTEM: string;
  10609. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10610. static readonly NAME_PARTICLESYSTEM: string;
  10611. static readonly NAME_GAMEPAD: string;
  10612. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10613. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10614. static readonly NAME_PREPASSRENDERER: string;
  10615. static readonly NAME_DEPTHRENDERER: string;
  10616. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10617. static readonly NAME_SPRITE: string;
  10618. static readonly NAME_OUTLINERENDERER: string;
  10619. static readonly NAME_PROCEDURALTEXTURE: string;
  10620. static readonly NAME_SHADOWGENERATOR: string;
  10621. static readonly NAME_OCTREE: string;
  10622. static readonly NAME_PHYSICSENGINE: string;
  10623. static readonly NAME_AUDIO: string;
  10624. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10625. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10626. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10627. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10628. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10629. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10630. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10631. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10632. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10633. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10634. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10635. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10636. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10637. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10638. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10639. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10640. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10641. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10642. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10643. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10644. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10645. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10646. static readonly STEP_AFTERRENDER_AUDIO: number;
  10647. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10648. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10649. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10650. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10651. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10652. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10653. static readonly STEP_POINTERMOVE_SPRITE: number;
  10654. static readonly STEP_POINTERDOWN_SPRITE: number;
  10655. static readonly STEP_POINTERUP_SPRITE: number;
  10656. }
  10657. /**
  10658. * This represents a scene component.
  10659. *
  10660. * This is used to decouple the dependency the scene is having on the different workloads like
  10661. * layers, post processes...
  10662. */
  10663. export interface ISceneComponent {
  10664. /**
  10665. * The name of the component. Each component must have a unique name.
  10666. */
  10667. name: string;
  10668. /**
  10669. * The scene the component belongs to.
  10670. */
  10671. scene: Scene;
  10672. /**
  10673. * Register the component to one instance of a scene.
  10674. */
  10675. register(): void;
  10676. /**
  10677. * Rebuilds the elements related to this component in case of
  10678. * context lost for instance.
  10679. */
  10680. rebuild(): void;
  10681. /**
  10682. * Disposes the component and the associated ressources.
  10683. */
  10684. dispose(): void;
  10685. }
  10686. /**
  10687. * This represents a SERIALIZABLE scene component.
  10688. *
  10689. * This extends Scene Component to add Serialization methods on top.
  10690. */
  10691. export interface ISceneSerializableComponent extends ISceneComponent {
  10692. /**
  10693. * Adds all the elements from the container to the scene
  10694. * @param container the container holding the elements
  10695. */
  10696. addFromContainer(container: AbstractScene): void;
  10697. /**
  10698. * Removes all the elements in the container from the scene
  10699. * @param container contains the elements to remove
  10700. * @param dispose if the removed element should be disposed (default: false)
  10701. */
  10702. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10703. /**
  10704. * Serializes the component data to the specified json object
  10705. * @param serializationObject The object to serialize to
  10706. */
  10707. serialize(serializationObject: any): void;
  10708. }
  10709. /**
  10710. * Strong typing of a Mesh related stage step action
  10711. */
  10712. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10713. /**
  10714. * Strong typing of a Evaluate Sub Mesh related stage step action
  10715. */
  10716. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10717. /**
  10718. * Strong typing of a Active Mesh related stage step action
  10719. */
  10720. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10721. /**
  10722. * Strong typing of a Camera related stage step action
  10723. */
  10724. export type CameraStageAction = (camera: Camera) => void;
  10725. /**
  10726. * Strong typing of a Camera Frame buffer related stage step action
  10727. */
  10728. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10729. /**
  10730. * Strong typing of a Render Target related stage step action
  10731. */
  10732. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10733. /**
  10734. * Strong typing of a RenderingGroup related stage step action
  10735. */
  10736. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10737. /**
  10738. * Strong typing of a Mesh Render related stage step action
  10739. */
  10740. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10741. /**
  10742. * Strong typing of a simple stage step action
  10743. */
  10744. export type SimpleStageAction = () => void;
  10745. /**
  10746. * Strong typing of a render target action.
  10747. */
  10748. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10749. /**
  10750. * Strong typing of a pointer move action.
  10751. */
  10752. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10753. /**
  10754. * Strong typing of a pointer up/down action.
  10755. */
  10756. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10757. /**
  10758. * Representation of a stage in the scene (Basically a list of ordered steps)
  10759. * @hidden
  10760. */
  10761. export class Stage<T extends Function> extends Array<{
  10762. index: number;
  10763. component: ISceneComponent;
  10764. action: T;
  10765. }> {
  10766. /**
  10767. * Hide ctor from the rest of the world.
  10768. * @param items The items to add.
  10769. */
  10770. private constructor();
  10771. /**
  10772. * Creates a new Stage.
  10773. * @returns A new instance of a Stage
  10774. */
  10775. static Create<T extends Function>(): Stage<T>;
  10776. /**
  10777. * Registers a step in an ordered way in the targeted stage.
  10778. * @param index Defines the position to register the step in
  10779. * @param component Defines the component attached to the step
  10780. * @param action Defines the action to launch during the step
  10781. */
  10782. registerStep(index: number, component: ISceneComponent, action: T): void;
  10783. /**
  10784. * Clears all the steps from the stage.
  10785. */
  10786. clear(): void;
  10787. }
  10788. }
  10789. declare module BABYLON {
  10790. interface Scene {
  10791. /** @hidden */
  10792. _pointerOverSprite: Nullable<Sprite>;
  10793. /** @hidden */
  10794. _pickedDownSprite: Nullable<Sprite>;
  10795. /** @hidden */
  10796. _tempSpritePickingRay: Nullable<Ray>;
  10797. /**
  10798. * All of the sprite managers added to this scene
  10799. * @see https://doc.babylonjs.com/babylon101/sprites
  10800. */
  10801. spriteManagers: Array<ISpriteManager>;
  10802. /**
  10803. * An event triggered when sprites rendering is about to start
  10804. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10805. */
  10806. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10807. /**
  10808. * An event triggered when sprites rendering is done
  10809. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10810. */
  10811. onAfterSpritesRenderingObservable: Observable<Scene>;
  10812. /** @hidden */
  10813. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10814. /** Launch a ray to try to pick a sprite in the scene
  10815. * @param x position on screen
  10816. * @param y position on screen
  10817. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10818. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10819. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10820. * @returns a PickingInfo
  10821. */
  10822. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10823. /** Use the given ray to pick a sprite in the scene
  10824. * @param ray The ray (in world space) to use to pick meshes
  10825. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10826. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10827. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10828. * @returns a PickingInfo
  10829. */
  10830. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10831. /** @hidden */
  10832. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10833. /** Launch a ray to try to pick sprites in the scene
  10834. * @param x position on screen
  10835. * @param y position on screen
  10836. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10837. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10838. * @returns a PickingInfo array
  10839. */
  10840. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10841. /** Use the given ray to pick sprites in the scene
  10842. * @param ray The ray (in world space) to use to pick meshes
  10843. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10844. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10845. * @returns a PickingInfo array
  10846. */
  10847. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10848. /**
  10849. * Force the sprite under the pointer
  10850. * @param sprite defines the sprite to use
  10851. */
  10852. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10853. /**
  10854. * Gets the sprite under the pointer
  10855. * @returns a Sprite or null if no sprite is under the pointer
  10856. */
  10857. getPointerOverSprite(): Nullable<Sprite>;
  10858. }
  10859. /**
  10860. * Defines the sprite scene component responsible to manage sprites
  10861. * in a given scene.
  10862. */
  10863. export class SpriteSceneComponent implements ISceneComponent {
  10864. /**
  10865. * The component name helpfull to identify the component in the list of scene components.
  10866. */
  10867. readonly name: string;
  10868. /**
  10869. * The scene the component belongs to.
  10870. */
  10871. scene: Scene;
  10872. /** @hidden */
  10873. private _spritePredicate;
  10874. /**
  10875. * Creates a new instance of the component for the given scene
  10876. * @param scene Defines the scene to register the component in
  10877. */
  10878. constructor(scene: Scene);
  10879. /**
  10880. * Registers the component in a given scene
  10881. */
  10882. register(): void;
  10883. /**
  10884. * Rebuilds the elements related to this component in case of
  10885. * context lost for instance.
  10886. */
  10887. rebuild(): void;
  10888. /**
  10889. * Disposes the component and the associated ressources.
  10890. */
  10891. dispose(): void;
  10892. private _pickSpriteButKeepRay;
  10893. private _pointerMove;
  10894. private _pointerDown;
  10895. private _pointerUp;
  10896. }
  10897. }
  10898. declare module BABYLON {
  10899. /** @hidden */
  10900. export var fogFragmentDeclaration: {
  10901. name: string;
  10902. shader: string;
  10903. };
  10904. }
  10905. declare module BABYLON {
  10906. /** @hidden */
  10907. export var fogFragment: {
  10908. name: string;
  10909. shader: string;
  10910. };
  10911. }
  10912. declare module BABYLON {
  10913. /** @hidden */
  10914. export var spritesPixelShader: {
  10915. name: string;
  10916. shader: string;
  10917. };
  10918. }
  10919. declare module BABYLON {
  10920. /** @hidden */
  10921. export var fogVertexDeclaration: {
  10922. name: string;
  10923. shader: string;
  10924. };
  10925. }
  10926. declare module BABYLON {
  10927. /** @hidden */
  10928. export var spritesVertexShader: {
  10929. name: string;
  10930. shader: string;
  10931. };
  10932. }
  10933. declare module BABYLON {
  10934. /**
  10935. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10936. */
  10937. export interface ISpriteManager extends IDisposable {
  10938. /**
  10939. * Gets manager's name
  10940. */
  10941. name: string;
  10942. /**
  10943. * Restricts the camera to viewing objects with the same layerMask.
  10944. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10945. */
  10946. layerMask: number;
  10947. /**
  10948. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10949. */
  10950. isPickable: boolean;
  10951. /**
  10952. * Gets the hosting scene
  10953. */
  10954. scene: Scene;
  10955. /**
  10956. * Specifies the rendering group id for this mesh (0 by default)
  10957. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10958. */
  10959. renderingGroupId: number;
  10960. /**
  10961. * Defines the list of sprites managed by the manager.
  10962. */
  10963. sprites: Array<Sprite>;
  10964. /**
  10965. * Gets or sets the spritesheet texture
  10966. */
  10967. texture: Texture;
  10968. /** Defines the default width of a cell in the spritesheet */
  10969. cellWidth: number;
  10970. /** Defines the default height of a cell in the spritesheet */
  10971. cellHeight: number;
  10972. /**
  10973. * Tests the intersection of a sprite with a specific ray.
  10974. * @param ray The ray we are sending to test the collision
  10975. * @param camera The camera space we are sending rays in
  10976. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10977. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10978. * @returns picking info or null.
  10979. */
  10980. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10981. /**
  10982. * Intersects the sprites with a ray
  10983. * @param ray defines the ray to intersect with
  10984. * @param camera defines the current active camera
  10985. * @param predicate defines a predicate used to select candidate sprites
  10986. * @returns null if no hit or a PickingInfo array
  10987. */
  10988. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10989. /**
  10990. * Renders the list of sprites on screen.
  10991. */
  10992. render(): void;
  10993. }
  10994. /**
  10995. * Class used to manage multiple sprites on the same spritesheet
  10996. * @see https://doc.babylonjs.com/babylon101/sprites
  10997. */
  10998. export class SpriteManager implements ISpriteManager {
  10999. /** defines the manager's name */
  11000. name: string;
  11001. /** Define the Url to load snippets */
  11002. static SnippetUrl: string;
  11003. /** Snippet ID if the manager was created from the snippet server */
  11004. snippetId: string;
  11005. /** Gets the list of sprites */
  11006. sprites: Sprite[];
  11007. /** Gets or sets the rendering group id (0 by default) */
  11008. renderingGroupId: number;
  11009. /** Gets or sets camera layer mask */
  11010. layerMask: number;
  11011. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11012. fogEnabled: boolean;
  11013. /** Gets or sets a boolean indicating if the sprites are pickable */
  11014. isPickable: boolean;
  11015. /** Defines the default width of a cell in the spritesheet */
  11016. cellWidth: number;
  11017. /** Defines the default height of a cell in the spritesheet */
  11018. cellHeight: number;
  11019. /** Associative array from JSON sprite data file */
  11020. private _cellData;
  11021. /** Array of sprite names from JSON sprite data file */
  11022. private _spriteMap;
  11023. /** True when packed cell data from JSON file is ready*/
  11024. private _packedAndReady;
  11025. private _textureContent;
  11026. private _useInstancing;
  11027. /**
  11028. * An event triggered when the manager is disposed.
  11029. */
  11030. onDisposeObservable: Observable<SpriteManager>;
  11031. private _onDisposeObserver;
  11032. /**
  11033. * Callback called when the manager is disposed
  11034. */
  11035. set onDispose(callback: () => void);
  11036. private _capacity;
  11037. private _fromPacked;
  11038. private _spriteTexture;
  11039. private _epsilon;
  11040. private _scene;
  11041. private _vertexData;
  11042. private _buffer;
  11043. private _vertexBuffers;
  11044. private _spriteBuffer;
  11045. private _indexBuffer;
  11046. private _effectBase;
  11047. private _effectFog;
  11048. private _vertexBufferSize;
  11049. /**
  11050. * Gets or sets the unique id of the sprite
  11051. */
  11052. uniqueId: number;
  11053. /**
  11054. * Gets the array of sprites
  11055. */
  11056. get children(): Sprite[];
  11057. /**
  11058. * Gets the hosting scene
  11059. */
  11060. get scene(): Scene;
  11061. /**
  11062. * Gets the capacity of the manager
  11063. */
  11064. get capacity(): number;
  11065. /**
  11066. * Gets or sets the spritesheet texture
  11067. */
  11068. get texture(): Texture;
  11069. set texture(value: Texture);
  11070. private _blendMode;
  11071. /**
  11072. * Blend mode use to render the particle, it can be any of
  11073. * the static Constants.ALPHA_x properties provided in this class.
  11074. * Default value is Constants.ALPHA_COMBINE
  11075. */
  11076. get blendMode(): number;
  11077. set blendMode(blendMode: number);
  11078. /** Disables writing to the depth buffer when rendering the sprites.
  11079. * It can be handy to disable depth writing when using textures without alpha channel
  11080. * and setting some specific blend modes.
  11081. */
  11082. disableDepthWrite: boolean;
  11083. /**
  11084. * Creates a new sprite manager
  11085. * @param name defines the manager's name
  11086. * @param imgUrl defines the sprite sheet url
  11087. * @param capacity defines the maximum allowed number of sprites
  11088. * @param cellSize defines the size of a sprite cell
  11089. * @param scene defines the hosting scene
  11090. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11091. * @param samplingMode defines the smapling mode to use with spritesheet
  11092. * @param fromPacked set to false; do not alter
  11093. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11094. */
  11095. constructor(
  11096. /** defines the manager's name */
  11097. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11098. /**
  11099. * Returns the string "SpriteManager"
  11100. * @returns "SpriteManager"
  11101. */
  11102. getClassName(): string;
  11103. private _makePacked;
  11104. private _appendSpriteVertex;
  11105. private _checkTextureAlpha;
  11106. /**
  11107. * Intersects the sprites with a ray
  11108. * @param ray defines the ray to intersect with
  11109. * @param camera defines the current active camera
  11110. * @param predicate defines a predicate used to select candidate sprites
  11111. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11112. * @returns null if no hit or a PickingInfo
  11113. */
  11114. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11115. /**
  11116. * Intersects the sprites with a ray
  11117. * @param ray defines the ray to intersect with
  11118. * @param camera defines the current active camera
  11119. * @param predicate defines a predicate used to select candidate sprites
  11120. * @returns null if no hit or a PickingInfo array
  11121. */
  11122. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11123. /**
  11124. * Render all child sprites
  11125. */
  11126. render(): void;
  11127. /**
  11128. * Release associated resources
  11129. */
  11130. dispose(): void;
  11131. /**
  11132. * Serializes the sprite manager to a JSON object
  11133. * @param serializeTexture defines if the texture must be serialized as well
  11134. * @returns the JSON object
  11135. */
  11136. serialize(serializeTexture?: boolean): any;
  11137. /**
  11138. * Parses a JSON object to create a new sprite manager.
  11139. * @param parsedManager The JSON object to parse
  11140. * @param scene The scene to create the sprite managerin
  11141. * @param rootUrl The root url to use to load external dependencies like texture
  11142. * @returns the new sprite manager
  11143. */
  11144. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11145. /**
  11146. * Creates a sprite manager from a snippet saved in a remote file
  11147. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11148. * @param url defines the url to load from
  11149. * @param scene defines the hosting scene
  11150. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11151. * @returns a promise that will resolve to the new sprite manager
  11152. */
  11153. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11154. /**
  11155. * Creates a sprite manager from a snippet saved by the sprite editor
  11156. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11157. * @param scene defines the hosting scene
  11158. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11159. * @returns a promise that will resolve to the new sprite manager
  11160. */
  11161. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11162. }
  11163. }
  11164. declare module BABYLON {
  11165. /** Interface used by value gradients (color, factor, ...) */
  11166. export interface IValueGradient {
  11167. /**
  11168. * Gets or sets the gradient value (between 0 and 1)
  11169. */
  11170. gradient: number;
  11171. }
  11172. /** Class used to store color4 gradient */
  11173. export class ColorGradient implements IValueGradient {
  11174. /**
  11175. * Gets or sets the gradient value (between 0 and 1)
  11176. */
  11177. gradient: number;
  11178. /**
  11179. * Gets or sets first associated color
  11180. */
  11181. color1: Color4;
  11182. /**
  11183. * Gets or sets second associated color
  11184. */
  11185. color2?: Color4 | undefined;
  11186. /**
  11187. * Creates a new color4 gradient
  11188. * @param gradient gets or sets the gradient value (between 0 and 1)
  11189. * @param color1 gets or sets first associated color
  11190. * @param color2 gets or sets first second color
  11191. */
  11192. constructor(
  11193. /**
  11194. * Gets or sets the gradient value (between 0 and 1)
  11195. */
  11196. gradient: number,
  11197. /**
  11198. * Gets or sets first associated color
  11199. */
  11200. color1: Color4,
  11201. /**
  11202. * Gets or sets second associated color
  11203. */
  11204. color2?: Color4 | undefined);
  11205. /**
  11206. * Will get a color picked randomly between color1 and color2.
  11207. * If color2 is undefined then color1 will be used
  11208. * @param result defines the target Color4 to store the result in
  11209. */
  11210. getColorToRef(result: Color4): void;
  11211. }
  11212. /** Class used to store color 3 gradient */
  11213. export class Color3Gradient implements IValueGradient {
  11214. /**
  11215. * Gets or sets the gradient value (between 0 and 1)
  11216. */
  11217. gradient: number;
  11218. /**
  11219. * Gets or sets the associated color
  11220. */
  11221. color: Color3;
  11222. /**
  11223. * Creates a new color3 gradient
  11224. * @param gradient gets or sets the gradient value (between 0 and 1)
  11225. * @param color gets or sets associated color
  11226. */
  11227. constructor(
  11228. /**
  11229. * Gets or sets the gradient value (between 0 and 1)
  11230. */
  11231. gradient: number,
  11232. /**
  11233. * Gets or sets the associated color
  11234. */
  11235. color: Color3);
  11236. }
  11237. /** Class used to store factor gradient */
  11238. export class FactorGradient implements IValueGradient {
  11239. /**
  11240. * Gets or sets the gradient value (between 0 and 1)
  11241. */
  11242. gradient: number;
  11243. /**
  11244. * Gets or sets first associated factor
  11245. */
  11246. factor1: number;
  11247. /**
  11248. * Gets or sets second associated factor
  11249. */
  11250. factor2?: number | undefined;
  11251. /**
  11252. * Creates a new factor gradient
  11253. * @param gradient gets or sets the gradient value (between 0 and 1)
  11254. * @param factor1 gets or sets first associated factor
  11255. * @param factor2 gets or sets second associated factor
  11256. */
  11257. constructor(
  11258. /**
  11259. * Gets or sets the gradient value (between 0 and 1)
  11260. */
  11261. gradient: number,
  11262. /**
  11263. * Gets or sets first associated factor
  11264. */
  11265. factor1: number,
  11266. /**
  11267. * Gets or sets second associated factor
  11268. */
  11269. factor2?: number | undefined);
  11270. /**
  11271. * Will get a number picked randomly between factor1 and factor2.
  11272. * If factor2 is undefined then factor1 will be used
  11273. * @returns the picked number
  11274. */
  11275. getFactor(): number;
  11276. }
  11277. /**
  11278. * Helper used to simplify some generic gradient tasks
  11279. */
  11280. export class GradientHelper {
  11281. /**
  11282. * Gets the current gradient from an array of IValueGradient
  11283. * @param ratio defines the current ratio to get
  11284. * @param gradients defines the array of IValueGradient
  11285. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11286. */
  11287. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11288. }
  11289. }
  11290. declare module BABYLON {
  11291. interface ThinEngine {
  11292. /**
  11293. * Creates a raw texture
  11294. * @param data defines the data to store in the texture
  11295. * @param width defines the width of the texture
  11296. * @param height defines the height of the texture
  11297. * @param format defines the format of the data
  11298. * @param generateMipMaps defines if the engine should generate the mip levels
  11299. * @param invertY defines if data must be stored with Y axis inverted
  11300. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11301. * @param compression defines the compression used (null by default)
  11302. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11303. * @returns the raw texture inside an InternalTexture
  11304. */
  11305. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11306. /**
  11307. * Update a raw texture
  11308. * @param texture defines the texture to update
  11309. * @param data defines the data to store in the texture
  11310. * @param format defines the format of the data
  11311. * @param invertY defines if data must be stored with Y axis inverted
  11312. */
  11313. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11314. /**
  11315. * Update a raw texture
  11316. * @param texture defines the texture to update
  11317. * @param data defines the data to store in the texture
  11318. * @param format defines the format of the data
  11319. * @param invertY defines if data must be stored with Y axis inverted
  11320. * @param compression defines the compression used (null by default)
  11321. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11322. */
  11323. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11324. /**
  11325. * Creates a new raw cube texture
  11326. * @param data defines the array of data to use to create each face
  11327. * @param size defines the size of the textures
  11328. * @param format defines the format of the data
  11329. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11330. * @param generateMipMaps defines if the engine should generate the mip levels
  11331. * @param invertY defines if data must be stored with Y axis inverted
  11332. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11333. * @param compression defines the compression used (null by default)
  11334. * @returns the cube texture as an InternalTexture
  11335. */
  11336. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11337. /**
  11338. * Update a raw cube texture
  11339. * @param texture defines the texture to udpdate
  11340. * @param data defines the data to store
  11341. * @param format defines the data format
  11342. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11343. * @param invertY defines if data must be stored with Y axis inverted
  11344. */
  11345. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11346. /**
  11347. * Update a raw cube texture
  11348. * @param texture defines the texture to udpdate
  11349. * @param data defines the data to store
  11350. * @param format defines the data format
  11351. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11352. * @param invertY defines if data must be stored with Y axis inverted
  11353. * @param compression defines the compression used (null by default)
  11354. */
  11355. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11356. /**
  11357. * Update a raw cube texture
  11358. * @param texture defines the texture to udpdate
  11359. * @param data defines the data to store
  11360. * @param format defines the data format
  11361. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11362. * @param invertY defines if data must be stored with Y axis inverted
  11363. * @param compression defines the compression used (null by default)
  11364. * @param level defines which level of the texture to update
  11365. */
  11366. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11367. /**
  11368. * Creates a new raw cube texture from a specified url
  11369. * @param url defines the url where the data is located
  11370. * @param scene defines the current scene
  11371. * @param size defines the size of the textures
  11372. * @param format defines the format of the data
  11373. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11374. * @param noMipmap defines if the engine should avoid generating the mip levels
  11375. * @param callback defines a callback used to extract texture data from loaded data
  11376. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11377. * @param onLoad defines a callback called when texture is loaded
  11378. * @param onError defines a callback called if there is an error
  11379. * @returns the cube texture as an InternalTexture
  11380. */
  11381. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  11382. /**
  11383. * Creates a new raw cube texture from a specified url
  11384. * @param url defines the url where the data is located
  11385. * @param scene defines the current scene
  11386. * @param size defines the size of the textures
  11387. * @param format defines the format of the data
  11388. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11389. * @param noMipmap defines if the engine should avoid generating the mip levels
  11390. * @param callback defines a callback used to extract texture data from loaded data
  11391. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11392. * @param onLoad defines a callback called when texture is loaded
  11393. * @param onError defines a callback called if there is an error
  11394. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11395. * @param invertY defines if data must be stored with Y axis inverted
  11396. * @returns the cube texture as an InternalTexture
  11397. */
  11398. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  11399. /**
  11400. * Creates a new raw 3D texture
  11401. * @param data defines the data used to create the texture
  11402. * @param width defines the width of the texture
  11403. * @param height defines the height of the texture
  11404. * @param depth defines the depth of the texture
  11405. * @param format defines the format of the texture
  11406. * @param generateMipMaps defines if the engine must generate mip levels
  11407. * @param invertY defines if data must be stored with Y axis inverted
  11408. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11409. * @param compression defines the compressed used (can be null)
  11410. * @param textureType defines the compressed used (can be null)
  11411. * @returns a new raw 3D texture (stored in an InternalTexture)
  11412. */
  11413. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11414. /**
  11415. * Update a raw 3D texture
  11416. * @param texture defines the texture to update
  11417. * @param data defines the data to store
  11418. * @param format defines the data format
  11419. * @param invertY defines if data must be stored with Y axis inverted
  11420. */
  11421. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11422. /**
  11423. * Update a raw 3D texture
  11424. * @param texture defines the texture to update
  11425. * @param data defines the data to store
  11426. * @param format defines the data format
  11427. * @param invertY defines if data must be stored with Y axis inverted
  11428. * @param compression defines the used compression (can be null)
  11429. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11430. */
  11431. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11432. /**
  11433. * Creates a new raw 2D array texture
  11434. * @param data defines the data used to create the texture
  11435. * @param width defines the width of the texture
  11436. * @param height defines the height of the texture
  11437. * @param depth defines the number of layers of the texture
  11438. * @param format defines the format of the texture
  11439. * @param generateMipMaps defines if the engine must generate mip levels
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11442. * @param compression defines the compressed used (can be null)
  11443. * @param textureType defines the compressed used (can be null)
  11444. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11445. */
  11446. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11447. /**
  11448. * Update a raw 2D array texture
  11449. * @param texture defines the texture to update
  11450. * @param data defines the data to store
  11451. * @param format defines the data format
  11452. * @param invertY defines if data must be stored with Y axis inverted
  11453. */
  11454. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11455. /**
  11456. * Update a raw 2D array texture
  11457. * @param texture defines the texture to update
  11458. * @param data defines the data to store
  11459. * @param format defines the data format
  11460. * @param invertY defines if data must be stored with Y axis inverted
  11461. * @param compression defines the used compression (can be null)
  11462. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11463. */
  11464. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11465. }
  11466. }
  11467. declare module BABYLON {
  11468. /**
  11469. * Raw texture can help creating a texture directly from an array of data.
  11470. * This can be super useful if you either get the data from an uncompressed source or
  11471. * if you wish to create your texture pixel by pixel.
  11472. */
  11473. export class RawTexture extends Texture {
  11474. /**
  11475. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11476. */
  11477. format: number;
  11478. /**
  11479. * Instantiates a new RawTexture.
  11480. * Raw texture can help creating a texture directly from an array of data.
  11481. * This can be super useful if you either get the data from an uncompressed source or
  11482. * if you wish to create your texture pixel by pixel.
  11483. * @param data define the array of data to use to create the texture
  11484. * @param width define the width of the texture
  11485. * @param height define the height of the texture
  11486. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11487. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11488. * @param generateMipMaps define whether mip maps should be generated or not
  11489. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11490. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11491. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11492. */
  11493. constructor(data: ArrayBufferView, width: number, height: number,
  11494. /**
  11495. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11496. */
  11497. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11498. /**
  11499. * Updates the texture underlying data.
  11500. * @param data Define the new data of the texture
  11501. */
  11502. update(data: ArrayBufferView): void;
  11503. /**
  11504. * Creates a luminance texture from some data.
  11505. * @param data Define the texture data
  11506. * @param width Define the width of the texture
  11507. * @param height Define the height of the texture
  11508. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11509. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11510. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11511. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11512. * @returns the luminance texture
  11513. */
  11514. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11515. /**
  11516. * Creates a luminance alpha texture from some data.
  11517. * @param data Define the texture data
  11518. * @param width Define the width of the texture
  11519. * @param height Define the height of the texture
  11520. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11521. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11522. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11523. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11524. * @returns the luminance alpha texture
  11525. */
  11526. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11527. /**
  11528. * Creates an alpha texture from some data.
  11529. * @param data Define the texture data
  11530. * @param width Define the width of the texture
  11531. * @param height Define the height of the texture
  11532. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11533. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11534. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11535. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11536. * @returns the alpha texture
  11537. */
  11538. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11539. /**
  11540. * Creates a RGB texture from some data.
  11541. * @param data Define the texture data
  11542. * @param width Define the width of the texture
  11543. * @param height Define the height of the texture
  11544. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11548. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11549. * @returns the RGB alpha texture
  11550. */
  11551. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11552. /**
  11553. * Creates a RGBA texture from some data.
  11554. * @param data Define the texture data
  11555. * @param width Define the width of the texture
  11556. * @param height Define the height of the texture
  11557. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11558. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11559. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11560. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11561. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11562. * @returns the RGBA texture
  11563. */
  11564. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11565. /**
  11566. * Creates a R texture from some data.
  11567. * @param data Define the texture data
  11568. * @param width Define the width of the texture
  11569. * @param height Define the height of the texture
  11570. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11571. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11572. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11573. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11574. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11575. * @returns the R texture
  11576. */
  11577. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11578. }
  11579. }
  11580. declare module BABYLON {
  11581. interface ThinEngine {
  11582. /**
  11583. * Update a dynamic index buffer
  11584. * @param indexBuffer defines the target index buffer
  11585. * @param indices defines the data to update
  11586. * @param offset defines the offset in the target index buffer where update should start
  11587. */
  11588. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11589. /**
  11590. * Updates a dynamic vertex buffer.
  11591. * @param vertexBuffer the vertex buffer to update
  11592. * @param data the data used to update the vertex buffer
  11593. * @param byteOffset the byte offset of the data
  11594. * @param byteLength the byte length of the data
  11595. */
  11596. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11597. }
  11598. }
  11599. declare module BABYLON {
  11600. interface AbstractScene {
  11601. /**
  11602. * The list of procedural textures added to the scene
  11603. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11604. */
  11605. proceduralTextures: Array<ProceduralTexture>;
  11606. }
  11607. /**
  11608. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11609. * in a given scene.
  11610. */
  11611. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11612. /**
  11613. * The component name helpfull to identify the component in the list of scene components.
  11614. */
  11615. readonly name: string;
  11616. /**
  11617. * The scene the component belongs to.
  11618. */
  11619. scene: Scene;
  11620. /**
  11621. * Creates a new instance of the component for the given scene
  11622. * @param scene Defines the scene to register the component in
  11623. */
  11624. constructor(scene: Scene);
  11625. /**
  11626. * Registers the component in a given scene
  11627. */
  11628. register(): void;
  11629. /**
  11630. * Rebuilds the elements related to this component in case of
  11631. * context lost for instance.
  11632. */
  11633. rebuild(): void;
  11634. /**
  11635. * Disposes the component and the associated ressources.
  11636. */
  11637. dispose(): void;
  11638. private _beforeClear;
  11639. }
  11640. }
  11641. declare module BABYLON {
  11642. interface ThinEngine {
  11643. /**
  11644. * Creates a new render target cube texture
  11645. * @param size defines the size of the texture
  11646. * @param options defines the options used to create the texture
  11647. * @returns a new render target cube texture stored in an InternalTexture
  11648. */
  11649. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11650. }
  11651. }
  11652. declare module BABYLON {
  11653. /** @hidden */
  11654. export var proceduralVertexShader: {
  11655. name: string;
  11656. shader: string;
  11657. };
  11658. }
  11659. declare module BABYLON {
  11660. /**
  11661. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  11662. * This is the base class of any Procedural texture and contains most of the shareable code.
  11663. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11664. */
  11665. export class ProceduralTexture extends Texture {
  11666. /**
  11667. * Define if the texture is enabled or not (disabled texture will not render)
  11668. */
  11669. isEnabled: boolean;
  11670. /**
  11671. * Define if the texture must be cleared before rendering (default is true)
  11672. */
  11673. autoClear: boolean;
  11674. /**
  11675. * Callback called when the texture is generated
  11676. */
  11677. onGenerated: () => void;
  11678. /**
  11679. * Event raised when the texture is generated
  11680. */
  11681. onGeneratedObservable: Observable<ProceduralTexture>;
  11682. /** @hidden */
  11683. _generateMipMaps: boolean;
  11684. /** @hidden **/
  11685. _effect: Effect;
  11686. /** @hidden */
  11687. _textures: {
  11688. [key: string]: Texture;
  11689. };
  11690. /** @hidden */
  11691. protected _fallbackTexture: Nullable<Texture>;
  11692. private _size;
  11693. private _currentRefreshId;
  11694. private _frameId;
  11695. private _refreshRate;
  11696. private _vertexBuffers;
  11697. private _indexBuffer;
  11698. private _uniforms;
  11699. private _samplers;
  11700. private _fragment;
  11701. private _floats;
  11702. private _ints;
  11703. private _floatsArrays;
  11704. private _colors3;
  11705. private _colors4;
  11706. private _vectors2;
  11707. private _vectors3;
  11708. private _matrices;
  11709. private _fallbackTextureUsed;
  11710. private _fullEngine;
  11711. private _cachedDefines;
  11712. private _contentUpdateId;
  11713. private _contentData;
  11714. /**
  11715. * Instantiates a new procedural texture.
  11716. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11717. * This is the base class of any Procedural texture and contains most of the shareable code.
  11718. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11719. * @param name Define the name of the texture
  11720. * @param size Define the size of the texture to create
  11721. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11722. * @param scene Define the scene the texture belongs to
  11723. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11724. * @param generateMipMaps Define if the texture should creates mip maps or not
  11725. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11726. */
  11727. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11728. /**
  11729. * The effect that is created when initializing the post process.
  11730. * @returns The created effect corresponding the the postprocess.
  11731. */
  11732. getEffect(): Effect;
  11733. /**
  11734. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11735. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11736. */
  11737. getContent(): Nullable<ArrayBufferView>;
  11738. private _createIndexBuffer;
  11739. /** @hidden */
  11740. _rebuild(): void;
  11741. /**
  11742. * Resets the texture in order to recreate its associated resources.
  11743. * This can be called in case of context loss
  11744. */
  11745. reset(): void;
  11746. protected _getDefines(): string;
  11747. /**
  11748. * Is the texture ready to be used ? (rendered at least once)
  11749. * @returns true if ready, otherwise, false.
  11750. */
  11751. isReady(): boolean;
  11752. /**
  11753. * Resets the refresh counter of the texture and start bak from scratch.
  11754. * Could be useful to regenerate the texture if it is setup to render only once.
  11755. */
  11756. resetRefreshCounter(): void;
  11757. /**
  11758. * Set the fragment shader to use in order to render the texture.
  11759. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11760. */
  11761. setFragment(fragment: any): void;
  11762. /**
  11763. * Define the refresh rate of the texture or the rendering frequency.
  11764. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11765. */
  11766. get refreshRate(): number;
  11767. set refreshRate(value: number);
  11768. /** @hidden */
  11769. _shouldRender(): boolean;
  11770. /**
  11771. * Get the size the texture is rendering at.
  11772. * @returns the size (texture is always squared)
  11773. */
  11774. getRenderSize(): number;
  11775. /**
  11776. * Resize the texture to new value.
  11777. * @param size Define the new size the texture should have
  11778. * @param generateMipMaps Define whether the new texture should create mip maps
  11779. */
  11780. resize(size: number, generateMipMaps: boolean): void;
  11781. private _checkUniform;
  11782. /**
  11783. * Set a texture in the shader program used to render.
  11784. * @param name Define the name of the uniform samplers as defined in the shader
  11785. * @param texture Define the texture to bind to this sampler
  11786. * @return the texture itself allowing "fluent" like uniform updates
  11787. */
  11788. setTexture(name: string, texture: Texture): ProceduralTexture;
  11789. /**
  11790. * Set a float in the shader.
  11791. * @param name Define the name of the uniform as defined in the shader
  11792. * @param value Define the value to give to the uniform
  11793. * @return the texture itself allowing "fluent" like uniform updates
  11794. */
  11795. setFloat(name: string, value: number): ProceduralTexture;
  11796. /**
  11797. * Set a int in the shader.
  11798. * @param name Define the name of the uniform as defined in the shader
  11799. * @param value Define the value to give to the uniform
  11800. * @return the texture itself allowing "fluent" like uniform updates
  11801. */
  11802. setInt(name: string, value: number): ProceduralTexture;
  11803. /**
  11804. * Set an array of floats in the shader.
  11805. * @param name Define the name of the uniform as defined in the shader
  11806. * @param value Define the value to give to the uniform
  11807. * @return the texture itself allowing "fluent" like uniform updates
  11808. */
  11809. setFloats(name: string, value: number[]): ProceduralTexture;
  11810. /**
  11811. * Set a vec3 in the shader from a Color3.
  11812. * @param name Define the name of the uniform as defined in the shader
  11813. * @param value Define the value to give to the uniform
  11814. * @return the texture itself allowing "fluent" like uniform updates
  11815. */
  11816. setColor3(name: string, value: Color3): ProceduralTexture;
  11817. /**
  11818. * Set a vec4 in the shader from a Color4.
  11819. * @param name Define the name of the uniform as defined in the shader
  11820. * @param value Define the value to give to the uniform
  11821. * @return the texture itself allowing "fluent" like uniform updates
  11822. */
  11823. setColor4(name: string, value: Color4): ProceduralTexture;
  11824. /**
  11825. * Set a vec2 in the shader from a Vector2.
  11826. * @param name Define the name of the uniform as defined in the shader
  11827. * @param value Define the value to give to the uniform
  11828. * @return the texture itself allowing "fluent" like uniform updates
  11829. */
  11830. setVector2(name: string, value: Vector2): ProceduralTexture;
  11831. /**
  11832. * Set a vec3 in the shader from a Vector3.
  11833. * @param name Define the name of the uniform as defined in the shader
  11834. * @param value Define the value to give to the uniform
  11835. * @return the texture itself allowing "fluent" like uniform updates
  11836. */
  11837. setVector3(name: string, value: Vector3): ProceduralTexture;
  11838. /**
  11839. * Set a mat4 in the shader from a MAtrix.
  11840. * @param name Define the name of the uniform as defined in the shader
  11841. * @param value Define the value to give to the uniform
  11842. * @return the texture itself allowing "fluent" like uniform updates
  11843. */
  11844. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11845. /**
  11846. * Render the texture to its associated render target.
  11847. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11848. */
  11849. render(useCameraPostProcess?: boolean): void;
  11850. /**
  11851. * Clone the texture.
  11852. * @returns the cloned texture
  11853. */
  11854. clone(): ProceduralTexture;
  11855. /**
  11856. * Dispose the texture and release its asoociated resources.
  11857. */
  11858. dispose(): void;
  11859. }
  11860. }
  11861. declare module BABYLON {
  11862. /**
  11863. * This represents the base class for particle system in Babylon.
  11864. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11865. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11866. * @example https://doc.babylonjs.com/babylon101/particles
  11867. */
  11868. export class BaseParticleSystem {
  11869. /**
  11870. * Source color is added to the destination color without alpha affecting the result
  11871. */
  11872. static BLENDMODE_ONEONE: number;
  11873. /**
  11874. * Blend current color and particle color using particle’s alpha
  11875. */
  11876. static BLENDMODE_STANDARD: number;
  11877. /**
  11878. * Add current color and particle color multiplied by particle’s alpha
  11879. */
  11880. static BLENDMODE_ADD: number;
  11881. /**
  11882. * Multiply current color with particle color
  11883. */
  11884. static BLENDMODE_MULTIPLY: number;
  11885. /**
  11886. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11887. */
  11888. static BLENDMODE_MULTIPLYADD: number;
  11889. /**
  11890. * List of animations used by the particle system.
  11891. */
  11892. animations: Animation[];
  11893. /**
  11894. * Gets or sets the unique id of the particle system
  11895. */
  11896. uniqueId: number;
  11897. /**
  11898. * The id of the Particle system.
  11899. */
  11900. id: string;
  11901. /**
  11902. * The friendly name of the Particle system.
  11903. */
  11904. name: string;
  11905. /**
  11906. * Snippet ID if the particle system was created from the snippet server
  11907. */
  11908. snippetId: string;
  11909. /**
  11910. * The rendering group used by the Particle system to chose when to render.
  11911. */
  11912. renderingGroupId: number;
  11913. /**
  11914. * The emitter represents the Mesh or position we are attaching the particle system to.
  11915. */
  11916. emitter: Nullable<AbstractMesh | Vector3>;
  11917. /**
  11918. * The maximum number of particles to emit per frame
  11919. */
  11920. emitRate: number;
  11921. /**
  11922. * If you want to launch only a few particles at once, that can be done, as well.
  11923. */
  11924. manualEmitCount: number;
  11925. /**
  11926. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11927. */
  11928. updateSpeed: number;
  11929. /**
  11930. * The amount of time the particle system is running (depends of the overall update speed).
  11931. */
  11932. targetStopDuration: number;
  11933. /**
  11934. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11935. */
  11936. disposeOnStop: boolean;
  11937. /**
  11938. * Minimum power of emitting particles.
  11939. */
  11940. minEmitPower: number;
  11941. /**
  11942. * Maximum power of emitting particles.
  11943. */
  11944. maxEmitPower: number;
  11945. /**
  11946. * Minimum life time of emitting particles.
  11947. */
  11948. minLifeTime: number;
  11949. /**
  11950. * Maximum life time of emitting particles.
  11951. */
  11952. maxLifeTime: number;
  11953. /**
  11954. * Minimum Size of emitting particles.
  11955. */
  11956. minSize: number;
  11957. /**
  11958. * Maximum Size of emitting particles.
  11959. */
  11960. maxSize: number;
  11961. /**
  11962. * Minimum scale of emitting particles on X axis.
  11963. */
  11964. minScaleX: number;
  11965. /**
  11966. * Maximum scale of emitting particles on X axis.
  11967. */
  11968. maxScaleX: number;
  11969. /**
  11970. * Minimum scale of emitting particles on Y axis.
  11971. */
  11972. minScaleY: number;
  11973. /**
  11974. * Maximum scale of emitting particles on Y axis.
  11975. */
  11976. maxScaleY: number;
  11977. /**
  11978. * Gets or sets the minimal initial rotation in radians.
  11979. */
  11980. minInitialRotation: number;
  11981. /**
  11982. * Gets or sets the maximal initial rotation in radians.
  11983. */
  11984. maxInitialRotation: number;
  11985. /**
  11986. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11987. */
  11988. minAngularSpeed: number;
  11989. /**
  11990. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11991. */
  11992. maxAngularSpeed: number;
  11993. /**
  11994. * The texture used to render each particle. (this can be a spritesheet)
  11995. */
  11996. particleTexture: Nullable<BaseTexture>;
  11997. /**
  11998. * The layer mask we are rendering the particles through.
  11999. */
  12000. layerMask: number;
  12001. /**
  12002. * This can help using your own shader to render the particle system.
  12003. * The according effect will be created
  12004. */
  12005. customShader: any;
  12006. /**
  12007. * By default particle system starts as soon as they are created. This prevents the
  12008. * automatic start to happen and let you decide when to start emitting particles.
  12009. */
  12010. preventAutoStart: boolean;
  12011. private _noiseTexture;
  12012. /**
  12013. * Gets or sets a texture used to add random noise to particle positions
  12014. */
  12015. get noiseTexture(): Nullable<ProceduralTexture>;
  12016. set noiseTexture(value: Nullable<ProceduralTexture>);
  12017. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12018. noiseStrength: Vector3;
  12019. /**
  12020. * Callback triggered when the particle animation is ending.
  12021. */
  12022. onAnimationEnd: Nullable<() => void>;
  12023. /**
  12024. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12025. */
  12026. blendMode: number;
  12027. /**
  12028. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12029. * to override the particles.
  12030. */
  12031. forceDepthWrite: boolean;
  12032. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  12033. preWarmCycles: number;
  12034. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12035. preWarmStepOffset: number;
  12036. /**
  12037. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  12038. */
  12039. spriteCellChangeSpeed: number;
  12040. /**
  12041. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12042. */
  12043. startSpriteCellID: number;
  12044. /**
  12045. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12046. */
  12047. endSpriteCellID: number;
  12048. /**
  12049. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12050. */
  12051. spriteCellWidth: number;
  12052. /**
  12053. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12054. */
  12055. spriteCellHeight: number;
  12056. /**
  12057. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12058. */
  12059. spriteRandomStartCell: boolean;
  12060. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12061. translationPivot: Vector2;
  12062. /** @hidden */
  12063. protected _isAnimationSheetEnabled: boolean;
  12064. /**
  12065. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12066. */
  12067. beginAnimationOnStart: boolean;
  12068. /**
  12069. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12070. */
  12071. beginAnimationFrom: number;
  12072. /**
  12073. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12074. */
  12075. beginAnimationTo: number;
  12076. /**
  12077. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12078. */
  12079. beginAnimationLoop: boolean;
  12080. /**
  12081. * Gets or sets a world offset applied to all particles
  12082. */
  12083. worldOffset: Vector3;
  12084. /**
  12085. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12086. */
  12087. get isAnimationSheetEnabled(): boolean;
  12088. set isAnimationSheetEnabled(value: boolean);
  12089. /**
  12090. * Get hosting scene
  12091. * @returns the scene
  12092. */
  12093. getScene(): Nullable<Scene>;
  12094. /**
  12095. * You can use gravity if you want to give an orientation to your particles.
  12096. */
  12097. gravity: Vector3;
  12098. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12099. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12100. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12101. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12102. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12103. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12104. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12105. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12106. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12107. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12108. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12109. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12110. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12111. /**
  12112. * Defines the delay in milliseconds before starting the system (0 by default)
  12113. */
  12114. startDelay: number;
  12115. /**
  12116. * Gets the current list of drag gradients.
  12117. * You must use addDragGradient and removeDragGradient to udpate this list
  12118. * @returns the list of drag gradients
  12119. */
  12120. getDragGradients(): Nullable<Array<FactorGradient>>;
  12121. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12122. limitVelocityDamping: number;
  12123. /**
  12124. * Gets the current list of limit velocity gradients.
  12125. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12126. * @returns the list of limit velocity gradients
  12127. */
  12128. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12129. /**
  12130. * Gets the current list of color gradients.
  12131. * You must use addColorGradient and removeColorGradient to udpate this list
  12132. * @returns the list of color gradients
  12133. */
  12134. getColorGradients(): Nullable<Array<ColorGradient>>;
  12135. /**
  12136. * Gets the current list of size gradients.
  12137. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12138. * @returns the list of size gradients
  12139. */
  12140. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12141. /**
  12142. * Gets the current list of color remap gradients.
  12143. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12144. * @returns the list of color remap gradients
  12145. */
  12146. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12147. /**
  12148. * Gets the current list of alpha remap gradients.
  12149. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12150. * @returns the list of alpha remap gradients
  12151. */
  12152. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12153. /**
  12154. * Gets the current list of life time gradients.
  12155. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12156. * @returns the list of life time gradients
  12157. */
  12158. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12159. /**
  12160. * Gets the current list of angular speed gradients.
  12161. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12162. * @returns the list of angular speed gradients
  12163. */
  12164. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12165. /**
  12166. * Gets the current list of velocity gradients.
  12167. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12168. * @returns the list of velocity gradients
  12169. */
  12170. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12171. /**
  12172. * Gets the current list of start size gradients.
  12173. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12174. * @returns the list of start size gradients
  12175. */
  12176. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12177. /**
  12178. * Gets the current list of emit rate gradients.
  12179. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12180. * @returns the list of emit rate gradients
  12181. */
  12182. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12183. /**
  12184. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12185. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12186. */
  12187. get direction1(): Vector3;
  12188. set direction1(value: Vector3);
  12189. /**
  12190. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12191. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12192. */
  12193. get direction2(): Vector3;
  12194. set direction2(value: Vector3);
  12195. /**
  12196. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12197. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12198. */
  12199. get minEmitBox(): Vector3;
  12200. set minEmitBox(value: Vector3);
  12201. /**
  12202. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12203. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12204. */
  12205. get maxEmitBox(): Vector3;
  12206. set maxEmitBox(value: Vector3);
  12207. /**
  12208. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12209. */
  12210. color1: Color4;
  12211. /**
  12212. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12213. */
  12214. color2: Color4;
  12215. /**
  12216. * Color the particle will have at the end of its lifetime
  12217. */
  12218. colorDead: Color4;
  12219. /**
  12220. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12221. */
  12222. textureMask: Color4;
  12223. /**
  12224. * The particle emitter type defines the emitter used by the particle system.
  12225. * It can be for example box, sphere, or cone...
  12226. */
  12227. particleEmitterType: IParticleEmitterType;
  12228. /** @hidden */
  12229. _isSubEmitter: boolean;
  12230. /**
  12231. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12232. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12233. */
  12234. billboardMode: number;
  12235. protected _isBillboardBased: boolean;
  12236. /**
  12237. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12238. */
  12239. get isBillboardBased(): boolean;
  12240. set isBillboardBased(value: boolean);
  12241. /**
  12242. * The scene the particle system belongs to.
  12243. */
  12244. protected _scene: Nullable<Scene>;
  12245. /**
  12246. * The engine the particle system belongs to.
  12247. */
  12248. protected _engine: ThinEngine;
  12249. /**
  12250. * Local cache of defines for image processing.
  12251. */
  12252. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12253. /**
  12254. * Default configuration related to image processing available in the standard Material.
  12255. */
  12256. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12257. /**
  12258. * Gets the image processing configuration used either in this material.
  12259. */
  12260. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12261. /**
  12262. * Sets the Default image processing configuration used either in the this material.
  12263. *
  12264. * If sets to null, the scene one is in use.
  12265. */
  12266. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12267. /**
  12268. * Attaches a new image processing configuration to the Standard Material.
  12269. * @param configuration
  12270. */
  12271. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12272. /** @hidden */
  12273. protected _reset(): void;
  12274. /** @hidden */
  12275. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12276. /**
  12277. * Instantiates a particle system.
  12278. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12279. * @param name The name of the particle system
  12280. */
  12281. constructor(name: string);
  12282. /**
  12283. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12284. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12285. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12286. * @returns the emitter
  12287. */
  12288. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12289. /**
  12290. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12291. * @param radius The radius of the hemisphere to emit from
  12292. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12293. * @returns the emitter
  12294. */
  12295. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12296. /**
  12297. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12298. * @param radius The radius of the sphere to emit from
  12299. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12300. * @returns the emitter
  12301. */
  12302. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12303. /**
  12304. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12305. * @param radius The radius of the sphere to emit from
  12306. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12307. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12308. * @returns the emitter
  12309. */
  12310. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12311. /**
  12312. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12313. * @param radius The radius of the emission cylinder
  12314. * @param height The height of the emission cylinder
  12315. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12316. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12317. * @returns the emitter
  12318. */
  12319. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12320. /**
  12321. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12322. * @param radius The radius of the cylinder to emit from
  12323. * @param height The height of the emission cylinder
  12324. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12325. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12326. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12327. * @returns the emitter
  12328. */
  12329. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12330. /**
  12331. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12332. * @param radius The radius of the cone to emit from
  12333. * @param angle The base angle of the cone
  12334. * @returns the emitter
  12335. */
  12336. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12337. /**
  12338. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12339. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12340. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12341. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12342. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12343. * @returns the emitter
  12344. */
  12345. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12346. }
  12347. }
  12348. declare module BABYLON {
  12349. /**
  12350. * Type of sub emitter
  12351. */
  12352. export enum SubEmitterType {
  12353. /**
  12354. * Attached to the particle over it's lifetime
  12355. */
  12356. ATTACHED = 0,
  12357. /**
  12358. * Created when the particle dies
  12359. */
  12360. END = 1
  12361. }
  12362. /**
  12363. * Sub emitter class used to emit particles from an existing particle
  12364. */
  12365. export class SubEmitter {
  12366. /**
  12367. * the particle system to be used by the sub emitter
  12368. */
  12369. particleSystem: ParticleSystem;
  12370. /**
  12371. * Type of the submitter (Default: END)
  12372. */
  12373. type: SubEmitterType;
  12374. /**
  12375. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  12376. * Note: This only is supported when using an emitter of type Mesh
  12377. */
  12378. inheritDirection: boolean;
  12379. /**
  12380. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12381. */
  12382. inheritedVelocityAmount: number;
  12383. /**
  12384. * Creates a sub emitter
  12385. * @param particleSystem the particle system to be used by the sub emitter
  12386. */
  12387. constructor(
  12388. /**
  12389. * the particle system to be used by the sub emitter
  12390. */
  12391. particleSystem: ParticleSystem);
  12392. /**
  12393. * Clones the sub emitter
  12394. * @returns the cloned sub emitter
  12395. */
  12396. clone(): SubEmitter;
  12397. /**
  12398. * Serialize current object to a JSON object
  12399. * @returns the serialized object
  12400. */
  12401. serialize(): any;
  12402. /** @hidden */
  12403. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12404. /**
  12405. * Creates a new SubEmitter from a serialized JSON version
  12406. * @param serializationObject defines the JSON object to read from
  12407. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12408. * @param rootUrl defines the rootUrl for data loading
  12409. * @returns a new SubEmitter
  12410. */
  12411. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12412. /** Release associated resources */
  12413. dispose(): void;
  12414. }
  12415. }
  12416. declare module BABYLON {
  12417. /** @hidden */
  12418. export var imageProcessingDeclaration: {
  12419. name: string;
  12420. shader: string;
  12421. };
  12422. }
  12423. declare module BABYLON {
  12424. /** @hidden */
  12425. export var imageProcessingFunctions: {
  12426. name: string;
  12427. shader: string;
  12428. };
  12429. }
  12430. declare module BABYLON {
  12431. /** @hidden */
  12432. export var particlesPixelShader: {
  12433. name: string;
  12434. shader: string;
  12435. };
  12436. }
  12437. declare module BABYLON {
  12438. /** @hidden */
  12439. export var particlesVertexShader: {
  12440. name: string;
  12441. shader: string;
  12442. };
  12443. }
  12444. declare module BABYLON {
  12445. /**
  12446. * Interface used to define entities containing multiple clip planes
  12447. */
  12448. export interface IClipPlanesHolder {
  12449. /**
  12450. * Gets or sets the active clipplane 1
  12451. */
  12452. clipPlane: Nullable<Plane>;
  12453. /**
  12454. * Gets or sets the active clipplane 2
  12455. */
  12456. clipPlane2: Nullable<Plane>;
  12457. /**
  12458. * Gets or sets the active clipplane 3
  12459. */
  12460. clipPlane3: Nullable<Plane>;
  12461. /**
  12462. * Gets or sets the active clipplane 4
  12463. */
  12464. clipPlane4: Nullable<Plane>;
  12465. /**
  12466. * Gets or sets the active clipplane 5
  12467. */
  12468. clipPlane5: Nullable<Plane>;
  12469. /**
  12470. * Gets or sets the active clipplane 6
  12471. */
  12472. clipPlane6: Nullable<Plane>;
  12473. }
  12474. }
  12475. declare module BABYLON {
  12476. /**
  12477. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12478. *
  12479. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12480. *
  12481. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12482. */
  12483. export class ThinMaterialHelper {
  12484. /**
  12485. * Binds the clip plane information from the holder to the effect.
  12486. * @param effect The effect we are binding the data to
  12487. * @param holder The entity containing the clip plane information
  12488. */
  12489. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12490. }
  12491. }
  12492. declare module BABYLON {
  12493. interface ThinEngine {
  12494. /**
  12495. * Sets alpha constants used by some alpha blending modes
  12496. * @param r defines the red component
  12497. * @param g defines the green component
  12498. * @param b defines the blue component
  12499. * @param a defines the alpha component
  12500. */
  12501. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12502. /**
  12503. * Sets the current alpha mode
  12504. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12505. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12506. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12507. */
  12508. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12509. /**
  12510. * Gets the current alpha mode
  12511. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12512. * @returns the current alpha mode
  12513. */
  12514. getAlphaMode(): number;
  12515. /**
  12516. * Sets the current alpha equation
  12517. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12518. */
  12519. setAlphaEquation(equation: number): void;
  12520. /**
  12521. * Gets the current alpha equation.
  12522. * @returns the current alpha equation
  12523. */
  12524. getAlphaEquation(): number;
  12525. }
  12526. }
  12527. declare module BABYLON {
  12528. /**
  12529. * This represents a particle system in Babylon.
  12530. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12531. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12532. * @example https://doc.babylonjs.com/babylon101/particles
  12533. */
  12534. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12535. /**
  12536. * Billboard mode will only apply to Y axis
  12537. */
  12538. static readonly BILLBOARDMODE_Y: number;
  12539. /**
  12540. * Billboard mode will apply to all axes
  12541. */
  12542. static readonly BILLBOARDMODE_ALL: number;
  12543. /**
  12544. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12545. */
  12546. static readonly BILLBOARDMODE_STRETCHED: number;
  12547. /**
  12548. * This function can be defined to provide custom update for active particles.
  12549. * This function will be called instead of regular update (age, position, color, etc.).
  12550. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12551. */
  12552. updateFunction: (particles: Particle[]) => void;
  12553. private _emitterWorldMatrix;
  12554. /**
  12555. * This function can be defined to specify initial direction for every new particle.
  12556. * It by default use the emitterType defined function
  12557. */
  12558. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12559. /**
  12560. * This function can be defined to specify initial position for every new particle.
  12561. * It by default use the emitterType defined function
  12562. */
  12563. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12564. /**
  12565. * @hidden
  12566. */
  12567. _inheritedVelocityOffset: Vector3;
  12568. /**
  12569. * An event triggered when the system is disposed
  12570. */
  12571. onDisposeObservable: Observable<IParticleSystem>;
  12572. private _onDisposeObserver;
  12573. /**
  12574. * Sets a callback that will be triggered when the system is disposed
  12575. */
  12576. set onDispose(callback: () => void);
  12577. private _particles;
  12578. private _epsilon;
  12579. private _capacity;
  12580. private _stockParticles;
  12581. private _newPartsExcess;
  12582. private _vertexData;
  12583. private _vertexBuffer;
  12584. private _vertexBuffers;
  12585. private _spriteBuffer;
  12586. private _indexBuffer;
  12587. private _effect;
  12588. private _customEffect;
  12589. private _cachedDefines;
  12590. private _scaledColorStep;
  12591. private _colorDiff;
  12592. private _scaledDirection;
  12593. private _scaledGravity;
  12594. private _currentRenderId;
  12595. private _alive;
  12596. private _useInstancing;
  12597. private _started;
  12598. private _stopped;
  12599. private _actualFrame;
  12600. private _scaledUpdateSpeed;
  12601. private _vertexBufferSize;
  12602. /** @hidden */
  12603. _currentEmitRateGradient: Nullable<FactorGradient>;
  12604. /** @hidden */
  12605. _currentEmitRate1: number;
  12606. /** @hidden */
  12607. _currentEmitRate2: number;
  12608. /** @hidden */
  12609. _currentStartSizeGradient: Nullable<FactorGradient>;
  12610. /** @hidden */
  12611. _currentStartSize1: number;
  12612. /** @hidden */
  12613. _currentStartSize2: number;
  12614. private readonly _rawTextureWidth;
  12615. private _rampGradientsTexture;
  12616. private _useRampGradients;
  12617. /** Gets or sets a matrix to use to compute projection */
  12618. defaultProjectionMatrix: Matrix;
  12619. /** Gets or sets a matrix to use to compute view */
  12620. defaultViewMatrix: Matrix;
  12621. /** Gets or sets a boolean indicating that ramp gradients must be used
  12622. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12623. */
  12624. get useRampGradients(): boolean;
  12625. set useRampGradients(value: boolean);
  12626. /**
  12627. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  12628. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  12629. */
  12630. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12631. private _subEmitters;
  12632. /**
  12633. * @hidden
  12634. * If the particle systems emitter should be disposed when the particle system is disposed
  12635. */
  12636. _disposeEmitterOnDispose: boolean;
  12637. /**
  12638. * The current active Sub-systems, this property is used by the root particle system only.
  12639. */
  12640. activeSubSystems: Array<ParticleSystem>;
  12641. /**
  12642. * Specifies if the particles are updated in emitter local space or world space
  12643. */
  12644. isLocal: boolean;
  12645. private _rootParticleSystem;
  12646. /**
  12647. * Gets the current list of active particles
  12648. */
  12649. get particles(): Particle[];
  12650. /**
  12651. * Gets the number of particles active at the same time.
  12652. * @returns The number of active particles.
  12653. */
  12654. getActiveCount(): number;
  12655. /**
  12656. * Returns the string "ParticleSystem"
  12657. * @returns a string containing the class name
  12658. */
  12659. getClassName(): string;
  12660. /**
  12661. * Gets a boolean indicating that the system is stopping
  12662. * @returns true if the system is currently stopping
  12663. */
  12664. isStopping(): boolean;
  12665. /**
  12666. * Gets the custom effect used to render the particles
  12667. * @param blendMode Blend mode for which the effect should be retrieved
  12668. * @returns The effect
  12669. */
  12670. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12671. /**
  12672. * Sets the custom effect used to render the particles
  12673. * @param effect The effect to set
  12674. * @param blendMode Blend mode for which the effect should be set
  12675. */
  12676. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12677. /** @hidden */
  12678. private _onBeforeDrawParticlesObservable;
  12679. /**
  12680. * Observable that will be called just before the particles are drawn
  12681. */
  12682. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12683. /**
  12684. * Gets the name of the particle vertex shader
  12685. */
  12686. get vertexShaderName(): string;
  12687. /**
  12688. * Instantiates a particle system.
  12689. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  12690. * @param name The name of the particle system
  12691. * @param capacity The max number of particles alive at the same time
  12692. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12693. * @param customEffect a custom effect used to change the way particles are rendered by default
  12694. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12695. * @param epsilon Offset used to render the particles
  12696. */
  12697. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12698. private _addFactorGradient;
  12699. private _removeFactorGradient;
  12700. /**
  12701. * Adds a new life time gradient
  12702. * @param gradient defines the gradient to use (between 0 and 1)
  12703. * @param factor defines the life time factor to affect to the specified gradient
  12704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12705. * @returns the current particle system
  12706. */
  12707. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12708. /**
  12709. * Remove a specific life time gradient
  12710. * @param gradient defines the gradient to remove
  12711. * @returns the current particle system
  12712. */
  12713. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12714. /**
  12715. * Adds a new size gradient
  12716. * @param gradient defines the gradient to use (between 0 and 1)
  12717. * @param factor defines the size factor to affect to the specified gradient
  12718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12719. * @returns the current particle system
  12720. */
  12721. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12722. /**
  12723. * Remove a specific size gradient
  12724. * @param gradient defines the gradient to remove
  12725. * @returns the current particle system
  12726. */
  12727. removeSizeGradient(gradient: number): IParticleSystem;
  12728. /**
  12729. * Adds a new color remap gradient
  12730. * @param gradient defines the gradient to use (between 0 and 1)
  12731. * @param min defines the color remap minimal range
  12732. * @param max defines the color remap maximal range
  12733. * @returns the current particle system
  12734. */
  12735. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12736. /**
  12737. * Remove a specific color remap gradient
  12738. * @param gradient defines the gradient to remove
  12739. * @returns the current particle system
  12740. */
  12741. removeColorRemapGradient(gradient: number): IParticleSystem;
  12742. /**
  12743. * Adds a new alpha remap gradient
  12744. * @param gradient defines the gradient to use (between 0 and 1)
  12745. * @param min defines the alpha remap minimal range
  12746. * @param max defines the alpha remap maximal range
  12747. * @returns the current particle system
  12748. */
  12749. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12750. /**
  12751. * Remove a specific alpha remap gradient
  12752. * @param gradient defines the gradient to remove
  12753. * @returns the current particle system
  12754. */
  12755. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12756. /**
  12757. * Adds a new angular speed gradient
  12758. * @param gradient defines the gradient to use (between 0 and 1)
  12759. * @param factor defines the angular speed to affect to the specified gradient
  12760. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12761. * @returns the current particle system
  12762. */
  12763. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12764. /**
  12765. * Remove a specific angular speed gradient
  12766. * @param gradient defines the gradient to remove
  12767. * @returns the current particle system
  12768. */
  12769. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12770. /**
  12771. * Adds a new velocity gradient
  12772. * @param gradient defines the gradient to use (between 0 and 1)
  12773. * @param factor defines the velocity to affect to the specified gradient
  12774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12775. * @returns the current particle system
  12776. */
  12777. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12778. /**
  12779. * Remove a specific velocity gradient
  12780. * @param gradient defines the gradient to remove
  12781. * @returns the current particle system
  12782. */
  12783. removeVelocityGradient(gradient: number): IParticleSystem;
  12784. /**
  12785. * Adds a new limit velocity gradient
  12786. * @param gradient defines the gradient to use (between 0 and 1)
  12787. * @param factor defines the limit velocity value to affect to the specified gradient
  12788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12789. * @returns the current particle system
  12790. */
  12791. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12792. /**
  12793. * Remove a specific limit velocity gradient
  12794. * @param gradient defines the gradient to remove
  12795. * @returns the current particle system
  12796. */
  12797. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12798. /**
  12799. * Adds a new drag gradient
  12800. * @param gradient defines the gradient to use (between 0 and 1)
  12801. * @param factor defines the drag value to affect to the specified gradient
  12802. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12803. * @returns the current particle system
  12804. */
  12805. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12806. /**
  12807. * Remove a specific drag gradient
  12808. * @param gradient defines the gradient to remove
  12809. * @returns the current particle system
  12810. */
  12811. removeDragGradient(gradient: number): IParticleSystem;
  12812. /**
  12813. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12814. * @param gradient defines the gradient to use (between 0 and 1)
  12815. * @param factor defines the emit rate value to affect to the specified gradient
  12816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12817. * @returns the current particle system
  12818. */
  12819. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12820. /**
  12821. * Remove a specific emit rate gradient
  12822. * @param gradient defines the gradient to remove
  12823. * @returns the current particle system
  12824. */
  12825. removeEmitRateGradient(gradient: number): IParticleSystem;
  12826. /**
  12827. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12828. * @param gradient defines the gradient to use (between 0 and 1)
  12829. * @param factor defines the start size value to affect to the specified gradient
  12830. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12831. * @returns the current particle system
  12832. */
  12833. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12834. /**
  12835. * Remove a specific start size gradient
  12836. * @param gradient defines the gradient to remove
  12837. * @returns the current particle system
  12838. */
  12839. removeStartSizeGradient(gradient: number): IParticleSystem;
  12840. private _createRampGradientTexture;
  12841. /**
  12842. * Gets the current list of ramp gradients.
  12843. * You must use addRampGradient and removeRampGradient to udpate this list
  12844. * @returns the list of ramp gradients
  12845. */
  12846. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12847. /** Force the system to rebuild all gradients that need to be resync */
  12848. forceRefreshGradients(): void;
  12849. private _syncRampGradientTexture;
  12850. /**
  12851. * Adds a new ramp gradient used to remap particle colors
  12852. * @param gradient defines the gradient to use (between 0 and 1)
  12853. * @param color defines the color to affect to the specified gradient
  12854. * @returns the current particle system
  12855. */
  12856. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12857. /**
  12858. * Remove a specific ramp gradient
  12859. * @param gradient defines the gradient to remove
  12860. * @returns the current particle system
  12861. */
  12862. removeRampGradient(gradient: number): ParticleSystem;
  12863. /**
  12864. * Adds a new color gradient
  12865. * @param gradient defines the gradient to use (between 0 and 1)
  12866. * @param color1 defines the color to affect to the specified gradient
  12867. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12868. * @returns this particle system
  12869. */
  12870. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12871. /**
  12872. * Remove a specific color gradient
  12873. * @param gradient defines the gradient to remove
  12874. * @returns this particle system
  12875. */
  12876. removeColorGradient(gradient: number): IParticleSystem;
  12877. private _fetchR;
  12878. protected _reset(): void;
  12879. private _resetEffect;
  12880. private _createVertexBuffers;
  12881. private _createIndexBuffer;
  12882. /**
  12883. * Gets the maximum number of particles active at the same time.
  12884. * @returns The max number of active particles.
  12885. */
  12886. getCapacity(): number;
  12887. /**
  12888. * Gets whether there are still active particles in the system.
  12889. * @returns True if it is alive, otherwise false.
  12890. */
  12891. isAlive(): boolean;
  12892. /**
  12893. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12894. * @returns True if it has been started, otherwise false.
  12895. */
  12896. isStarted(): boolean;
  12897. private _prepareSubEmitterInternalArray;
  12898. /**
  12899. * Starts the particle system and begins to emit
  12900. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12901. */
  12902. start(delay?: number): void;
  12903. /**
  12904. * Stops the particle system.
  12905. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  12906. */
  12907. stop(stopSubEmitters?: boolean): void;
  12908. /**
  12909. * Remove all active particles
  12910. */
  12911. reset(): void;
  12912. /**
  12913. * @hidden (for internal use only)
  12914. */
  12915. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12916. /**
  12917. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12918. * Its lifetime will start back at 0.
  12919. */
  12920. recycleParticle: (particle: Particle) => void;
  12921. private _stopSubEmitters;
  12922. private _createParticle;
  12923. private _removeFromRoot;
  12924. private _emitFromParticle;
  12925. private _update;
  12926. /** @hidden */
  12927. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12928. /** @hidden */
  12929. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12930. /**
  12931. * Fill the defines array according to the current settings of the particle system
  12932. * @param defines Array to be updated
  12933. * @param blendMode blend mode to take into account when updating the array
  12934. */
  12935. fillDefines(defines: Array<string>, blendMode: number): void;
  12936. /**
  12937. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12938. * @param uniforms Uniforms array to fill
  12939. * @param attributes Attributes array to fill
  12940. * @param samplers Samplers array to fill
  12941. */
  12942. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12943. /** @hidden */
  12944. private _getEffect;
  12945. /**
  12946. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12947. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12948. */
  12949. animate(preWarmOnly?: boolean): void;
  12950. private _appendParticleVertices;
  12951. /**
  12952. * Rebuilds the particle system.
  12953. */
  12954. rebuild(): void;
  12955. /**
  12956. * Is this system ready to be used/rendered
  12957. * @return true if the system is ready
  12958. */
  12959. isReady(): boolean;
  12960. private _render;
  12961. /**
  12962. * Renders the particle system in its current state.
  12963. * @returns the current number of particles
  12964. */
  12965. render(): number;
  12966. /**
  12967. * Disposes the particle system and free the associated resources
  12968. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12969. */
  12970. dispose(disposeTexture?: boolean): void;
  12971. /**
  12972. * Clones the particle system.
  12973. * @param name The name of the cloned object
  12974. * @param newEmitter The new emitter to use
  12975. * @returns the cloned particle system
  12976. */
  12977. clone(name: string, newEmitter: any): ParticleSystem;
  12978. /**
  12979. * Serializes the particle system to a JSON object
  12980. * @param serializeTexture defines if the texture must be serialized as well
  12981. * @returns the JSON object
  12982. */
  12983. serialize(serializeTexture?: boolean): any;
  12984. /** @hidden */
  12985. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12986. /** @hidden */
  12987. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  12988. /**
  12989. * Parses a JSON object to create a particle system.
  12990. * @param parsedParticleSystem The JSON object to parse
  12991. * @param sceneOrEngine The scene or the engine to create the particle system in
  12992. * @param rootUrl The root url to use to load external dependencies like texture
  12993. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12994. * @returns the Parsed particle system
  12995. */
  12996. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12997. }
  12998. }
  12999. declare module BABYLON {
  13000. /**
  13001. * A particle represents one of the element emitted by a particle system.
  13002. * This is mainly define by its coordinates, direction, velocity and age.
  13003. */
  13004. export class Particle {
  13005. /**
  13006. * The particle system the particle belongs to.
  13007. */
  13008. particleSystem: ParticleSystem;
  13009. private static _Count;
  13010. /**
  13011. * Unique ID of the particle
  13012. */
  13013. id: number;
  13014. /**
  13015. * The world position of the particle in the scene.
  13016. */
  13017. position: Vector3;
  13018. /**
  13019. * The world direction of the particle in the scene.
  13020. */
  13021. direction: Vector3;
  13022. /**
  13023. * The color of the particle.
  13024. */
  13025. color: Color4;
  13026. /**
  13027. * The color change of the particle per step.
  13028. */
  13029. colorStep: Color4;
  13030. /**
  13031. * Defines how long will the life of the particle be.
  13032. */
  13033. lifeTime: number;
  13034. /**
  13035. * The current age of the particle.
  13036. */
  13037. age: number;
  13038. /**
  13039. * The current size of the particle.
  13040. */
  13041. size: number;
  13042. /**
  13043. * The current scale of the particle.
  13044. */
  13045. scale: Vector2;
  13046. /**
  13047. * The current angle of the particle.
  13048. */
  13049. angle: number;
  13050. /**
  13051. * Defines how fast is the angle changing.
  13052. */
  13053. angularSpeed: number;
  13054. /**
  13055. * Defines the cell index used by the particle to be rendered from a sprite.
  13056. */
  13057. cellIndex: number;
  13058. /**
  13059. * The information required to support color remapping
  13060. */
  13061. remapData: Vector4;
  13062. /** @hidden */
  13063. _randomCellOffset?: number;
  13064. /** @hidden */
  13065. _initialDirection: Nullable<Vector3>;
  13066. /** @hidden */
  13067. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13068. /** @hidden */
  13069. _initialStartSpriteCellID: number;
  13070. /** @hidden */
  13071. _initialEndSpriteCellID: number;
  13072. /** @hidden */
  13073. _currentColorGradient: Nullable<ColorGradient>;
  13074. /** @hidden */
  13075. _currentColor1: Color4;
  13076. /** @hidden */
  13077. _currentColor2: Color4;
  13078. /** @hidden */
  13079. _currentSizeGradient: Nullable<FactorGradient>;
  13080. /** @hidden */
  13081. _currentSize1: number;
  13082. /** @hidden */
  13083. _currentSize2: number;
  13084. /** @hidden */
  13085. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13086. /** @hidden */
  13087. _currentAngularSpeed1: number;
  13088. /** @hidden */
  13089. _currentAngularSpeed2: number;
  13090. /** @hidden */
  13091. _currentVelocityGradient: Nullable<FactorGradient>;
  13092. /** @hidden */
  13093. _currentVelocity1: number;
  13094. /** @hidden */
  13095. _currentVelocity2: number;
  13096. /** @hidden */
  13097. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13098. /** @hidden */
  13099. _currentLimitVelocity1: number;
  13100. /** @hidden */
  13101. _currentLimitVelocity2: number;
  13102. /** @hidden */
  13103. _currentDragGradient: Nullable<FactorGradient>;
  13104. /** @hidden */
  13105. _currentDrag1: number;
  13106. /** @hidden */
  13107. _currentDrag2: number;
  13108. /** @hidden */
  13109. _randomNoiseCoordinates1: Vector3;
  13110. /** @hidden */
  13111. _randomNoiseCoordinates2: Vector3;
  13112. /** @hidden */
  13113. _localPosition?: Vector3;
  13114. /**
  13115. * Creates a new instance Particle
  13116. * @param particleSystem the particle system the particle belongs to
  13117. */
  13118. constructor(
  13119. /**
  13120. * The particle system the particle belongs to.
  13121. */
  13122. particleSystem: ParticleSystem);
  13123. private updateCellInfoFromSystem;
  13124. /**
  13125. * Defines how the sprite cell index is updated for the particle
  13126. */
  13127. updateCellIndex(): void;
  13128. /** @hidden */
  13129. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13130. /** @hidden */
  13131. _inheritParticleInfoToSubEmitters(): void;
  13132. /** @hidden */
  13133. _reset(): void;
  13134. /**
  13135. * Copy the properties of particle to another one.
  13136. * @param other the particle to copy the information to.
  13137. */
  13138. copyTo(other: Particle): void;
  13139. }
  13140. }
  13141. declare module BABYLON {
  13142. /**
  13143. * Particle emitter represents a volume emitting particles.
  13144. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13145. */
  13146. export interface IParticleEmitterType {
  13147. /**
  13148. * Called by the particle System when the direction is computed for the created particle.
  13149. * @param worldMatrix is the world matrix of the particle system
  13150. * @param directionToUpdate is the direction vector to update with the result
  13151. * @param particle is the particle we are computed the direction for
  13152. * @param isLocal defines if the direction should be set in local space
  13153. */
  13154. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13155. /**
  13156. * Called by the particle System when the position is computed for the created particle.
  13157. * @param worldMatrix is the world matrix of the particle system
  13158. * @param positionToUpdate is the position vector to update with the result
  13159. * @param particle is the particle we are computed the position for
  13160. * @param isLocal defines if the position should be set in local space
  13161. */
  13162. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13163. /**
  13164. * Clones the current emitter and returns a copy of it
  13165. * @returns the new emitter
  13166. */
  13167. clone(): IParticleEmitterType;
  13168. /**
  13169. * Called by the GPUParticleSystem to setup the update shader
  13170. * @param effect defines the update shader
  13171. */
  13172. applyToShader(effect: Effect): void;
  13173. /**
  13174. * Returns a string to use to update the GPU particles update shader
  13175. * @returns the effect defines string
  13176. */
  13177. getEffectDefines(): string;
  13178. /**
  13179. * Returns a string representing the class name
  13180. * @returns a string containing the class name
  13181. */
  13182. getClassName(): string;
  13183. /**
  13184. * Serializes the particle system to a JSON object.
  13185. * @returns the JSON object
  13186. */
  13187. serialize(): any;
  13188. /**
  13189. * Parse properties from a JSON object
  13190. * @param serializationObject defines the JSON object
  13191. * @param scene defines the hosting scene
  13192. */
  13193. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13194. }
  13195. }
  13196. declare module BABYLON {
  13197. /**
  13198. * Particle emitter emitting particles from the inside of a box.
  13199. * It emits the particles randomly between 2 given directions.
  13200. */
  13201. export class BoxParticleEmitter implements IParticleEmitterType {
  13202. /**
  13203. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13204. */
  13205. direction1: Vector3;
  13206. /**
  13207. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13208. */
  13209. direction2: Vector3;
  13210. /**
  13211. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13212. */
  13213. minEmitBox: Vector3;
  13214. /**
  13215. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  13216. */
  13217. maxEmitBox: Vector3;
  13218. /**
  13219. * Creates a new instance BoxParticleEmitter
  13220. */
  13221. constructor();
  13222. /**
  13223. * Called by the particle System when the direction is computed for the created particle.
  13224. * @param worldMatrix is the world matrix of the particle system
  13225. * @param directionToUpdate is the direction vector to update with the result
  13226. * @param particle is the particle we are computed the direction for
  13227. * @param isLocal defines if the direction should be set in local space
  13228. */
  13229. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13230. /**
  13231. * Called by the particle System when the position is computed for the created particle.
  13232. * @param worldMatrix is the world matrix of the particle system
  13233. * @param positionToUpdate is the position vector to update with the result
  13234. * @param particle is the particle we are computed the position for
  13235. * @param isLocal defines if the position should be set in local space
  13236. */
  13237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13238. /**
  13239. * Clones the current emitter and returns a copy of it
  13240. * @returns the new emitter
  13241. */
  13242. clone(): BoxParticleEmitter;
  13243. /**
  13244. * Called by the GPUParticleSystem to setup the update shader
  13245. * @param effect defines the update shader
  13246. */
  13247. applyToShader(effect: Effect): void;
  13248. /**
  13249. * Returns a string to use to update the GPU particles update shader
  13250. * @returns a string containng the defines string
  13251. */
  13252. getEffectDefines(): string;
  13253. /**
  13254. * Returns the string "BoxParticleEmitter"
  13255. * @returns a string containing the class name
  13256. */
  13257. getClassName(): string;
  13258. /**
  13259. * Serializes the particle system to a JSON object.
  13260. * @returns the JSON object
  13261. */
  13262. serialize(): any;
  13263. /**
  13264. * Parse properties from a JSON object
  13265. * @param serializationObject defines the JSON object
  13266. */
  13267. parse(serializationObject: any): void;
  13268. }
  13269. }
  13270. declare module BABYLON {
  13271. /**
  13272. * Particle emitter emitting particles from the inside of a cone.
  13273. * It emits the particles alongside the cone volume from the base to the particle.
  13274. * The emission direction might be randomized.
  13275. */
  13276. export class ConeParticleEmitter implements IParticleEmitterType {
  13277. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13278. directionRandomizer: number;
  13279. private _radius;
  13280. private _angle;
  13281. private _height;
  13282. /**
  13283. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13284. */
  13285. radiusRange: number;
  13286. /**
  13287. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13288. */
  13289. heightRange: number;
  13290. /**
  13291. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13292. */
  13293. emitFromSpawnPointOnly: boolean;
  13294. /**
  13295. * Gets or sets the radius of the emission cone
  13296. */
  13297. get radius(): number;
  13298. set radius(value: number);
  13299. /**
  13300. * Gets or sets the angle of the emission cone
  13301. */
  13302. get angle(): number;
  13303. set angle(value: number);
  13304. private _buildHeight;
  13305. /**
  13306. * Creates a new instance ConeParticleEmitter
  13307. * @param radius the radius of the emission cone (1 by default)
  13308. * @param angle the cone base angle (PI by default)
  13309. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13310. */
  13311. constructor(radius?: number, angle?: number,
  13312. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13313. directionRandomizer?: number);
  13314. /**
  13315. * Called by the particle System when the direction is computed for the created particle.
  13316. * @param worldMatrix is the world matrix of the particle system
  13317. * @param directionToUpdate is the direction vector to update with the result
  13318. * @param particle is the particle we are computed the direction for
  13319. * @param isLocal defines if the direction should be set in local space
  13320. */
  13321. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13322. /**
  13323. * Called by the particle System when the position is computed for the created particle.
  13324. * @param worldMatrix is the world matrix of the particle system
  13325. * @param positionToUpdate is the position vector to update with the result
  13326. * @param particle is the particle we are computed the position for
  13327. * @param isLocal defines if the position should be set in local space
  13328. */
  13329. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13330. /**
  13331. * Clones the current emitter and returns a copy of it
  13332. * @returns the new emitter
  13333. */
  13334. clone(): ConeParticleEmitter;
  13335. /**
  13336. * Called by the GPUParticleSystem to setup the update shader
  13337. * @param effect defines the update shader
  13338. */
  13339. applyToShader(effect: Effect): void;
  13340. /**
  13341. * Returns a string to use to update the GPU particles update shader
  13342. * @returns a string containng the defines string
  13343. */
  13344. getEffectDefines(): string;
  13345. /**
  13346. * Returns the string "ConeParticleEmitter"
  13347. * @returns a string containing the class name
  13348. */
  13349. getClassName(): string;
  13350. /**
  13351. * Serializes the particle system to a JSON object.
  13352. * @returns the JSON object
  13353. */
  13354. serialize(): any;
  13355. /**
  13356. * Parse properties from a JSON object
  13357. * @param serializationObject defines the JSON object
  13358. */
  13359. parse(serializationObject: any): void;
  13360. }
  13361. }
  13362. declare module BABYLON {
  13363. /**
  13364. * Particle emitter emitting particles from the inside of a cylinder.
  13365. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13366. */
  13367. export class CylinderParticleEmitter implements IParticleEmitterType {
  13368. /**
  13369. * The radius of the emission cylinder.
  13370. */
  13371. radius: number;
  13372. /**
  13373. * The height of the emission cylinder.
  13374. */
  13375. height: number;
  13376. /**
  13377. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13378. */
  13379. radiusRange: number;
  13380. /**
  13381. * How much to randomize the particle direction [0-1].
  13382. */
  13383. directionRandomizer: number;
  13384. /**
  13385. * Creates a new instance CylinderParticleEmitter
  13386. * @param radius the radius of the emission cylinder (1 by default)
  13387. * @param height the height of the emission cylinder (1 by default)
  13388. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13389. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13390. */
  13391. constructor(
  13392. /**
  13393. * The radius of the emission cylinder.
  13394. */
  13395. radius?: number,
  13396. /**
  13397. * The height of the emission cylinder.
  13398. */
  13399. height?: number,
  13400. /**
  13401. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13402. */
  13403. radiusRange?: number,
  13404. /**
  13405. * How much to randomize the particle direction [0-1].
  13406. */
  13407. directionRandomizer?: number);
  13408. /**
  13409. * Called by the particle System when the direction is computed for the created particle.
  13410. * @param worldMatrix is the world matrix of the particle system
  13411. * @param directionToUpdate is the direction vector to update with the result
  13412. * @param particle is the particle we are computed the direction for
  13413. * @param isLocal defines if the direction should be set in local space
  13414. */
  13415. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13416. /**
  13417. * Called by the particle System when the position is computed for the created particle.
  13418. * @param worldMatrix is the world matrix of the particle system
  13419. * @param positionToUpdate is the position vector to update with the result
  13420. * @param particle is the particle we are computed the position for
  13421. * @param isLocal defines if the position should be set in local space
  13422. */
  13423. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13424. /**
  13425. * Clones the current emitter and returns a copy of it
  13426. * @returns the new emitter
  13427. */
  13428. clone(): CylinderParticleEmitter;
  13429. /**
  13430. * Called by the GPUParticleSystem to setup the update shader
  13431. * @param effect defines the update shader
  13432. */
  13433. applyToShader(effect: Effect): void;
  13434. /**
  13435. * Returns a string to use to update the GPU particles update shader
  13436. * @returns a string containng the defines string
  13437. */
  13438. getEffectDefines(): string;
  13439. /**
  13440. * Returns the string "CylinderParticleEmitter"
  13441. * @returns a string containing the class name
  13442. */
  13443. getClassName(): string;
  13444. /**
  13445. * Serializes the particle system to a JSON object.
  13446. * @returns the JSON object
  13447. */
  13448. serialize(): any;
  13449. /**
  13450. * Parse properties from a JSON object
  13451. * @param serializationObject defines the JSON object
  13452. */
  13453. parse(serializationObject: any): void;
  13454. }
  13455. /**
  13456. * Particle emitter emitting particles from the inside of a cylinder.
  13457. * It emits the particles randomly between two vectors.
  13458. */
  13459. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13460. /**
  13461. * The min limit of the emission direction.
  13462. */
  13463. direction1: Vector3;
  13464. /**
  13465. * The max limit of the emission direction.
  13466. */
  13467. direction2: Vector3;
  13468. /**
  13469. * Creates a new instance CylinderDirectedParticleEmitter
  13470. * @param radius the radius of the emission cylinder (1 by default)
  13471. * @param height the height of the emission cylinder (1 by default)
  13472. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13473. * @param direction1 the min limit of the emission direction (up vector by default)
  13474. * @param direction2 the max limit of the emission direction (up vector by default)
  13475. */
  13476. constructor(radius?: number, height?: number, radiusRange?: number,
  13477. /**
  13478. * The min limit of the emission direction.
  13479. */
  13480. direction1?: Vector3,
  13481. /**
  13482. * The max limit of the emission direction.
  13483. */
  13484. direction2?: Vector3);
  13485. /**
  13486. * Called by the particle System when the direction is computed for the created particle.
  13487. * @param worldMatrix is the world matrix of the particle system
  13488. * @param directionToUpdate is the direction vector to update with the result
  13489. * @param particle is the particle we are computed the direction for
  13490. */
  13491. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13492. /**
  13493. * Clones the current emitter and returns a copy of it
  13494. * @returns the new emitter
  13495. */
  13496. clone(): CylinderDirectedParticleEmitter;
  13497. /**
  13498. * Called by the GPUParticleSystem to setup the update shader
  13499. * @param effect defines the update shader
  13500. */
  13501. applyToShader(effect: Effect): void;
  13502. /**
  13503. * Returns a string to use to update the GPU particles update shader
  13504. * @returns a string containng the defines string
  13505. */
  13506. getEffectDefines(): string;
  13507. /**
  13508. * Returns the string "CylinderDirectedParticleEmitter"
  13509. * @returns a string containing the class name
  13510. */
  13511. getClassName(): string;
  13512. /**
  13513. * Serializes the particle system to a JSON object.
  13514. * @returns the JSON object
  13515. */
  13516. serialize(): any;
  13517. /**
  13518. * Parse properties from a JSON object
  13519. * @param serializationObject defines the JSON object
  13520. */
  13521. parse(serializationObject: any): void;
  13522. }
  13523. }
  13524. declare module BABYLON {
  13525. /**
  13526. * Particle emitter emitting particles from the inside of a hemisphere.
  13527. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13528. */
  13529. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13530. /**
  13531. * The radius of the emission hemisphere.
  13532. */
  13533. radius: number;
  13534. /**
  13535. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13536. */
  13537. radiusRange: number;
  13538. /**
  13539. * How much to randomize the particle direction [0-1].
  13540. */
  13541. directionRandomizer: number;
  13542. /**
  13543. * Creates a new instance HemisphericParticleEmitter
  13544. * @param radius the radius of the emission hemisphere (1 by default)
  13545. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13546. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13547. */
  13548. constructor(
  13549. /**
  13550. * The radius of the emission hemisphere.
  13551. */
  13552. radius?: number,
  13553. /**
  13554. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13555. */
  13556. radiusRange?: number,
  13557. /**
  13558. * How much to randomize the particle direction [0-1].
  13559. */
  13560. directionRandomizer?: number);
  13561. /**
  13562. * Called by the particle System when the direction is computed for the created particle.
  13563. * @param worldMatrix is the world matrix of the particle system
  13564. * @param directionToUpdate is the direction vector to update with the result
  13565. * @param particle is the particle we are computed the direction for
  13566. * @param isLocal defines if the direction should be set in local space
  13567. */
  13568. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13569. /**
  13570. * Called by the particle System when the position is computed for the created particle.
  13571. * @param worldMatrix is the world matrix of the particle system
  13572. * @param positionToUpdate is the position vector to update with the result
  13573. * @param particle is the particle we are computed the position for
  13574. * @param isLocal defines if the position should be set in local space
  13575. */
  13576. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13577. /**
  13578. * Clones the current emitter and returns a copy of it
  13579. * @returns the new emitter
  13580. */
  13581. clone(): HemisphericParticleEmitter;
  13582. /**
  13583. * Called by the GPUParticleSystem to setup the update shader
  13584. * @param effect defines the update shader
  13585. */
  13586. applyToShader(effect: Effect): void;
  13587. /**
  13588. * Returns a string to use to update the GPU particles update shader
  13589. * @returns a string containng the defines string
  13590. */
  13591. getEffectDefines(): string;
  13592. /**
  13593. * Returns the string "HemisphericParticleEmitter"
  13594. * @returns a string containing the class name
  13595. */
  13596. getClassName(): string;
  13597. /**
  13598. * Serializes the particle system to a JSON object.
  13599. * @returns the JSON object
  13600. */
  13601. serialize(): any;
  13602. /**
  13603. * Parse properties from a JSON object
  13604. * @param serializationObject defines the JSON object
  13605. */
  13606. parse(serializationObject: any): void;
  13607. }
  13608. }
  13609. declare module BABYLON {
  13610. /**
  13611. * Particle emitter emitting particles from a point.
  13612. * It emits the particles randomly between 2 given directions.
  13613. */
  13614. export class PointParticleEmitter implements IParticleEmitterType {
  13615. /**
  13616. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13617. */
  13618. direction1: Vector3;
  13619. /**
  13620. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13621. */
  13622. direction2: Vector3;
  13623. /**
  13624. * Creates a new instance PointParticleEmitter
  13625. */
  13626. constructor();
  13627. /**
  13628. * Called by the particle System when the direction is computed for the created particle.
  13629. * @param worldMatrix is the world matrix of the particle system
  13630. * @param directionToUpdate is the direction vector to update with the result
  13631. * @param particle is the particle we are computed the direction for
  13632. * @param isLocal defines if the direction should be set in local space
  13633. */
  13634. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13635. /**
  13636. * Called by the particle System when the position is computed for the created particle.
  13637. * @param worldMatrix is the world matrix of the particle system
  13638. * @param positionToUpdate is the position vector to update with the result
  13639. * @param particle is the particle we are computed the position for
  13640. * @param isLocal defines if the position should be set in local space
  13641. */
  13642. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13643. /**
  13644. * Clones the current emitter and returns a copy of it
  13645. * @returns the new emitter
  13646. */
  13647. clone(): PointParticleEmitter;
  13648. /**
  13649. * Called by the GPUParticleSystem to setup the update shader
  13650. * @param effect defines the update shader
  13651. */
  13652. applyToShader(effect: Effect): void;
  13653. /**
  13654. * Returns a string to use to update the GPU particles update shader
  13655. * @returns a string containng the defines string
  13656. */
  13657. getEffectDefines(): string;
  13658. /**
  13659. * Returns the string "PointParticleEmitter"
  13660. * @returns a string containing the class name
  13661. */
  13662. getClassName(): string;
  13663. /**
  13664. * Serializes the particle system to a JSON object.
  13665. * @returns the JSON object
  13666. */
  13667. serialize(): any;
  13668. /**
  13669. * Parse properties from a JSON object
  13670. * @param serializationObject defines the JSON object
  13671. */
  13672. parse(serializationObject: any): void;
  13673. }
  13674. }
  13675. declare module BABYLON {
  13676. /**
  13677. * Particle emitter emitting particles from the inside of a sphere.
  13678. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13679. */
  13680. export class SphereParticleEmitter implements IParticleEmitterType {
  13681. /**
  13682. * The radius of the emission sphere.
  13683. */
  13684. radius: number;
  13685. /**
  13686. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13687. */
  13688. radiusRange: number;
  13689. /**
  13690. * How much to randomize the particle direction [0-1].
  13691. */
  13692. directionRandomizer: number;
  13693. /**
  13694. * Creates a new instance SphereParticleEmitter
  13695. * @param radius the radius of the emission sphere (1 by default)
  13696. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13697. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13698. */
  13699. constructor(
  13700. /**
  13701. * The radius of the emission sphere.
  13702. */
  13703. radius?: number,
  13704. /**
  13705. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13706. */
  13707. radiusRange?: number,
  13708. /**
  13709. * How much to randomize the particle direction [0-1].
  13710. */
  13711. directionRandomizer?: number);
  13712. /**
  13713. * Called by the particle System when the direction is computed for the created particle.
  13714. * @param worldMatrix is the world matrix of the particle system
  13715. * @param directionToUpdate is the direction vector to update with the result
  13716. * @param particle is the particle we are computed the direction for
  13717. * @param isLocal defines if the direction should be set in local space
  13718. */
  13719. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13720. /**
  13721. * Called by the particle System when the position is computed for the created particle.
  13722. * @param worldMatrix is the world matrix of the particle system
  13723. * @param positionToUpdate is the position vector to update with the result
  13724. * @param particle is the particle we are computed the position for
  13725. * @param isLocal defines if the position should be set in local space
  13726. */
  13727. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13728. /**
  13729. * Clones the current emitter and returns a copy of it
  13730. * @returns the new emitter
  13731. */
  13732. clone(): SphereParticleEmitter;
  13733. /**
  13734. * Called by the GPUParticleSystem to setup the update shader
  13735. * @param effect defines the update shader
  13736. */
  13737. applyToShader(effect: Effect): void;
  13738. /**
  13739. * Returns a string to use to update the GPU particles update shader
  13740. * @returns a string containng the defines string
  13741. */
  13742. getEffectDefines(): string;
  13743. /**
  13744. * Returns the string "SphereParticleEmitter"
  13745. * @returns a string containing the class name
  13746. */
  13747. getClassName(): string;
  13748. /**
  13749. * Serializes the particle system to a JSON object.
  13750. * @returns the JSON object
  13751. */
  13752. serialize(): any;
  13753. /**
  13754. * Parse properties from a JSON object
  13755. * @param serializationObject defines the JSON object
  13756. */
  13757. parse(serializationObject: any): void;
  13758. }
  13759. /**
  13760. * Particle emitter emitting particles from the inside of a sphere.
  13761. * It emits the particles randomly between two vectors.
  13762. */
  13763. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13764. /**
  13765. * The min limit of the emission direction.
  13766. */
  13767. direction1: Vector3;
  13768. /**
  13769. * The max limit of the emission direction.
  13770. */
  13771. direction2: Vector3;
  13772. /**
  13773. * Creates a new instance SphereDirectedParticleEmitter
  13774. * @param radius the radius of the emission sphere (1 by default)
  13775. * @param direction1 the min limit of the emission direction (up vector by default)
  13776. * @param direction2 the max limit of the emission direction (up vector by default)
  13777. */
  13778. constructor(radius?: number,
  13779. /**
  13780. * The min limit of the emission direction.
  13781. */
  13782. direction1?: Vector3,
  13783. /**
  13784. * The max limit of the emission direction.
  13785. */
  13786. direction2?: Vector3);
  13787. /**
  13788. * Called by the particle System when the direction is computed for the created particle.
  13789. * @param worldMatrix is the world matrix of the particle system
  13790. * @param directionToUpdate is the direction vector to update with the result
  13791. * @param particle is the particle we are computed the direction for
  13792. */
  13793. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13794. /**
  13795. * Clones the current emitter and returns a copy of it
  13796. * @returns the new emitter
  13797. */
  13798. clone(): SphereDirectedParticleEmitter;
  13799. /**
  13800. * Called by the GPUParticleSystem to setup the update shader
  13801. * @param effect defines the update shader
  13802. */
  13803. applyToShader(effect: Effect): void;
  13804. /**
  13805. * Returns a string to use to update the GPU particles update shader
  13806. * @returns a string containng the defines string
  13807. */
  13808. getEffectDefines(): string;
  13809. /**
  13810. * Returns the string "SphereDirectedParticleEmitter"
  13811. * @returns a string containing the class name
  13812. */
  13813. getClassName(): string;
  13814. /**
  13815. * Serializes the particle system to a JSON object.
  13816. * @returns the JSON object
  13817. */
  13818. serialize(): any;
  13819. /**
  13820. * Parse properties from a JSON object
  13821. * @param serializationObject defines the JSON object
  13822. */
  13823. parse(serializationObject: any): void;
  13824. }
  13825. }
  13826. declare module BABYLON {
  13827. /**
  13828. * Particle emitter emitting particles from a custom list of positions.
  13829. */
  13830. export class CustomParticleEmitter implements IParticleEmitterType {
  13831. /**
  13832. * Gets or sets the position generator that will create the inital position of each particle.
  13833. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13834. */
  13835. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13836. /**
  13837. * Gets or sets the destination generator that will create the final destination of each particle.
  13838. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13839. */
  13840. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13841. /**
  13842. * Creates a new instance CustomParticleEmitter
  13843. */
  13844. constructor();
  13845. /**
  13846. * Called by the particle System when the direction is computed for the created particle.
  13847. * @param worldMatrix is the world matrix of the particle system
  13848. * @param directionToUpdate is the direction vector to update with the result
  13849. * @param particle is the particle we are computed the direction for
  13850. * @param isLocal defines if the direction should be set in local space
  13851. */
  13852. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13853. /**
  13854. * Called by the particle System when the position is computed for the created particle.
  13855. * @param worldMatrix is the world matrix of the particle system
  13856. * @param positionToUpdate is the position vector to update with the result
  13857. * @param particle is the particle we are computed the position for
  13858. * @param isLocal defines if the position should be set in local space
  13859. */
  13860. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13861. /**
  13862. * Clones the current emitter and returns a copy of it
  13863. * @returns the new emitter
  13864. */
  13865. clone(): CustomParticleEmitter;
  13866. /**
  13867. * Called by the GPUParticleSystem to setup the update shader
  13868. * @param effect defines the update shader
  13869. */
  13870. applyToShader(effect: Effect): void;
  13871. /**
  13872. * Returns a string to use to update the GPU particles update shader
  13873. * @returns a string containng the defines string
  13874. */
  13875. getEffectDefines(): string;
  13876. /**
  13877. * Returns the string "PointParticleEmitter"
  13878. * @returns a string containing the class name
  13879. */
  13880. getClassName(): string;
  13881. /**
  13882. * Serializes the particle system to a JSON object.
  13883. * @returns the JSON object
  13884. */
  13885. serialize(): any;
  13886. /**
  13887. * Parse properties from a JSON object
  13888. * @param serializationObject defines the JSON object
  13889. */
  13890. parse(serializationObject: any): void;
  13891. }
  13892. }
  13893. declare module BABYLON {
  13894. /**
  13895. * Particle emitter emitting particles from the inside of a box.
  13896. * It emits the particles randomly between 2 given directions.
  13897. */
  13898. export class MeshParticleEmitter implements IParticleEmitterType {
  13899. private _indices;
  13900. private _positions;
  13901. private _normals;
  13902. private _storedNormal;
  13903. private _mesh;
  13904. /**
  13905. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13906. */
  13907. direction1: Vector3;
  13908. /**
  13909. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13910. */
  13911. direction2: Vector3;
  13912. /**
  13913. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13914. */
  13915. useMeshNormalsForDirection: boolean;
  13916. /** Defines the mesh to use as source */
  13917. get mesh(): Nullable<AbstractMesh>;
  13918. set mesh(value: Nullable<AbstractMesh>);
  13919. /**
  13920. * Creates a new instance MeshParticleEmitter
  13921. * @param mesh defines the mesh to use as source
  13922. */
  13923. constructor(mesh?: Nullable<AbstractMesh>);
  13924. /**
  13925. * Called by the particle System when the direction is computed for the created particle.
  13926. * @param worldMatrix is the world matrix of the particle system
  13927. * @param directionToUpdate is the direction vector to update with the result
  13928. * @param particle is the particle we are computed the direction for
  13929. * @param isLocal defines if the direction should be set in local space
  13930. */
  13931. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13932. /**
  13933. * Called by the particle System when the position is computed for the created particle.
  13934. * @param worldMatrix is the world matrix of the particle system
  13935. * @param positionToUpdate is the position vector to update with the result
  13936. * @param particle is the particle we are computed the position for
  13937. * @param isLocal defines if the position should be set in local space
  13938. */
  13939. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13940. /**
  13941. * Clones the current emitter and returns a copy of it
  13942. * @returns the new emitter
  13943. */
  13944. clone(): MeshParticleEmitter;
  13945. /**
  13946. * Called by the GPUParticleSystem to setup the update shader
  13947. * @param effect defines the update shader
  13948. */
  13949. applyToShader(effect: Effect): void;
  13950. /**
  13951. * Returns a string to use to update the GPU particles update shader
  13952. * @returns a string containng the defines string
  13953. */
  13954. getEffectDefines(): string;
  13955. /**
  13956. * Returns the string "BoxParticleEmitter"
  13957. * @returns a string containing the class name
  13958. */
  13959. getClassName(): string;
  13960. /**
  13961. * Serializes the particle system to a JSON object.
  13962. * @returns the JSON object
  13963. */
  13964. serialize(): any;
  13965. /**
  13966. * Parse properties from a JSON object
  13967. * @param serializationObject defines the JSON object
  13968. * @param scene defines the hosting scene
  13969. */
  13970. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13971. }
  13972. }
  13973. declare module BABYLON {
  13974. /**
  13975. * Interface representing a particle system in Babylon.js.
  13976. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13977. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13978. */
  13979. export interface IParticleSystem {
  13980. /**
  13981. * List of animations used by the particle system.
  13982. */
  13983. animations: Animation[];
  13984. /**
  13985. * The id of the Particle system.
  13986. */
  13987. id: string;
  13988. /**
  13989. * The name of the Particle system.
  13990. */
  13991. name: string;
  13992. /**
  13993. * The emitter represents the Mesh or position we are attaching the particle system to.
  13994. */
  13995. emitter: Nullable<AbstractMesh | Vector3>;
  13996. /**
  13997. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13998. */
  13999. isBillboardBased: boolean;
  14000. /**
  14001. * The rendering group used by the Particle system to chose when to render.
  14002. */
  14003. renderingGroupId: number;
  14004. /**
  14005. * The layer mask we are rendering the particles through.
  14006. */
  14007. layerMask: number;
  14008. /**
  14009. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14010. */
  14011. updateSpeed: number;
  14012. /**
  14013. * The amount of time the particle system is running (depends of the overall update speed).
  14014. */
  14015. targetStopDuration: number;
  14016. /**
  14017. * The texture used to render each particle. (this can be a spritesheet)
  14018. */
  14019. particleTexture: Nullable<BaseTexture>;
  14020. /**
  14021. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14022. */
  14023. blendMode: number;
  14024. /**
  14025. * Minimum life time of emitting particles.
  14026. */
  14027. minLifeTime: number;
  14028. /**
  14029. * Maximum life time of emitting particles.
  14030. */
  14031. maxLifeTime: number;
  14032. /**
  14033. * Minimum Size of emitting particles.
  14034. */
  14035. minSize: number;
  14036. /**
  14037. * Maximum Size of emitting particles.
  14038. */
  14039. maxSize: number;
  14040. /**
  14041. * Minimum scale of emitting particles on X axis.
  14042. */
  14043. minScaleX: number;
  14044. /**
  14045. * Maximum scale of emitting particles on X axis.
  14046. */
  14047. maxScaleX: number;
  14048. /**
  14049. * Minimum scale of emitting particles on Y axis.
  14050. */
  14051. minScaleY: number;
  14052. /**
  14053. * Maximum scale of emitting particles on Y axis.
  14054. */
  14055. maxScaleY: number;
  14056. /**
  14057. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14058. */
  14059. color1: Color4;
  14060. /**
  14061. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14062. */
  14063. color2: Color4;
  14064. /**
  14065. * Color the particle will have at the end of its lifetime.
  14066. */
  14067. colorDead: Color4;
  14068. /**
  14069. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14070. */
  14071. emitRate: number;
  14072. /**
  14073. * You can use gravity if you want to give an orientation to your particles.
  14074. */
  14075. gravity: Vector3;
  14076. /**
  14077. * Minimum power of emitting particles.
  14078. */
  14079. minEmitPower: number;
  14080. /**
  14081. * Maximum power of emitting particles.
  14082. */
  14083. maxEmitPower: number;
  14084. /**
  14085. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14086. */
  14087. minAngularSpeed: number;
  14088. /**
  14089. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14090. */
  14091. maxAngularSpeed: number;
  14092. /**
  14093. * Gets or sets the minimal initial rotation in radians.
  14094. */
  14095. minInitialRotation: number;
  14096. /**
  14097. * Gets or sets the maximal initial rotation in radians.
  14098. */
  14099. maxInitialRotation: number;
  14100. /**
  14101. * The particle emitter type defines the emitter used by the particle system.
  14102. * It can be for example box, sphere, or cone...
  14103. */
  14104. particleEmitterType: Nullable<IParticleEmitterType>;
  14105. /**
  14106. * Defines the delay in milliseconds before starting the system (0 by default)
  14107. */
  14108. startDelay: number;
  14109. /**
  14110. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  14111. */
  14112. preWarmCycles: number;
  14113. /**
  14114. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14115. */
  14116. preWarmStepOffset: number;
  14117. /**
  14118. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  14119. */
  14120. spriteCellChangeSpeed: number;
  14121. /**
  14122. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14123. */
  14124. startSpriteCellID: number;
  14125. /**
  14126. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14127. */
  14128. endSpriteCellID: number;
  14129. /**
  14130. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14131. */
  14132. spriteCellWidth: number;
  14133. /**
  14134. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14135. */
  14136. spriteCellHeight: number;
  14137. /**
  14138. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14139. */
  14140. spriteRandomStartCell: boolean;
  14141. /**
  14142. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14143. */
  14144. isAnimationSheetEnabled: boolean;
  14145. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14146. translationPivot: Vector2;
  14147. /**
  14148. * Gets or sets a texture used to add random noise to particle positions
  14149. */
  14150. noiseTexture: Nullable<BaseTexture>;
  14151. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14152. noiseStrength: Vector3;
  14153. /**
  14154. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14155. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14156. */
  14157. billboardMode: number;
  14158. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14159. limitVelocityDamping: number;
  14160. /**
  14161. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14162. */
  14163. beginAnimationOnStart: boolean;
  14164. /**
  14165. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14166. */
  14167. beginAnimationFrom: number;
  14168. /**
  14169. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14170. */
  14171. beginAnimationTo: number;
  14172. /**
  14173. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14174. */
  14175. beginAnimationLoop: boolean;
  14176. /**
  14177. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14178. */
  14179. disposeOnStop: boolean;
  14180. /**
  14181. * Specifies if the particles are updated in emitter local space or world space
  14182. */
  14183. isLocal: boolean;
  14184. /** Snippet ID if the particle system was created from the snippet server */
  14185. snippetId: string;
  14186. /** Gets or sets a matrix to use to compute projection */
  14187. defaultProjectionMatrix: Matrix;
  14188. /**
  14189. * Gets the maximum number of particles active at the same time.
  14190. * @returns The max number of active particles.
  14191. */
  14192. getCapacity(): number;
  14193. /**
  14194. * Gets the number of particles active at the same time.
  14195. * @returns The number of active particles.
  14196. */
  14197. getActiveCount(): number;
  14198. /**
  14199. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14200. * @returns True if it has been started, otherwise false.
  14201. */
  14202. isStarted(): boolean;
  14203. /**
  14204. * Animates the particle system for this frame.
  14205. */
  14206. animate(): void;
  14207. /**
  14208. * Renders the particle system in its current state.
  14209. * @returns the current number of particles
  14210. */
  14211. render(): number;
  14212. /**
  14213. * Dispose the particle system and frees its associated resources.
  14214. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14215. */
  14216. dispose(disposeTexture?: boolean): void;
  14217. /**
  14218. * An event triggered when the system is disposed
  14219. */
  14220. onDisposeObservable: Observable<IParticleSystem>;
  14221. /**
  14222. * Clones the particle system.
  14223. * @param name The name of the cloned object
  14224. * @param newEmitter The new emitter to use
  14225. * @returns the cloned particle system
  14226. */
  14227. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14228. /**
  14229. * Serializes the particle system to a JSON object
  14230. * @param serializeTexture defines if the texture must be serialized as well
  14231. * @returns the JSON object
  14232. */
  14233. serialize(serializeTexture: boolean): any;
  14234. /**
  14235. * Rebuild the particle system
  14236. */
  14237. rebuild(): void;
  14238. /** Force the system to rebuild all gradients that need to be resync */
  14239. forceRefreshGradients(): void;
  14240. /**
  14241. * Starts the particle system and begins to emit
  14242. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14243. */
  14244. start(delay?: number): void;
  14245. /**
  14246. * Stops the particle system.
  14247. */
  14248. stop(): void;
  14249. /**
  14250. * Remove all active particles
  14251. */
  14252. reset(): void;
  14253. /**
  14254. * Gets a boolean indicating that the system is stopping
  14255. * @returns true if the system is currently stopping
  14256. */
  14257. isStopping(): boolean;
  14258. /**
  14259. * Is this system ready to be used/rendered
  14260. * @return true if the system is ready
  14261. */
  14262. isReady(): boolean;
  14263. /**
  14264. * Returns the string "ParticleSystem"
  14265. * @returns a string containing the class name
  14266. */
  14267. getClassName(): string;
  14268. /**
  14269. * Gets the custom effect used to render the particles
  14270. * @param blendMode Blend mode for which the effect should be retrieved
  14271. * @returns The effect
  14272. */
  14273. getCustomEffect(blendMode: number): Nullable<Effect>;
  14274. /**
  14275. * Sets the custom effect used to render the particles
  14276. * @param effect The effect to set
  14277. * @param blendMode Blend mode for which the effect should be set
  14278. */
  14279. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14280. /**
  14281. * Fill the defines array according to the current settings of the particle system
  14282. * @param defines Array to be updated
  14283. * @param blendMode blend mode to take into account when updating the array
  14284. */
  14285. fillDefines(defines: Array<string>, blendMode: number): void;
  14286. /**
  14287. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14288. * @param uniforms Uniforms array to fill
  14289. * @param attributes Attributes array to fill
  14290. * @param samplers Samplers array to fill
  14291. */
  14292. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14293. /**
  14294. * Observable that will be called just before the particles are drawn
  14295. */
  14296. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14297. /**
  14298. * Gets the name of the particle vertex shader
  14299. */
  14300. vertexShaderName: string;
  14301. /**
  14302. * Adds a new color gradient
  14303. * @param gradient defines the gradient to use (between 0 and 1)
  14304. * @param color1 defines the color to affect to the specified gradient
  14305. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14306. * @returns the current particle system
  14307. */
  14308. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14309. /**
  14310. * Remove a specific color gradient
  14311. * @param gradient defines the gradient to remove
  14312. * @returns the current particle system
  14313. */
  14314. removeColorGradient(gradient: number): IParticleSystem;
  14315. /**
  14316. * Adds a new size gradient
  14317. * @param gradient defines the gradient to use (between 0 and 1)
  14318. * @param factor defines the size factor to affect to the specified gradient
  14319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14320. * @returns the current particle system
  14321. */
  14322. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14323. /**
  14324. * Remove a specific size gradient
  14325. * @param gradient defines the gradient to remove
  14326. * @returns the current particle system
  14327. */
  14328. removeSizeGradient(gradient: number): IParticleSystem;
  14329. /**
  14330. * Gets the current list of color gradients.
  14331. * You must use addColorGradient and removeColorGradient to udpate this list
  14332. * @returns the list of color gradients
  14333. */
  14334. getColorGradients(): Nullable<Array<ColorGradient>>;
  14335. /**
  14336. * Gets the current list of size gradients.
  14337. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14338. * @returns the list of size gradients
  14339. */
  14340. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14341. /**
  14342. * Gets the current list of angular speed gradients.
  14343. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14344. * @returns the list of angular speed gradients
  14345. */
  14346. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14347. /**
  14348. * Adds a new angular speed gradient
  14349. * @param gradient defines the gradient to use (between 0 and 1)
  14350. * @param factor defines the angular speed to affect to the specified gradient
  14351. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14352. * @returns the current particle system
  14353. */
  14354. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14355. /**
  14356. * Remove a specific angular speed gradient
  14357. * @param gradient defines the gradient to remove
  14358. * @returns the current particle system
  14359. */
  14360. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14361. /**
  14362. * Gets the current list of velocity gradients.
  14363. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14364. * @returns the list of velocity gradients
  14365. */
  14366. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14367. /**
  14368. * Adds a new velocity gradient
  14369. * @param gradient defines the gradient to use (between 0 and 1)
  14370. * @param factor defines the velocity to affect to the specified gradient
  14371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14372. * @returns the current particle system
  14373. */
  14374. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14375. /**
  14376. * Remove a specific velocity gradient
  14377. * @param gradient defines the gradient to remove
  14378. * @returns the current particle system
  14379. */
  14380. removeVelocityGradient(gradient: number): IParticleSystem;
  14381. /**
  14382. * Gets the current list of limit velocity gradients.
  14383. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14384. * @returns the list of limit velocity gradients
  14385. */
  14386. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14387. /**
  14388. * Adds a new limit velocity gradient
  14389. * @param gradient defines the gradient to use (between 0 and 1)
  14390. * @param factor defines the limit velocity to affect to the specified gradient
  14391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14392. * @returns the current particle system
  14393. */
  14394. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14395. /**
  14396. * Remove a specific limit velocity gradient
  14397. * @param gradient defines the gradient to remove
  14398. * @returns the current particle system
  14399. */
  14400. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14401. /**
  14402. * Adds a new drag gradient
  14403. * @param gradient defines the gradient to use (between 0 and 1)
  14404. * @param factor defines the drag to affect to the specified gradient
  14405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14406. * @returns the current particle system
  14407. */
  14408. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14409. /**
  14410. * Remove a specific drag gradient
  14411. * @param gradient defines the gradient to remove
  14412. * @returns the current particle system
  14413. */
  14414. removeDragGradient(gradient: number): IParticleSystem;
  14415. /**
  14416. * Gets the current list of drag gradients.
  14417. * You must use addDragGradient and removeDragGradient to udpate this list
  14418. * @returns the list of drag gradients
  14419. */
  14420. getDragGradients(): Nullable<Array<FactorGradient>>;
  14421. /**
  14422. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14423. * @param gradient defines the gradient to use (between 0 and 1)
  14424. * @param factor defines the emit rate to affect to the specified gradient
  14425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14426. * @returns the current particle system
  14427. */
  14428. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14429. /**
  14430. * Remove a specific emit rate gradient
  14431. * @param gradient defines the gradient to remove
  14432. * @returns the current particle system
  14433. */
  14434. removeEmitRateGradient(gradient: number): IParticleSystem;
  14435. /**
  14436. * Gets the current list of emit rate gradients.
  14437. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14438. * @returns the list of emit rate gradients
  14439. */
  14440. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14441. /**
  14442. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14443. * @param gradient defines the gradient to use (between 0 and 1)
  14444. * @param factor defines the start size to affect to the specified gradient
  14445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14446. * @returns the current particle system
  14447. */
  14448. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14449. /**
  14450. * Remove a specific start size gradient
  14451. * @param gradient defines the gradient to remove
  14452. * @returns the current particle system
  14453. */
  14454. removeStartSizeGradient(gradient: number): IParticleSystem;
  14455. /**
  14456. * Gets the current list of start size gradients.
  14457. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14458. * @returns the list of start size gradients
  14459. */
  14460. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14461. /**
  14462. * Adds a new life time gradient
  14463. * @param gradient defines the gradient to use (between 0 and 1)
  14464. * @param factor defines the life time factor to affect to the specified gradient
  14465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14466. * @returns the current particle system
  14467. */
  14468. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14469. /**
  14470. * Remove a specific life time gradient
  14471. * @param gradient defines the gradient to remove
  14472. * @returns the current particle system
  14473. */
  14474. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14475. /**
  14476. * Gets the current list of life time gradients.
  14477. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14478. * @returns the list of life time gradients
  14479. */
  14480. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14481. /**
  14482. * Gets the current list of color gradients.
  14483. * You must use addColorGradient and removeColorGradient to udpate this list
  14484. * @returns the list of color gradients
  14485. */
  14486. getColorGradients(): Nullable<Array<ColorGradient>>;
  14487. /**
  14488. * Adds a new ramp gradient used to remap particle colors
  14489. * @param gradient defines the gradient to use (between 0 and 1)
  14490. * @param color defines the color to affect to the specified gradient
  14491. * @returns the current particle system
  14492. */
  14493. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14494. /**
  14495. * Gets the current list of ramp gradients.
  14496. * You must use addRampGradient and removeRampGradient to udpate this list
  14497. * @returns the list of ramp gradients
  14498. */
  14499. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14500. /** Gets or sets a boolean indicating that ramp gradients must be used
  14501. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14502. */
  14503. useRampGradients: boolean;
  14504. /**
  14505. * Adds a new color remap gradient
  14506. * @param gradient defines the gradient to use (between 0 and 1)
  14507. * @param min defines the color remap minimal range
  14508. * @param max defines the color remap maximal range
  14509. * @returns the current particle system
  14510. */
  14511. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14512. /**
  14513. * Gets the current list of color remap gradients.
  14514. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14515. * @returns the list of color remap gradients
  14516. */
  14517. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14518. /**
  14519. * Adds a new alpha remap gradient
  14520. * @param gradient defines the gradient to use (between 0 and 1)
  14521. * @param min defines the alpha remap minimal range
  14522. * @param max defines the alpha remap maximal range
  14523. * @returns the current particle system
  14524. */
  14525. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14526. /**
  14527. * Gets the current list of alpha remap gradients.
  14528. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14529. * @returns the list of alpha remap gradients
  14530. */
  14531. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14532. /**
  14533. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14534. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14535. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14536. * @returns the emitter
  14537. */
  14538. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14539. /**
  14540. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14541. * @param radius The radius of the hemisphere to emit from
  14542. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14543. * @returns the emitter
  14544. */
  14545. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14546. /**
  14547. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14548. * @param radius The radius of the sphere to emit from
  14549. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14550. * @returns the emitter
  14551. */
  14552. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14553. /**
  14554. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14555. * @param radius The radius of the sphere to emit from
  14556. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14557. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14558. * @returns the emitter
  14559. */
  14560. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14561. /**
  14562. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14563. * @param radius The radius of the emission cylinder
  14564. * @param height The height of the emission cylinder
  14565. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14566. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14567. * @returns the emitter
  14568. */
  14569. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14570. /**
  14571. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14572. * @param radius The radius of the cylinder to emit from
  14573. * @param height The height of the emission cylinder
  14574. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14575. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14576. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14577. * @returns the emitter
  14578. */
  14579. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14580. /**
  14581. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14582. * @param radius The radius of the cone to emit from
  14583. * @param angle The base angle of the cone
  14584. * @returns the emitter
  14585. */
  14586. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14587. /**
  14588. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14589. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14590. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14591. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14592. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14593. * @returns the emitter
  14594. */
  14595. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14596. /**
  14597. * Get hosting scene
  14598. * @returns the scene
  14599. */
  14600. getScene(): Nullable<Scene>;
  14601. }
  14602. }
  14603. declare module BABYLON {
  14604. /**
  14605. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14606. * @see https://doc.babylonjs.com/how_to/transformnode
  14607. */
  14608. export class TransformNode extends Node {
  14609. /**
  14610. * Object will not rotate to face the camera
  14611. */
  14612. static BILLBOARDMODE_NONE: number;
  14613. /**
  14614. * Object will rotate to face the camera but only on the x axis
  14615. */
  14616. static BILLBOARDMODE_X: number;
  14617. /**
  14618. * Object will rotate to face the camera but only on the y axis
  14619. */
  14620. static BILLBOARDMODE_Y: number;
  14621. /**
  14622. * Object will rotate to face the camera but only on the z axis
  14623. */
  14624. static BILLBOARDMODE_Z: number;
  14625. /**
  14626. * Object will rotate to face the camera
  14627. */
  14628. static BILLBOARDMODE_ALL: number;
  14629. /**
  14630. * Object will rotate to face the camera's position instead of orientation
  14631. */
  14632. static BILLBOARDMODE_USE_POSITION: number;
  14633. private static _TmpRotation;
  14634. private static _TmpScaling;
  14635. private static _TmpTranslation;
  14636. private _forward;
  14637. private _forwardInverted;
  14638. private _up;
  14639. private _right;
  14640. private _rightInverted;
  14641. private _position;
  14642. private _rotation;
  14643. private _rotationQuaternion;
  14644. protected _scaling: Vector3;
  14645. protected _isDirty: boolean;
  14646. private _transformToBoneReferal;
  14647. private _isAbsoluteSynced;
  14648. private _billboardMode;
  14649. /**
  14650. * Gets or sets the billboard mode. Default is 0.
  14651. *
  14652. * | Value | Type | Description |
  14653. * | --- | --- | --- |
  14654. * | 0 | BILLBOARDMODE_NONE | |
  14655. * | 1 | BILLBOARDMODE_X | |
  14656. * | 2 | BILLBOARDMODE_Y | |
  14657. * | 4 | BILLBOARDMODE_Z | |
  14658. * | 7 | BILLBOARDMODE_ALL | |
  14659. *
  14660. */
  14661. get billboardMode(): number;
  14662. set billboardMode(value: number);
  14663. private _preserveParentRotationForBillboard;
  14664. /**
  14665. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14666. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14667. */
  14668. get preserveParentRotationForBillboard(): boolean;
  14669. set preserveParentRotationForBillboard(value: boolean);
  14670. /**
  14671. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14672. */
  14673. scalingDeterminant: number;
  14674. private _infiniteDistance;
  14675. /**
  14676. * Gets or sets the distance of the object to max, often used by skybox
  14677. */
  14678. get infiniteDistance(): boolean;
  14679. set infiniteDistance(value: boolean);
  14680. /**
  14681. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14682. * By default the system will update normals to compensate
  14683. */
  14684. ignoreNonUniformScaling: boolean;
  14685. /**
  14686. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14687. */
  14688. reIntegrateRotationIntoRotationQuaternion: boolean;
  14689. /** @hidden */
  14690. _poseMatrix: Nullable<Matrix>;
  14691. /** @hidden */
  14692. _localMatrix: Matrix;
  14693. private _usePivotMatrix;
  14694. private _absolutePosition;
  14695. private _absoluteScaling;
  14696. private _absoluteRotationQuaternion;
  14697. private _pivotMatrix;
  14698. private _pivotMatrixInverse;
  14699. protected _postMultiplyPivotMatrix: boolean;
  14700. protected _isWorldMatrixFrozen: boolean;
  14701. /** @hidden */
  14702. _indexInSceneTransformNodesArray: number;
  14703. /**
  14704. * An event triggered after the world matrix is updated
  14705. */
  14706. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14707. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14708. /**
  14709. * Gets a string identifying the name of the class
  14710. * @returns "TransformNode" string
  14711. */
  14712. getClassName(): string;
  14713. /**
  14714. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14715. */
  14716. get position(): Vector3;
  14717. set position(newPosition: Vector3);
  14718. /**
  14719. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14720. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14721. */
  14722. get rotation(): Vector3;
  14723. set rotation(newRotation: Vector3);
  14724. /**
  14725. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14726. */
  14727. get scaling(): Vector3;
  14728. set scaling(newScaling: Vector3);
  14729. /**
  14730. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14731. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14732. */
  14733. get rotationQuaternion(): Nullable<Quaternion>;
  14734. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14735. /**
  14736. * The forward direction of that transform in world space.
  14737. */
  14738. get forward(): Vector3;
  14739. /**
  14740. * The up direction of that transform in world space.
  14741. */
  14742. get up(): Vector3;
  14743. /**
  14744. * The right direction of that transform in world space.
  14745. */
  14746. get right(): Vector3;
  14747. /**
  14748. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14749. * @param matrix the matrix to copy the pose from
  14750. * @returns this TransformNode.
  14751. */
  14752. updatePoseMatrix(matrix: Matrix): TransformNode;
  14753. /**
  14754. * Returns the mesh Pose matrix.
  14755. * @returns the pose matrix
  14756. */
  14757. getPoseMatrix(): Matrix;
  14758. /** @hidden */
  14759. _isSynchronized(): boolean;
  14760. /** @hidden */
  14761. _initCache(): void;
  14762. /**
  14763. * Flag the transform node as dirty (Forcing it to update everything)
  14764. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14765. * @returns this transform node
  14766. */
  14767. markAsDirty(property: string): TransformNode;
  14768. /**
  14769. * Returns the current mesh absolute position.
  14770. * Returns a Vector3.
  14771. */
  14772. get absolutePosition(): Vector3;
  14773. /**
  14774. * Returns the current mesh absolute scaling.
  14775. * Returns a Vector3.
  14776. */
  14777. get absoluteScaling(): Vector3;
  14778. /**
  14779. * Returns the current mesh absolute rotation.
  14780. * Returns a Quaternion.
  14781. */
  14782. get absoluteRotationQuaternion(): Quaternion;
  14783. /**
  14784. * Sets a new matrix to apply before all other transformation
  14785. * @param matrix defines the transform matrix
  14786. * @returns the current TransformNode
  14787. */
  14788. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14789. /**
  14790. * Sets a new pivot matrix to the current node
  14791. * @param matrix defines the new pivot matrix to use
  14792. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14793. * @returns the current TransformNode
  14794. */
  14795. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14796. /**
  14797. * Returns the mesh pivot matrix.
  14798. * Default : Identity.
  14799. * @returns the matrix
  14800. */
  14801. getPivotMatrix(): Matrix;
  14802. /**
  14803. * Instantiate (when possible) or clone that node with its hierarchy
  14804. * @param newParent defines the new parent to use for the instance (or clone)
  14805. * @param options defines options to configure how copy is done
  14806. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14807. * @returns an instance (or a clone) of the current node with its hiearchy
  14808. */
  14809. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14810. doNotInstantiate: boolean;
  14811. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14812. /**
  14813. * Prevents the World matrix to be computed any longer
  14814. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14815. * @returns the TransformNode.
  14816. */
  14817. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14818. /**
  14819. * Allows back the World matrix computation.
  14820. * @returns the TransformNode.
  14821. */
  14822. unfreezeWorldMatrix(): this;
  14823. /**
  14824. * True if the World matrix has been frozen.
  14825. */
  14826. get isWorldMatrixFrozen(): boolean;
  14827. /**
  14828. * Retuns the mesh absolute position in the World.
  14829. * @returns a Vector3.
  14830. */
  14831. getAbsolutePosition(): Vector3;
  14832. /**
  14833. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14834. * @param absolutePosition the absolute position to set
  14835. * @returns the TransformNode.
  14836. */
  14837. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14838. /**
  14839. * Sets the mesh position in its local space.
  14840. * @param vector3 the position to set in localspace
  14841. * @returns the TransformNode.
  14842. */
  14843. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14844. /**
  14845. * Returns the mesh position in the local space from the current World matrix values.
  14846. * @returns a new Vector3.
  14847. */
  14848. getPositionExpressedInLocalSpace(): Vector3;
  14849. /**
  14850. * Translates the mesh along the passed Vector3 in its local space.
  14851. * @param vector3 the distance to translate in localspace
  14852. * @returns the TransformNode.
  14853. */
  14854. locallyTranslate(vector3: Vector3): TransformNode;
  14855. private static _lookAtVectorCache;
  14856. /**
  14857. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14858. * @param targetPoint the position (must be in same space as current mesh) to look at
  14859. * @param yawCor optional yaw (y-axis) correction in radians
  14860. * @param pitchCor optional pitch (x-axis) correction in radians
  14861. * @param rollCor optional roll (z-axis) correction in radians
  14862. * @param space the choosen space of the target
  14863. * @returns the TransformNode.
  14864. */
  14865. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14866. /**
  14867. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14868. * This Vector3 is expressed in the World space.
  14869. * @param localAxis axis to rotate
  14870. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14871. */
  14872. getDirection(localAxis: Vector3): Vector3;
  14873. /**
  14874. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14875. * localAxis is expressed in the mesh local space.
  14876. * result is computed in the Wordl space from the mesh World matrix.
  14877. * @param localAxis axis to rotate
  14878. * @param result the resulting transformnode
  14879. * @returns this TransformNode.
  14880. */
  14881. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14882. /**
  14883. * Sets this transform node rotation to the given local axis.
  14884. * @param localAxis the axis in local space
  14885. * @param yawCor optional yaw (y-axis) correction in radians
  14886. * @param pitchCor optional pitch (x-axis) correction in radians
  14887. * @param rollCor optional roll (z-axis) correction in radians
  14888. * @returns this TransformNode
  14889. */
  14890. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14891. /**
  14892. * Sets a new pivot point to the current node
  14893. * @param point defines the new pivot point to use
  14894. * @param space defines if the point is in world or local space (local by default)
  14895. * @returns the current TransformNode
  14896. */
  14897. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14898. /**
  14899. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14900. * @returns the pivot point
  14901. */
  14902. getPivotPoint(): Vector3;
  14903. /**
  14904. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14905. * @param result the vector3 to store the result
  14906. * @returns this TransformNode.
  14907. */
  14908. getPivotPointToRef(result: Vector3): TransformNode;
  14909. /**
  14910. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14911. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14912. */
  14913. getAbsolutePivotPoint(): Vector3;
  14914. /**
  14915. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14916. * @param result vector3 to store the result
  14917. * @returns this TransformNode.
  14918. */
  14919. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14920. /**
  14921. * Defines the passed node as the parent of the current node.
  14922. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14923. * @see https://doc.babylonjs.com/how_to/parenting
  14924. * @param node the node ot set as the parent
  14925. * @returns this TransformNode.
  14926. */
  14927. setParent(node: Nullable<Node>): TransformNode;
  14928. private _nonUniformScaling;
  14929. /**
  14930. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14931. */
  14932. get nonUniformScaling(): boolean;
  14933. /** @hidden */
  14934. _updateNonUniformScalingState(value: boolean): boolean;
  14935. /**
  14936. * Attach the current TransformNode to another TransformNode associated with a bone
  14937. * @param bone Bone affecting the TransformNode
  14938. * @param affectedTransformNode TransformNode associated with the bone
  14939. * @returns this object
  14940. */
  14941. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14942. /**
  14943. * Detach the transform node if its associated with a bone
  14944. * @returns this object
  14945. */
  14946. detachFromBone(): TransformNode;
  14947. private static _rotationAxisCache;
  14948. /**
  14949. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14950. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14951. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14952. * The passed axis is also normalized.
  14953. * @param axis the axis to rotate around
  14954. * @param amount the amount to rotate in radians
  14955. * @param space Space to rotate in (Default: local)
  14956. * @returns the TransformNode.
  14957. */
  14958. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14959. /**
  14960. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14961. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14962. * The passed axis is also normalized. .
  14963. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14964. * @param point the point to rotate around
  14965. * @param axis the axis to rotate around
  14966. * @param amount the amount to rotate in radians
  14967. * @returns the TransformNode
  14968. */
  14969. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14970. /**
  14971. * Translates the mesh along the axis vector for the passed distance in the given space.
  14972. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14973. * @param axis the axis to translate in
  14974. * @param distance the distance to translate
  14975. * @param space Space to rotate in (Default: local)
  14976. * @returns the TransformNode.
  14977. */
  14978. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14979. /**
  14980. * Adds a rotation step to the mesh current rotation.
  14981. * x, y, z are Euler angles expressed in radians.
  14982. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14983. * This means this rotation is made in the mesh local space only.
  14984. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14985. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14986. * ```javascript
  14987. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14988. * ```
  14989. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14990. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14991. * @param x Rotation to add
  14992. * @param y Rotation to add
  14993. * @param z Rotation to add
  14994. * @returns the TransformNode.
  14995. */
  14996. addRotation(x: number, y: number, z: number): TransformNode;
  14997. /**
  14998. * @hidden
  14999. */
  15000. protected _getEffectiveParent(): Nullable<Node>;
  15001. /**
  15002. * Computes the world matrix of the node
  15003. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15004. * @returns the world matrix
  15005. */
  15006. computeWorldMatrix(force?: boolean): Matrix;
  15007. /**
  15008. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15009. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15010. */
  15011. resetLocalMatrix(independentOfChildren?: boolean): void;
  15012. protected _afterComputeWorldMatrix(): void;
  15013. /**
  15014. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15015. * @param func callback function to add
  15016. *
  15017. * @returns the TransformNode.
  15018. */
  15019. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15020. /**
  15021. * Removes a registered callback function.
  15022. * @param func callback function to remove
  15023. * @returns the TransformNode.
  15024. */
  15025. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15026. /**
  15027. * Gets the position of the current mesh in camera space
  15028. * @param camera defines the camera to use
  15029. * @returns a position
  15030. */
  15031. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15032. /**
  15033. * Returns the distance from the mesh to the active camera
  15034. * @param camera defines the camera to use
  15035. * @returns the distance
  15036. */
  15037. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15038. /**
  15039. * Clone the current transform node
  15040. * @param name Name of the new clone
  15041. * @param newParent New parent for the clone
  15042. * @param doNotCloneChildren Do not clone children hierarchy
  15043. * @returns the new transform node
  15044. */
  15045. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15046. /**
  15047. * Serializes the objects information.
  15048. * @param currentSerializationObject defines the object to serialize in
  15049. * @returns the serialized object
  15050. */
  15051. serialize(currentSerializationObject?: any): any;
  15052. /**
  15053. * Returns a new TransformNode object parsed from the source provided.
  15054. * @param parsedTransformNode is the source.
  15055. * @param scene the scne the object belongs to
  15056. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15057. * @returns a new TransformNode object parsed from the source provided.
  15058. */
  15059. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15060. /**
  15061. * Get all child-transformNodes of this node
  15062. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  15063. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  15064. * @returns an array of TransformNode
  15065. */
  15066. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15067. /**
  15068. * Releases resources associated with this transform node.
  15069. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15070. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15071. */
  15072. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15073. /**
  15074. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15075. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15076. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15077. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15078. * @returns the current mesh
  15079. */
  15080. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15081. private _syncAbsoluteScalingAndRotation;
  15082. }
  15083. }
  15084. declare module BABYLON {
  15085. /**
  15086. * Class used to override all child animations of a given target
  15087. */
  15088. export class AnimationPropertiesOverride {
  15089. /**
  15090. * Gets or sets a value indicating if animation blending must be used
  15091. */
  15092. enableBlending: boolean;
  15093. /**
  15094. * Gets or sets the blending speed to use when enableBlending is true
  15095. */
  15096. blendingSpeed: number;
  15097. /**
  15098. * Gets or sets the default loop mode to use
  15099. */
  15100. loopMode: number;
  15101. }
  15102. }
  15103. declare module BABYLON {
  15104. /**
  15105. * Class used to store bone information
  15106. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15107. */
  15108. export class Bone extends Node {
  15109. /**
  15110. * defines the bone name
  15111. */
  15112. name: string;
  15113. private static _tmpVecs;
  15114. private static _tmpQuat;
  15115. private static _tmpMats;
  15116. /**
  15117. * Gets the list of child bones
  15118. */
  15119. children: Bone[];
  15120. /** Gets the animations associated with this bone */
  15121. animations: Animation[];
  15122. /**
  15123. * Gets or sets bone length
  15124. */
  15125. length: number;
  15126. /**
  15127. * @hidden Internal only
  15128. * Set this value to map this bone to a different index in the transform matrices
  15129. * Set this value to -1 to exclude the bone from the transform matrices
  15130. */
  15131. _index: Nullable<number>;
  15132. private _skeleton;
  15133. private _localMatrix;
  15134. private _restPose;
  15135. private _bindPose;
  15136. private _baseMatrix;
  15137. private _absoluteTransform;
  15138. private _invertedAbsoluteTransform;
  15139. private _parent;
  15140. private _scalingDeterminant;
  15141. private _worldTransform;
  15142. private _localScaling;
  15143. private _localRotation;
  15144. private _localPosition;
  15145. private _needToDecompose;
  15146. private _needToCompose;
  15147. /** @hidden */
  15148. _linkedTransformNode: Nullable<TransformNode>;
  15149. /** @hidden */
  15150. _waitingTransformNodeId: Nullable<string>;
  15151. /** @hidden */
  15152. get _matrix(): Matrix;
  15153. /** @hidden */
  15154. set _matrix(value: Matrix);
  15155. /**
  15156. * Create a new bone
  15157. * @param name defines the bone name
  15158. * @param skeleton defines the parent skeleton
  15159. * @param parentBone defines the parent (can be null if the bone is the root)
  15160. * @param localMatrix defines the local matrix
  15161. * @param restPose defines the rest pose matrix
  15162. * @param baseMatrix defines the base matrix
  15163. * @param index defines index of the bone in the hiearchy
  15164. */
  15165. constructor(
  15166. /**
  15167. * defines the bone name
  15168. */
  15169. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15170. /**
  15171. * Gets the current object class name.
  15172. * @return the class name
  15173. */
  15174. getClassName(): string;
  15175. /**
  15176. * Gets the parent skeleton
  15177. * @returns a skeleton
  15178. */
  15179. getSkeleton(): Skeleton;
  15180. /**
  15181. * Gets parent bone
  15182. * @returns a bone or null if the bone is the root of the bone hierarchy
  15183. */
  15184. getParent(): Nullable<Bone>;
  15185. /**
  15186. * Returns an array containing the root bones
  15187. * @returns an array containing the root bones
  15188. */
  15189. getChildren(): Array<Bone>;
  15190. /**
  15191. * Gets the node index in matrix array generated for rendering
  15192. * @returns the node index
  15193. */
  15194. getIndex(): number;
  15195. /**
  15196. * Sets the parent bone
  15197. * @param parent defines the parent (can be null if the bone is the root)
  15198. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15199. */
  15200. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15201. /**
  15202. * Gets the local matrix
  15203. * @returns a matrix
  15204. */
  15205. getLocalMatrix(): Matrix;
  15206. /**
  15207. * Gets the base matrix (initial matrix which remains unchanged)
  15208. * @returns a matrix
  15209. */
  15210. getBaseMatrix(): Matrix;
  15211. /**
  15212. * Gets the rest pose matrix
  15213. * @returns a matrix
  15214. */
  15215. getRestPose(): Matrix;
  15216. /**
  15217. * Sets the rest pose matrix
  15218. * @param matrix the local-space rest pose to set for this bone
  15219. */
  15220. setRestPose(matrix: Matrix): void;
  15221. /**
  15222. * Gets the bind pose matrix
  15223. * @returns the bind pose matrix
  15224. */
  15225. getBindPose(): Matrix;
  15226. /**
  15227. * Sets the bind pose matrix
  15228. * @param matrix the local-space bind pose to set for this bone
  15229. */
  15230. setBindPose(matrix: Matrix): void;
  15231. /**
  15232. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15233. */
  15234. getWorldMatrix(): Matrix;
  15235. /**
  15236. * Sets the local matrix to rest pose matrix
  15237. */
  15238. returnToRest(): void;
  15239. /**
  15240. * Gets the inverse of the absolute transform matrix.
  15241. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15242. * @returns a matrix
  15243. */
  15244. getInvertedAbsoluteTransform(): Matrix;
  15245. /**
  15246. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15247. * @returns a matrix
  15248. */
  15249. getAbsoluteTransform(): Matrix;
  15250. /**
  15251. * Links with the given transform node.
  15252. * The local matrix of this bone is copied from the transform node every frame.
  15253. * @param transformNode defines the transform node to link to
  15254. */
  15255. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15256. /**
  15257. * Gets the node used to drive the bone's transformation
  15258. * @returns a transform node or null
  15259. */
  15260. getTransformNode(): Nullable<TransformNode>;
  15261. /** Gets or sets current position (in local space) */
  15262. get position(): Vector3;
  15263. set position(newPosition: Vector3);
  15264. /** Gets or sets current rotation (in local space) */
  15265. get rotation(): Vector3;
  15266. set rotation(newRotation: Vector3);
  15267. /** Gets or sets current rotation quaternion (in local space) */
  15268. get rotationQuaternion(): Quaternion;
  15269. set rotationQuaternion(newRotation: Quaternion);
  15270. /** Gets or sets current scaling (in local space) */
  15271. get scaling(): Vector3;
  15272. set scaling(newScaling: Vector3);
  15273. /**
  15274. * Gets the animation properties override
  15275. */
  15276. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15277. private _decompose;
  15278. private _compose;
  15279. /**
  15280. * Update the base and local matrices
  15281. * @param matrix defines the new base or local matrix
  15282. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15283. * @param updateLocalMatrix defines if the local matrix should be updated
  15284. */
  15285. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15286. /** @hidden */
  15287. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15288. /**
  15289. * Flag the bone as dirty (Forcing it to update everything)
  15290. */
  15291. markAsDirty(): void;
  15292. /** @hidden */
  15293. _markAsDirtyAndCompose(): void;
  15294. private _markAsDirtyAndDecompose;
  15295. /**
  15296. * Translate the bone in local or world space
  15297. * @param vec The amount to translate the bone
  15298. * @param space The space that the translation is in
  15299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15300. */
  15301. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15302. /**
  15303. * Set the postion of the bone in local or world space
  15304. * @param position The position to set the bone
  15305. * @param space The space that the position is in
  15306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15307. */
  15308. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15309. /**
  15310. * Set the absolute position of the bone (world space)
  15311. * @param position The position to set the bone
  15312. * @param mesh The mesh that this bone is attached to
  15313. */
  15314. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15315. /**
  15316. * Scale the bone on the x, y and z axes (in local space)
  15317. * @param x The amount to scale the bone on the x axis
  15318. * @param y The amount to scale the bone on the y axis
  15319. * @param z The amount to scale the bone on the z axis
  15320. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15321. */
  15322. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15323. /**
  15324. * Set the bone scaling in local space
  15325. * @param scale defines the scaling vector
  15326. */
  15327. setScale(scale: Vector3): void;
  15328. /**
  15329. * Gets the current scaling in local space
  15330. * @returns the current scaling vector
  15331. */
  15332. getScale(): Vector3;
  15333. /**
  15334. * Gets the current scaling in local space and stores it in a target vector
  15335. * @param result defines the target vector
  15336. */
  15337. getScaleToRef(result: Vector3): void;
  15338. /**
  15339. * Set the yaw, pitch, and roll of the bone in local or world space
  15340. * @param yaw The rotation of the bone on the y axis
  15341. * @param pitch The rotation of the bone on the x axis
  15342. * @param roll The rotation of the bone on the z axis
  15343. * @param space The space that the axes of rotation are in
  15344. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15345. */
  15346. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15347. /**
  15348. * Add a rotation to the bone on an axis in local or world space
  15349. * @param axis The axis to rotate the bone on
  15350. * @param amount The amount to rotate the bone
  15351. * @param space The space that the axis is in
  15352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15353. */
  15354. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15355. /**
  15356. * Set the rotation of the bone to a particular axis angle in local or world space
  15357. * @param axis The axis to rotate the bone on
  15358. * @param angle The angle that the bone should be rotated to
  15359. * @param space The space that the axis is in
  15360. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15361. */
  15362. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15363. /**
  15364. * Set the euler rotation of the bone in local of world space
  15365. * @param rotation The euler rotation that the bone should be set to
  15366. * @param space The space that the rotation is in
  15367. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15368. */
  15369. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15370. /**
  15371. * Set the quaternion rotation of the bone in local of world space
  15372. * @param quat The quaternion rotation that the bone should be set to
  15373. * @param space The space that the rotation is in
  15374. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15375. */
  15376. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15377. /**
  15378. * Set the rotation matrix of the bone in local of world space
  15379. * @param rotMat The rotation matrix that the bone should be set to
  15380. * @param space The space that the rotation is in
  15381. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15382. */
  15383. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15384. private _rotateWithMatrix;
  15385. private _getNegativeRotationToRef;
  15386. /**
  15387. * Get the position of the bone in local or world space
  15388. * @param space The space that the returned position is in
  15389. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15390. * @returns The position of the bone
  15391. */
  15392. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15393. /**
  15394. * Copy the position of the bone to a vector3 in local or world space
  15395. * @param space The space that the returned position is in
  15396. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15397. * @param result The vector3 to copy the position to
  15398. */
  15399. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15400. /**
  15401. * Get the absolute position of the bone (world space)
  15402. * @param mesh The mesh that this bone is attached to
  15403. * @returns The absolute position of the bone
  15404. */
  15405. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15406. /**
  15407. * Copy the absolute position of the bone (world space) to the result param
  15408. * @param mesh The mesh that this bone is attached to
  15409. * @param result The vector3 to copy the absolute position to
  15410. */
  15411. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15412. /**
  15413. * Compute the absolute transforms of this bone and its children
  15414. */
  15415. computeAbsoluteTransforms(): void;
  15416. /**
  15417. * Get the world direction from an axis that is in the local space of the bone
  15418. * @param localAxis The local direction that is used to compute the world direction
  15419. * @param mesh The mesh that this bone is attached to
  15420. * @returns The world direction
  15421. */
  15422. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15423. /**
  15424. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15425. * @param localAxis The local direction that is used to compute the world direction
  15426. * @param mesh The mesh that this bone is attached to
  15427. * @param result The vector3 that the world direction will be copied to
  15428. */
  15429. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15430. /**
  15431. * Get the euler rotation of the bone in local or world space
  15432. * @param space The space that the rotation should be in
  15433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15434. * @returns The euler rotation
  15435. */
  15436. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15437. /**
  15438. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15439. * @param space The space that the rotation should be in
  15440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15441. * @param result The vector3 that the rotation should be copied to
  15442. */
  15443. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15444. /**
  15445. * Get the quaternion rotation of the bone in either local or world space
  15446. * @param space The space that the rotation should be in
  15447. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15448. * @returns The quaternion rotation
  15449. */
  15450. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15451. /**
  15452. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15453. * @param space The space that the rotation should be in
  15454. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15455. * @param result The quaternion that the rotation should be copied to
  15456. */
  15457. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15458. /**
  15459. * Get the rotation matrix of the bone in local or world space
  15460. * @param space The space that the rotation should be in
  15461. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15462. * @returns The rotation matrix
  15463. */
  15464. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15465. /**
  15466. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15467. * @param space The space that the rotation should be in
  15468. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15469. * @param result The quaternion that the rotation should be copied to
  15470. */
  15471. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15472. /**
  15473. * Get the world position of a point that is in the local space of the bone
  15474. * @param position The local position
  15475. * @param mesh The mesh that this bone is attached to
  15476. * @returns The world position
  15477. */
  15478. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15479. /**
  15480. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15481. * @param position The local position
  15482. * @param mesh The mesh that this bone is attached to
  15483. * @param result The vector3 that the world position should be copied to
  15484. */
  15485. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15486. /**
  15487. * Get the local position of a point that is in world space
  15488. * @param position The world position
  15489. * @param mesh The mesh that this bone is attached to
  15490. * @returns The local position
  15491. */
  15492. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15493. /**
  15494. * Get the local position of a point that is in world space and copy it to the result param
  15495. * @param position The world position
  15496. * @param mesh The mesh that this bone is attached to
  15497. * @param result The vector3 that the local position should be copied to
  15498. */
  15499. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15500. }
  15501. }
  15502. declare module BABYLON {
  15503. /**
  15504. * Defines a runtime animation
  15505. */
  15506. export class RuntimeAnimation {
  15507. private _events;
  15508. /**
  15509. * The current frame of the runtime animation
  15510. */
  15511. private _currentFrame;
  15512. /**
  15513. * The animation used by the runtime animation
  15514. */
  15515. private _animation;
  15516. /**
  15517. * The target of the runtime animation
  15518. */
  15519. private _target;
  15520. /**
  15521. * The initiating animatable
  15522. */
  15523. private _host;
  15524. /**
  15525. * The original value of the runtime animation
  15526. */
  15527. private _originalValue;
  15528. /**
  15529. * The original blend value of the runtime animation
  15530. */
  15531. private _originalBlendValue;
  15532. /**
  15533. * The offsets cache of the runtime animation
  15534. */
  15535. private _offsetsCache;
  15536. /**
  15537. * The high limits cache of the runtime animation
  15538. */
  15539. private _highLimitsCache;
  15540. /**
  15541. * Specifies if the runtime animation has been stopped
  15542. */
  15543. private _stopped;
  15544. /**
  15545. * The blending factor of the runtime animation
  15546. */
  15547. private _blendingFactor;
  15548. /**
  15549. * The BabylonJS scene
  15550. */
  15551. private _scene;
  15552. /**
  15553. * The current value of the runtime animation
  15554. */
  15555. private _currentValue;
  15556. /** @hidden */
  15557. _animationState: _IAnimationState;
  15558. /**
  15559. * The active target of the runtime animation
  15560. */
  15561. private _activeTargets;
  15562. private _currentActiveTarget;
  15563. private _directTarget;
  15564. /**
  15565. * The target path of the runtime animation
  15566. */
  15567. private _targetPath;
  15568. /**
  15569. * The weight of the runtime animation
  15570. */
  15571. private _weight;
  15572. /**
  15573. * The ratio offset of the runtime animation
  15574. */
  15575. private _ratioOffset;
  15576. /**
  15577. * The previous delay of the runtime animation
  15578. */
  15579. private _previousDelay;
  15580. /**
  15581. * The previous ratio of the runtime animation
  15582. */
  15583. private _previousRatio;
  15584. private _enableBlending;
  15585. private _keys;
  15586. private _minFrame;
  15587. private _maxFrame;
  15588. private _minValue;
  15589. private _maxValue;
  15590. private _targetIsArray;
  15591. /**
  15592. * Gets the current frame of the runtime animation
  15593. */
  15594. get currentFrame(): number;
  15595. /**
  15596. * Gets the weight of the runtime animation
  15597. */
  15598. get weight(): number;
  15599. /**
  15600. * Gets the current value of the runtime animation
  15601. */
  15602. get currentValue(): any;
  15603. /**
  15604. * Gets the target path of the runtime animation
  15605. */
  15606. get targetPath(): string;
  15607. /**
  15608. * Gets the actual target of the runtime animation
  15609. */
  15610. get target(): any;
  15611. /**
  15612. * Gets the additive state of the runtime animation
  15613. */
  15614. get isAdditive(): boolean;
  15615. /** @hidden */
  15616. _onLoop: () => void;
  15617. /**
  15618. * Create a new RuntimeAnimation object
  15619. * @param target defines the target of the animation
  15620. * @param animation defines the source animation object
  15621. * @param scene defines the hosting scene
  15622. * @param host defines the initiating Animatable
  15623. */
  15624. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15625. private _preparePath;
  15626. /**
  15627. * Gets the animation from the runtime animation
  15628. */
  15629. get animation(): Animation;
  15630. /**
  15631. * Resets the runtime animation to the beginning
  15632. * @param restoreOriginal defines whether to restore the target property to the original value
  15633. */
  15634. reset(restoreOriginal?: boolean): void;
  15635. /**
  15636. * Specifies if the runtime animation is stopped
  15637. * @returns Boolean specifying if the runtime animation is stopped
  15638. */
  15639. isStopped(): boolean;
  15640. /**
  15641. * Disposes of the runtime animation
  15642. */
  15643. dispose(): void;
  15644. /**
  15645. * Apply the interpolated value to the target
  15646. * @param currentValue defines the value computed by the animation
  15647. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15648. */
  15649. setValue(currentValue: any, weight: number): void;
  15650. private _getOriginalValues;
  15651. private _setValue;
  15652. /**
  15653. * Gets the loop pmode of the runtime animation
  15654. * @returns Loop Mode
  15655. */
  15656. private _getCorrectLoopMode;
  15657. /**
  15658. * Move the current animation to a given frame
  15659. * @param frame defines the frame to move to
  15660. */
  15661. goToFrame(frame: number): void;
  15662. /**
  15663. * @hidden Internal use only
  15664. */
  15665. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15666. /**
  15667. * Execute the current animation
  15668. * @param delay defines the delay to add to the current frame
  15669. * @param from defines the lower bound of the animation range
  15670. * @param to defines the upper bound of the animation range
  15671. * @param loop defines if the current animation must loop
  15672. * @param speedRatio defines the current speed ratio
  15673. * @param weight defines the weight of the animation (default is -1 so no weight)
  15674. * @param onLoop optional callback called when animation loops
  15675. * @returns a boolean indicating if the animation is running
  15676. */
  15677. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15678. }
  15679. }
  15680. declare module BABYLON {
  15681. /**
  15682. * Class used to store an actual running animation
  15683. */
  15684. export class Animatable {
  15685. /** defines the target object */
  15686. target: any;
  15687. /** defines the starting frame number (default is 0) */
  15688. fromFrame: number;
  15689. /** defines the ending frame number (default is 100) */
  15690. toFrame: number;
  15691. /** defines if the animation must loop (default is false) */
  15692. loopAnimation: boolean;
  15693. /** defines a callback to call when animation ends if it is not looping */
  15694. onAnimationEnd?: (() => void) | null | undefined;
  15695. /** defines a callback to call when animation loops */
  15696. onAnimationLoop?: (() => void) | null | undefined;
  15697. /** defines whether the animation should be evaluated additively */
  15698. isAdditive: boolean;
  15699. private _localDelayOffset;
  15700. private _pausedDelay;
  15701. private _runtimeAnimations;
  15702. private _paused;
  15703. private _scene;
  15704. private _speedRatio;
  15705. private _weight;
  15706. private _syncRoot;
  15707. /**
  15708. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15709. * This will only apply for non looping animation (default is true)
  15710. */
  15711. disposeOnEnd: boolean;
  15712. /**
  15713. * Gets a boolean indicating if the animation has started
  15714. */
  15715. animationStarted: boolean;
  15716. /**
  15717. * Observer raised when the animation ends
  15718. */
  15719. onAnimationEndObservable: Observable<Animatable>;
  15720. /**
  15721. * Observer raised when the animation loops
  15722. */
  15723. onAnimationLoopObservable: Observable<Animatable>;
  15724. /**
  15725. * Gets the root Animatable used to synchronize and normalize animations
  15726. */
  15727. get syncRoot(): Nullable<Animatable>;
  15728. /**
  15729. * Gets the current frame of the first RuntimeAnimation
  15730. * Used to synchronize Animatables
  15731. */
  15732. get masterFrame(): number;
  15733. /**
  15734. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15735. */
  15736. get weight(): number;
  15737. set weight(value: number);
  15738. /**
  15739. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15740. */
  15741. get speedRatio(): number;
  15742. set speedRatio(value: number);
  15743. /**
  15744. * Creates a new Animatable
  15745. * @param scene defines the hosting scene
  15746. * @param target defines the target object
  15747. * @param fromFrame defines the starting frame number (default is 0)
  15748. * @param toFrame defines the ending frame number (default is 100)
  15749. * @param loopAnimation defines if the animation must loop (default is false)
  15750. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15751. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15752. * @param animations defines a group of animation to add to the new Animatable
  15753. * @param onAnimationLoop defines a callback to call when animation loops
  15754. * @param isAdditive defines whether the animation should be evaluated additively
  15755. */
  15756. constructor(scene: Scene,
  15757. /** defines the target object */
  15758. target: any,
  15759. /** defines the starting frame number (default is 0) */
  15760. fromFrame?: number,
  15761. /** defines the ending frame number (default is 100) */
  15762. toFrame?: number,
  15763. /** defines if the animation must loop (default is false) */
  15764. loopAnimation?: boolean, speedRatio?: number,
  15765. /** defines a callback to call when animation ends if it is not looping */
  15766. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15767. /** defines a callback to call when animation loops */
  15768. onAnimationLoop?: (() => void) | null | undefined,
  15769. /** defines whether the animation should be evaluated additively */
  15770. isAdditive?: boolean);
  15771. /**
  15772. * Synchronize and normalize current Animatable with a source Animatable
  15773. * This is useful when using animation weights and when animations are not of the same length
  15774. * @param root defines the root Animatable to synchronize with
  15775. * @returns the current Animatable
  15776. */
  15777. syncWith(root: Animatable): Animatable;
  15778. /**
  15779. * Gets the list of runtime animations
  15780. * @returns an array of RuntimeAnimation
  15781. */
  15782. getAnimations(): RuntimeAnimation[];
  15783. /**
  15784. * Adds more animations to the current animatable
  15785. * @param target defines the target of the animations
  15786. * @param animations defines the new animations to add
  15787. */
  15788. appendAnimations(target: any, animations: Animation[]): void;
  15789. /**
  15790. * Gets the source animation for a specific property
  15791. * @param property defines the propertyu to look for
  15792. * @returns null or the source animation for the given property
  15793. */
  15794. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15795. /**
  15796. * Gets the runtime animation for a specific property
  15797. * @param property defines the propertyu to look for
  15798. * @returns null or the runtime animation for the given property
  15799. */
  15800. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15801. /**
  15802. * Resets the animatable to its original state
  15803. */
  15804. reset(): void;
  15805. /**
  15806. * Allows the animatable to blend with current running animations
  15807. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15808. * @param blendingSpeed defines the blending speed to use
  15809. */
  15810. enableBlending(blendingSpeed: number): void;
  15811. /**
  15812. * Disable animation blending
  15813. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15814. */
  15815. disableBlending(): void;
  15816. /**
  15817. * Jump directly to a given frame
  15818. * @param frame defines the frame to jump to
  15819. */
  15820. goToFrame(frame: number): void;
  15821. /**
  15822. * Pause the animation
  15823. */
  15824. pause(): void;
  15825. /**
  15826. * Restart the animation
  15827. */
  15828. restart(): void;
  15829. private _raiseOnAnimationEnd;
  15830. /**
  15831. * Stop and delete the current animation
  15832. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15833. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  15834. */
  15835. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15836. /**
  15837. * Wait asynchronously for the animation to end
  15838. * @returns a promise which will be fullfilled when the animation ends
  15839. */
  15840. waitAsync(): Promise<Animatable>;
  15841. /** @hidden */
  15842. _animate(delay: number): boolean;
  15843. }
  15844. interface Scene {
  15845. /** @hidden */
  15846. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15847. /** @hidden */
  15848. _processLateAnimationBindingsForMatrices(holder: {
  15849. totalWeight: number;
  15850. totalAdditiveWeight: number;
  15851. animations: RuntimeAnimation[];
  15852. additiveAnimations: RuntimeAnimation[];
  15853. originalValue: Matrix;
  15854. }): any;
  15855. /** @hidden */
  15856. _processLateAnimationBindingsForQuaternions(holder: {
  15857. totalWeight: number;
  15858. totalAdditiveWeight: number;
  15859. animations: RuntimeAnimation[];
  15860. additiveAnimations: RuntimeAnimation[];
  15861. originalValue: Quaternion;
  15862. }, refQuaternion: Quaternion): Quaternion;
  15863. /** @hidden */
  15864. _processLateAnimationBindings(): void;
  15865. /**
  15866. * Will start the animation sequence of a given target
  15867. * @param target defines the target
  15868. * @param from defines from which frame should animation start
  15869. * @param to defines until which frame should animation run.
  15870. * @param weight defines the weight to apply to the animation (1.0 by default)
  15871. * @param loop defines if the animation loops
  15872. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15873. * @param onAnimationEnd defines the function to be executed when the animation ends
  15874. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15875. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15876. * @param onAnimationLoop defines the callback to call when an animation loops
  15877. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15878. * @returns the animatable object created for this animation
  15879. */
  15880. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15881. /**
  15882. * Will start the animation sequence of a given target
  15883. * @param target defines the target
  15884. * @param from defines from which frame should animation start
  15885. * @param to defines until which frame should animation run.
  15886. * @param loop defines if the animation loops
  15887. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15888. * @param onAnimationEnd defines the function to be executed when the animation ends
  15889. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15890. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15891. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15892. * @param onAnimationLoop defines the callback to call when an animation loops
  15893. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15894. * @returns the animatable object created for this animation
  15895. */
  15896. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15897. /**
  15898. * Will start the animation sequence of a given target and its hierarchy
  15899. * @param target defines the target
  15900. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15901. * @param from defines from which frame should animation start
  15902. * @param to defines until which frame should animation run.
  15903. * @param loop defines if the animation loops
  15904. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15905. * @param onAnimationEnd defines the function to be executed when the animation ends
  15906. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15907. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15908. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15909. * @param onAnimationLoop defines the callback to call when an animation loops
  15910. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15911. * @returns the list of created animatables
  15912. */
  15913. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15914. /**
  15915. * Begin a new animation on a given node
  15916. * @param target defines the target where the animation will take place
  15917. * @param animations defines the list of animations to start
  15918. * @param from defines the initial value
  15919. * @param to defines the final value
  15920. * @param loop defines if you want animation to loop (off by default)
  15921. * @param speedRatio defines the speed ratio to apply to all animations
  15922. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15923. * @param onAnimationLoop defines the callback to call when an animation loops
  15924. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15925. * @returns the list of created animatables
  15926. */
  15927. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15928. /**
  15929. * Begin a new animation on a given node and its hierarchy
  15930. * @param target defines the root node where the animation will take place
  15931. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15932. * @param animations defines the list of animations to start
  15933. * @param from defines the initial value
  15934. * @param to defines the final value
  15935. * @param loop defines if you want animation to loop (off by default)
  15936. * @param speedRatio defines the speed ratio to apply to all animations
  15937. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15938. * @param onAnimationLoop defines the callback to call when an animation loops
  15939. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15940. * @returns the list of animatables created for all nodes
  15941. */
  15942. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15943. /**
  15944. * Gets the animatable associated with a specific target
  15945. * @param target defines the target of the animatable
  15946. * @returns the required animatable if found
  15947. */
  15948. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15949. /**
  15950. * Gets all animatables associated with a given target
  15951. * @param target defines the target to look animatables for
  15952. * @returns an array of Animatables
  15953. */
  15954. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15955. /**
  15956. * Stops and removes all animations that have been applied to the scene
  15957. */
  15958. stopAllAnimations(): void;
  15959. /**
  15960. * Gets the current delta time used by animation engine
  15961. */
  15962. deltaTime: number;
  15963. }
  15964. interface Bone {
  15965. /**
  15966. * Copy an animation range from another bone
  15967. * @param source defines the source bone
  15968. * @param rangeName defines the range name to copy
  15969. * @param frameOffset defines the frame offset
  15970. * @param rescaleAsRequired defines if rescaling must be applied if required
  15971. * @param skelDimensionsRatio defines the scaling ratio
  15972. * @returns true if operation was successful
  15973. */
  15974. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15975. }
  15976. }
  15977. declare module BABYLON {
  15978. /**
  15979. * Class used to handle skinning animations
  15980. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15981. */
  15982. export class Skeleton implements IAnimatable {
  15983. /** defines the skeleton name */
  15984. name: string;
  15985. /** defines the skeleton Id */
  15986. id: string;
  15987. /**
  15988. * Defines the list of child bones
  15989. */
  15990. bones: Bone[];
  15991. /**
  15992. * Defines an estimate of the dimension of the skeleton at rest
  15993. */
  15994. dimensionsAtRest: Vector3;
  15995. /**
  15996. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15997. */
  15998. needInitialSkinMatrix: boolean;
  15999. /**
  16000. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16001. */
  16002. overrideMesh: Nullable<AbstractMesh>;
  16003. /**
  16004. * Gets the list of animations attached to this skeleton
  16005. */
  16006. animations: Array<Animation>;
  16007. private _scene;
  16008. private _isDirty;
  16009. private _transformMatrices;
  16010. private _transformMatrixTexture;
  16011. private _meshesWithPoseMatrix;
  16012. private _animatables;
  16013. private _identity;
  16014. private _synchronizedWithMesh;
  16015. private _ranges;
  16016. private _lastAbsoluteTransformsUpdateId;
  16017. private _canUseTextureForBones;
  16018. private _uniqueId;
  16019. /** @hidden */
  16020. _numBonesWithLinkedTransformNode: number;
  16021. /** @hidden */
  16022. _hasWaitingData: Nullable<boolean>;
  16023. /** @hidden */
  16024. _waitingOverrideMeshId: Nullable<string>;
  16025. /**
  16026. * Specifies if the skeleton should be serialized
  16027. */
  16028. doNotSerialize: boolean;
  16029. private _useTextureToStoreBoneMatrices;
  16030. /**
  16031. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16032. * Please note that this option is not available if the hardware does not support it
  16033. */
  16034. get useTextureToStoreBoneMatrices(): boolean;
  16035. set useTextureToStoreBoneMatrices(value: boolean);
  16036. private _animationPropertiesOverride;
  16037. /**
  16038. * Gets or sets the animation properties override
  16039. */
  16040. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16041. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16042. /**
  16043. * List of inspectable custom properties (used by the Inspector)
  16044. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16045. */
  16046. inspectableCustomProperties: IInspectable[];
  16047. /**
  16048. * An observable triggered before computing the skeleton's matrices
  16049. */
  16050. onBeforeComputeObservable: Observable<Skeleton>;
  16051. /**
  16052. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16053. */
  16054. get isUsingTextureForMatrices(): boolean;
  16055. /**
  16056. * Gets the unique ID of this skeleton
  16057. */
  16058. get uniqueId(): number;
  16059. /**
  16060. * Creates a new skeleton
  16061. * @param name defines the skeleton name
  16062. * @param id defines the skeleton Id
  16063. * @param scene defines the hosting scene
  16064. */
  16065. constructor(
  16066. /** defines the skeleton name */
  16067. name: string,
  16068. /** defines the skeleton Id */
  16069. id: string, scene: Scene);
  16070. /**
  16071. * Gets the current object class name.
  16072. * @return the class name
  16073. */
  16074. getClassName(): string;
  16075. /**
  16076. * Returns an array containing the root bones
  16077. * @returns an array containing the root bones
  16078. */
  16079. getChildren(): Array<Bone>;
  16080. /**
  16081. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16082. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16083. * @returns a Float32Array containing matrices data
  16084. */
  16085. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16086. /**
  16087. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16088. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16089. * @returns a raw texture containing the data
  16090. */
  16091. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16092. /**
  16093. * Gets the current hosting scene
  16094. * @returns a scene object
  16095. */
  16096. getScene(): Scene;
  16097. /**
  16098. * Gets a string representing the current skeleton data
  16099. * @param fullDetails defines a boolean indicating if we want a verbose version
  16100. * @returns a string representing the current skeleton data
  16101. */
  16102. toString(fullDetails?: boolean): string;
  16103. /**
  16104. * Get bone's index searching by name
  16105. * @param name defines bone's name to search for
  16106. * @return the indice of the bone. Returns -1 if not found
  16107. */
  16108. getBoneIndexByName(name: string): number;
  16109. /**
  16110. * Creater a new animation range
  16111. * @param name defines the name of the range
  16112. * @param from defines the start key
  16113. * @param to defines the end key
  16114. */
  16115. createAnimationRange(name: string, from: number, to: number): void;
  16116. /**
  16117. * Delete a specific animation range
  16118. * @param name defines the name of the range
  16119. * @param deleteFrames defines if frames must be removed as well
  16120. */
  16121. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16122. /**
  16123. * Gets a specific animation range
  16124. * @param name defines the name of the range to look for
  16125. * @returns the requested animation range or null if not found
  16126. */
  16127. getAnimationRange(name: string): Nullable<AnimationRange>;
  16128. /**
  16129. * Gets the list of all animation ranges defined on this skeleton
  16130. * @returns an array
  16131. */
  16132. getAnimationRanges(): Nullable<AnimationRange>[];
  16133. /**
  16134. * Copy animation range from a source skeleton.
  16135. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16136. * @param source defines the source skeleton
  16137. * @param name defines the name of the range to copy
  16138. * @param rescaleAsRequired defines if rescaling must be applied if required
  16139. * @returns true if operation was successful
  16140. */
  16141. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16142. /**
  16143. * Forces the skeleton to go to rest pose
  16144. */
  16145. returnToRest(): void;
  16146. private _getHighestAnimationFrame;
  16147. /**
  16148. * Begin a specific animation range
  16149. * @param name defines the name of the range to start
  16150. * @param loop defines if looping must be turned on (false by default)
  16151. * @param speedRatio defines the speed ratio to apply (1 by default)
  16152. * @param onAnimationEnd defines a callback which will be called when animation will end
  16153. * @returns a new animatable
  16154. */
  16155. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16156. /**
  16157. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16158. * @param skeleton defines the Skeleton containing the animation range to convert
  16159. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16160. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16161. * @returns the original skeleton
  16162. */
  16163. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16164. /** @hidden */
  16165. _markAsDirty(): void;
  16166. /** @hidden */
  16167. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16168. /** @hidden */
  16169. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16170. private _computeTransformMatrices;
  16171. /**
  16172. * Build all resources required to render a skeleton
  16173. */
  16174. prepare(): void;
  16175. /**
  16176. * Gets the list of animatables currently running for this skeleton
  16177. * @returns an array of animatables
  16178. */
  16179. getAnimatables(): IAnimatable[];
  16180. /**
  16181. * Clone the current skeleton
  16182. * @param name defines the name of the new skeleton
  16183. * @param id defines the id of the new skeleton
  16184. * @returns the new skeleton
  16185. */
  16186. clone(name: string, id?: string): Skeleton;
  16187. /**
  16188. * Enable animation blending for this skeleton
  16189. * @param blendingSpeed defines the blending speed to apply
  16190. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16191. */
  16192. enableBlending(blendingSpeed?: number): void;
  16193. /**
  16194. * Releases all resources associated with the current skeleton
  16195. */
  16196. dispose(): void;
  16197. /**
  16198. * Serialize the skeleton in a JSON object
  16199. * @returns a JSON object
  16200. */
  16201. serialize(): any;
  16202. /**
  16203. * Creates a new skeleton from serialized data
  16204. * @param parsedSkeleton defines the serialized data
  16205. * @param scene defines the hosting scene
  16206. * @returns a new skeleton
  16207. */
  16208. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16209. /**
  16210. * Compute all node absolute transforms
  16211. * @param forceUpdate defines if computation must be done even if cache is up to date
  16212. */
  16213. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16214. /**
  16215. * Gets the root pose matrix
  16216. * @returns a matrix
  16217. */
  16218. getPoseMatrix(): Nullable<Matrix>;
  16219. /**
  16220. * Sorts bones per internal index
  16221. */
  16222. sortBones(): void;
  16223. private _sortBones;
  16224. }
  16225. }
  16226. declare module BABYLON {
  16227. /**
  16228. * Creates an instance based on a source mesh.
  16229. */
  16230. export class InstancedMesh extends AbstractMesh {
  16231. private _sourceMesh;
  16232. private _currentLOD;
  16233. /** @hidden */
  16234. _indexInSourceMeshInstanceArray: number;
  16235. constructor(name: string, source: Mesh);
  16236. /**
  16237. * Returns the string "InstancedMesh".
  16238. */
  16239. getClassName(): string;
  16240. /** Gets the list of lights affecting that mesh */
  16241. get lightSources(): Light[];
  16242. _resyncLightSources(): void;
  16243. _resyncLightSource(light: Light): void;
  16244. _removeLightSource(light: Light, dispose: boolean): void;
  16245. /**
  16246. * If the source mesh receives shadows
  16247. */
  16248. get receiveShadows(): boolean;
  16249. /**
  16250. * The material of the source mesh
  16251. */
  16252. get material(): Nullable<Material>;
  16253. /**
  16254. * Visibility of the source mesh
  16255. */
  16256. get visibility(): number;
  16257. /**
  16258. * Skeleton of the source mesh
  16259. */
  16260. get skeleton(): Nullable<Skeleton>;
  16261. /**
  16262. * Rendering ground id of the source mesh
  16263. */
  16264. get renderingGroupId(): number;
  16265. set renderingGroupId(value: number);
  16266. /**
  16267. * Returns the total number of vertices (integer).
  16268. */
  16269. getTotalVertices(): number;
  16270. /**
  16271. * Returns a positive integer : the total number of indices in this mesh geometry.
  16272. * @returns the numner of indices or zero if the mesh has no geometry.
  16273. */
  16274. getTotalIndices(): number;
  16275. /**
  16276. * The source mesh of the instance
  16277. */
  16278. get sourceMesh(): Mesh;
  16279. /**
  16280. * Creates a new InstancedMesh object from the mesh model.
  16281. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16282. * @param name defines the name of the new instance
  16283. * @returns a new InstancedMesh
  16284. */
  16285. createInstance(name: string): InstancedMesh;
  16286. /**
  16287. * Is this node ready to be used/rendered
  16288. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16289. * @return {boolean} is it ready
  16290. */
  16291. isReady(completeCheck?: boolean): boolean;
  16292. /**
  16293. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16294. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16295. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  16296. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16297. */
  16298. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16299. /**
  16300. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16301. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16302. * The `data` are either a numeric array either a Float32Array.
  16303. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16304. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  16305. * Note that a new underlying VertexBuffer object is created each call.
  16306. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16307. *
  16308. * Possible `kind` values :
  16309. * - VertexBuffer.PositionKind
  16310. * - VertexBuffer.UVKind
  16311. * - VertexBuffer.UV2Kind
  16312. * - VertexBuffer.UV3Kind
  16313. * - VertexBuffer.UV4Kind
  16314. * - VertexBuffer.UV5Kind
  16315. * - VertexBuffer.UV6Kind
  16316. * - VertexBuffer.ColorKind
  16317. * - VertexBuffer.MatricesIndicesKind
  16318. * - VertexBuffer.MatricesIndicesExtraKind
  16319. * - VertexBuffer.MatricesWeightsKind
  16320. * - VertexBuffer.MatricesWeightsExtraKind
  16321. *
  16322. * Returns the Mesh.
  16323. */
  16324. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16325. /**
  16326. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16327. * If the mesh has no geometry, it is simply returned as it is.
  16328. * The `data` are either a numeric array either a Float32Array.
  16329. * No new underlying VertexBuffer object is created.
  16330. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16331. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16332. *
  16333. * Possible `kind` values :
  16334. * - VertexBuffer.PositionKind
  16335. * - VertexBuffer.UVKind
  16336. * - VertexBuffer.UV2Kind
  16337. * - VertexBuffer.UV3Kind
  16338. * - VertexBuffer.UV4Kind
  16339. * - VertexBuffer.UV5Kind
  16340. * - VertexBuffer.UV6Kind
  16341. * - VertexBuffer.ColorKind
  16342. * - VertexBuffer.MatricesIndicesKind
  16343. * - VertexBuffer.MatricesIndicesExtraKind
  16344. * - VertexBuffer.MatricesWeightsKind
  16345. * - VertexBuffer.MatricesWeightsExtraKind
  16346. *
  16347. * Returns the Mesh.
  16348. */
  16349. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16350. /**
  16351. * Sets the mesh indices.
  16352. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16353. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16354. * This method creates a new index buffer each call.
  16355. * Returns the Mesh.
  16356. */
  16357. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16358. /**
  16359. * Boolean : True if the mesh owns the requested kind of data.
  16360. */
  16361. isVerticesDataPresent(kind: string): boolean;
  16362. /**
  16363. * Returns an array of indices (IndicesArray).
  16364. */
  16365. getIndices(): Nullable<IndicesArray>;
  16366. get _positions(): Nullable<Vector3[]>;
  16367. /**
  16368. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16369. * This means the mesh underlying bounding box and sphere are recomputed.
  16370. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16371. * @returns the current mesh
  16372. */
  16373. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16374. /** @hidden */
  16375. _preActivate(): InstancedMesh;
  16376. /** @hidden */
  16377. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16378. /** @hidden */
  16379. _postActivate(): void;
  16380. getWorldMatrix(): Matrix;
  16381. get isAnInstance(): boolean;
  16382. /**
  16383. * Returns the current associated LOD AbstractMesh.
  16384. */
  16385. getLOD(camera: Camera): AbstractMesh;
  16386. /** @hidden */
  16387. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16388. /** @hidden */
  16389. _syncSubMeshes(): InstancedMesh;
  16390. /** @hidden */
  16391. _generatePointsArray(): boolean;
  16392. /** @hidden */
  16393. _updateBoundingInfo(): AbstractMesh;
  16394. /**
  16395. * Creates a new InstancedMesh from the current mesh.
  16396. * - name (string) : the cloned mesh name
  16397. * - newParent (optional Node) : the optional Node to parent the clone to.
  16398. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16399. *
  16400. * Returns the clone.
  16401. */
  16402. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16403. /**
  16404. * Disposes the InstancedMesh.
  16405. * Returns nothing.
  16406. */
  16407. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16408. }
  16409. interface Mesh {
  16410. /**
  16411. * Register a custom buffer that will be instanced
  16412. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16413. * @param kind defines the buffer kind
  16414. * @param stride defines the stride in floats
  16415. */
  16416. registerInstancedBuffer(kind: string, stride: number): void;
  16417. /**
  16418. * true to use the edge renderer for all instances of this mesh
  16419. */
  16420. edgesShareWithInstances: boolean;
  16421. /** @hidden */
  16422. _userInstancedBuffersStorage: {
  16423. data: {
  16424. [key: string]: Float32Array;
  16425. };
  16426. sizes: {
  16427. [key: string]: number;
  16428. };
  16429. vertexBuffers: {
  16430. [key: string]: Nullable<VertexBuffer>;
  16431. };
  16432. strides: {
  16433. [key: string]: number;
  16434. };
  16435. };
  16436. }
  16437. interface AbstractMesh {
  16438. /**
  16439. * Object used to store instanced buffers defined by user
  16440. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16441. */
  16442. instancedBuffers: {
  16443. [key: string]: any;
  16444. };
  16445. }
  16446. }
  16447. declare module BABYLON {
  16448. /**
  16449. * Defines the options associated with the creation of a shader material.
  16450. */
  16451. export interface IShaderMaterialOptions {
  16452. /**
  16453. * Does the material work in alpha blend mode
  16454. */
  16455. needAlphaBlending: boolean;
  16456. /**
  16457. * Does the material work in alpha test mode
  16458. */
  16459. needAlphaTesting: boolean;
  16460. /**
  16461. * The list of attribute names used in the shader
  16462. */
  16463. attributes: string[];
  16464. /**
  16465. * The list of unifrom names used in the shader
  16466. */
  16467. uniforms: string[];
  16468. /**
  16469. * The list of UBO names used in the shader
  16470. */
  16471. uniformBuffers: string[];
  16472. /**
  16473. * The list of sampler names used in the shader
  16474. */
  16475. samplers: string[];
  16476. /**
  16477. * The list of defines used in the shader
  16478. */
  16479. defines: string[];
  16480. }
  16481. /**
  16482. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16483. *
  16484. * This returned material effects how the mesh will look based on the code in the shaders.
  16485. *
  16486. * @see https://doc.babylonjs.com/how_to/shader_material
  16487. */
  16488. export class ShaderMaterial extends Material {
  16489. private _shaderPath;
  16490. private _options;
  16491. private _textures;
  16492. private _textureArrays;
  16493. private _floats;
  16494. private _ints;
  16495. private _floatsArrays;
  16496. private _colors3;
  16497. private _colors3Arrays;
  16498. private _colors4;
  16499. private _colors4Arrays;
  16500. private _vectors2;
  16501. private _vectors3;
  16502. private _vectors4;
  16503. private _matrices;
  16504. private _matrixArrays;
  16505. private _matrices3x3;
  16506. private _matrices2x2;
  16507. private _vectors2Arrays;
  16508. private _vectors3Arrays;
  16509. private _vectors4Arrays;
  16510. private _cachedWorldViewMatrix;
  16511. private _cachedWorldViewProjectionMatrix;
  16512. private _renderId;
  16513. private _multiview;
  16514. private _cachedDefines;
  16515. /** Define the Url to load snippets */
  16516. static SnippetUrl: string;
  16517. /** Snippet ID if the material was created from the snippet server */
  16518. snippetId: string;
  16519. /**
  16520. * Instantiate a new shader material.
  16521. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  16522. * This returned material effects how the mesh will look based on the code in the shaders.
  16523. * @see https://doc.babylonjs.com/how_to/shader_material
  16524. * @param name Define the name of the material in the scene
  16525. * @param scene Define the scene the material belongs to
  16526. * @param shaderPath Defines the route to the shader code in one of three ways:
  16527. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16528. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16529. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16530. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16531. * @param options Define the options used to create the shader
  16532. */
  16533. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16534. /**
  16535. * Gets the shader path used to define the shader code
  16536. * It can be modified to trigger a new compilation
  16537. */
  16538. get shaderPath(): any;
  16539. /**
  16540. * Sets the shader path used to define the shader code
  16541. * It can be modified to trigger a new compilation
  16542. */
  16543. set shaderPath(shaderPath: any);
  16544. /**
  16545. * Gets the options used to compile the shader.
  16546. * They can be modified to trigger a new compilation
  16547. */
  16548. get options(): IShaderMaterialOptions;
  16549. /**
  16550. * Gets the current class name of the material e.g. "ShaderMaterial"
  16551. * Mainly use in serialization.
  16552. * @returns the class name
  16553. */
  16554. getClassName(): string;
  16555. /**
  16556. * Specifies if the material will require alpha blending
  16557. * @returns a boolean specifying if alpha blending is needed
  16558. */
  16559. needAlphaBlending(): boolean;
  16560. /**
  16561. * Specifies if this material should be rendered in alpha test mode
  16562. * @returns a boolean specifying if an alpha test is needed.
  16563. */
  16564. needAlphaTesting(): boolean;
  16565. private _checkUniform;
  16566. /**
  16567. * Set a texture in the shader.
  16568. * @param name Define the name of the uniform samplers as defined in the shader
  16569. * @param texture Define the texture to bind to this sampler
  16570. * @return the material itself allowing "fluent" like uniform updates
  16571. */
  16572. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16573. /**
  16574. * Set a texture array in the shader.
  16575. * @param name Define the name of the uniform sampler array as defined in the shader
  16576. * @param textures Define the list of textures to bind to this sampler
  16577. * @return the material itself allowing "fluent" like uniform updates
  16578. */
  16579. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16580. /**
  16581. * Set a float in the shader.
  16582. * @param name Define the name of the uniform as defined in the shader
  16583. * @param value Define the value to give to the uniform
  16584. * @return the material itself allowing "fluent" like uniform updates
  16585. */
  16586. setFloat(name: string, value: number): ShaderMaterial;
  16587. /**
  16588. * Set a int in the shader.
  16589. * @param name Define the name of the uniform as defined in the shader
  16590. * @param value Define the value to give to the uniform
  16591. * @return the material itself allowing "fluent" like uniform updates
  16592. */
  16593. setInt(name: string, value: number): ShaderMaterial;
  16594. /**
  16595. * Set an array of floats in the shader.
  16596. * @param name Define the name of the uniform as defined in the shader
  16597. * @param value Define the value to give to the uniform
  16598. * @return the material itself allowing "fluent" like uniform updates
  16599. */
  16600. setFloats(name: string, value: number[]): ShaderMaterial;
  16601. /**
  16602. * Set a vec3 in the shader from a Color3.
  16603. * @param name Define the name of the uniform as defined in the shader
  16604. * @param value Define the value to give to the uniform
  16605. * @return the material itself allowing "fluent" like uniform updates
  16606. */
  16607. setColor3(name: string, value: Color3): ShaderMaterial;
  16608. /**
  16609. * Set a vec3 array in the shader from a Color3 array.
  16610. * @param name Define the name of the uniform as defined in the shader
  16611. * @param value Define the value to give to the uniform
  16612. * @return the material itself allowing "fluent" like uniform updates
  16613. */
  16614. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16615. /**
  16616. * Set a vec4 in the shader from a Color4.
  16617. * @param name Define the name of the uniform as defined in the shader
  16618. * @param value Define the value to give to the uniform
  16619. * @return the material itself allowing "fluent" like uniform updates
  16620. */
  16621. setColor4(name: string, value: Color4): ShaderMaterial;
  16622. /**
  16623. * Set a vec4 array in the shader from a Color4 array.
  16624. * @param name Define the name of the uniform as defined in the shader
  16625. * @param value Define the value to give to the uniform
  16626. * @return the material itself allowing "fluent" like uniform updates
  16627. */
  16628. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16629. /**
  16630. * Set a vec2 in the shader from a Vector2.
  16631. * @param name Define the name of the uniform as defined in the shader
  16632. * @param value Define the value to give to the uniform
  16633. * @return the material itself allowing "fluent" like uniform updates
  16634. */
  16635. setVector2(name: string, value: Vector2): ShaderMaterial;
  16636. /**
  16637. * Set a vec3 in the shader from a Vector3.
  16638. * @param name Define the name of the uniform as defined in the shader
  16639. * @param value Define the value to give to the uniform
  16640. * @return the material itself allowing "fluent" like uniform updates
  16641. */
  16642. setVector3(name: string, value: Vector3): ShaderMaterial;
  16643. /**
  16644. * Set a vec4 in the shader from a Vector4.
  16645. * @param name Define the name of the uniform as defined in the shader
  16646. * @param value Define the value to give to the uniform
  16647. * @return the material itself allowing "fluent" like uniform updates
  16648. */
  16649. setVector4(name: string, value: Vector4): ShaderMaterial;
  16650. /**
  16651. * Set a mat4 in the shader from a Matrix.
  16652. * @param name Define the name of the uniform as defined in the shader
  16653. * @param value Define the value to give to the uniform
  16654. * @return the material itself allowing "fluent" like uniform updates
  16655. */
  16656. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16657. /**
  16658. * Set a float32Array in the shader from a matrix array.
  16659. * @param name Define the name of the uniform as defined in the shader
  16660. * @param value Define the value to give to the uniform
  16661. * @return the material itself allowing "fluent" like uniform updates
  16662. */
  16663. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16664. /**
  16665. * Set a mat3 in the shader from a Float32Array.
  16666. * @param name Define the name of the uniform as defined in the shader
  16667. * @param value Define the value to give to the uniform
  16668. * @return the material itself allowing "fluent" like uniform updates
  16669. */
  16670. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16671. /**
  16672. * Set a mat2 in the shader from a Float32Array.
  16673. * @param name Define the name of the uniform as defined in the shader
  16674. * @param value Define the value to give to the uniform
  16675. * @return the material itself allowing "fluent" like uniform updates
  16676. */
  16677. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16678. /**
  16679. * Set a vec2 array in the shader from a number array.
  16680. * @param name Define the name of the uniform as defined in the shader
  16681. * @param value Define the value to give to the uniform
  16682. * @return the material itself allowing "fluent" like uniform updates
  16683. */
  16684. setArray2(name: string, value: number[]): ShaderMaterial;
  16685. /**
  16686. * Set a vec3 array in the shader from a number array.
  16687. * @param name Define the name of the uniform as defined in the shader
  16688. * @param value Define the value to give to the uniform
  16689. * @return the material itself allowing "fluent" like uniform updates
  16690. */
  16691. setArray3(name: string, value: number[]): ShaderMaterial;
  16692. /**
  16693. * Set a vec4 array in the shader from a number array.
  16694. * @param name Define the name of the uniform as defined in the shader
  16695. * @param value Define the value to give to the uniform
  16696. * @return the material itself allowing "fluent" like uniform updates
  16697. */
  16698. setArray4(name: string, value: number[]): ShaderMaterial;
  16699. private _checkCache;
  16700. /**
  16701. * Specifies that the submesh is ready to be used
  16702. * @param mesh defines the mesh to check
  16703. * @param subMesh defines which submesh to check
  16704. * @param useInstances specifies that instances should be used
  16705. * @returns a boolean indicating that the submesh is ready or not
  16706. */
  16707. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16708. /**
  16709. * Checks if the material is ready to render the requested mesh
  16710. * @param mesh Define the mesh to render
  16711. * @param useInstances Define whether or not the material is used with instances
  16712. * @returns true if ready, otherwise false
  16713. */
  16714. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16715. /**
  16716. * Binds the world matrix to the material
  16717. * @param world defines the world transformation matrix
  16718. * @param effectOverride - If provided, use this effect instead of internal effect
  16719. */
  16720. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16721. /**
  16722. * Binds the submesh to this material by preparing the effect and shader to draw
  16723. * @param world defines the world transformation matrix
  16724. * @param mesh defines the mesh containing the submesh
  16725. * @param subMesh defines the submesh to bind the material to
  16726. */
  16727. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16728. /**
  16729. * Binds the material to the mesh
  16730. * @param world defines the world transformation matrix
  16731. * @param mesh defines the mesh to bind the material to
  16732. * @param effectOverride - If provided, use this effect instead of internal effect
  16733. */
  16734. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16735. protected _afterBind(mesh?: Mesh): void;
  16736. /**
  16737. * Gets the active textures from the material
  16738. * @returns an array of textures
  16739. */
  16740. getActiveTextures(): BaseTexture[];
  16741. /**
  16742. * Specifies if the material uses a texture
  16743. * @param texture defines the texture to check against the material
  16744. * @returns a boolean specifying if the material uses the texture
  16745. */
  16746. hasTexture(texture: BaseTexture): boolean;
  16747. /**
  16748. * Makes a duplicate of the material, and gives it a new name
  16749. * @param name defines the new name for the duplicated material
  16750. * @returns the cloned material
  16751. */
  16752. clone(name: string): ShaderMaterial;
  16753. /**
  16754. * Disposes the material
  16755. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16756. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16757. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16758. */
  16759. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16760. /**
  16761. * Serializes this material in a JSON representation
  16762. * @returns the serialized material object
  16763. */
  16764. serialize(): any;
  16765. /**
  16766. * Creates a shader material from parsed shader material data
  16767. * @param source defines the JSON represnetation of the material
  16768. * @param scene defines the hosting scene
  16769. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16770. * @returns a new material
  16771. */
  16772. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16773. /**
  16774. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16775. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16776. * @param url defines the url to load from
  16777. * @param scene defines the hosting scene
  16778. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16779. * @returns a promise that will resolve to the new ShaderMaterial
  16780. */
  16781. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16782. /**
  16783. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16784. * @param snippetId defines the snippet to load
  16785. * @param scene defines the hosting scene
  16786. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16787. * @returns a promise that will resolve to the new ShaderMaterial
  16788. */
  16789. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16790. }
  16791. }
  16792. declare module BABYLON {
  16793. /** @hidden */
  16794. export var colorPixelShader: {
  16795. name: string;
  16796. shader: string;
  16797. };
  16798. }
  16799. declare module BABYLON {
  16800. /** @hidden */
  16801. export var colorVertexShader: {
  16802. name: string;
  16803. shader: string;
  16804. };
  16805. }
  16806. declare module BABYLON {
  16807. /**
  16808. * Line mesh
  16809. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16810. */
  16811. export class LinesMesh extends Mesh {
  16812. /**
  16813. * If vertex color should be applied to the mesh
  16814. */
  16815. readonly useVertexColor?: boolean | undefined;
  16816. /**
  16817. * If vertex alpha should be applied to the mesh
  16818. */
  16819. readonly useVertexAlpha?: boolean | undefined;
  16820. /**
  16821. * Color of the line (Default: White)
  16822. */
  16823. color: Color3;
  16824. /**
  16825. * Alpha of the line (Default: 1)
  16826. */
  16827. alpha: number;
  16828. /**
  16829. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16830. * This margin is expressed in world space coordinates, so its value may vary.
  16831. * Default value is 0.1
  16832. */
  16833. intersectionThreshold: number;
  16834. private _colorShader;
  16835. private color4;
  16836. /**
  16837. * Creates a new LinesMesh
  16838. * @param name defines the name
  16839. * @param scene defines the hosting scene
  16840. * @param parent defines the parent mesh if any
  16841. * @param source defines the optional source LinesMesh used to clone data from
  16842. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16843. * When false, achieved by calling a clone(), also passing False.
  16844. * This will make creation of children, recursive.
  16845. * @param useVertexColor defines if this LinesMesh supports vertex color
  16846. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16847. */
  16848. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16849. /**
  16850. * If vertex color should be applied to the mesh
  16851. */
  16852. useVertexColor?: boolean | undefined,
  16853. /**
  16854. * If vertex alpha should be applied to the mesh
  16855. */
  16856. useVertexAlpha?: boolean | undefined);
  16857. private _addClipPlaneDefine;
  16858. private _removeClipPlaneDefine;
  16859. isReady(): boolean;
  16860. /**
  16861. * Returns the string "LineMesh"
  16862. */
  16863. getClassName(): string;
  16864. /**
  16865. * @hidden
  16866. */
  16867. get material(): Material;
  16868. /**
  16869. * @hidden
  16870. */
  16871. set material(value: Material);
  16872. /**
  16873. * @hidden
  16874. */
  16875. get checkCollisions(): boolean;
  16876. /** @hidden */
  16877. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16878. /** @hidden */
  16879. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16880. /**
  16881. * Disposes of the line mesh
  16882. * @param doNotRecurse If children should be disposed
  16883. */
  16884. dispose(doNotRecurse?: boolean): void;
  16885. /**
  16886. * Returns a new LineMesh object cloned from the current one.
  16887. */
  16888. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16889. /**
  16890. * Creates a new InstancedLinesMesh object from the mesh model.
  16891. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16892. * @param name defines the name of the new instance
  16893. * @returns a new InstancedLinesMesh
  16894. */
  16895. createInstance(name: string): InstancedLinesMesh;
  16896. }
  16897. /**
  16898. * Creates an instance based on a source LinesMesh
  16899. */
  16900. export class InstancedLinesMesh extends InstancedMesh {
  16901. /**
  16902. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16903. * This margin is expressed in world space coordinates, so its value may vary.
  16904. * Initilized with the intersectionThreshold value of the source LinesMesh
  16905. */
  16906. intersectionThreshold: number;
  16907. constructor(name: string, source: LinesMesh);
  16908. /**
  16909. * Returns the string "InstancedLinesMesh".
  16910. */
  16911. getClassName(): string;
  16912. }
  16913. }
  16914. declare module BABYLON {
  16915. /** @hidden */
  16916. export var linePixelShader: {
  16917. name: string;
  16918. shader: string;
  16919. };
  16920. }
  16921. declare module BABYLON {
  16922. /** @hidden */
  16923. export var lineVertexShader: {
  16924. name: string;
  16925. shader: string;
  16926. };
  16927. }
  16928. declare module BABYLON {
  16929. interface Scene {
  16930. /** @hidden */
  16931. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16932. }
  16933. interface AbstractMesh {
  16934. /**
  16935. * Gets the edgesRenderer associated with the mesh
  16936. */
  16937. edgesRenderer: Nullable<EdgesRenderer>;
  16938. }
  16939. interface LinesMesh {
  16940. /**
  16941. * Enables the edge rendering mode on the mesh.
  16942. * This mode makes the mesh edges visible
  16943. * @param epsilon defines the maximal distance between two angles to detect a face
  16944. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16945. * @returns the currentAbstractMesh
  16946. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16947. */
  16948. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16949. }
  16950. interface InstancedLinesMesh {
  16951. /**
  16952. * Enables the edge rendering mode on the mesh.
  16953. * This mode makes the mesh edges visible
  16954. * @param epsilon defines the maximal distance between two angles to detect a face
  16955. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16956. * @returns the current InstancedLinesMesh
  16957. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16958. */
  16959. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16960. }
  16961. /**
  16962. * Defines the minimum contract an Edges renderer should follow.
  16963. */
  16964. export interface IEdgesRenderer extends IDisposable {
  16965. /**
  16966. * Gets or sets a boolean indicating if the edgesRenderer is active
  16967. */
  16968. isEnabled: boolean;
  16969. /**
  16970. * Renders the edges of the attached mesh,
  16971. */
  16972. render(): void;
  16973. /**
  16974. * Checks wether or not the edges renderer is ready to render.
  16975. * @return true if ready, otherwise false.
  16976. */
  16977. isReady(): boolean;
  16978. /**
  16979. * List of instances to render in case the source mesh has instances
  16980. */
  16981. customInstances: SmartArray<Matrix>;
  16982. }
  16983. /**
  16984. * Defines the additional options of the edges renderer
  16985. */
  16986. export interface IEdgesRendererOptions {
  16987. /**
  16988. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  16989. * If not defined, the default value is true
  16990. */
  16991. useAlternateEdgeFinder?: boolean;
  16992. /**
  16993. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  16994. * If not defined, the default value is true.
  16995. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  16996. * This option is used only if useAlternateEdgeFinder = true
  16997. */
  16998. useFastVertexMerger?: boolean;
  16999. /**
  17000. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17001. * The default value is 1e-6
  17002. * This option is used only if useAlternateEdgeFinder = true
  17003. */
  17004. epsilonVertexMerge?: number;
  17005. /**
  17006. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  17007. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  17008. * This option is used only if useAlternateEdgeFinder = true
  17009. */
  17010. applyTessellation?: boolean;
  17011. /**
  17012. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  17013. * The default value is 1e-6
  17014. * This option is used only if useAlternateEdgeFinder = true
  17015. */
  17016. epsilonVertexAligned?: number;
  17017. }
  17018. /**
  17019. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17020. */
  17021. export class EdgesRenderer implements IEdgesRenderer {
  17022. /**
  17023. * Define the size of the edges with an orthographic camera
  17024. */
  17025. edgesWidthScalerForOrthographic: number;
  17026. /**
  17027. * Define the size of the edges with a perspective camera
  17028. */
  17029. edgesWidthScalerForPerspective: number;
  17030. protected _source: AbstractMesh;
  17031. protected _linesPositions: number[];
  17032. protected _linesNormals: number[];
  17033. protected _linesIndices: number[];
  17034. protected _epsilon: number;
  17035. protected _indicesCount: number;
  17036. protected _lineShader: ShaderMaterial;
  17037. protected _ib: DataBuffer;
  17038. protected _buffers: {
  17039. [key: string]: Nullable<VertexBuffer>;
  17040. };
  17041. protected _buffersForInstances: {
  17042. [key: string]: Nullable<VertexBuffer>;
  17043. };
  17044. protected _checkVerticesInsteadOfIndices: boolean;
  17045. protected _options: Nullable<IEdgesRendererOptions>;
  17046. private _meshRebuildObserver;
  17047. private _meshDisposeObserver;
  17048. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17049. isEnabled: boolean;
  17050. /**
  17051. * List of instances to render in case the source mesh has instances
  17052. */
  17053. customInstances: SmartArray<Matrix>;
  17054. private static GetShader;
  17055. /**
  17056. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17057. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17058. * @param source Mesh used to create edges
  17059. * @param epsilon sum of angles in adjacency to check for edge
  17060. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17061. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17062. * @param options The options to apply when generating the edges
  17063. */
  17064. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17065. protected _prepareRessources(): void;
  17066. /** @hidden */
  17067. _rebuild(): void;
  17068. /**
  17069. * Releases the required resources for the edges renderer
  17070. */
  17071. dispose(): void;
  17072. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17073. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17074. /**
  17075. * Checks if the pair of p0 and p1 is en edge
  17076. * @param faceIndex
  17077. * @param edge
  17078. * @param faceNormals
  17079. * @param p0
  17080. * @param p1
  17081. * @private
  17082. */
  17083. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17084. /**
  17085. * push line into the position, normal and index buffer
  17086. * @protected
  17087. */
  17088. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17089. /**
  17090. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17091. */
  17092. private _tessellateTriangle;
  17093. private _generateEdgesLinesAlternate;
  17094. /**
  17095. * Generates lines edges from adjacencjes
  17096. * @private
  17097. */
  17098. _generateEdgesLines(): void;
  17099. /**
  17100. * Checks wether or not the edges renderer is ready to render.
  17101. * @return true if ready, otherwise false.
  17102. */
  17103. isReady(): boolean;
  17104. /**
  17105. * Renders the edges of the attached mesh,
  17106. */
  17107. render(): void;
  17108. }
  17109. /**
  17110. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17111. */
  17112. export class LineEdgesRenderer extends EdgesRenderer {
  17113. /**
  17114. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17115. * @param source LineMesh used to generate edges
  17116. * @param epsilon not important (specified angle for edge detection)
  17117. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17118. */
  17119. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17120. /**
  17121. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17122. */
  17123. _generateEdgesLines(): void;
  17124. }
  17125. }
  17126. declare module BABYLON {
  17127. /**
  17128. * This represents the object necessary to create a rendering group.
  17129. * This is exclusively used and created by the rendering manager.
  17130. * To modify the behavior, you use the available helpers in your scene or meshes.
  17131. * @hidden
  17132. */
  17133. export class RenderingGroup {
  17134. index: number;
  17135. private static _zeroVector;
  17136. private _scene;
  17137. private _opaqueSubMeshes;
  17138. private _transparentSubMeshes;
  17139. private _alphaTestSubMeshes;
  17140. private _depthOnlySubMeshes;
  17141. private _particleSystems;
  17142. private _spriteManagers;
  17143. private _opaqueSortCompareFn;
  17144. private _alphaTestSortCompareFn;
  17145. private _transparentSortCompareFn;
  17146. private _renderOpaque;
  17147. private _renderAlphaTest;
  17148. private _renderTransparent;
  17149. /** @hidden */
  17150. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17151. onBeforeTransparentRendering: () => void;
  17152. /**
  17153. * Set the opaque sort comparison function.
  17154. * If null the sub meshes will be render in the order they were created
  17155. */
  17156. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17157. /**
  17158. * Set the alpha test sort comparison function.
  17159. * If null the sub meshes will be render in the order they were created
  17160. */
  17161. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17162. /**
  17163. * Set the transparent sort comparison function.
  17164. * If null the sub meshes will be render in the order they were created
  17165. */
  17166. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17167. /**
  17168. * Creates a new rendering group.
  17169. * @param index The rendering group index
  17170. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17171. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17172. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17173. */
  17174. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17175. /**
  17176. * Render all the sub meshes contained in the group.
  17177. * @param customRenderFunction Used to override the default render behaviour of the group.
  17178. * @returns true if rendered some submeshes.
  17179. */
  17180. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17181. /**
  17182. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17183. * @param subMeshes The submeshes to render
  17184. */
  17185. private renderOpaqueSorted;
  17186. /**
  17187. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17188. * @param subMeshes The submeshes to render
  17189. */
  17190. private renderAlphaTestSorted;
  17191. /**
  17192. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17193. * @param subMeshes The submeshes to render
  17194. */
  17195. private renderTransparentSorted;
  17196. /**
  17197. * Renders the submeshes in a specified order.
  17198. * @param subMeshes The submeshes to sort before render
  17199. * @param sortCompareFn The comparison function use to sort
  17200. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17201. * @param transparent Specifies to activate blending if true
  17202. */
  17203. private static renderSorted;
  17204. /**
  17205. * Renders the submeshes in the order they were dispatched (no sort applied).
  17206. * @param subMeshes The submeshes to render
  17207. */
  17208. private static renderUnsorted;
  17209. /**
  17210. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17211. * are rendered back to front if in the same alpha index.
  17212. *
  17213. * @param a The first submesh
  17214. * @param b The second submesh
  17215. * @returns The result of the comparison
  17216. */
  17217. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17218. /**
  17219. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17220. * are rendered back to front.
  17221. *
  17222. * @param a The first submesh
  17223. * @param b The second submesh
  17224. * @returns The result of the comparison
  17225. */
  17226. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17227. /**
  17228. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17229. * are rendered front to back (prevent overdraw).
  17230. *
  17231. * @param a The first submesh
  17232. * @param b The second submesh
  17233. * @returns The result of the comparison
  17234. */
  17235. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17236. /**
  17237. * Resets the different lists of submeshes to prepare a new frame.
  17238. */
  17239. prepare(): void;
  17240. dispose(): void;
  17241. /**
  17242. * Inserts the submesh in its correct queue depending on its material.
  17243. * @param subMesh The submesh to dispatch
  17244. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17245. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17246. */
  17247. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17248. dispatchSprites(spriteManager: ISpriteManager): void;
  17249. dispatchParticles(particleSystem: IParticleSystem): void;
  17250. private _renderParticles;
  17251. private _renderSprites;
  17252. }
  17253. }
  17254. declare module BABYLON {
  17255. /**
  17256. * Interface describing the different options available in the rendering manager
  17257. * regarding Auto Clear between groups.
  17258. */
  17259. export interface IRenderingManagerAutoClearSetup {
  17260. /**
  17261. * Defines whether or not autoclear is enable.
  17262. */
  17263. autoClear: boolean;
  17264. /**
  17265. * Defines whether or not to autoclear the depth buffer.
  17266. */
  17267. depth: boolean;
  17268. /**
  17269. * Defines whether or not to autoclear the stencil buffer.
  17270. */
  17271. stencil: boolean;
  17272. }
  17273. /**
  17274. * This class is used by the onRenderingGroupObservable
  17275. */
  17276. export class RenderingGroupInfo {
  17277. /**
  17278. * The Scene that being rendered
  17279. */
  17280. scene: Scene;
  17281. /**
  17282. * The camera currently used for the rendering pass
  17283. */
  17284. camera: Nullable<Camera>;
  17285. /**
  17286. * The ID of the renderingGroup being processed
  17287. */
  17288. renderingGroupId: number;
  17289. }
  17290. /**
  17291. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17292. * It is enable to manage the different groups as well as the different necessary sort functions.
  17293. * This should not be used directly aside of the few static configurations
  17294. */
  17295. export class RenderingManager {
  17296. /**
  17297. * The max id used for rendering groups (not included)
  17298. */
  17299. static MAX_RENDERINGGROUPS: number;
  17300. /**
  17301. * The min id used for rendering groups (included)
  17302. */
  17303. static MIN_RENDERINGGROUPS: number;
  17304. /**
  17305. * Used to globally prevent autoclearing scenes.
  17306. */
  17307. static AUTOCLEAR: boolean;
  17308. /**
  17309. * @hidden
  17310. */
  17311. _useSceneAutoClearSetup: boolean;
  17312. private _scene;
  17313. private _renderingGroups;
  17314. private _depthStencilBufferAlreadyCleaned;
  17315. private _autoClearDepthStencil;
  17316. private _customOpaqueSortCompareFn;
  17317. private _customAlphaTestSortCompareFn;
  17318. private _customTransparentSortCompareFn;
  17319. private _renderingGroupInfo;
  17320. /**
  17321. * Instantiates a new rendering group for a particular scene
  17322. * @param scene Defines the scene the groups belongs to
  17323. */
  17324. constructor(scene: Scene);
  17325. private _clearDepthStencilBuffer;
  17326. /**
  17327. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17328. * @hidden
  17329. */
  17330. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17331. /**
  17332. * Resets the different information of the group to prepare a new frame
  17333. * @hidden
  17334. */
  17335. reset(): void;
  17336. /**
  17337. * Dispose and release the group and its associated resources.
  17338. * @hidden
  17339. */
  17340. dispose(): void;
  17341. /**
  17342. * Clear the info related to rendering groups preventing retention points during dispose.
  17343. */
  17344. freeRenderingGroups(): void;
  17345. private _prepareRenderingGroup;
  17346. /**
  17347. * Add a sprite manager to the rendering manager in order to render it this frame.
  17348. * @param spriteManager Define the sprite manager to render
  17349. */
  17350. dispatchSprites(spriteManager: ISpriteManager): void;
  17351. /**
  17352. * Add a particle system to the rendering manager in order to render it this frame.
  17353. * @param particleSystem Define the particle system to render
  17354. */
  17355. dispatchParticles(particleSystem: IParticleSystem): void;
  17356. /**
  17357. * Add a submesh to the manager in order to render it this frame
  17358. * @param subMesh The submesh to dispatch
  17359. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17360. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17361. */
  17362. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17363. /**
  17364. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17365. * This allowed control for front to back rendering or reversly depending of the special needs.
  17366. *
  17367. * @param renderingGroupId The rendering group id corresponding to its index
  17368. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17369. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17370. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17371. */
  17372. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  17373. /**
  17374. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17375. *
  17376. * @param renderingGroupId The rendering group id corresponding to its index
  17377. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17378. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17379. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17380. */
  17381. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17382. /**
  17383. * Gets the current auto clear configuration for one rendering group of the rendering
  17384. * manager.
  17385. * @param index the rendering group index to get the information for
  17386. * @returns The auto clear setup for the requested rendering group
  17387. */
  17388. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17389. }
  17390. }
  17391. declare module BABYLON {
  17392. /**
  17393. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17394. */
  17395. export interface ICustomShaderOptions {
  17396. /**
  17397. * Gets or sets the custom shader name to use
  17398. */
  17399. shaderName: string;
  17400. /**
  17401. * The list of attribute names used in the shader
  17402. */
  17403. attributes?: string[];
  17404. /**
  17405. * The list of unifrom names used in the shader
  17406. */
  17407. uniforms?: string[];
  17408. /**
  17409. * The list of sampler names used in the shader
  17410. */
  17411. samplers?: string[];
  17412. /**
  17413. * The list of defines used in the shader
  17414. */
  17415. defines?: string[];
  17416. }
  17417. /**
  17418. * Interface to implement to create a shadow generator compatible with BJS.
  17419. */
  17420. export interface IShadowGenerator {
  17421. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17422. id: string;
  17423. /**
  17424. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17425. * @returns The render target texture if present otherwise, null
  17426. */
  17427. getShadowMap(): Nullable<RenderTargetTexture>;
  17428. /**
  17429. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17430. * @param subMesh The submesh we want to render in the shadow map
  17431. * @param useInstances Defines wether will draw in the map using instances
  17432. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17433. * @returns true if ready otherwise, false
  17434. */
  17435. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17436. /**
  17437. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17438. * @param defines Defines of the material we want to update
  17439. * @param lightIndex Index of the light in the enabled light list of the material
  17440. */
  17441. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17442. /**
  17443. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17444. * defined in the generator but impacting the effect).
  17445. * It implies the unifroms available on the materials are the standard BJS ones.
  17446. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17447. * @param effect The effect we are binfing the information for
  17448. */
  17449. bindShadowLight(lightIndex: string, effect: Effect): void;
  17450. /**
  17451. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17452. * (eq to shadow prjection matrix * light transform matrix)
  17453. * @returns The transform matrix used to create the shadow map
  17454. */
  17455. getTransformMatrix(): Matrix;
  17456. /**
  17457. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17458. * Cube and 2D textures for instance.
  17459. */
  17460. recreateShadowMap(): void;
  17461. /**
  17462. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17463. * @param onCompiled Callback triggered at the and of the effects compilation
  17464. * @param options Sets of optional options forcing the compilation with different modes
  17465. */
  17466. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17467. useInstances: boolean;
  17468. }>): void;
  17469. /**
  17470. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17471. * @param options Sets of optional options forcing the compilation with different modes
  17472. * @returns A promise that resolves when the compilation completes
  17473. */
  17474. forceCompilationAsync(options?: Partial<{
  17475. useInstances: boolean;
  17476. }>): Promise<void>;
  17477. /**
  17478. * Serializes the shadow generator setup to a json object.
  17479. * @returns The serialized JSON object
  17480. */
  17481. serialize(): any;
  17482. /**
  17483. * Disposes the Shadow map and related Textures and effects.
  17484. */
  17485. dispose(): void;
  17486. }
  17487. /**
  17488. * Default implementation IShadowGenerator.
  17489. * This is the main object responsible of generating shadows in the framework.
  17490. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17491. */
  17492. export class ShadowGenerator implements IShadowGenerator {
  17493. /**
  17494. * Name of the shadow generator class
  17495. */
  17496. static CLASSNAME: string;
  17497. /**
  17498. * Shadow generator mode None: no filtering applied.
  17499. */
  17500. static readonly FILTER_NONE: number;
  17501. /**
  17502. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17503. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17504. */
  17505. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17506. /**
  17507. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17508. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17509. */
  17510. static readonly FILTER_POISSONSAMPLING: number;
  17511. /**
  17512. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17513. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17514. */
  17515. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17516. /**
  17517. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17518. * edge artifacts on steep falloff.
  17519. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17520. */
  17521. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17522. /**
  17523. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17524. * edge artifacts on steep falloff.
  17525. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17526. */
  17527. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17528. /**
  17529. * Shadow generator mode PCF: Percentage Closer Filtering
  17530. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17531. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17532. */
  17533. static readonly FILTER_PCF: number;
  17534. /**
  17535. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17536. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17537. * Contact Hardening
  17538. */
  17539. static readonly FILTER_PCSS: number;
  17540. /**
  17541. * Reserved for PCF and PCSS
  17542. * Highest Quality.
  17543. *
  17544. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17545. *
  17546. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17547. */
  17548. static readonly QUALITY_HIGH: number;
  17549. /**
  17550. * Reserved for PCF and PCSS
  17551. * Good tradeoff for quality/perf cross devices
  17552. *
  17553. * Execute PCF on a 3*3 kernel.
  17554. *
  17555. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17556. */
  17557. static readonly QUALITY_MEDIUM: number;
  17558. /**
  17559. * Reserved for PCF and PCSS
  17560. * The lowest quality but the fastest.
  17561. *
  17562. * Execute PCF on a 1*1 kernel.
  17563. *
  17564. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17565. */
  17566. static readonly QUALITY_LOW: number;
  17567. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17568. id: string;
  17569. /** Gets or sets the custom shader name to use */
  17570. customShaderOptions: ICustomShaderOptions;
  17571. /**
  17572. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17573. */
  17574. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17575. /**
  17576. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17577. */
  17578. onAfterShadowMapRenderObservable: Observable<Effect>;
  17579. /**
  17580. * Observable triggered before a mesh is rendered in the shadow map.
  17581. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17582. */
  17583. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17584. /**
  17585. * Observable triggered after a mesh is rendered in the shadow map.
  17586. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17587. */
  17588. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17589. protected _bias: number;
  17590. /**
  17591. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17592. */
  17593. get bias(): number;
  17594. /**
  17595. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17596. */
  17597. set bias(bias: number);
  17598. protected _normalBias: number;
  17599. /**
  17600. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17601. */
  17602. get normalBias(): number;
  17603. /**
  17604. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17605. */
  17606. set normalBias(normalBias: number);
  17607. protected _blurBoxOffset: number;
  17608. /**
  17609. * Gets the blur box offset: offset applied during the blur pass.
  17610. * Only useful if useKernelBlur = false
  17611. */
  17612. get blurBoxOffset(): number;
  17613. /**
  17614. * Sets the blur box offset: offset applied during the blur pass.
  17615. * Only useful if useKernelBlur = false
  17616. */
  17617. set blurBoxOffset(value: number);
  17618. protected _blurScale: number;
  17619. /**
  17620. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17621. * 2 means half of the size.
  17622. */
  17623. get blurScale(): number;
  17624. /**
  17625. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17626. * 2 means half of the size.
  17627. */
  17628. set blurScale(value: number);
  17629. protected _blurKernel: number;
  17630. /**
  17631. * Gets the blur kernel: kernel size of the blur pass.
  17632. * Only useful if useKernelBlur = true
  17633. */
  17634. get blurKernel(): number;
  17635. /**
  17636. * Sets the blur kernel: kernel size of the blur pass.
  17637. * Only useful if useKernelBlur = true
  17638. */
  17639. set blurKernel(value: number);
  17640. protected _useKernelBlur: boolean;
  17641. /**
  17642. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17643. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17644. */
  17645. get useKernelBlur(): boolean;
  17646. /**
  17647. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17648. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17649. */
  17650. set useKernelBlur(value: boolean);
  17651. protected _depthScale: number;
  17652. /**
  17653. * Gets the depth scale used in ESM mode.
  17654. */
  17655. get depthScale(): number;
  17656. /**
  17657. * Sets the depth scale used in ESM mode.
  17658. * This can override the scale stored on the light.
  17659. */
  17660. set depthScale(value: number);
  17661. protected _validateFilter(filter: number): number;
  17662. protected _filter: number;
  17663. /**
  17664. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17665. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17666. */
  17667. get filter(): number;
  17668. /**
  17669. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17670. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17671. */
  17672. set filter(value: number);
  17673. /**
  17674. * Gets if the current filter is set to Poisson Sampling.
  17675. */
  17676. get usePoissonSampling(): boolean;
  17677. /**
  17678. * Sets the current filter to Poisson Sampling.
  17679. */
  17680. set usePoissonSampling(value: boolean);
  17681. /**
  17682. * Gets if the current filter is set to ESM.
  17683. */
  17684. get useExponentialShadowMap(): boolean;
  17685. /**
  17686. * Sets the current filter is to ESM.
  17687. */
  17688. set useExponentialShadowMap(value: boolean);
  17689. /**
  17690. * Gets if the current filter is set to filtered ESM.
  17691. */
  17692. get useBlurExponentialShadowMap(): boolean;
  17693. /**
  17694. * Gets if the current filter is set to filtered ESM.
  17695. */
  17696. set useBlurExponentialShadowMap(value: boolean);
  17697. /**
  17698. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17699. * exponential to prevent steep falloff artifacts).
  17700. */
  17701. get useCloseExponentialShadowMap(): boolean;
  17702. /**
  17703. * Sets the current filter to "close ESM" (using the inverse of the
  17704. * exponential to prevent steep falloff artifacts).
  17705. */
  17706. set useCloseExponentialShadowMap(value: boolean);
  17707. /**
  17708. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17709. * exponential to prevent steep falloff artifacts).
  17710. */
  17711. get useBlurCloseExponentialShadowMap(): boolean;
  17712. /**
  17713. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17714. * exponential to prevent steep falloff artifacts).
  17715. */
  17716. set useBlurCloseExponentialShadowMap(value: boolean);
  17717. /**
  17718. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17719. */
  17720. get usePercentageCloserFiltering(): boolean;
  17721. /**
  17722. * Sets the current filter to "PCF" (percentage closer filtering).
  17723. */
  17724. set usePercentageCloserFiltering(value: boolean);
  17725. protected _filteringQuality: number;
  17726. /**
  17727. * Gets the PCF or PCSS Quality.
  17728. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17729. */
  17730. get filteringQuality(): number;
  17731. /**
  17732. * Sets the PCF or PCSS Quality.
  17733. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17734. */
  17735. set filteringQuality(filteringQuality: number);
  17736. /**
  17737. * Gets if the current filter is set to "PCSS" (contact hardening).
  17738. */
  17739. get useContactHardeningShadow(): boolean;
  17740. /**
  17741. * Sets the current filter to "PCSS" (contact hardening).
  17742. */
  17743. set useContactHardeningShadow(value: boolean);
  17744. protected _contactHardeningLightSizeUVRatio: number;
  17745. /**
  17746. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17747. * Using a ratio helps keeping shape stability independently of the map size.
  17748. *
  17749. * It does not account for the light projection as it was having too much
  17750. * instability during the light setup or during light position changes.
  17751. *
  17752. * Only valid if useContactHardeningShadow is true.
  17753. */
  17754. get contactHardeningLightSizeUVRatio(): number;
  17755. /**
  17756. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17757. * Using a ratio helps keeping shape stability independently of the map size.
  17758. *
  17759. * It does not account for the light projection as it was having too much
  17760. * instability during the light setup or during light position changes.
  17761. *
  17762. * Only valid if useContactHardeningShadow is true.
  17763. */
  17764. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17765. protected _darkness: number;
  17766. /** Gets or sets the actual darkness of a shadow */
  17767. get darkness(): number;
  17768. set darkness(value: number);
  17769. /**
  17770. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17771. * 0 means strongest and 1 would means no shadow.
  17772. * @returns the darkness.
  17773. */
  17774. getDarkness(): number;
  17775. /**
  17776. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17777. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17778. * @returns the shadow generator allowing fluent coding.
  17779. */
  17780. setDarkness(darkness: number): ShadowGenerator;
  17781. protected _transparencyShadow: boolean;
  17782. /** Gets or sets the ability to have transparent shadow */
  17783. get transparencyShadow(): boolean;
  17784. set transparencyShadow(value: boolean);
  17785. /**
  17786. * Sets the ability to have transparent shadow (boolean).
  17787. * @param transparent True if transparent else False
  17788. * @returns the shadow generator allowing fluent coding
  17789. */
  17790. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17791. /**
  17792. * Enables or disables shadows with varying strength based on the transparency
  17793. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17794. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17795. * mesh.visibility * alphaTexture.a
  17796. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17797. */
  17798. enableSoftTransparentShadow: boolean;
  17799. protected _shadowMap: Nullable<RenderTargetTexture>;
  17800. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17801. /**
  17802. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17803. * @returns The render target texture if present otherwise, null
  17804. */
  17805. getShadowMap(): Nullable<RenderTargetTexture>;
  17806. /**
  17807. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17808. * @returns The render target texture if the shadow map is present otherwise, null
  17809. */
  17810. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17811. /**
  17812. * Gets the class name of that object
  17813. * @returns "ShadowGenerator"
  17814. */
  17815. getClassName(): string;
  17816. /**
  17817. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17818. * @param mesh Mesh to add
  17819. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17820. * @returns the Shadow Generator itself
  17821. */
  17822. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17823. /**
  17824. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17825. * @param mesh Mesh to remove
  17826. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17827. * @returns the Shadow Generator itself
  17828. */
  17829. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17830. /**
  17831. * Controls the extent to which the shadows fade out at the edge of the frustum
  17832. */
  17833. frustumEdgeFalloff: number;
  17834. protected _light: IShadowLight;
  17835. /**
  17836. * Returns the associated light object.
  17837. * @returns the light generating the shadow
  17838. */
  17839. getLight(): IShadowLight;
  17840. /**
  17841. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17842. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17843. * It might on the other hand introduce peter panning.
  17844. */
  17845. forceBackFacesOnly: boolean;
  17846. protected _scene: Scene;
  17847. protected _lightDirection: Vector3;
  17848. protected _effect: Effect;
  17849. protected _viewMatrix: Matrix;
  17850. protected _projectionMatrix: Matrix;
  17851. protected _transformMatrix: Matrix;
  17852. protected _cachedPosition: Vector3;
  17853. protected _cachedDirection: Vector3;
  17854. protected _cachedDefines: string;
  17855. protected _currentRenderID: number;
  17856. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17857. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17858. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17859. protected _blurPostProcesses: PostProcess[];
  17860. protected _mapSize: number;
  17861. protected _currentFaceIndex: number;
  17862. protected _currentFaceIndexCache: number;
  17863. protected _textureType: number;
  17864. protected _defaultTextureMatrix: Matrix;
  17865. protected _storedUniqueId: Nullable<number>;
  17866. /** @hidden */
  17867. static _SceneComponentInitialization: (scene: Scene) => void;
  17868. /**
  17869. * Creates a ShadowGenerator object.
  17870. * A ShadowGenerator is the required tool to use the shadows.
  17871. * Each light casting shadows needs to use its own ShadowGenerator.
  17872. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17873. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17874. * @param light The light object generating the shadows.
  17875. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  17876. */
  17877. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17878. protected _initializeGenerator(): void;
  17879. protected _createTargetRenderTexture(): void;
  17880. protected _initializeShadowMap(): void;
  17881. protected _initializeBlurRTTAndPostProcesses(): void;
  17882. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17883. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17884. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17885. protected _applyFilterValues(): void;
  17886. /**
  17887. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17888. * @param onCompiled Callback triggered at the and of the effects compilation
  17889. * @param options Sets of optional options forcing the compilation with different modes
  17890. */
  17891. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17892. useInstances: boolean;
  17893. }>): void;
  17894. /**
  17895. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17896. * @param options Sets of optional options forcing the compilation with different modes
  17897. * @returns A promise that resolves when the compilation completes
  17898. */
  17899. forceCompilationAsync(options?: Partial<{
  17900. useInstances: boolean;
  17901. }>): Promise<void>;
  17902. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17903. private _prepareShadowDefines;
  17904. /**
  17905. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17906. * @param subMesh The submesh we want to render in the shadow map
  17907. * @param useInstances Defines wether will draw in the map using instances
  17908. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17909. * @returns true if ready otherwise, false
  17910. */
  17911. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17912. /**
  17913. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17914. * @param defines Defines of the material we want to update
  17915. * @param lightIndex Index of the light in the enabled light list of the material
  17916. */
  17917. prepareDefines(defines: any, lightIndex: number): void;
  17918. /**
  17919. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17920. * defined in the generator but impacting the effect).
  17921. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17922. * @param effect The effect we are binfing the information for
  17923. */
  17924. bindShadowLight(lightIndex: string, effect: Effect): void;
  17925. /**
  17926. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17927. * (eq to shadow prjection matrix * light transform matrix)
  17928. * @returns The transform matrix used to create the shadow map
  17929. */
  17930. getTransformMatrix(): Matrix;
  17931. /**
  17932. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17933. * Cube and 2D textures for instance.
  17934. */
  17935. recreateShadowMap(): void;
  17936. protected _disposeBlurPostProcesses(): void;
  17937. protected _disposeRTTandPostProcesses(): void;
  17938. /**
  17939. * Disposes the ShadowGenerator.
  17940. * Returns nothing.
  17941. */
  17942. dispose(): void;
  17943. /**
  17944. * Serializes the shadow generator setup to a json object.
  17945. * @returns The serialized JSON object
  17946. */
  17947. serialize(): any;
  17948. /**
  17949. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17950. * @param parsedShadowGenerator The JSON object to parse
  17951. * @param scene The scene to create the shadow map for
  17952. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17953. * @returns The parsed shadow generator
  17954. */
  17955. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17956. }
  17957. }
  17958. declare module BABYLON {
  17959. /**
  17960. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17961. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17962. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  17963. */
  17964. export abstract class Light extends Node {
  17965. /**
  17966. * Falloff Default: light is falling off following the material specification:
  17967. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17968. */
  17969. static readonly FALLOFF_DEFAULT: number;
  17970. /**
  17971. * Falloff Physical: light is falling off following the inverse squared distance law.
  17972. */
  17973. static readonly FALLOFF_PHYSICAL: number;
  17974. /**
  17975. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17976. * to enhance interoperability with other engines.
  17977. */
  17978. static readonly FALLOFF_GLTF: number;
  17979. /**
  17980. * Falloff Standard: light is falling off like in the standard material
  17981. * to enhance interoperability with other materials.
  17982. */
  17983. static readonly FALLOFF_STANDARD: number;
  17984. /**
  17985. * If every light affecting the material is in this lightmapMode,
  17986. * material.lightmapTexture adds or multiplies
  17987. * (depends on material.useLightmapAsShadowmap)
  17988. * after every other light calculations.
  17989. */
  17990. static readonly LIGHTMAP_DEFAULT: number;
  17991. /**
  17992. * material.lightmapTexture as only diffuse lighting from this light
  17993. * adds only specular lighting from this light
  17994. * adds dynamic shadows
  17995. */
  17996. static readonly LIGHTMAP_SPECULAR: number;
  17997. /**
  17998. * material.lightmapTexture as only lighting
  17999. * no light calculation from this light
  18000. * only adds dynamic shadows from this light
  18001. */
  18002. static readonly LIGHTMAP_SHADOWSONLY: number;
  18003. /**
  18004. * Each light type uses the default quantity according to its type:
  18005. * point/spot lights use luminous intensity
  18006. * directional lights use illuminance
  18007. */
  18008. static readonly INTENSITYMODE_AUTOMATIC: number;
  18009. /**
  18010. * lumen (lm)
  18011. */
  18012. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18013. /**
  18014. * candela (lm/sr)
  18015. */
  18016. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18017. /**
  18018. * lux (lm/m^2)
  18019. */
  18020. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18021. /**
  18022. * nit (cd/m^2)
  18023. */
  18024. static readonly INTENSITYMODE_LUMINANCE: number;
  18025. /**
  18026. * Light type const id of the point light.
  18027. */
  18028. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18029. /**
  18030. * Light type const id of the directional light.
  18031. */
  18032. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18033. /**
  18034. * Light type const id of the spot light.
  18035. */
  18036. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18037. /**
  18038. * Light type const id of the hemispheric light.
  18039. */
  18040. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18041. /**
  18042. * Diffuse gives the basic color to an object.
  18043. */
  18044. diffuse: Color3;
  18045. /**
  18046. * Specular produces a highlight color on an object.
  18047. * Note: This is note affecting PBR materials.
  18048. */
  18049. specular: Color3;
  18050. /**
  18051. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18052. * falling off base on range or angle.
  18053. * This can be set to any values in Light.FALLOFF_x.
  18054. *
  18055. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18056. * other types of materials.
  18057. */
  18058. falloffType: number;
  18059. /**
  18060. * Strength of the light.
  18061. * Note: By default it is define in the framework own unit.
  18062. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18063. */
  18064. intensity: number;
  18065. private _range;
  18066. protected _inverseSquaredRange: number;
  18067. /**
  18068. * Defines how far from the source the light is impacting in scene units.
  18069. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18070. */
  18071. get range(): number;
  18072. /**
  18073. * Defines how far from the source the light is impacting in scene units.
  18074. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18075. */
  18076. set range(value: number);
  18077. /**
  18078. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18079. * of light.
  18080. */
  18081. private _photometricScale;
  18082. private _intensityMode;
  18083. /**
  18084. * Gets the photometric scale used to interpret the intensity.
  18085. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18086. */
  18087. get intensityMode(): number;
  18088. /**
  18089. * Sets the photometric scale used to interpret the intensity.
  18090. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18091. */
  18092. set intensityMode(value: number);
  18093. private _radius;
  18094. /**
  18095. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18096. */
  18097. get radius(): number;
  18098. /**
  18099. * sets the light radius used by PBR Materials to simulate soft area lights.
  18100. */
  18101. set radius(value: number);
  18102. private _renderPriority;
  18103. /**
  18104. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18105. * exceeding the number allowed of the materials.
  18106. */
  18107. renderPriority: number;
  18108. private _shadowEnabled;
  18109. /**
  18110. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18111. * the current shadow generator.
  18112. */
  18113. get shadowEnabled(): boolean;
  18114. /**
  18115. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18116. * the current shadow generator.
  18117. */
  18118. set shadowEnabled(value: boolean);
  18119. private _includedOnlyMeshes;
  18120. /**
  18121. * Gets the only meshes impacted by this light.
  18122. */
  18123. get includedOnlyMeshes(): AbstractMesh[];
  18124. /**
  18125. * Sets the only meshes impacted by this light.
  18126. */
  18127. set includedOnlyMeshes(value: AbstractMesh[]);
  18128. private _excludedMeshes;
  18129. /**
  18130. * Gets the meshes not impacted by this light.
  18131. */
  18132. get excludedMeshes(): AbstractMesh[];
  18133. /**
  18134. * Sets the meshes not impacted by this light.
  18135. */
  18136. set excludedMeshes(value: AbstractMesh[]);
  18137. private _excludeWithLayerMask;
  18138. /**
  18139. * Gets the layer id use to find what meshes are not impacted by the light.
  18140. * Inactive if 0
  18141. */
  18142. get excludeWithLayerMask(): number;
  18143. /**
  18144. * Sets the layer id use to find what meshes are not impacted by the light.
  18145. * Inactive if 0
  18146. */
  18147. set excludeWithLayerMask(value: number);
  18148. private _includeOnlyWithLayerMask;
  18149. /**
  18150. * Gets the layer id use to find what meshes are impacted by the light.
  18151. * Inactive if 0
  18152. */
  18153. get includeOnlyWithLayerMask(): number;
  18154. /**
  18155. * Sets the layer id use to find what meshes are impacted by the light.
  18156. * Inactive if 0
  18157. */
  18158. set includeOnlyWithLayerMask(value: number);
  18159. private _lightmapMode;
  18160. /**
  18161. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18162. */
  18163. get lightmapMode(): number;
  18164. /**
  18165. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18166. */
  18167. set lightmapMode(value: number);
  18168. /**
  18169. * Shadow generator associted to the light.
  18170. * @hidden Internal use only.
  18171. */
  18172. _shadowGenerator: Nullable<IShadowGenerator>;
  18173. /**
  18174. * @hidden Internal use only.
  18175. */
  18176. _excludedMeshesIds: string[];
  18177. /**
  18178. * @hidden Internal use only.
  18179. */
  18180. _includedOnlyMeshesIds: string[];
  18181. /**
  18182. * The current light unifom buffer.
  18183. * @hidden Internal use only.
  18184. */
  18185. _uniformBuffer: UniformBuffer;
  18186. /** @hidden */
  18187. _renderId: number;
  18188. /**
  18189. * Creates a Light object in the scene.
  18190. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18191. * @param name The firendly name of the light
  18192. * @param scene The scene the light belongs too
  18193. */
  18194. constructor(name: string, scene: Scene);
  18195. protected abstract _buildUniformLayout(): void;
  18196. /**
  18197. * Sets the passed Effect "effect" with the Light information.
  18198. * @param effect The effect to update
  18199. * @param lightIndex The index of the light in the effect to update
  18200. * @returns The light
  18201. */
  18202. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18203. /**
  18204. * Sets the passed Effect "effect" with the Light textures.
  18205. * @param effect The effect to update
  18206. * @param lightIndex The index of the light in the effect to update
  18207. * @returns The light
  18208. */
  18209. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18210. /**
  18211. * Binds the lights information from the scene to the effect for the given mesh.
  18212. * @param lightIndex Light index
  18213. * @param scene The scene where the light belongs to
  18214. * @param effect The effect we are binding the data to
  18215. * @param useSpecular Defines if specular is supported
  18216. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18217. */
  18218. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18219. /**
  18220. * Sets the passed Effect "effect" with the Light information.
  18221. * @param effect The effect to update
  18222. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18223. * @returns The light
  18224. */
  18225. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18226. /**
  18227. * Returns the string "Light".
  18228. * @returns the class name
  18229. */
  18230. getClassName(): string;
  18231. /** @hidden */
  18232. readonly _isLight: boolean;
  18233. /**
  18234. * Converts the light information to a readable string for debug purpose.
  18235. * @param fullDetails Supports for multiple levels of logging within scene loading
  18236. * @returns the human readable light info
  18237. */
  18238. toString(fullDetails?: boolean): string;
  18239. /** @hidden */
  18240. protected _syncParentEnabledState(): void;
  18241. /**
  18242. * Set the enabled state of this node.
  18243. * @param value - the new enabled state
  18244. */
  18245. setEnabled(value: boolean): void;
  18246. /**
  18247. * Returns the Light associated shadow generator if any.
  18248. * @return the associated shadow generator.
  18249. */
  18250. getShadowGenerator(): Nullable<IShadowGenerator>;
  18251. /**
  18252. * Returns a Vector3, the absolute light position in the World.
  18253. * @returns the world space position of the light
  18254. */
  18255. getAbsolutePosition(): Vector3;
  18256. /**
  18257. * Specifies if the light will affect the passed mesh.
  18258. * @param mesh The mesh to test against the light
  18259. * @return true the mesh is affected otherwise, false.
  18260. */
  18261. canAffectMesh(mesh: AbstractMesh): boolean;
  18262. /**
  18263. * Sort function to order lights for rendering.
  18264. * @param a First Light object to compare to second.
  18265. * @param b Second Light object to compare first.
  18266. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18267. */
  18268. static CompareLightsPriority(a: Light, b: Light): number;
  18269. /**
  18270. * Releases resources associated with this node.
  18271. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18272. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18273. */
  18274. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18275. /**
  18276. * Returns the light type ID (integer).
  18277. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18278. */
  18279. getTypeID(): number;
  18280. /**
  18281. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18282. * @returns the scaled intensity in intensity mode unit
  18283. */
  18284. getScaledIntensity(): number;
  18285. /**
  18286. * Returns a new Light object, named "name", from the current one.
  18287. * @param name The name of the cloned light
  18288. * @param newParent The parent of this light, if it has one
  18289. * @returns the new created light
  18290. */
  18291. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18292. /**
  18293. * Serializes the current light into a Serialization object.
  18294. * @returns the serialized object.
  18295. */
  18296. serialize(): any;
  18297. /**
  18298. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18299. * This new light is named "name" and added to the passed scene.
  18300. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18301. * @param name The friendly name of the light
  18302. * @param scene The scene the new light will belong to
  18303. * @returns the constructor function
  18304. */
  18305. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18306. /**
  18307. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18308. * @param parsedLight The JSON representation of the light
  18309. * @param scene The scene to create the parsed light in
  18310. * @returns the created light after parsing
  18311. */
  18312. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18313. private _hookArrayForExcluded;
  18314. private _hookArrayForIncludedOnly;
  18315. private _resyncMeshes;
  18316. /**
  18317. * Forces the meshes to update their light related information in their rendering used effects
  18318. * @hidden Internal Use Only
  18319. */
  18320. _markMeshesAsLightDirty(): void;
  18321. /**
  18322. * Recomputes the cached photometric scale if needed.
  18323. */
  18324. private _computePhotometricScale;
  18325. /**
  18326. * Returns the Photometric Scale according to the light type and intensity mode.
  18327. */
  18328. private _getPhotometricScale;
  18329. /**
  18330. * Reorder the light in the scene according to their defined priority.
  18331. * @hidden Internal Use Only
  18332. */
  18333. _reorderLightsInScene(): void;
  18334. /**
  18335. * Prepares the list of defines specific to the light type.
  18336. * @param defines the list of defines
  18337. * @param lightIndex defines the index of the light for the effect
  18338. */
  18339. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18340. }
  18341. }
  18342. declare module BABYLON {
  18343. /**
  18344. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18345. * This is the base of the follow, arc rotate cameras and Free camera
  18346. * @see https://doc.babylonjs.com/features/cameras
  18347. */
  18348. export class TargetCamera extends Camera {
  18349. private static _RigCamTransformMatrix;
  18350. private static _TargetTransformMatrix;
  18351. private static _TargetFocalPoint;
  18352. private _tmpUpVector;
  18353. private _tmpTargetVector;
  18354. /**
  18355. * Define the current direction the camera is moving to
  18356. */
  18357. cameraDirection: Vector3;
  18358. /**
  18359. * Define the current rotation the camera is rotating to
  18360. */
  18361. cameraRotation: Vector2;
  18362. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18363. ignoreParentScaling: boolean;
  18364. /**
  18365. * When set, the up vector of the camera will be updated by the rotation of the camera
  18366. */
  18367. updateUpVectorFromRotation: boolean;
  18368. private _tmpQuaternion;
  18369. /**
  18370. * Define the current rotation of the camera
  18371. */
  18372. rotation: Vector3;
  18373. /**
  18374. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18375. */
  18376. rotationQuaternion: Quaternion;
  18377. /**
  18378. * Define the current speed of the camera
  18379. */
  18380. speed: number;
  18381. /**
  18382. * Add constraint to the camera to prevent it to move freely in all directions and
  18383. * around all axis.
  18384. */
  18385. noRotationConstraint: boolean;
  18386. /**
  18387. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18388. * panning
  18389. */
  18390. invertRotation: boolean;
  18391. /**
  18392. * Speed multiplier for inverse camera panning
  18393. */
  18394. inverseRotationSpeed: number;
  18395. /**
  18396. * Define the current target of the camera as an object or a position.
  18397. */
  18398. lockedTarget: any;
  18399. /** @hidden */
  18400. _currentTarget: Vector3;
  18401. /** @hidden */
  18402. _initialFocalDistance: number;
  18403. /** @hidden */
  18404. _viewMatrix: Matrix;
  18405. /** @hidden */
  18406. _camMatrix: Matrix;
  18407. /** @hidden */
  18408. _cameraTransformMatrix: Matrix;
  18409. /** @hidden */
  18410. _cameraRotationMatrix: Matrix;
  18411. /** @hidden */
  18412. _referencePoint: Vector3;
  18413. /** @hidden */
  18414. _transformedReferencePoint: Vector3;
  18415. /** @hidden */
  18416. _reset: () => void;
  18417. private _defaultUp;
  18418. /**
  18419. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18420. * This is the base of the follow, arc rotate cameras and Free camera
  18421. * @see https://doc.babylonjs.com/features/cameras
  18422. * @param name Defines the name of the camera in the scene
  18423. * @param position Defines the start position of the camera in the scene
  18424. * @param scene Defines the scene the camera belongs to
  18425. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18426. */
  18427. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18428. /**
  18429. * Gets the position in front of the camera at a given distance.
  18430. * @param distance The distance from the camera we want the position to be
  18431. * @returns the position
  18432. */
  18433. getFrontPosition(distance: number): Vector3;
  18434. /** @hidden */
  18435. _getLockedTargetPosition(): Nullable<Vector3>;
  18436. private _storedPosition;
  18437. private _storedRotation;
  18438. private _storedRotationQuaternion;
  18439. /**
  18440. * Store current camera state of the camera (fov, position, rotation, etc..)
  18441. * @returns the camera
  18442. */
  18443. storeState(): Camera;
  18444. /**
  18445. * Restored camera state. You must call storeState() first
  18446. * @returns whether it was successful or not
  18447. * @hidden
  18448. */
  18449. _restoreStateValues(): boolean;
  18450. /** @hidden */
  18451. _initCache(): void;
  18452. /** @hidden */
  18453. _updateCache(ignoreParentClass?: boolean): void;
  18454. /** @hidden */
  18455. _isSynchronizedViewMatrix(): boolean;
  18456. /** @hidden */
  18457. _computeLocalCameraSpeed(): number;
  18458. /**
  18459. * Defines the target the camera should look at.
  18460. * @param target Defines the new target as a Vector or a mesh
  18461. */
  18462. setTarget(target: Vector3): void;
  18463. /**
  18464. * Defines the target point of the camera.
  18465. * The camera looks towards it form the radius distance.
  18466. */
  18467. get target(): Vector3;
  18468. set target(value: Vector3);
  18469. /**
  18470. * Return the current target position of the camera. This value is expressed in local space.
  18471. * @returns the target position
  18472. */
  18473. getTarget(): Vector3;
  18474. /** @hidden */
  18475. _decideIfNeedsToMove(): boolean;
  18476. /** @hidden */
  18477. _updatePosition(): void;
  18478. /** @hidden */
  18479. _checkInputs(): void;
  18480. protected _updateCameraRotationMatrix(): void;
  18481. /**
  18482. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  18483. * @returns the current camera
  18484. */
  18485. private _rotateUpVectorWithCameraRotationMatrix;
  18486. private _cachedRotationZ;
  18487. private _cachedQuaternionRotationZ;
  18488. /** @hidden */
  18489. _getViewMatrix(): Matrix;
  18490. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18491. /**
  18492. * @hidden
  18493. */
  18494. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18495. /**
  18496. * @hidden
  18497. */
  18498. _updateRigCameras(): void;
  18499. private _getRigCamPositionAndTarget;
  18500. /**
  18501. * Gets the current object class name.
  18502. * @return the class name
  18503. */
  18504. getClassName(): string;
  18505. }
  18506. }
  18507. declare module BABYLON {
  18508. /**
  18509. * Gather the list of keyboard event types as constants.
  18510. */
  18511. export class KeyboardEventTypes {
  18512. /**
  18513. * The keydown event is fired when a key becomes active (pressed).
  18514. */
  18515. static readonly KEYDOWN: number;
  18516. /**
  18517. * The keyup event is fired when a key has been released.
  18518. */
  18519. static readonly KEYUP: number;
  18520. }
  18521. /**
  18522. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18523. */
  18524. export class KeyboardInfo {
  18525. /**
  18526. * Defines the type of event (KeyboardEventTypes)
  18527. */
  18528. type: number;
  18529. /**
  18530. * Defines the related dom event
  18531. */
  18532. event: KeyboardEvent;
  18533. /**
  18534. * Instantiates a new keyboard info.
  18535. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18536. * @param type Defines the type of event (KeyboardEventTypes)
  18537. * @param event Defines the related dom event
  18538. */
  18539. constructor(
  18540. /**
  18541. * Defines the type of event (KeyboardEventTypes)
  18542. */
  18543. type: number,
  18544. /**
  18545. * Defines the related dom event
  18546. */
  18547. event: KeyboardEvent);
  18548. }
  18549. /**
  18550. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18551. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18552. */
  18553. export class KeyboardInfoPre extends KeyboardInfo {
  18554. /**
  18555. * Defines the type of event (KeyboardEventTypes)
  18556. */
  18557. type: number;
  18558. /**
  18559. * Defines the related dom event
  18560. */
  18561. event: KeyboardEvent;
  18562. /**
  18563. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18564. */
  18565. skipOnPointerObservable: boolean;
  18566. /**
  18567. * Instantiates a new keyboard pre info.
  18568. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18569. * @param type Defines the type of event (KeyboardEventTypes)
  18570. * @param event Defines the related dom event
  18571. */
  18572. constructor(
  18573. /**
  18574. * Defines the type of event (KeyboardEventTypes)
  18575. */
  18576. type: number,
  18577. /**
  18578. * Defines the related dom event
  18579. */
  18580. event: KeyboardEvent);
  18581. }
  18582. }
  18583. declare module BABYLON {
  18584. /**
  18585. * Manage the keyboard inputs to control the movement of a free camera.
  18586. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18587. */
  18588. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18589. /**
  18590. * Defines the camera the input is attached to.
  18591. */
  18592. camera: FreeCamera;
  18593. /**
  18594. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18595. */
  18596. keysUp: number[];
  18597. /**
  18598. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18599. */
  18600. keysUpward: number[];
  18601. /**
  18602. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18603. */
  18604. keysDown: number[];
  18605. /**
  18606. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18607. */
  18608. keysDownward: number[];
  18609. /**
  18610. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18611. */
  18612. keysLeft: number[];
  18613. /**
  18614. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18615. */
  18616. keysRight: number[];
  18617. private _keys;
  18618. private _onCanvasBlurObserver;
  18619. private _onKeyboardObserver;
  18620. private _engine;
  18621. private _scene;
  18622. /**
  18623. * Attach the input controls to a specific dom element to get the input from.
  18624. * @param element Defines the element the controls should be listened from
  18625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18626. */
  18627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18628. /**
  18629. * Detach the current controls from the specified dom element.
  18630. * @param element Defines the element to stop listening the inputs from
  18631. */
  18632. detachControl(element: Nullable<HTMLElement>): void;
  18633. /**
  18634. * Update the current camera state depending on the inputs that have been used this frame.
  18635. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18636. */
  18637. checkInputs(): void;
  18638. /**
  18639. * Gets the class name of the current intput.
  18640. * @returns the class name
  18641. */
  18642. getClassName(): string;
  18643. /** @hidden */
  18644. _onLostFocus(): void;
  18645. /**
  18646. * Get the friendly name associated with the input class.
  18647. * @returns the input friendly name
  18648. */
  18649. getSimpleName(): string;
  18650. }
  18651. }
  18652. declare module BABYLON {
  18653. /**
  18654. * Gather the list of pointer event types as constants.
  18655. */
  18656. export class PointerEventTypes {
  18657. /**
  18658. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  18659. */
  18660. static readonly POINTERDOWN: number;
  18661. /**
  18662. * The pointerup event is fired when a pointer is no longer active.
  18663. */
  18664. static readonly POINTERUP: number;
  18665. /**
  18666. * The pointermove event is fired when a pointer changes coordinates.
  18667. */
  18668. static readonly POINTERMOVE: number;
  18669. /**
  18670. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18671. */
  18672. static readonly POINTERWHEEL: number;
  18673. /**
  18674. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18675. */
  18676. static readonly POINTERPICK: number;
  18677. /**
  18678. * The pointertap event is fired when a the object has been touched and released without drag.
  18679. */
  18680. static readonly POINTERTAP: number;
  18681. /**
  18682. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18683. */
  18684. static readonly POINTERDOUBLETAP: number;
  18685. }
  18686. /**
  18687. * Base class of pointer info types.
  18688. */
  18689. export class PointerInfoBase {
  18690. /**
  18691. * Defines the type of event (PointerEventTypes)
  18692. */
  18693. type: number;
  18694. /**
  18695. * Defines the related dom event
  18696. */
  18697. event: PointerEvent | MouseWheelEvent;
  18698. /**
  18699. * Instantiates the base class of pointers info.
  18700. * @param type Defines the type of event (PointerEventTypes)
  18701. * @param event Defines the related dom event
  18702. */
  18703. constructor(
  18704. /**
  18705. * Defines the type of event (PointerEventTypes)
  18706. */
  18707. type: number,
  18708. /**
  18709. * Defines the related dom event
  18710. */
  18711. event: PointerEvent | MouseWheelEvent);
  18712. }
  18713. /**
  18714. * This class is used to store pointer related info for the onPrePointerObservable event.
  18715. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18716. */
  18717. export class PointerInfoPre extends PointerInfoBase {
  18718. /**
  18719. * Ray from a pointer if availible (eg. 6dof controller)
  18720. */
  18721. ray: Nullable<Ray>;
  18722. /**
  18723. * Defines the local position of the pointer on the canvas.
  18724. */
  18725. localPosition: Vector2;
  18726. /**
  18727. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18728. */
  18729. skipOnPointerObservable: boolean;
  18730. /**
  18731. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18732. * @param type Defines the type of event (PointerEventTypes)
  18733. * @param event Defines the related dom event
  18734. * @param localX Defines the local x coordinates of the pointer when the event occured
  18735. * @param localY Defines the local y coordinates of the pointer when the event occured
  18736. */
  18737. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18738. }
  18739. /**
  18740. * This type contains all the data related to a pointer event in Babylon.js.
  18741. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  18742. */
  18743. export class PointerInfo extends PointerInfoBase {
  18744. /**
  18745. * Defines the picking info associated to the info (if any)\
  18746. */
  18747. pickInfo: Nullable<PickingInfo>;
  18748. /**
  18749. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18750. * @param type Defines the type of event (PointerEventTypes)
  18751. * @param event Defines the related dom event
  18752. * @param pickInfo Defines the picking info associated to the info (if any)\
  18753. */
  18754. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18755. /**
  18756. * Defines the picking info associated to the info (if any)\
  18757. */
  18758. pickInfo: Nullable<PickingInfo>);
  18759. }
  18760. /**
  18761. * Data relating to a touch event on the screen.
  18762. */
  18763. export interface PointerTouch {
  18764. /**
  18765. * X coordinate of touch.
  18766. */
  18767. x: number;
  18768. /**
  18769. * Y coordinate of touch.
  18770. */
  18771. y: number;
  18772. /**
  18773. * Id of touch. Unique for each finger.
  18774. */
  18775. pointerId: number;
  18776. /**
  18777. * Event type passed from DOM.
  18778. */
  18779. type: any;
  18780. }
  18781. }
  18782. declare module BABYLON {
  18783. /**
  18784. * Manage the mouse inputs to control the movement of a free camera.
  18785. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18786. */
  18787. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18788. /**
  18789. * Define if touch is enabled in the mouse input
  18790. */
  18791. touchEnabled: boolean;
  18792. /**
  18793. * Defines the camera the input is attached to.
  18794. */
  18795. camera: FreeCamera;
  18796. /**
  18797. * Defines the buttons associated with the input to handle camera move.
  18798. */
  18799. buttons: number[];
  18800. /**
  18801. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18802. */
  18803. angularSensibility: number;
  18804. private _pointerInput;
  18805. private _onMouseMove;
  18806. private _observer;
  18807. private previousPosition;
  18808. /**
  18809. * Observable for when a pointer move event occurs containing the move offset
  18810. */
  18811. onPointerMovedObservable: Observable<{
  18812. offsetX: number;
  18813. offsetY: number;
  18814. }>;
  18815. /**
  18816. * @hidden
  18817. * If the camera should be rotated automatically based on pointer movement
  18818. */
  18819. _allowCameraRotation: boolean;
  18820. /**
  18821. * Manage the mouse inputs to control the movement of a free camera.
  18822. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18823. * @param touchEnabled Defines if touch is enabled or not
  18824. */
  18825. constructor(
  18826. /**
  18827. * Define if touch is enabled in the mouse input
  18828. */
  18829. touchEnabled?: boolean);
  18830. /**
  18831. * Attach the input controls to a specific dom element to get the input from.
  18832. * @param element Defines the element the controls should be listened from
  18833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18834. */
  18835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18836. /**
  18837. * Called on JS contextmenu event.
  18838. * Override this method to provide functionality.
  18839. */
  18840. protected onContextMenu(evt: PointerEvent): void;
  18841. /**
  18842. * Detach the current controls from the specified dom element.
  18843. * @param element Defines the element to stop listening the inputs from
  18844. */
  18845. detachControl(element: Nullable<HTMLElement>): void;
  18846. /**
  18847. * Gets the class name of the current intput.
  18848. * @returns the class name
  18849. */
  18850. getClassName(): string;
  18851. /**
  18852. * Get the friendly name associated with the input class.
  18853. * @returns the input friendly name
  18854. */
  18855. getSimpleName(): string;
  18856. }
  18857. }
  18858. declare module BABYLON {
  18859. /**
  18860. * Manage the touch inputs to control the movement of a free camera.
  18861. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18862. */
  18863. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18864. /**
  18865. * Define if mouse events can be treated as touch events
  18866. */
  18867. allowMouse: boolean;
  18868. /**
  18869. * Defines the camera the input is attached to.
  18870. */
  18871. camera: FreeCamera;
  18872. /**
  18873. * Defines the touch sensibility for rotation.
  18874. * The higher the faster.
  18875. */
  18876. touchAngularSensibility: number;
  18877. /**
  18878. * Defines the touch sensibility for move.
  18879. * The higher the faster.
  18880. */
  18881. touchMoveSensibility: number;
  18882. private _offsetX;
  18883. private _offsetY;
  18884. private _pointerPressed;
  18885. private _pointerInput;
  18886. private _observer;
  18887. private _onLostFocus;
  18888. /**
  18889. * Manage the touch inputs to control the movement of a free camera.
  18890. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18891. * @param allowMouse Defines if mouse events can be treated as touch events
  18892. */
  18893. constructor(
  18894. /**
  18895. * Define if mouse events can be treated as touch events
  18896. */
  18897. allowMouse?: boolean);
  18898. /**
  18899. * Attach the input controls to a specific dom element to get the input from.
  18900. * @param element Defines the element the controls should be listened from
  18901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18902. */
  18903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18904. /**
  18905. * Detach the current controls from the specified dom element.
  18906. * @param element Defines the element to stop listening the inputs from
  18907. */
  18908. detachControl(element: Nullable<HTMLElement>): void;
  18909. /**
  18910. * Update the current camera state depending on the inputs that have been used this frame.
  18911. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18912. */
  18913. checkInputs(): void;
  18914. /**
  18915. * Gets the class name of the current intput.
  18916. * @returns the class name
  18917. */
  18918. getClassName(): string;
  18919. /**
  18920. * Get the friendly name associated with the input class.
  18921. * @returns the input friendly name
  18922. */
  18923. getSimpleName(): string;
  18924. }
  18925. }
  18926. declare module BABYLON {
  18927. /**
  18928. * Default Inputs manager for the FreeCamera.
  18929. * It groups all the default supported inputs for ease of use.
  18930. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18931. */
  18932. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18933. /**
  18934. * @hidden
  18935. */
  18936. _mouseInput: Nullable<FreeCameraMouseInput>;
  18937. /**
  18938. * Instantiates a new FreeCameraInputsManager.
  18939. * @param camera Defines the camera the inputs belong to
  18940. */
  18941. constructor(camera: FreeCamera);
  18942. /**
  18943. * Add keyboard input support to the input manager.
  18944. * @returns the current input manager
  18945. */
  18946. addKeyboard(): FreeCameraInputsManager;
  18947. /**
  18948. * Add mouse input support to the input manager.
  18949. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18950. * @returns the current input manager
  18951. */
  18952. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18953. /**
  18954. * Removes the mouse input support from the manager
  18955. * @returns the current input manager
  18956. */
  18957. removeMouse(): FreeCameraInputsManager;
  18958. /**
  18959. * Add touch input support to the input manager.
  18960. * @returns the current input manager
  18961. */
  18962. addTouch(): FreeCameraInputsManager;
  18963. /**
  18964. * Remove all attached input methods from a camera
  18965. */
  18966. clear(): void;
  18967. }
  18968. }
  18969. declare module BABYLON {
  18970. /**
  18971. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18972. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18973. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18974. */
  18975. export class FreeCamera extends TargetCamera {
  18976. /**
  18977. * Define the collision ellipsoid of the camera.
  18978. * This is helpful to simulate a camera body like the player body around the camera
  18979. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18980. */
  18981. ellipsoid: Vector3;
  18982. /**
  18983. * Define an offset for the position of the ellipsoid around the camera.
  18984. * This can be helpful to determine the center of the body near the gravity center of the body
  18985. * instead of its head.
  18986. */
  18987. ellipsoidOffset: Vector3;
  18988. /**
  18989. * Enable or disable collisions of the camera with the rest of the scene objects.
  18990. */
  18991. checkCollisions: boolean;
  18992. /**
  18993. * Enable or disable gravity on the camera.
  18994. */
  18995. applyGravity: boolean;
  18996. /**
  18997. * Define the input manager associated to the camera.
  18998. */
  18999. inputs: FreeCameraInputsManager;
  19000. /**
  19001. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19002. * Higher values reduce sensitivity.
  19003. */
  19004. get angularSensibility(): number;
  19005. /**
  19006. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19007. * Higher values reduce sensitivity.
  19008. */
  19009. set angularSensibility(value: number);
  19010. /**
  19011. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19012. */
  19013. get keysUp(): number[];
  19014. set keysUp(value: number[]);
  19015. /**
  19016. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19017. */
  19018. get keysUpward(): number[];
  19019. set keysUpward(value: number[]);
  19020. /**
  19021. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19022. */
  19023. get keysDown(): number[];
  19024. set keysDown(value: number[]);
  19025. /**
  19026. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19027. */
  19028. get keysDownward(): number[];
  19029. set keysDownward(value: number[]);
  19030. /**
  19031. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19032. */
  19033. get keysLeft(): number[];
  19034. set keysLeft(value: number[]);
  19035. /**
  19036. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19037. */
  19038. get keysRight(): number[];
  19039. set keysRight(value: number[]);
  19040. /**
  19041. * Event raised when the camera collide with a mesh in the scene.
  19042. */
  19043. onCollide: (collidedMesh: AbstractMesh) => void;
  19044. private _collider;
  19045. private _needMoveForGravity;
  19046. private _oldPosition;
  19047. private _diffPosition;
  19048. private _newPosition;
  19049. /** @hidden */
  19050. _localDirection: Vector3;
  19051. /** @hidden */
  19052. _transformedDirection: Vector3;
  19053. /**
  19054. * Instantiates a Free Camera.
  19055. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19056. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19057. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19058. * @param name Define the name of the camera in the scene
  19059. * @param position Define the start position of the camera in the scene
  19060. * @param scene Define the scene the camera belongs to
  19061. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19062. */
  19063. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19064. /**
  19065. * Attached controls to the current camera.
  19066. * @param element Defines the element the controls should be listened from
  19067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19068. */
  19069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19070. /**
  19071. * Detach the current controls from the camera.
  19072. * The camera will stop reacting to inputs.
  19073. * @param element Defines the element to stop listening the inputs from
  19074. */
  19075. detachControl(element: HTMLElement): void;
  19076. private _collisionMask;
  19077. /**
  19078. * Define a collision mask to limit the list of object the camera can collide with
  19079. */
  19080. get collisionMask(): number;
  19081. set collisionMask(mask: number);
  19082. /** @hidden */
  19083. _collideWithWorld(displacement: Vector3): void;
  19084. private _onCollisionPositionChange;
  19085. /** @hidden */
  19086. _checkInputs(): void;
  19087. /** @hidden */
  19088. _decideIfNeedsToMove(): boolean;
  19089. /** @hidden */
  19090. _updatePosition(): void;
  19091. /**
  19092. * Destroy the camera and release the current resources hold by it.
  19093. */
  19094. dispose(): void;
  19095. /**
  19096. * Gets the current object class name.
  19097. * @return the class name
  19098. */
  19099. getClassName(): string;
  19100. }
  19101. }
  19102. declare module BABYLON {
  19103. /**
  19104. * Represents a gamepad control stick position
  19105. */
  19106. export class StickValues {
  19107. /**
  19108. * The x component of the control stick
  19109. */
  19110. x: number;
  19111. /**
  19112. * The y component of the control stick
  19113. */
  19114. y: number;
  19115. /**
  19116. * Initializes the gamepad x and y control stick values
  19117. * @param x The x component of the gamepad control stick value
  19118. * @param y The y component of the gamepad control stick value
  19119. */
  19120. constructor(
  19121. /**
  19122. * The x component of the control stick
  19123. */
  19124. x: number,
  19125. /**
  19126. * The y component of the control stick
  19127. */
  19128. y: number);
  19129. }
  19130. /**
  19131. * An interface which manages callbacks for gamepad button changes
  19132. */
  19133. export interface GamepadButtonChanges {
  19134. /**
  19135. * Called when a gamepad has been changed
  19136. */
  19137. changed: boolean;
  19138. /**
  19139. * Called when a gamepad press event has been triggered
  19140. */
  19141. pressChanged: boolean;
  19142. /**
  19143. * Called when a touch event has been triggered
  19144. */
  19145. touchChanged: boolean;
  19146. /**
  19147. * Called when a value has changed
  19148. */
  19149. valueChanged: boolean;
  19150. }
  19151. /**
  19152. * Represents a gamepad
  19153. */
  19154. export class Gamepad {
  19155. /**
  19156. * The id of the gamepad
  19157. */
  19158. id: string;
  19159. /**
  19160. * The index of the gamepad
  19161. */
  19162. index: number;
  19163. /**
  19164. * The browser gamepad
  19165. */
  19166. browserGamepad: any;
  19167. /**
  19168. * Specifies what type of gamepad this represents
  19169. */
  19170. type: number;
  19171. private _leftStick;
  19172. private _rightStick;
  19173. /** @hidden */
  19174. _isConnected: boolean;
  19175. private _leftStickAxisX;
  19176. private _leftStickAxisY;
  19177. private _rightStickAxisX;
  19178. private _rightStickAxisY;
  19179. /**
  19180. * Triggered when the left control stick has been changed
  19181. */
  19182. private _onleftstickchanged;
  19183. /**
  19184. * Triggered when the right control stick has been changed
  19185. */
  19186. private _onrightstickchanged;
  19187. /**
  19188. * Represents a gamepad controller
  19189. */
  19190. static GAMEPAD: number;
  19191. /**
  19192. * Represents a generic controller
  19193. */
  19194. static GENERIC: number;
  19195. /**
  19196. * Represents an XBox controller
  19197. */
  19198. static XBOX: number;
  19199. /**
  19200. * Represents a pose-enabled controller
  19201. */
  19202. static POSE_ENABLED: number;
  19203. /**
  19204. * Represents an Dual Shock controller
  19205. */
  19206. static DUALSHOCK: number;
  19207. /**
  19208. * Specifies whether the left control stick should be Y-inverted
  19209. */
  19210. protected _invertLeftStickY: boolean;
  19211. /**
  19212. * Specifies if the gamepad has been connected
  19213. */
  19214. get isConnected(): boolean;
  19215. /**
  19216. * Initializes the gamepad
  19217. * @param id The id of the gamepad
  19218. * @param index The index of the gamepad
  19219. * @param browserGamepad The browser gamepad
  19220. * @param leftStickX The x component of the left joystick
  19221. * @param leftStickY The y component of the left joystick
  19222. * @param rightStickX The x component of the right joystick
  19223. * @param rightStickY The y component of the right joystick
  19224. */
  19225. constructor(
  19226. /**
  19227. * The id of the gamepad
  19228. */
  19229. id: string,
  19230. /**
  19231. * The index of the gamepad
  19232. */
  19233. index: number,
  19234. /**
  19235. * The browser gamepad
  19236. */
  19237. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19238. /**
  19239. * Callback triggered when the left joystick has changed
  19240. * @param callback
  19241. */
  19242. onleftstickchanged(callback: (values: StickValues) => void): void;
  19243. /**
  19244. * Callback triggered when the right joystick has changed
  19245. * @param callback
  19246. */
  19247. onrightstickchanged(callback: (values: StickValues) => void): void;
  19248. /**
  19249. * Gets the left joystick
  19250. */
  19251. get leftStick(): StickValues;
  19252. /**
  19253. * Sets the left joystick values
  19254. */
  19255. set leftStick(newValues: StickValues);
  19256. /**
  19257. * Gets the right joystick
  19258. */
  19259. get rightStick(): StickValues;
  19260. /**
  19261. * Sets the right joystick value
  19262. */
  19263. set rightStick(newValues: StickValues);
  19264. /**
  19265. * Updates the gamepad joystick positions
  19266. */
  19267. update(): void;
  19268. /**
  19269. * Disposes the gamepad
  19270. */
  19271. dispose(): void;
  19272. }
  19273. /**
  19274. * Represents a generic gamepad
  19275. */
  19276. export class GenericPad extends Gamepad {
  19277. private _buttons;
  19278. private _onbuttondown;
  19279. private _onbuttonup;
  19280. /**
  19281. * Observable triggered when a button has been pressed
  19282. */
  19283. onButtonDownObservable: Observable<number>;
  19284. /**
  19285. * Observable triggered when a button has been released
  19286. */
  19287. onButtonUpObservable: Observable<number>;
  19288. /**
  19289. * Callback triggered when a button has been pressed
  19290. * @param callback Called when a button has been pressed
  19291. */
  19292. onbuttondown(callback: (buttonPressed: number) => void): void;
  19293. /**
  19294. * Callback triggered when a button has been released
  19295. * @param callback Called when a button has been released
  19296. */
  19297. onbuttonup(callback: (buttonReleased: number) => void): void;
  19298. /**
  19299. * Initializes the generic gamepad
  19300. * @param id The id of the generic gamepad
  19301. * @param index The index of the generic gamepad
  19302. * @param browserGamepad The browser gamepad
  19303. */
  19304. constructor(id: string, index: number, browserGamepad: any);
  19305. private _setButtonValue;
  19306. /**
  19307. * Updates the generic gamepad
  19308. */
  19309. update(): void;
  19310. /**
  19311. * Disposes the generic gamepad
  19312. */
  19313. dispose(): void;
  19314. }
  19315. }
  19316. declare module BABYLON {
  19317. /**
  19318. * Defines the types of pose enabled controllers that are supported
  19319. */
  19320. export enum PoseEnabledControllerType {
  19321. /**
  19322. * HTC Vive
  19323. */
  19324. VIVE = 0,
  19325. /**
  19326. * Oculus Rift
  19327. */
  19328. OCULUS = 1,
  19329. /**
  19330. * Windows mixed reality
  19331. */
  19332. WINDOWS = 2,
  19333. /**
  19334. * Samsung gear VR
  19335. */
  19336. GEAR_VR = 3,
  19337. /**
  19338. * Google Daydream
  19339. */
  19340. DAYDREAM = 4,
  19341. /**
  19342. * Generic
  19343. */
  19344. GENERIC = 5
  19345. }
  19346. /**
  19347. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19348. */
  19349. export interface MutableGamepadButton {
  19350. /**
  19351. * Value of the button/trigger
  19352. */
  19353. value: number;
  19354. /**
  19355. * If the button/trigger is currently touched
  19356. */
  19357. touched: boolean;
  19358. /**
  19359. * If the button/trigger is currently pressed
  19360. */
  19361. pressed: boolean;
  19362. }
  19363. /**
  19364. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19365. * @hidden
  19366. */
  19367. export interface ExtendedGamepadButton extends GamepadButton {
  19368. /**
  19369. * If the button/trigger is currently pressed
  19370. */
  19371. readonly pressed: boolean;
  19372. /**
  19373. * If the button/trigger is currently touched
  19374. */
  19375. readonly touched: boolean;
  19376. /**
  19377. * Value of the button/trigger
  19378. */
  19379. readonly value: number;
  19380. }
  19381. /** @hidden */
  19382. export interface _GamePadFactory {
  19383. /**
  19384. * Returns whether or not the current gamepad can be created for this type of controller.
  19385. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19386. * @returns true if it can be created, otherwise false
  19387. */
  19388. canCreate(gamepadInfo: any): boolean;
  19389. /**
  19390. * Creates a new instance of the Gamepad.
  19391. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19392. * @returns the new gamepad instance
  19393. */
  19394. create(gamepadInfo: any): Gamepad;
  19395. }
  19396. /**
  19397. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19398. */
  19399. export class PoseEnabledControllerHelper {
  19400. /** @hidden */
  19401. static _ControllerFactories: _GamePadFactory[];
  19402. /** @hidden */
  19403. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19404. /**
  19405. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19406. * @param vrGamepad the gamepad to initialized
  19407. * @returns a vr controller of the type the gamepad identified as
  19408. */
  19409. static InitiateController(vrGamepad: any): Gamepad;
  19410. }
  19411. /**
  19412. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19413. */
  19414. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19415. /**
  19416. * If the controller is used in a webXR session
  19417. */
  19418. isXR: boolean;
  19419. private _deviceRoomPosition;
  19420. private _deviceRoomRotationQuaternion;
  19421. /**
  19422. * The device position in babylon space
  19423. */
  19424. devicePosition: Vector3;
  19425. /**
  19426. * The device rotation in babylon space
  19427. */
  19428. deviceRotationQuaternion: Quaternion;
  19429. /**
  19430. * The scale factor of the device in babylon space
  19431. */
  19432. deviceScaleFactor: number;
  19433. /**
  19434. * (Likely devicePosition should be used instead) The device position in its room space
  19435. */
  19436. position: Vector3;
  19437. /**
  19438. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19439. */
  19440. rotationQuaternion: Quaternion;
  19441. /**
  19442. * The type of controller (Eg. Windows mixed reality)
  19443. */
  19444. controllerType: PoseEnabledControllerType;
  19445. protected _calculatedPosition: Vector3;
  19446. private _calculatedRotation;
  19447. /**
  19448. * The raw pose from the device
  19449. */
  19450. rawPose: DevicePose;
  19451. private _trackPosition;
  19452. private _maxRotationDistFromHeadset;
  19453. private _draggedRoomRotation;
  19454. /**
  19455. * @hidden
  19456. */
  19457. _disableTrackPosition(fixedPosition: Vector3): void;
  19458. /**
  19459. * Internal, the mesh attached to the controller
  19460. * @hidden
  19461. */
  19462. _mesh: Nullable<AbstractMesh>;
  19463. private _poseControlledCamera;
  19464. private _leftHandSystemQuaternion;
  19465. /**
  19466. * Internal, matrix used to convert room space to babylon space
  19467. * @hidden
  19468. */
  19469. _deviceToWorld: Matrix;
  19470. /**
  19471. * Node to be used when casting a ray from the controller
  19472. * @hidden
  19473. */
  19474. _pointingPoseNode: Nullable<TransformNode>;
  19475. /**
  19476. * Name of the child mesh that can be used to cast a ray from the controller
  19477. */
  19478. static readonly POINTING_POSE: string;
  19479. /**
  19480. * Creates a new PoseEnabledController from a gamepad
  19481. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19482. */
  19483. constructor(browserGamepad: any);
  19484. private _workingMatrix;
  19485. /**
  19486. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19487. */
  19488. update(): void;
  19489. /**
  19490. * Updates only the pose device and mesh without doing any button event checking
  19491. */
  19492. protected _updatePoseAndMesh(): void;
  19493. /**
  19494. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19495. * @param poseData raw pose fromthe device
  19496. */
  19497. updateFromDevice(poseData: DevicePose): void;
  19498. /**
  19499. * @hidden
  19500. */
  19501. _meshAttachedObservable: Observable<AbstractMesh>;
  19502. /**
  19503. * Attaches a mesh to the controller
  19504. * @param mesh the mesh to be attached
  19505. */
  19506. attachToMesh(mesh: AbstractMesh): void;
  19507. /**
  19508. * Attaches the controllers mesh to a camera
  19509. * @param camera the camera the mesh should be attached to
  19510. */
  19511. attachToPoseControlledCamera(camera: TargetCamera): void;
  19512. /**
  19513. * Disposes of the controller
  19514. */
  19515. dispose(): void;
  19516. /**
  19517. * The mesh that is attached to the controller
  19518. */
  19519. get mesh(): Nullable<AbstractMesh>;
  19520. /**
  19521. * Gets the ray of the controller in the direction the controller is pointing
  19522. * @param length the length the resulting ray should be
  19523. * @returns a ray in the direction the controller is pointing
  19524. */
  19525. getForwardRay(length?: number): Ray;
  19526. }
  19527. }
  19528. declare module BABYLON {
  19529. /**
  19530. * Defines the WebVRController object that represents controllers tracked in 3D space
  19531. */
  19532. export abstract class WebVRController extends PoseEnabledController {
  19533. /**
  19534. * Internal, the default controller model for the controller
  19535. */
  19536. protected _defaultModel: Nullable<AbstractMesh>;
  19537. /**
  19538. * Fired when the trigger state has changed
  19539. */
  19540. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19541. /**
  19542. * Fired when the main button state has changed
  19543. */
  19544. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19545. /**
  19546. * Fired when the secondary button state has changed
  19547. */
  19548. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19549. /**
  19550. * Fired when the pad state has changed
  19551. */
  19552. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19553. /**
  19554. * Fired when controllers stick values have changed
  19555. */
  19556. onPadValuesChangedObservable: Observable<StickValues>;
  19557. /**
  19558. * Array of button availible on the controller
  19559. */
  19560. protected _buttons: Array<MutableGamepadButton>;
  19561. private _onButtonStateChange;
  19562. /**
  19563. * Fired when a controller button's state has changed
  19564. * @param callback the callback containing the button that was modified
  19565. */
  19566. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19567. /**
  19568. * X and Y axis corresponding to the controllers joystick
  19569. */
  19570. pad: StickValues;
  19571. /**
  19572. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19573. */
  19574. hand: string;
  19575. /**
  19576. * The default controller model for the controller
  19577. */
  19578. get defaultModel(): Nullable<AbstractMesh>;
  19579. /**
  19580. * Creates a new WebVRController from a gamepad
  19581. * @param vrGamepad the gamepad that the WebVRController should be created from
  19582. */
  19583. constructor(vrGamepad: any);
  19584. /**
  19585. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19586. */
  19587. update(): void;
  19588. /**
  19589. * Function to be called when a button is modified
  19590. */
  19591. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19592. /**
  19593. * Loads a mesh and attaches it to the controller
  19594. * @param scene the scene the mesh should be added to
  19595. * @param meshLoaded callback for when the mesh has been loaded
  19596. */
  19597. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19598. private _setButtonValue;
  19599. private _changes;
  19600. private _checkChanges;
  19601. /**
  19602. * Disposes of th webVRCOntroller
  19603. */
  19604. dispose(): void;
  19605. }
  19606. }
  19607. declare module BABYLON {
  19608. /**
  19609. * The HemisphericLight simulates the ambient environment light,
  19610. * so the passed direction is the light reflection direction, not the incoming direction.
  19611. */
  19612. export class HemisphericLight extends Light {
  19613. /**
  19614. * The groundColor is the light in the opposite direction to the one specified during creation.
  19615. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  19616. */
  19617. groundColor: Color3;
  19618. /**
  19619. * The light reflection direction, not the incoming direction.
  19620. */
  19621. direction: Vector3;
  19622. /**
  19623. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19624. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19625. * The HemisphericLight can't cast shadows.
  19626. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19627. * @param name The friendly name of the light
  19628. * @param direction The direction of the light reflection
  19629. * @param scene The scene the light belongs to
  19630. */
  19631. constructor(name: string, direction: Vector3, scene: Scene);
  19632. protected _buildUniformLayout(): void;
  19633. /**
  19634. * Returns the string "HemisphericLight".
  19635. * @return The class name
  19636. */
  19637. getClassName(): string;
  19638. /**
  19639. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19640. * Returns the updated direction.
  19641. * @param target The target the direction should point to
  19642. * @return The computed direction
  19643. */
  19644. setDirectionToTarget(target: Vector3): Vector3;
  19645. /**
  19646. * Returns the shadow generator associated to the light.
  19647. * @returns Always null for hemispheric lights because it does not support shadows.
  19648. */
  19649. getShadowGenerator(): Nullable<IShadowGenerator>;
  19650. /**
  19651. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19652. * @param effect The effect to update
  19653. * @param lightIndex The index of the light in the effect to update
  19654. * @returns The hemispheric light
  19655. */
  19656. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19657. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19658. /**
  19659. * Computes the world matrix of the node
  19660. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19661. * @param useWasUpdatedFlag defines a reserved property
  19662. * @returns the world matrix
  19663. */
  19664. computeWorldMatrix(): Matrix;
  19665. /**
  19666. * Returns the integer 3.
  19667. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19668. */
  19669. getTypeID(): number;
  19670. /**
  19671. * Prepares the list of defines specific to the light type.
  19672. * @param defines the list of defines
  19673. * @param lightIndex defines the index of the light for the effect
  19674. */
  19675. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19676. }
  19677. }
  19678. declare module BABYLON {
  19679. /** @hidden */
  19680. export var vrMultiviewToSingleviewPixelShader: {
  19681. name: string;
  19682. shader: string;
  19683. };
  19684. }
  19685. declare module BABYLON {
  19686. /**
  19687. * Renders to multiple views with a single draw call
  19688. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19689. */
  19690. export class MultiviewRenderTarget extends RenderTargetTexture {
  19691. /**
  19692. * Creates a multiview render target
  19693. * @param scene scene used with the render target
  19694. * @param size the size of the render target (used for each view)
  19695. */
  19696. constructor(scene: Scene, size?: number | {
  19697. width: number;
  19698. height: number;
  19699. } | {
  19700. ratio: number;
  19701. });
  19702. /**
  19703. * @hidden
  19704. * @param faceIndex the face index, if its a cube texture
  19705. */
  19706. _bindFrameBuffer(faceIndex?: number): void;
  19707. /**
  19708. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19709. * @returns the view count
  19710. */
  19711. getViewCount(): number;
  19712. }
  19713. }
  19714. declare module BABYLON {
  19715. interface Engine {
  19716. /**
  19717. * Creates a new multiview render target
  19718. * @param width defines the width of the texture
  19719. * @param height defines the height of the texture
  19720. * @returns the created multiview texture
  19721. */
  19722. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19723. /**
  19724. * Binds a multiview framebuffer to be drawn to
  19725. * @param multiviewTexture texture to bind
  19726. */
  19727. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19728. }
  19729. interface Camera {
  19730. /**
  19731. * @hidden
  19732. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19733. */
  19734. _useMultiviewToSingleView: boolean;
  19735. /**
  19736. * @hidden
  19737. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19738. */
  19739. _multiviewTexture: Nullable<RenderTargetTexture>;
  19740. /**
  19741. * @hidden
  19742. * ensures the multiview texture of the camera exists and has the specified width/height
  19743. * @param width height to set on the multiview texture
  19744. * @param height width to set on the multiview texture
  19745. */
  19746. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19747. }
  19748. interface Scene {
  19749. /** @hidden */
  19750. _transformMatrixR: Matrix;
  19751. /** @hidden */
  19752. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19753. /** @hidden */
  19754. _createMultiviewUbo(): void;
  19755. /** @hidden */
  19756. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19757. /** @hidden */
  19758. _renderMultiviewToSingleView(camera: Camera): void;
  19759. }
  19760. }
  19761. declare module BABYLON {
  19762. /**
  19763. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19764. * This will not be used for webXR as it supports displaying texture arrays directly
  19765. */
  19766. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19767. /**
  19768. * Gets a string identifying the name of the class
  19769. * @returns "VRMultiviewToSingleviewPostProcess" string
  19770. */
  19771. getClassName(): string;
  19772. /**
  19773. * Initializes a VRMultiviewToSingleview
  19774. * @param name name of the post process
  19775. * @param camera camera to be applied to
  19776. * @param scaleFactor scaling factor to the size of the output texture
  19777. */
  19778. constructor(name: string, camera: Camera, scaleFactor: number);
  19779. }
  19780. }
  19781. declare module BABYLON {
  19782. /**
  19783. * Interface used to define additional presentation attributes
  19784. */
  19785. export interface IVRPresentationAttributes {
  19786. /**
  19787. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19788. */
  19789. highRefreshRate: boolean;
  19790. /**
  19791. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19792. */
  19793. foveationLevel: number;
  19794. }
  19795. interface Engine {
  19796. /** @hidden */
  19797. _vrDisplay: any;
  19798. /** @hidden */
  19799. _vrSupported: boolean;
  19800. /** @hidden */
  19801. _oldSize: Size;
  19802. /** @hidden */
  19803. _oldHardwareScaleFactor: number;
  19804. /** @hidden */
  19805. _vrExclusivePointerMode: boolean;
  19806. /** @hidden */
  19807. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19808. /** @hidden */
  19809. _onVRDisplayPointerRestricted: () => void;
  19810. /** @hidden */
  19811. _onVRDisplayPointerUnrestricted: () => void;
  19812. /** @hidden */
  19813. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19814. /** @hidden */
  19815. _onVrDisplayDisconnect: Nullable<() => void>;
  19816. /** @hidden */
  19817. _onVrDisplayPresentChange: Nullable<() => void>;
  19818. /**
  19819. * Observable signaled when VR display mode changes
  19820. */
  19821. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19822. /**
  19823. * Observable signaled when VR request present is complete
  19824. */
  19825. onVRRequestPresentComplete: Observable<boolean>;
  19826. /**
  19827. * Observable signaled when VR request present starts
  19828. */
  19829. onVRRequestPresentStart: Observable<Engine>;
  19830. /**
  19831. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19832. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19833. */
  19834. isInVRExclusivePointerMode: boolean;
  19835. /**
  19836. * Gets a boolean indicating if a webVR device was detected
  19837. * @returns true if a webVR device was detected
  19838. */
  19839. isVRDevicePresent(): boolean;
  19840. /**
  19841. * Gets the current webVR device
  19842. * @returns the current webVR device (or null)
  19843. */
  19844. getVRDevice(): any;
  19845. /**
  19846. * Initializes a webVR display and starts listening to display change events
  19847. * The onVRDisplayChangedObservable will be notified upon these changes
  19848. * @returns A promise containing a VRDisplay and if vr is supported
  19849. */
  19850. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19851. /** @hidden */
  19852. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19853. /**
  19854. * Gets or sets the presentation attributes used to configure VR rendering
  19855. */
  19856. vrPresentationAttributes?: IVRPresentationAttributes;
  19857. /**
  19858. * Call this function to switch to webVR mode
  19859. * Will do nothing if webVR is not supported or if there is no webVR device
  19860. * @param options the webvr options provided to the camera. mainly used for multiview
  19861. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19862. */
  19863. enableVR(options: WebVROptions): void;
  19864. /** @hidden */
  19865. _onVRFullScreenTriggered(): void;
  19866. }
  19867. }
  19868. declare module BABYLON {
  19869. /**
  19870. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19871. * IMPORTANT!! The data is right-hand data.
  19872. * @export
  19873. * @interface DevicePose
  19874. */
  19875. export interface DevicePose {
  19876. /**
  19877. * The position of the device, values in array are [x,y,z].
  19878. */
  19879. readonly position: Nullable<Float32Array>;
  19880. /**
  19881. * The linearVelocity of the device, values in array are [x,y,z].
  19882. */
  19883. readonly linearVelocity: Nullable<Float32Array>;
  19884. /**
  19885. * The linearAcceleration of the device, values in array are [x,y,z].
  19886. */
  19887. readonly linearAcceleration: Nullable<Float32Array>;
  19888. /**
  19889. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19890. */
  19891. readonly orientation: Nullable<Float32Array>;
  19892. /**
  19893. * The angularVelocity of the device, values in array are [x,y,z].
  19894. */
  19895. readonly angularVelocity: Nullable<Float32Array>;
  19896. /**
  19897. * The angularAcceleration of the device, values in array are [x,y,z].
  19898. */
  19899. readonly angularAcceleration: Nullable<Float32Array>;
  19900. }
  19901. /**
  19902. * Interface representing a pose controlled object in Babylon.
  19903. * A pose controlled object has both regular pose values as well as pose values
  19904. * from an external device such as a VR head mounted display
  19905. */
  19906. export interface PoseControlled {
  19907. /**
  19908. * The position of the object in babylon space.
  19909. */
  19910. position: Vector3;
  19911. /**
  19912. * The rotation quaternion of the object in babylon space.
  19913. */
  19914. rotationQuaternion: Quaternion;
  19915. /**
  19916. * The position of the device in babylon space.
  19917. */
  19918. devicePosition?: Vector3;
  19919. /**
  19920. * The rotation quaternion of the device in babylon space.
  19921. */
  19922. deviceRotationQuaternion: Quaternion;
  19923. /**
  19924. * The raw pose coming from the device.
  19925. */
  19926. rawPose: Nullable<DevicePose>;
  19927. /**
  19928. * The scale of the device to be used when translating from device space to babylon space.
  19929. */
  19930. deviceScaleFactor: number;
  19931. /**
  19932. * Updates the poseControlled values based on the input device pose.
  19933. * @param poseData the pose data to update the object with
  19934. */
  19935. updateFromDevice(poseData: DevicePose): void;
  19936. }
  19937. /**
  19938. * Set of options to customize the webVRCamera
  19939. */
  19940. export interface WebVROptions {
  19941. /**
  19942. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19943. */
  19944. trackPosition?: boolean;
  19945. /**
  19946. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19947. */
  19948. positionScale?: number;
  19949. /**
  19950. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19951. */
  19952. displayName?: string;
  19953. /**
  19954. * Should the native controller meshes be initialized. (default: true)
  19955. */
  19956. controllerMeshes?: boolean;
  19957. /**
  19958. * Creating a default HemiLight only on controllers. (default: true)
  19959. */
  19960. defaultLightingOnControllers?: boolean;
  19961. /**
  19962. * If you don't want to use the default VR button of the helper. (default: false)
  19963. */
  19964. useCustomVRButton?: boolean;
  19965. /**
  19966. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19967. */
  19968. customVRButton?: HTMLButtonElement;
  19969. /**
  19970. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19971. */
  19972. rayLength?: number;
  19973. /**
  19974. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19975. */
  19976. defaultHeight?: number;
  19977. /**
  19978. * If multiview should be used if availible (default: false)
  19979. */
  19980. useMultiview?: boolean;
  19981. }
  19982. /**
  19983. * This represents a WebVR camera.
  19984. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19985. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19986. */
  19987. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19988. private webVROptions;
  19989. /**
  19990. * @hidden
  19991. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19992. */
  19993. _vrDevice: any;
  19994. /**
  19995. * The rawPose of the vrDevice.
  19996. */
  19997. rawPose: Nullable<DevicePose>;
  19998. private _onVREnabled;
  19999. private _specsVersion;
  20000. private _attached;
  20001. private _frameData;
  20002. protected _descendants: Array<Node>;
  20003. private _deviceRoomPosition;
  20004. /** @hidden */
  20005. _deviceRoomRotationQuaternion: Quaternion;
  20006. private _standingMatrix;
  20007. /**
  20008. * Represents device position in babylon space.
  20009. */
  20010. devicePosition: Vector3;
  20011. /**
  20012. * Represents device rotation in babylon space.
  20013. */
  20014. deviceRotationQuaternion: Quaternion;
  20015. /**
  20016. * The scale of the device to be used when translating from device space to babylon space.
  20017. */
  20018. deviceScaleFactor: number;
  20019. private _deviceToWorld;
  20020. private _worldToDevice;
  20021. /**
  20022. * References to the webVR controllers for the vrDevice.
  20023. */
  20024. controllers: Array<WebVRController>;
  20025. /**
  20026. * Emits an event when a controller is attached.
  20027. */
  20028. onControllersAttachedObservable: Observable<WebVRController[]>;
  20029. /**
  20030. * Emits an event when a controller's mesh has been loaded;
  20031. */
  20032. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20033. /**
  20034. * Emits an event when the HMD's pose has been updated.
  20035. */
  20036. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20037. private _poseSet;
  20038. /**
  20039. * If the rig cameras be used as parent instead of this camera.
  20040. */
  20041. rigParenting: boolean;
  20042. private _lightOnControllers;
  20043. private _defaultHeight?;
  20044. /**
  20045. * Instantiates a WebVRFreeCamera.
  20046. * @param name The name of the WebVRFreeCamera
  20047. * @param position The starting anchor position for the camera
  20048. * @param scene The scene the camera belongs to
  20049. * @param webVROptions a set of customizable options for the webVRCamera
  20050. */
  20051. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20052. /**
  20053. * Gets the device distance from the ground in meters.
  20054. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  20055. */
  20056. deviceDistanceToRoomGround(): number;
  20057. /**
  20058. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20059. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20060. */
  20061. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20062. /**
  20063. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20064. * @returns A promise with a boolean set to if the standing matrix is supported.
  20065. */
  20066. useStandingMatrixAsync(): Promise<boolean>;
  20067. /**
  20068. * Disposes the camera
  20069. */
  20070. dispose(): void;
  20071. /**
  20072. * Gets a vrController by name.
  20073. * @param name The name of the controller to retreive
  20074. * @returns the controller matching the name specified or null if not found
  20075. */
  20076. getControllerByName(name: string): Nullable<WebVRController>;
  20077. private _leftController;
  20078. /**
  20079. * The controller corresponding to the users left hand.
  20080. */
  20081. get leftController(): Nullable<WebVRController>;
  20082. private _rightController;
  20083. /**
  20084. * The controller corresponding to the users right hand.
  20085. */
  20086. get rightController(): Nullable<WebVRController>;
  20087. /**
  20088. * Casts a ray forward from the vrCamera's gaze.
  20089. * @param length Length of the ray (default: 100)
  20090. * @returns the ray corresponding to the gaze
  20091. */
  20092. getForwardRay(length?: number): Ray;
  20093. /**
  20094. * @hidden
  20095. * Updates the camera based on device's frame data
  20096. */
  20097. _checkInputs(): void;
  20098. /**
  20099. * Updates the poseControlled values based on the input device pose.
  20100. * @param poseData Pose coming from the device
  20101. */
  20102. updateFromDevice(poseData: DevicePose): void;
  20103. private _htmlElementAttached;
  20104. private _detachIfAttached;
  20105. /**
  20106. * WebVR's attach control will start broadcasting frames to the device.
  20107. * Note that in certain browsers (chrome for example) this function must be called
  20108. * within a user-interaction callback. Example:
  20109. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20110. *
  20111. * @param element html element to attach the vrDevice to
  20112. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20113. */
  20114. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20115. /**
  20116. * Detaches the camera from the html element and disables VR
  20117. *
  20118. * @param element html element to detach from
  20119. */
  20120. detachControl(element: HTMLElement): void;
  20121. /**
  20122. * @returns the name of this class
  20123. */
  20124. getClassName(): string;
  20125. /**
  20126. * Calls resetPose on the vrDisplay
  20127. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20128. */
  20129. resetToCurrentRotation(): void;
  20130. /**
  20131. * @hidden
  20132. * Updates the rig cameras (left and right eye)
  20133. */
  20134. _updateRigCameras(): void;
  20135. private _workingVector;
  20136. private _oneVector;
  20137. private _workingMatrix;
  20138. private updateCacheCalled;
  20139. private _correctPositionIfNotTrackPosition;
  20140. /**
  20141. * @hidden
  20142. * Updates the cached values of the camera
  20143. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20144. */
  20145. _updateCache(ignoreParentClass?: boolean): void;
  20146. /**
  20147. * @hidden
  20148. * Get current device position in babylon world
  20149. */
  20150. _computeDevicePosition(): void;
  20151. /**
  20152. * Updates the current device position and rotation in the babylon world
  20153. */
  20154. update(): void;
  20155. /**
  20156. * @hidden
  20157. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20158. * @returns an identity matrix
  20159. */
  20160. _getViewMatrix(): Matrix;
  20161. private _tmpMatrix;
  20162. /**
  20163. * This function is called by the two RIG cameras.
  20164. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20165. * @hidden
  20166. */
  20167. _getWebVRViewMatrix(): Matrix;
  20168. /** @hidden */
  20169. _getWebVRProjectionMatrix(): Matrix;
  20170. private _onGamepadConnectedObserver;
  20171. private _onGamepadDisconnectedObserver;
  20172. private _updateCacheWhenTrackingDisabledObserver;
  20173. /**
  20174. * Initializes the controllers and their meshes
  20175. */
  20176. initControllers(): void;
  20177. }
  20178. }
  20179. declare module BABYLON {
  20180. /**
  20181. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20182. *
  20183. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20184. *
  20185. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20186. */
  20187. export class MaterialHelper {
  20188. /**
  20189. * Bind the current view position to an effect.
  20190. * @param effect The effect to be bound
  20191. * @param scene The scene the eyes position is used from
  20192. * @param variableName name of the shader variable that will hold the eye position
  20193. */
  20194. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20195. /**
  20196. * Helps preparing the defines values about the UVs in used in the effect.
  20197. * UVs are shared as much as we can accross channels in the shaders.
  20198. * @param texture The texture we are preparing the UVs for
  20199. * @param defines The defines to update
  20200. * @param key The channel key "diffuse", "specular"... used in the shader
  20201. */
  20202. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20203. /**
  20204. * Binds a texture matrix value to its corrsponding uniform
  20205. * @param texture The texture to bind the matrix for
  20206. * @param uniformBuffer The uniform buffer receivin the data
  20207. * @param key The channel key "diffuse", "specular"... used in the shader
  20208. */
  20209. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20210. /**
  20211. * Gets the current status of the fog (should it be enabled?)
  20212. * @param mesh defines the mesh to evaluate for fog support
  20213. * @param scene defines the hosting scene
  20214. * @returns true if fog must be enabled
  20215. */
  20216. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20217. /**
  20218. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20219. * @param mesh defines the current mesh
  20220. * @param scene defines the current scene
  20221. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20222. * @param pointsCloud defines if point cloud rendering has to be turned on
  20223. * @param fogEnabled defines if fog has to be turned on
  20224. * @param alphaTest defines if alpha testing has to be turned on
  20225. * @param defines defines the current list of defines
  20226. */
  20227. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20228. /**
  20229. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20230. * @param scene defines the current scene
  20231. * @param engine defines the current engine
  20232. * @param defines specifies the list of active defines
  20233. * @param useInstances defines if instances have to be turned on
  20234. * @param useClipPlane defines if clip plane have to be turned on
  20235. * @param useInstances defines if instances have to be turned on
  20236. * @param useThinInstances defines if thin instances have to be turned on
  20237. */
  20238. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20239. /**
  20240. * Prepares the defines for bones
  20241. * @param mesh The mesh containing the geometry data we will draw
  20242. * @param defines The defines to update
  20243. */
  20244. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20245. /**
  20246. * Prepares the defines for morph targets
  20247. * @param mesh The mesh containing the geometry data we will draw
  20248. * @param defines The defines to update
  20249. */
  20250. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20251. /**
  20252. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20253. * @param mesh The mesh containing the geometry data we will draw
  20254. * @param defines The defines to update
  20255. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20256. * @param useBones Precise whether bones should be used or not (override mesh info)
  20257. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20258. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20259. * @returns false if defines are considered not dirty and have not been checked
  20260. */
  20261. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20262. /**
  20263. * Prepares the defines related to multiview
  20264. * @param scene The scene we are intending to draw
  20265. * @param defines The defines to update
  20266. */
  20267. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20268. /**
  20269. * Prepares the defines related to the prepass
  20270. * @param scene The scene we are intending to draw
  20271. * @param defines The defines to update
  20272. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20273. */
  20274. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20275. /**
  20276. * Prepares the defines related to the light information passed in parameter
  20277. * @param scene The scene we are intending to draw
  20278. * @param mesh The mesh the effect is compiling for
  20279. * @param light The light the effect is compiling for
  20280. * @param lightIndex The index of the light
  20281. * @param defines The defines to update
  20282. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20283. * @param state Defines the current state regarding what is needed (normals, etc...)
  20284. */
  20285. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20286. needNormals: boolean;
  20287. needRebuild: boolean;
  20288. shadowEnabled: boolean;
  20289. specularEnabled: boolean;
  20290. lightmapMode: boolean;
  20291. }): void;
  20292. /**
  20293. * Prepares the defines related to the light information passed in parameter
  20294. * @param scene The scene we are intending to draw
  20295. * @param mesh The mesh the effect is compiling for
  20296. * @param defines The defines to update
  20297. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20298. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20299. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20300. * @returns true if normals will be required for the rest of the effect
  20301. */
  20302. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20303. /**
  20304. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20305. * @param lightIndex defines the light index
  20306. * @param uniformsList The uniform list
  20307. * @param samplersList The sampler list
  20308. * @param projectedLightTexture defines if projected texture must be used
  20309. * @param uniformBuffersList defines an optional list of uniform buffers
  20310. */
  20311. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20312. /**
  20313. * Prepares the uniforms and samplers list to be used in the effect
  20314. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20315. * @param samplersList The sampler list
  20316. * @param defines The defines helping in the list generation
  20317. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20318. */
  20319. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20320. /**
  20321. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20322. * @param defines The defines to update while falling back
  20323. * @param fallbacks The authorized effect fallbacks
  20324. * @param maxSimultaneousLights The maximum number of lights allowed
  20325. * @param rank the current rank of the Effect
  20326. * @returns The newly affected rank
  20327. */
  20328. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20329. private static _TmpMorphInfluencers;
  20330. /**
  20331. * Prepares the list of attributes required for morph targets according to the effect defines.
  20332. * @param attribs The current list of supported attribs
  20333. * @param mesh The mesh to prepare the morph targets attributes for
  20334. * @param influencers The number of influencers
  20335. */
  20336. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20337. /**
  20338. * Prepares the list of attributes required for morph targets according to the effect defines.
  20339. * @param attribs The current list of supported attribs
  20340. * @param mesh The mesh to prepare the morph targets attributes for
  20341. * @param defines The current Defines of the effect
  20342. */
  20343. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20344. /**
  20345. * Prepares the list of attributes required for bones according to the effect defines.
  20346. * @param attribs The current list of supported attribs
  20347. * @param mesh The mesh to prepare the bones attributes for
  20348. * @param defines The current Defines of the effect
  20349. * @param fallbacks The current efffect fallback strategy
  20350. */
  20351. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20352. /**
  20353. * Check and prepare the list of attributes required for instances according to the effect defines.
  20354. * @param attribs The current list of supported attribs
  20355. * @param defines The current MaterialDefines of the effect
  20356. */
  20357. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20358. /**
  20359. * Add the list of attributes required for instances to the attribs array.
  20360. * @param attribs The current list of supported attribs
  20361. */
  20362. static PushAttributesForInstances(attribs: string[]): void;
  20363. /**
  20364. * Binds the light information to the effect.
  20365. * @param light The light containing the generator
  20366. * @param effect The effect we are binding the data to
  20367. * @param lightIndex The light index in the effect used to render
  20368. */
  20369. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20370. /**
  20371. * Binds the lights information from the scene to the effect for the given mesh.
  20372. * @param light Light to bind
  20373. * @param lightIndex Light index
  20374. * @param scene The scene where the light belongs to
  20375. * @param effect The effect we are binding the data to
  20376. * @param useSpecular Defines if specular is supported
  20377. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20378. */
  20379. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20380. /**
  20381. * Binds the lights information from the scene to the effect for the given mesh.
  20382. * @param scene The scene the lights belongs to
  20383. * @param mesh The mesh we are binding the information to render
  20384. * @param effect The effect we are binding the data to
  20385. * @param defines The generated defines for the effect
  20386. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20387. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20388. */
  20389. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20390. private static _tempFogColor;
  20391. /**
  20392. * Binds the fog information from the scene to the effect for the given mesh.
  20393. * @param scene The scene the lights belongs to
  20394. * @param mesh The mesh we are binding the information to render
  20395. * @param effect The effect we are binding the data to
  20396. * @param linearSpace Defines if the fog effect is applied in linear space
  20397. */
  20398. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20399. /**
  20400. * Binds the bones information from the mesh to the effect.
  20401. * @param mesh The mesh we are binding the information to render
  20402. * @param effect The effect we are binding the data to
  20403. */
  20404. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20405. /**
  20406. * Binds the morph targets information from the mesh to the effect.
  20407. * @param abstractMesh The mesh we are binding the information to render
  20408. * @param effect The effect we are binding the data to
  20409. */
  20410. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20411. /**
  20412. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20413. * @param defines The generated defines used in the effect
  20414. * @param effect The effect we are binding the data to
  20415. * @param scene The scene we are willing to render with logarithmic scale for
  20416. */
  20417. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20418. /**
  20419. * Binds the clip plane information from the scene to the effect.
  20420. * @param scene The scene the clip plane information are extracted from
  20421. * @param effect The effect we are binding the data to
  20422. */
  20423. static BindClipPlane(effect: Effect, scene: Scene): void;
  20424. }
  20425. }
  20426. declare module BABYLON {
  20427. /**
  20428. * Block used to expose an input value
  20429. */
  20430. export class InputBlock extends NodeMaterialBlock {
  20431. private _mode;
  20432. private _associatedVariableName;
  20433. private _storedValue;
  20434. private _valueCallback;
  20435. private _type;
  20436. private _animationType;
  20437. /** Gets or set a value used to limit the range of float values */
  20438. min: number;
  20439. /** Gets or set a value used to limit the range of float values */
  20440. max: number;
  20441. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20442. isBoolean: boolean;
  20443. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20444. matrixMode: number;
  20445. /** @hidden */
  20446. _systemValue: Nullable<NodeMaterialSystemValues>;
  20447. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20448. visibleInInspector: boolean;
  20449. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20450. isConstant: boolean;
  20451. /** Gets or sets the group to use to display this block in the Inspector */
  20452. groupInInspector: string;
  20453. /** Gets an observable raised when the value is changed */
  20454. onValueChangedObservable: Observable<InputBlock>;
  20455. /**
  20456. * Gets or sets the connection point type (default is float)
  20457. */
  20458. get type(): NodeMaterialBlockConnectionPointTypes;
  20459. /**
  20460. * Creates a new InputBlock
  20461. * @param name defines the block name
  20462. * @param target defines the target of that block (Vertex by default)
  20463. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20464. */
  20465. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20466. /**
  20467. * Validates if a name is a reserve word.
  20468. * @param newName the new name to be given to the node.
  20469. * @returns false if the name is a reserve word, else true.
  20470. */
  20471. validateBlockName(newName: string): boolean;
  20472. /**
  20473. * Gets the output component
  20474. */
  20475. get output(): NodeMaterialConnectionPoint;
  20476. /**
  20477. * Set the source of this connection point to a vertex attribute
  20478. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20479. * @returns the current connection point
  20480. */
  20481. setAsAttribute(attributeName?: string): InputBlock;
  20482. /**
  20483. * Set the source of this connection point to a system value
  20484. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20485. * @returns the current connection point
  20486. */
  20487. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20488. /**
  20489. * Gets or sets the value of that point.
  20490. * Please note that this value will be ignored if valueCallback is defined
  20491. */
  20492. get value(): any;
  20493. set value(value: any);
  20494. /**
  20495. * Gets or sets a callback used to get the value of that point.
  20496. * Please note that setting this value will force the connection point to ignore the value property
  20497. */
  20498. get valueCallback(): () => any;
  20499. set valueCallback(value: () => any);
  20500. /**
  20501. * Gets or sets the associated variable name in the shader
  20502. */
  20503. get associatedVariableName(): string;
  20504. set associatedVariableName(value: string);
  20505. /** Gets or sets the type of animation applied to the input */
  20506. get animationType(): AnimatedInputBlockTypes;
  20507. set animationType(value: AnimatedInputBlockTypes);
  20508. /**
  20509. * Gets a boolean indicating that this connection point not defined yet
  20510. */
  20511. get isUndefined(): boolean;
  20512. /**
  20513. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20514. * In this case the connection point name must be the name of the uniform to use.
  20515. * Can only be set on inputs
  20516. */
  20517. get isUniform(): boolean;
  20518. set isUniform(value: boolean);
  20519. /**
  20520. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20521. * In this case the connection point name must be the name of the attribute to use
  20522. * Can only be set on inputs
  20523. */
  20524. get isAttribute(): boolean;
  20525. set isAttribute(value: boolean);
  20526. /**
  20527. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20528. * Can only be set on exit points
  20529. */
  20530. get isVarying(): boolean;
  20531. set isVarying(value: boolean);
  20532. /**
  20533. * Gets a boolean indicating that the current connection point is a system value
  20534. */
  20535. get isSystemValue(): boolean;
  20536. /**
  20537. * Gets or sets the current well known value or null if not defined as a system value
  20538. */
  20539. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20540. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20541. /**
  20542. * Gets the current class name
  20543. * @returns the class name
  20544. */
  20545. getClassName(): string;
  20546. /**
  20547. * Animate the input if animationType !== None
  20548. * @param scene defines the rendering scene
  20549. */
  20550. animate(scene: Scene): void;
  20551. private _emitDefine;
  20552. initialize(state: NodeMaterialBuildState): void;
  20553. /**
  20554. * Set the input block to its default value (based on its type)
  20555. */
  20556. setDefaultValue(): void;
  20557. private _emitConstant;
  20558. /** @hidden */
  20559. get _noContextSwitch(): boolean;
  20560. private _emit;
  20561. /** @hidden */
  20562. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20563. /** @hidden */
  20564. _transmit(effect: Effect, scene: Scene): void;
  20565. protected _buildBlock(state: NodeMaterialBuildState): void;
  20566. protected _dumpPropertiesCode(): string;
  20567. dispose(): void;
  20568. serialize(): any;
  20569. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20570. }
  20571. }
  20572. declare module BABYLON {
  20573. /**
  20574. * Enum used to define the compatibility state between two connection points
  20575. */
  20576. export enum NodeMaterialConnectionPointCompatibilityStates {
  20577. /** Points are compatibles */
  20578. Compatible = 0,
  20579. /** Points are incompatible because of their types */
  20580. TypeIncompatible = 1,
  20581. /** Points are incompatible because of their targets (vertex vs fragment) */
  20582. TargetIncompatible = 2
  20583. }
  20584. /**
  20585. * Defines the direction of a connection point
  20586. */
  20587. export enum NodeMaterialConnectionPointDirection {
  20588. /** Input */
  20589. Input = 0,
  20590. /** Output */
  20591. Output = 1
  20592. }
  20593. /**
  20594. * Defines a connection point for a block
  20595. */
  20596. export class NodeMaterialConnectionPoint {
  20597. /** @hidden */
  20598. _ownerBlock: NodeMaterialBlock;
  20599. /** @hidden */
  20600. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20601. private _endpoints;
  20602. private _associatedVariableName;
  20603. private _direction;
  20604. /** @hidden */
  20605. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20606. /** @hidden */
  20607. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20608. private _type;
  20609. /** @hidden */
  20610. _enforceAssociatedVariableName: boolean;
  20611. /** Gets the direction of the point */
  20612. get direction(): NodeMaterialConnectionPointDirection;
  20613. /** Indicates that this connection point needs dual validation before being connected to another point */
  20614. needDualDirectionValidation: boolean;
  20615. /**
  20616. * Gets or sets the additional types supported by this connection point
  20617. */
  20618. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20619. /**
  20620. * Gets or sets the additional types excluded by this connection point
  20621. */
  20622. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20623. /**
  20624. * Observable triggered when this point is connected
  20625. */
  20626. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20627. /**
  20628. * Gets or sets the associated variable name in the shader
  20629. */
  20630. get associatedVariableName(): string;
  20631. set associatedVariableName(value: string);
  20632. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20633. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20634. /**
  20635. * Gets or sets the connection point type (default is float)
  20636. */
  20637. get type(): NodeMaterialBlockConnectionPointTypes;
  20638. set type(value: NodeMaterialBlockConnectionPointTypes);
  20639. /**
  20640. * Gets or sets the connection point name
  20641. */
  20642. name: string;
  20643. /**
  20644. * Gets or sets the connection point name
  20645. */
  20646. displayName: string;
  20647. /**
  20648. * Gets or sets a boolean indicating that this connection point can be omitted
  20649. */
  20650. isOptional: boolean;
  20651. /**
  20652. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20653. */
  20654. isExposedOnFrame: boolean;
  20655. /**
  20656. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20657. */
  20658. define: string;
  20659. /** @hidden */
  20660. _prioritizeVertex: boolean;
  20661. private _target;
  20662. /** Gets or sets the target of that connection point */
  20663. get target(): NodeMaterialBlockTargets;
  20664. set target(value: NodeMaterialBlockTargets);
  20665. /**
  20666. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20667. */
  20668. get isConnected(): boolean;
  20669. /**
  20670. * Gets a boolean indicating that the current point is connected to an input block
  20671. */
  20672. get isConnectedToInputBlock(): boolean;
  20673. /**
  20674. * Gets a the connected input block (if any)
  20675. */
  20676. get connectInputBlock(): Nullable<InputBlock>;
  20677. /** Get the other side of the connection (if any) */
  20678. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20679. /** Get the block that owns this connection point */
  20680. get ownerBlock(): NodeMaterialBlock;
  20681. /** Get the block connected on the other side of this connection (if any) */
  20682. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20683. /** Get the block connected on the endpoints of this connection (if any) */
  20684. get connectedBlocks(): Array<NodeMaterialBlock>;
  20685. /** Gets the list of connected endpoints */
  20686. get endpoints(): NodeMaterialConnectionPoint[];
  20687. /** Gets a boolean indicating if that output point is connected to at least one input */
  20688. get hasEndpoints(): boolean;
  20689. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20690. get isConnectedInVertexShader(): boolean;
  20691. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20692. get isConnectedInFragmentShader(): boolean;
  20693. /**
  20694. * Creates a block suitable to be used as an input for this input point.
  20695. * If null is returned, a block based on the point type will be created.
  20696. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  20697. */
  20698. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20699. /**
  20700. * Creates a new connection point
  20701. * @param name defines the connection point name
  20702. * @param ownerBlock defines the block hosting this connection point
  20703. * @param direction defines the direction of the connection point
  20704. */
  20705. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20706. /**
  20707. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20708. * @returns the class name
  20709. */
  20710. getClassName(): string;
  20711. /**
  20712. * Gets a boolean indicating if the current point can be connected to another point
  20713. * @param connectionPoint defines the other connection point
  20714. * @returns a boolean
  20715. */
  20716. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20717. /**
  20718. * Gets a number indicating if the current point can be connected to another point
  20719. * @param connectionPoint defines the other connection point
  20720. * @returns a number defining the compatibility state
  20721. */
  20722. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20723. /**
  20724. * Connect this point to another connection point
  20725. * @param connectionPoint defines the other connection point
  20726. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20727. * @returns the current connection point
  20728. */
  20729. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20730. /**
  20731. * Disconnect this point from one of his endpoint
  20732. * @param endpoint defines the other connection point
  20733. * @returns the current connection point
  20734. */
  20735. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20736. /**
  20737. * Serializes this point in a JSON representation
  20738. * @param isInput defines if the connection point is an input (default is true)
  20739. * @returns the serialized point object
  20740. */
  20741. serialize(isInput?: boolean): any;
  20742. /**
  20743. * Release resources
  20744. */
  20745. dispose(): void;
  20746. }
  20747. }
  20748. declare module BABYLON {
  20749. /**
  20750. * Enum used to define the material modes
  20751. */
  20752. export enum NodeMaterialModes {
  20753. /** Regular material */
  20754. Material = 0,
  20755. /** For post process */
  20756. PostProcess = 1,
  20757. /** For particle system */
  20758. Particle = 2
  20759. }
  20760. }
  20761. declare module BABYLON {
  20762. /**
  20763. * Block used to read a texture from a sampler
  20764. */
  20765. export class TextureBlock extends NodeMaterialBlock {
  20766. private _defineName;
  20767. private _linearDefineName;
  20768. private _gammaDefineName;
  20769. private _tempTextureRead;
  20770. private _samplerName;
  20771. private _transformedUVName;
  20772. private _textureTransformName;
  20773. private _textureInfoName;
  20774. private _mainUVName;
  20775. private _mainUVDefineName;
  20776. private _fragmentOnly;
  20777. /**
  20778. * Gets or sets the texture associated with the node
  20779. */
  20780. texture: Nullable<Texture>;
  20781. /**
  20782. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20783. */
  20784. convertToGammaSpace: boolean;
  20785. /**
  20786. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20787. */
  20788. convertToLinearSpace: boolean;
  20789. /**
  20790. * Create a new TextureBlock
  20791. * @param name defines the block name
  20792. */
  20793. constructor(name: string, fragmentOnly?: boolean);
  20794. /**
  20795. * Gets the current class name
  20796. * @returns the class name
  20797. */
  20798. getClassName(): string;
  20799. /**
  20800. * Gets the uv input component
  20801. */
  20802. get uv(): NodeMaterialConnectionPoint;
  20803. /**
  20804. * Gets the rgba output component
  20805. */
  20806. get rgba(): NodeMaterialConnectionPoint;
  20807. /**
  20808. * Gets the rgb output component
  20809. */
  20810. get rgb(): NodeMaterialConnectionPoint;
  20811. /**
  20812. * Gets the r output component
  20813. */
  20814. get r(): NodeMaterialConnectionPoint;
  20815. /**
  20816. * Gets the g output component
  20817. */
  20818. get g(): NodeMaterialConnectionPoint;
  20819. /**
  20820. * Gets the b output component
  20821. */
  20822. get b(): NodeMaterialConnectionPoint;
  20823. /**
  20824. * Gets the a output component
  20825. */
  20826. get a(): NodeMaterialConnectionPoint;
  20827. get target(): NodeMaterialBlockTargets;
  20828. autoConfigure(material: NodeMaterial): void;
  20829. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20830. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20831. isReady(): boolean;
  20832. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20833. private get _isMixed();
  20834. private _injectVertexCode;
  20835. private _writeTextureRead;
  20836. private _writeOutput;
  20837. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20838. protected _dumpPropertiesCode(): string;
  20839. serialize(): any;
  20840. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20841. }
  20842. }
  20843. declare module BABYLON {
  20844. /** @hidden */
  20845. export var reflectionFunction: {
  20846. name: string;
  20847. shader: string;
  20848. };
  20849. }
  20850. declare module BABYLON {
  20851. /**
  20852. * Base block used to read a reflection texture from a sampler
  20853. */
  20854. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20855. /** @hidden */
  20856. _define3DName: string;
  20857. /** @hidden */
  20858. _defineCubicName: string;
  20859. /** @hidden */
  20860. _defineExplicitName: string;
  20861. /** @hidden */
  20862. _defineProjectionName: string;
  20863. /** @hidden */
  20864. _defineLocalCubicName: string;
  20865. /** @hidden */
  20866. _defineSphericalName: string;
  20867. /** @hidden */
  20868. _definePlanarName: string;
  20869. /** @hidden */
  20870. _defineEquirectangularName: string;
  20871. /** @hidden */
  20872. _defineMirroredEquirectangularFixedName: string;
  20873. /** @hidden */
  20874. _defineEquirectangularFixedName: string;
  20875. /** @hidden */
  20876. _defineSkyboxName: string;
  20877. /** @hidden */
  20878. _defineOppositeZ: string;
  20879. /** @hidden */
  20880. _cubeSamplerName: string;
  20881. /** @hidden */
  20882. _2DSamplerName: string;
  20883. protected _positionUVWName: string;
  20884. protected _directionWName: string;
  20885. protected _reflectionVectorName: string;
  20886. /** @hidden */
  20887. _reflectionCoordsName: string;
  20888. /** @hidden */
  20889. _reflectionMatrixName: string;
  20890. protected _reflectionColorName: string;
  20891. /**
  20892. * Gets or sets the texture associated with the node
  20893. */
  20894. texture: Nullable<BaseTexture>;
  20895. /**
  20896. * Create a new ReflectionTextureBaseBlock
  20897. * @param name defines the block name
  20898. */
  20899. constructor(name: string);
  20900. /**
  20901. * Gets the current class name
  20902. * @returns the class name
  20903. */
  20904. getClassName(): string;
  20905. /**
  20906. * Gets the world position input component
  20907. */
  20908. abstract get position(): NodeMaterialConnectionPoint;
  20909. /**
  20910. * Gets the world position input component
  20911. */
  20912. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20913. /**
  20914. * Gets the world normal input component
  20915. */
  20916. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20917. /**
  20918. * Gets the world input component
  20919. */
  20920. abstract get world(): NodeMaterialConnectionPoint;
  20921. /**
  20922. * Gets the camera (or eye) position component
  20923. */
  20924. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20925. /**
  20926. * Gets the view input component
  20927. */
  20928. abstract get view(): NodeMaterialConnectionPoint;
  20929. protected _getTexture(): Nullable<BaseTexture>;
  20930. autoConfigure(material: NodeMaterial): void;
  20931. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20932. isReady(): boolean;
  20933. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20934. /**
  20935. * Gets the code to inject in the vertex shader
  20936. * @param state current state of the node material building
  20937. * @returns the shader code
  20938. */
  20939. handleVertexSide(state: NodeMaterialBuildState): string;
  20940. /**
  20941. * Handles the inits for the fragment code path
  20942. * @param state node material build state
  20943. */
  20944. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20945. /**
  20946. * Generates the reflection coords code for the fragment code path
  20947. * @param worldNormalVarName name of the world normal variable
  20948. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20949. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20950. * @returns the shader code
  20951. */
  20952. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20953. /**
  20954. * Generates the reflection color code for the fragment code path
  20955. * @param lodVarName name of the lod variable
  20956. * @param swizzleLookupTexture swizzle to use for the final color variable
  20957. * @returns the shader code
  20958. */
  20959. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20960. /**
  20961. * Generates the code corresponding to the connected output points
  20962. * @param state node material build state
  20963. * @param varName name of the variable to output
  20964. * @returns the shader code
  20965. */
  20966. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20967. protected _buildBlock(state: NodeMaterialBuildState): this;
  20968. protected _dumpPropertiesCode(): string;
  20969. serialize(): any;
  20970. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20971. }
  20972. }
  20973. declare module BABYLON {
  20974. /**
  20975. * Defines a connection point to be used for points with a custom object type
  20976. */
  20977. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20978. private _blockType;
  20979. private _blockName;
  20980. private _nameForCheking?;
  20981. /**
  20982. * Creates a new connection point
  20983. * @param name defines the connection point name
  20984. * @param ownerBlock defines the block hosting this connection point
  20985. * @param direction defines the direction of the connection point
  20986. */
  20987. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20988. /**
  20989. * Gets a number indicating if the current point can be connected to another point
  20990. * @param connectionPoint defines the other connection point
  20991. * @returns a number defining the compatibility state
  20992. */
  20993. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20994. /**
  20995. * Creates a block suitable to be used as an input for this input point.
  20996. * If null is returned, a block based on the point type will be created.
  20997. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  20998. */
  20999. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21000. }
  21001. }
  21002. declare module BABYLON {
  21003. /**
  21004. * Enum defining the type of properties that can be edited in the property pages in the NME
  21005. */
  21006. export enum PropertyTypeForEdition {
  21007. /** property is a boolean */
  21008. Boolean = 0,
  21009. /** property is a float */
  21010. Float = 1,
  21011. /** property is a Vector2 */
  21012. Vector2 = 2,
  21013. /** property is a list of values */
  21014. List = 3
  21015. }
  21016. /**
  21017. * Interface that defines an option in a variable of type list
  21018. */
  21019. export interface IEditablePropertyListOption {
  21020. /** label of the option */
  21021. "label": string;
  21022. /** value of the option */
  21023. "value": number;
  21024. }
  21025. /**
  21026. * Interface that defines the options available for an editable property
  21027. */
  21028. export interface IEditablePropertyOption {
  21029. /** min value */
  21030. "min"?: number;
  21031. /** max value */
  21032. "max"?: number;
  21033. /** notifiers: indicates which actions to take when the property is changed */
  21034. "notifiers"?: {
  21035. /** the material should be rebuilt */
  21036. "rebuild"?: boolean;
  21037. /** the preview should be updated */
  21038. "update"?: boolean;
  21039. };
  21040. /** list of the options for a variable of type list */
  21041. "options"?: IEditablePropertyListOption[];
  21042. }
  21043. /**
  21044. * Interface that describes an editable property
  21045. */
  21046. export interface IPropertyDescriptionForEdition {
  21047. /** name of the property */
  21048. "propertyName": string;
  21049. /** display name of the property */
  21050. "displayName": string;
  21051. /** type of the property */
  21052. "type": PropertyTypeForEdition;
  21053. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21054. "groupName": string;
  21055. /** options for the property */
  21056. "options": IEditablePropertyOption;
  21057. }
  21058. /**
  21059. * Decorator that flags a property in a node material block as being editable
  21060. */
  21061. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21062. }
  21063. declare module BABYLON {
  21064. /**
  21065. * Block used to implement the refraction part of the sub surface module of the PBR material
  21066. */
  21067. export class RefractionBlock extends NodeMaterialBlock {
  21068. /** @hidden */
  21069. _define3DName: string;
  21070. /** @hidden */
  21071. _refractionMatrixName: string;
  21072. /** @hidden */
  21073. _defineLODRefractionAlpha: string;
  21074. /** @hidden */
  21075. _defineLinearSpecularRefraction: string;
  21076. /** @hidden */
  21077. _defineOppositeZ: string;
  21078. /** @hidden */
  21079. _cubeSamplerName: string;
  21080. /** @hidden */
  21081. _2DSamplerName: string;
  21082. /** @hidden */
  21083. _vRefractionMicrosurfaceInfosName: string;
  21084. /** @hidden */
  21085. _vRefractionInfosName: string;
  21086. private _scene;
  21087. /**
  21088. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21089. * Materials half opaque for instance using refraction could benefit from this control.
  21090. */
  21091. linkRefractionWithTransparency: boolean;
  21092. /**
  21093. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21094. */
  21095. invertRefractionY: boolean;
  21096. /**
  21097. * Gets or sets the texture associated with the node
  21098. */
  21099. texture: Nullable<BaseTexture>;
  21100. /**
  21101. * Create a new RefractionBlock
  21102. * @param name defines the block name
  21103. */
  21104. constructor(name: string);
  21105. /**
  21106. * Gets the current class name
  21107. * @returns the class name
  21108. */
  21109. getClassName(): string;
  21110. /**
  21111. * Gets the intensity input component
  21112. */
  21113. get intensity(): NodeMaterialConnectionPoint;
  21114. /**
  21115. * Gets the index of refraction input component
  21116. */
  21117. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21118. /**
  21119. * Gets the tint at distance input component
  21120. */
  21121. get tintAtDistance(): NodeMaterialConnectionPoint;
  21122. /**
  21123. * Gets the view input component
  21124. */
  21125. get view(): NodeMaterialConnectionPoint;
  21126. /**
  21127. * Gets the refraction object output component
  21128. */
  21129. get refraction(): NodeMaterialConnectionPoint;
  21130. /**
  21131. * Returns true if the block has a texture
  21132. */
  21133. get hasTexture(): boolean;
  21134. protected _getTexture(): Nullable<BaseTexture>;
  21135. autoConfigure(material: NodeMaterial): void;
  21136. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21137. isReady(): boolean;
  21138. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21139. /**
  21140. * Gets the main code of the block (fragment side)
  21141. * @param state current state of the node material building
  21142. * @returns the shader code
  21143. */
  21144. getCode(state: NodeMaterialBuildState): string;
  21145. protected _buildBlock(state: NodeMaterialBuildState): this;
  21146. protected _dumpPropertiesCode(): string;
  21147. serialize(): any;
  21148. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21149. }
  21150. }
  21151. declare module BABYLON {
  21152. /**
  21153. * Base block used as input for post process
  21154. */
  21155. export class CurrentScreenBlock extends NodeMaterialBlock {
  21156. private _samplerName;
  21157. private _linearDefineName;
  21158. private _gammaDefineName;
  21159. private _mainUVName;
  21160. private _tempTextureRead;
  21161. /**
  21162. * Gets or sets the texture associated with the node
  21163. */
  21164. texture: Nullable<BaseTexture>;
  21165. /**
  21166. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21167. */
  21168. convertToGammaSpace: boolean;
  21169. /**
  21170. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21171. */
  21172. convertToLinearSpace: boolean;
  21173. /**
  21174. * Create a new CurrentScreenBlock
  21175. * @param name defines the block name
  21176. */
  21177. constructor(name: string);
  21178. /**
  21179. * Gets the current class name
  21180. * @returns the class name
  21181. */
  21182. getClassName(): string;
  21183. /**
  21184. * Gets the uv input component
  21185. */
  21186. get uv(): NodeMaterialConnectionPoint;
  21187. /**
  21188. * Gets the rgba output component
  21189. */
  21190. get rgba(): NodeMaterialConnectionPoint;
  21191. /**
  21192. * Gets the rgb output component
  21193. */
  21194. get rgb(): NodeMaterialConnectionPoint;
  21195. /**
  21196. * Gets the r output component
  21197. */
  21198. get r(): NodeMaterialConnectionPoint;
  21199. /**
  21200. * Gets the g output component
  21201. */
  21202. get g(): NodeMaterialConnectionPoint;
  21203. /**
  21204. * Gets the b output component
  21205. */
  21206. get b(): NodeMaterialConnectionPoint;
  21207. /**
  21208. * Gets the a output component
  21209. */
  21210. get a(): NodeMaterialConnectionPoint;
  21211. /**
  21212. * Initialize the block and prepare the context for build
  21213. * @param state defines the state that will be used for the build
  21214. */
  21215. initialize(state: NodeMaterialBuildState): void;
  21216. get target(): NodeMaterialBlockTargets;
  21217. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21218. isReady(): boolean;
  21219. private _injectVertexCode;
  21220. private _writeTextureRead;
  21221. private _writeOutput;
  21222. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21223. serialize(): any;
  21224. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21225. }
  21226. }
  21227. declare module BABYLON {
  21228. /**
  21229. * Base block used for the particle texture
  21230. */
  21231. export class ParticleTextureBlock extends NodeMaterialBlock {
  21232. private _samplerName;
  21233. private _linearDefineName;
  21234. private _gammaDefineName;
  21235. private _tempTextureRead;
  21236. /**
  21237. * Gets or sets the texture associated with the node
  21238. */
  21239. texture: Nullable<BaseTexture>;
  21240. /**
  21241. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21242. */
  21243. convertToGammaSpace: boolean;
  21244. /**
  21245. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21246. */
  21247. convertToLinearSpace: boolean;
  21248. /**
  21249. * Create a new ParticleTextureBlock
  21250. * @param name defines the block name
  21251. */
  21252. constructor(name: string);
  21253. /**
  21254. * Gets the current class name
  21255. * @returns the class name
  21256. */
  21257. getClassName(): string;
  21258. /**
  21259. * Gets the uv input component
  21260. */
  21261. get uv(): NodeMaterialConnectionPoint;
  21262. /**
  21263. * Gets the rgba output component
  21264. */
  21265. get rgba(): NodeMaterialConnectionPoint;
  21266. /**
  21267. * Gets the rgb output component
  21268. */
  21269. get rgb(): NodeMaterialConnectionPoint;
  21270. /**
  21271. * Gets the r output component
  21272. */
  21273. get r(): NodeMaterialConnectionPoint;
  21274. /**
  21275. * Gets the g output component
  21276. */
  21277. get g(): NodeMaterialConnectionPoint;
  21278. /**
  21279. * Gets the b output component
  21280. */
  21281. get b(): NodeMaterialConnectionPoint;
  21282. /**
  21283. * Gets the a output component
  21284. */
  21285. get a(): NodeMaterialConnectionPoint;
  21286. /**
  21287. * Initialize the block and prepare the context for build
  21288. * @param state defines the state that will be used for the build
  21289. */
  21290. initialize(state: NodeMaterialBuildState): void;
  21291. autoConfigure(material: NodeMaterial): void;
  21292. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21293. isReady(): boolean;
  21294. private _writeOutput;
  21295. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21296. serialize(): any;
  21297. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21298. }
  21299. }
  21300. declare module BABYLON {
  21301. /**
  21302. * Class used to store shared data between 2 NodeMaterialBuildState
  21303. */
  21304. export class NodeMaterialBuildStateSharedData {
  21305. /**
  21306. * Gets the list of emitted varyings
  21307. */
  21308. temps: string[];
  21309. /**
  21310. * Gets the list of emitted varyings
  21311. */
  21312. varyings: string[];
  21313. /**
  21314. * Gets the varying declaration string
  21315. */
  21316. varyingDeclaration: string;
  21317. /**
  21318. * Input blocks
  21319. */
  21320. inputBlocks: InputBlock[];
  21321. /**
  21322. * Input blocks
  21323. */
  21324. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21325. /**
  21326. * Bindable blocks (Blocks that need to set data to the effect)
  21327. */
  21328. bindableBlocks: NodeMaterialBlock[];
  21329. /**
  21330. * List of blocks that can provide a compilation fallback
  21331. */
  21332. blocksWithFallbacks: NodeMaterialBlock[];
  21333. /**
  21334. * List of blocks that can provide a define update
  21335. */
  21336. blocksWithDefines: NodeMaterialBlock[];
  21337. /**
  21338. * List of blocks that can provide a repeatable content
  21339. */
  21340. repeatableContentBlocks: NodeMaterialBlock[];
  21341. /**
  21342. * List of blocks that can provide a dynamic list of uniforms
  21343. */
  21344. dynamicUniformBlocks: NodeMaterialBlock[];
  21345. /**
  21346. * List of blocks that can block the isReady function for the material
  21347. */
  21348. blockingBlocks: NodeMaterialBlock[];
  21349. /**
  21350. * Gets the list of animated inputs
  21351. */
  21352. animatedInputs: InputBlock[];
  21353. /**
  21354. * Build Id used to avoid multiple recompilations
  21355. */
  21356. buildId: number;
  21357. /** List of emitted variables */
  21358. variableNames: {
  21359. [key: string]: number;
  21360. };
  21361. /** List of emitted defines */
  21362. defineNames: {
  21363. [key: string]: number;
  21364. };
  21365. /** Should emit comments? */
  21366. emitComments: boolean;
  21367. /** Emit build activity */
  21368. verbose: boolean;
  21369. /** Gets or sets the hosting scene */
  21370. scene: Scene;
  21371. /**
  21372. * Gets the compilation hints emitted at compilation time
  21373. */
  21374. hints: {
  21375. needWorldViewMatrix: boolean;
  21376. needWorldViewProjectionMatrix: boolean;
  21377. needAlphaBlending: boolean;
  21378. needAlphaTesting: boolean;
  21379. };
  21380. /**
  21381. * List of compilation checks
  21382. */
  21383. checks: {
  21384. emitVertex: boolean;
  21385. emitFragment: boolean;
  21386. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21387. };
  21388. /**
  21389. * Is vertex program allowed to be empty?
  21390. */
  21391. allowEmptyVertexProgram: boolean;
  21392. /** Creates a new shared data */
  21393. constructor();
  21394. /**
  21395. * Emits console errors and exceptions if there is a failing check
  21396. */
  21397. emitErrors(): void;
  21398. }
  21399. }
  21400. declare module BABYLON {
  21401. /**
  21402. * Class used to store node based material build state
  21403. */
  21404. export class NodeMaterialBuildState {
  21405. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21406. supportUniformBuffers: boolean;
  21407. /**
  21408. * Gets the list of emitted attributes
  21409. */
  21410. attributes: string[];
  21411. /**
  21412. * Gets the list of emitted uniforms
  21413. */
  21414. uniforms: string[];
  21415. /**
  21416. * Gets the list of emitted constants
  21417. */
  21418. constants: string[];
  21419. /**
  21420. * Gets the list of emitted samplers
  21421. */
  21422. samplers: string[];
  21423. /**
  21424. * Gets the list of emitted functions
  21425. */
  21426. functions: {
  21427. [key: string]: string;
  21428. };
  21429. /**
  21430. * Gets the list of emitted extensions
  21431. */
  21432. extensions: {
  21433. [key: string]: string;
  21434. };
  21435. /**
  21436. * Gets the target of the compilation state
  21437. */
  21438. target: NodeMaterialBlockTargets;
  21439. /**
  21440. * Gets the list of emitted counters
  21441. */
  21442. counters: {
  21443. [key: string]: number;
  21444. };
  21445. /**
  21446. * Shared data between multiple NodeMaterialBuildState instances
  21447. */
  21448. sharedData: NodeMaterialBuildStateSharedData;
  21449. /** @hidden */
  21450. _vertexState: NodeMaterialBuildState;
  21451. /** @hidden */
  21452. _attributeDeclaration: string;
  21453. /** @hidden */
  21454. _uniformDeclaration: string;
  21455. /** @hidden */
  21456. _constantDeclaration: string;
  21457. /** @hidden */
  21458. _samplerDeclaration: string;
  21459. /** @hidden */
  21460. _varyingTransfer: string;
  21461. /** @hidden */
  21462. _injectAtEnd: string;
  21463. private _repeatableContentAnchorIndex;
  21464. /** @hidden */
  21465. _builtCompilationString: string;
  21466. /**
  21467. * Gets the emitted compilation strings
  21468. */
  21469. compilationString: string;
  21470. /**
  21471. * Finalize the compilation strings
  21472. * @param state defines the current compilation state
  21473. */
  21474. finalize(state: NodeMaterialBuildState): void;
  21475. /** @hidden */
  21476. get _repeatableContentAnchor(): string;
  21477. /** @hidden */
  21478. _getFreeVariableName(prefix: string): string;
  21479. /** @hidden */
  21480. _getFreeDefineName(prefix: string): string;
  21481. /** @hidden */
  21482. _excludeVariableName(name: string): void;
  21483. /** @hidden */
  21484. _emit2DSampler(name: string): void;
  21485. /** @hidden */
  21486. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21487. /** @hidden */
  21488. _emitExtension(name: string, extension: string, define?: string): void;
  21489. /** @hidden */
  21490. _emitFunction(name: string, code: string, comments: string): void;
  21491. /** @hidden */
  21492. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21493. replaceStrings?: {
  21494. search: RegExp;
  21495. replace: string;
  21496. }[];
  21497. repeatKey?: string;
  21498. }): string;
  21499. /** @hidden */
  21500. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21501. repeatKey?: string;
  21502. removeAttributes?: boolean;
  21503. removeUniforms?: boolean;
  21504. removeVaryings?: boolean;
  21505. removeIfDef?: boolean;
  21506. replaceStrings?: {
  21507. search: RegExp;
  21508. replace: string;
  21509. }[];
  21510. }, storeKey?: string): void;
  21511. /** @hidden */
  21512. _registerTempVariable(name: string): boolean;
  21513. /** @hidden */
  21514. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21515. /** @hidden */
  21516. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21517. /** @hidden */
  21518. _emitFloat(value: number): string;
  21519. }
  21520. }
  21521. declare module BABYLON {
  21522. /**
  21523. * Helper class used to generate session unique ID
  21524. */
  21525. export class UniqueIdGenerator {
  21526. private static _UniqueIdCounter;
  21527. /**
  21528. * Gets an unique (relatively to the current scene) Id
  21529. */
  21530. static get UniqueId(): number;
  21531. }
  21532. }
  21533. declare module BABYLON {
  21534. /**
  21535. * Defines a block that can be used inside a node based material
  21536. */
  21537. export class NodeMaterialBlock {
  21538. private _buildId;
  21539. private _buildTarget;
  21540. private _target;
  21541. private _isFinalMerger;
  21542. private _isInput;
  21543. private _name;
  21544. protected _isUnique: boolean;
  21545. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21546. inputsAreExclusive: boolean;
  21547. /** @hidden */
  21548. _codeVariableName: string;
  21549. /** @hidden */
  21550. _inputs: NodeMaterialConnectionPoint[];
  21551. /** @hidden */
  21552. _outputs: NodeMaterialConnectionPoint[];
  21553. /** @hidden */
  21554. _preparationId: number;
  21555. /**
  21556. * Gets the name of the block
  21557. */
  21558. get name(): string;
  21559. /**
  21560. * Sets the name of the block. Will check if the name is valid.
  21561. */
  21562. set name(newName: string);
  21563. /**
  21564. * Gets or sets the unique id of the node
  21565. */
  21566. uniqueId: number;
  21567. /**
  21568. * Gets or sets the comments associated with this block
  21569. */
  21570. comments: string;
  21571. /**
  21572. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21573. */
  21574. get isUnique(): boolean;
  21575. /**
  21576. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21577. */
  21578. get isFinalMerger(): boolean;
  21579. /**
  21580. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21581. */
  21582. get isInput(): boolean;
  21583. /**
  21584. * Gets or sets the build Id
  21585. */
  21586. get buildId(): number;
  21587. set buildId(value: number);
  21588. /**
  21589. * Gets or sets the target of the block
  21590. */
  21591. get target(): NodeMaterialBlockTargets;
  21592. set target(value: NodeMaterialBlockTargets);
  21593. /**
  21594. * Gets the list of input points
  21595. */
  21596. get inputs(): NodeMaterialConnectionPoint[];
  21597. /** Gets the list of output points */
  21598. get outputs(): NodeMaterialConnectionPoint[];
  21599. /**
  21600. * Find an input by its name
  21601. * @param name defines the name of the input to look for
  21602. * @returns the input or null if not found
  21603. */
  21604. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21605. /**
  21606. * Find an output by its name
  21607. * @param name defines the name of the outputto look for
  21608. * @returns the output or null if not found
  21609. */
  21610. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21611. /**
  21612. * Creates a new NodeMaterialBlock
  21613. * @param name defines the block name
  21614. * @param target defines the target of that block (Vertex by default)
  21615. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21616. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21617. */
  21618. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21619. /**
  21620. * Initialize the block and prepare the context for build
  21621. * @param state defines the state that will be used for the build
  21622. */
  21623. initialize(state: NodeMaterialBuildState): void;
  21624. /**
  21625. * Bind data to effect. Will only be called for blocks with isBindable === true
  21626. * @param effect defines the effect to bind data to
  21627. * @param nodeMaterial defines the hosting NodeMaterial
  21628. * @param mesh defines the mesh that will be rendered
  21629. * @param subMesh defines the submesh that will be rendered
  21630. */
  21631. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21632. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21633. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21634. protected _writeFloat(value: number): string;
  21635. /**
  21636. * Gets the current class name e.g. "NodeMaterialBlock"
  21637. * @returns the class name
  21638. */
  21639. getClassName(): string;
  21640. /**
  21641. * Register a new input. Must be called inside a block constructor
  21642. * @param name defines the connection point name
  21643. * @param type defines the connection point type
  21644. * @param isOptional defines a boolean indicating that this input can be omitted
  21645. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21646. * @param point an already created connection point. If not provided, create a new one
  21647. * @returns the current block
  21648. */
  21649. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21650. /**
  21651. * Register a new output. Must be called inside a block constructor
  21652. * @param name defines the connection point name
  21653. * @param type defines the connection point type
  21654. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21655. * @param point an already created connection point. If not provided, create a new one
  21656. * @returns the current block
  21657. */
  21658. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21659. /**
  21660. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21661. * @param forOutput defines an optional connection point to check compatibility with
  21662. * @returns the first available input or null
  21663. */
  21664. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21665. /**
  21666. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21667. * @param forBlock defines an optional block to check compatibility with
  21668. * @returns the first available input or null
  21669. */
  21670. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21671. /**
  21672. * Gets the sibling of the given output
  21673. * @param current defines the current output
  21674. * @returns the next output in the list or null
  21675. */
  21676. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21677. /**
  21678. * Connect current block with another block
  21679. * @param other defines the block to connect with
  21680. * @param options define the various options to help pick the right connections
  21681. * @returns the current block
  21682. */
  21683. connectTo(other: NodeMaterialBlock, options?: {
  21684. input?: string;
  21685. output?: string;
  21686. outputSwizzle?: string;
  21687. }): this | undefined;
  21688. protected _buildBlock(state: NodeMaterialBuildState): void;
  21689. /**
  21690. * Add uniforms, samplers and uniform buffers at compilation time
  21691. * @param state defines the state to update
  21692. * @param nodeMaterial defines the node material requesting the update
  21693. * @param defines defines the material defines to update
  21694. * @param uniformBuffers defines the list of uniform buffer names
  21695. */
  21696. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21697. /**
  21698. * Add potential fallbacks if shader compilation fails
  21699. * @param mesh defines the mesh to be rendered
  21700. * @param fallbacks defines the current prioritized list of fallbacks
  21701. */
  21702. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21703. /**
  21704. * Initialize defines for shader compilation
  21705. * @param mesh defines the mesh to be rendered
  21706. * @param nodeMaterial defines the node material requesting the update
  21707. * @param defines defines the material defines to update
  21708. * @param useInstances specifies that instances should be used
  21709. */
  21710. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21711. /**
  21712. * Update defines for shader compilation
  21713. * @param mesh defines the mesh to be rendered
  21714. * @param nodeMaterial defines the node material requesting the update
  21715. * @param defines defines the material defines to update
  21716. * @param useInstances specifies that instances should be used
  21717. * @param subMesh defines which submesh to render
  21718. */
  21719. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21720. /**
  21721. * Lets the block try to connect some inputs automatically
  21722. * @param material defines the hosting NodeMaterial
  21723. */
  21724. autoConfigure(material: NodeMaterial): void;
  21725. /**
  21726. * Function called when a block is declared as repeatable content generator
  21727. * @param vertexShaderState defines the current compilation state for the vertex shader
  21728. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21729. * @param mesh defines the mesh to be rendered
  21730. * @param defines defines the material defines to update
  21731. */
  21732. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21733. /**
  21734. * Checks if the block is ready
  21735. * @param mesh defines the mesh to be rendered
  21736. * @param nodeMaterial defines the node material requesting the update
  21737. * @param defines defines the material defines to update
  21738. * @param useInstances specifies that instances should be used
  21739. * @returns true if the block is ready
  21740. */
  21741. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21742. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21743. private _processBuild;
  21744. /**
  21745. * Validates the new name for the block node.
  21746. * @param newName the new name to be given to the node.
  21747. * @returns false if the name is a reserve word, else true.
  21748. */
  21749. validateBlockName(newName: string): boolean;
  21750. /**
  21751. * Compile the current node and generate the shader code
  21752. * @param state defines the current compilation state (uniforms, samplers, current string)
  21753. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21754. * @returns true if already built
  21755. */
  21756. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21757. protected _inputRename(name: string): string;
  21758. protected _outputRename(name: string): string;
  21759. protected _dumpPropertiesCode(): string;
  21760. /** @hidden */
  21761. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21762. /** @hidden */
  21763. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21764. /**
  21765. * Clone the current block to a new identical block
  21766. * @param scene defines the hosting scene
  21767. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21768. * @returns a copy of the current block
  21769. */
  21770. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21771. /**
  21772. * Serializes this block in a JSON representation
  21773. * @returns the serialized block object
  21774. */
  21775. serialize(): any;
  21776. /** @hidden */
  21777. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21778. private _deserializePortDisplayNamesAndExposedOnFrame;
  21779. /**
  21780. * Release resources
  21781. */
  21782. dispose(): void;
  21783. }
  21784. }
  21785. declare module BABYLON {
  21786. /**
  21787. * Base class of materials working in push mode in babylon JS
  21788. * @hidden
  21789. */
  21790. export class PushMaterial extends Material {
  21791. protected _activeEffect: Effect;
  21792. protected _normalMatrix: Matrix;
  21793. constructor(name: string, scene: Scene);
  21794. getEffect(): Effect;
  21795. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21796. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21797. /**
  21798. * Binds the given world matrix to the active effect
  21799. *
  21800. * @param world the matrix to bind
  21801. */
  21802. bindOnlyWorldMatrix(world: Matrix): void;
  21803. /**
  21804. * Binds the given normal matrix to the active effect
  21805. *
  21806. * @param normalMatrix the matrix to bind
  21807. */
  21808. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21809. bind(world: Matrix, mesh?: Mesh): void;
  21810. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21811. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21812. }
  21813. }
  21814. declare module BABYLON {
  21815. /**
  21816. * Root class for all node material optimizers
  21817. */
  21818. export class NodeMaterialOptimizer {
  21819. /**
  21820. * Function used to optimize a NodeMaterial graph
  21821. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21822. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21823. */
  21824. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21825. }
  21826. }
  21827. declare module BABYLON {
  21828. /**
  21829. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21830. */
  21831. export class TransformBlock extends NodeMaterialBlock {
  21832. /**
  21833. * Defines the value to use to complement W value to transform it to a Vector4
  21834. */
  21835. complementW: number;
  21836. /**
  21837. * Defines the value to use to complement z value to transform it to a Vector4
  21838. */
  21839. complementZ: number;
  21840. /**
  21841. * Creates a new TransformBlock
  21842. * @param name defines the block name
  21843. */
  21844. constructor(name: string);
  21845. /**
  21846. * Gets the current class name
  21847. * @returns the class name
  21848. */
  21849. getClassName(): string;
  21850. /**
  21851. * Gets the vector input
  21852. */
  21853. get vector(): NodeMaterialConnectionPoint;
  21854. /**
  21855. * Gets the output component
  21856. */
  21857. get output(): NodeMaterialConnectionPoint;
  21858. /**
  21859. * Gets the xyz output component
  21860. */
  21861. get xyz(): NodeMaterialConnectionPoint;
  21862. /**
  21863. * Gets the matrix transform input
  21864. */
  21865. get transform(): NodeMaterialConnectionPoint;
  21866. protected _buildBlock(state: NodeMaterialBuildState): this;
  21867. /**
  21868. * Update defines for shader compilation
  21869. * @param mesh defines the mesh to be rendered
  21870. * @param nodeMaterial defines the node material requesting the update
  21871. * @param defines defines the material defines to update
  21872. * @param useInstances specifies that instances should be used
  21873. * @param subMesh defines which submesh to render
  21874. */
  21875. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21876. serialize(): any;
  21877. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21878. protected _dumpPropertiesCode(): string;
  21879. }
  21880. }
  21881. declare module BABYLON {
  21882. /**
  21883. * Block used to output the vertex position
  21884. */
  21885. export class VertexOutputBlock extends NodeMaterialBlock {
  21886. /**
  21887. * Creates a new VertexOutputBlock
  21888. * @param name defines the block name
  21889. */
  21890. constructor(name: string);
  21891. /**
  21892. * Gets the current class name
  21893. * @returns the class name
  21894. */
  21895. getClassName(): string;
  21896. /**
  21897. * Gets the vector input component
  21898. */
  21899. get vector(): NodeMaterialConnectionPoint;
  21900. protected _buildBlock(state: NodeMaterialBuildState): this;
  21901. }
  21902. }
  21903. declare module BABYLON {
  21904. /**
  21905. * Block used to output the final color
  21906. */
  21907. export class FragmentOutputBlock extends NodeMaterialBlock {
  21908. /**
  21909. * Create a new FragmentOutputBlock
  21910. * @param name defines the block name
  21911. */
  21912. constructor(name: string);
  21913. /**
  21914. * Gets the current class name
  21915. * @returns the class name
  21916. */
  21917. getClassName(): string;
  21918. /**
  21919. * Gets the rgba input component
  21920. */
  21921. get rgba(): NodeMaterialConnectionPoint;
  21922. /**
  21923. * Gets the rgb input component
  21924. */
  21925. get rgb(): NodeMaterialConnectionPoint;
  21926. /**
  21927. * Gets the a input component
  21928. */
  21929. get a(): NodeMaterialConnectionPoint;
  21930. protected _buildBlock(state: NodeMaterialBuildState): this;
  21931. }
  21932. }
  21933. declare module BABYLON {
  21934. /**
  21935. * Block used for the particle ramp gradient section
  21936. */
  21937. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21938. /**
  21939. * Create a new ParticleRampGradientBlock
  21940. * @param name defines the block name
  21941. */
  21942. constructor(name: string);
  21943. /**
  21944. * Gets the current class name
  21945. * @returns the class name
  21946. */
  21947. getClassName(): string;
  21948. /**
  21949. * Gets the color input component
  21950. */
  21951. get color(): NodeMaterialConnectionPoint;
  21952. /**
  21953. * Gets the rampColor output component
  21954. */
  21955. get rampColor(): NodeMaterialConnectionPoint;
  21956. /**
  21957. * Initialize the block and prepare the context for build
  21958. * @param state defines the state that will be used for the build
  21959. */
  21960. initialize(state: NodeMaterialBuildState): void;
  21961. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21962. }
  21963. }
  21964. declare module BABYLON {
  21965. /**
  21966. * Block used for the particle blend multiply section
  21967. */
  21968. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21969. /**
  21970. * Create a new ParticleBlendMultiplyBlock
  21971. * @param name defines the block name
  21972. */
  21973. constructor(name: string);
  21974. /**
  21975. * Gets the current class name
  21976. * @returns the class name
  21977. */
  21978. getClassName(): string;
  21979. /**
  21980. * Gets the color input component
  21981. */
  21982. get color(): NodeMaterialConnectionPoint;
  21983. /**
  21984. * Gets the alphaTexture input component
  21985. */
  21986. get alphaTexture(): NodeMaterialConnectionPoint;
  21987. /**
  21988. * Gets the alphaColor input component
  21989. */
  21990. get alphaColor(): NodeMaterialConnectionPoint;
  21991. /**
  21992. * Gets the blendColor output component
  21993. */
  21994. get blendColor(): NodeMaterialConnectionPoint;
  21995. /**
  21996. * Initialize the block and prepare the context for build
  21997. * @param state defines the state that will be used for the build
  21998. */
  21999. initialize(state: NodeMaterialBuildState): void;
  22000. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22001. }
  22002. }
  22003. declare module BABYLON {
  22004. /**
  22005. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22006. */
  22007. export class VectorMergerBlock extends NodeMaterialBlock {
  22008. /**
  22009. * Create a new VectorMergerBlock
  22010. * @param name defines the block name
  22011. */
  22012. constructor(name: string);
  22013. /**
  22014. * Gets the current class name
  22015. * @returns the class name
  22016. */
  22017. getClassName(): string;
  22018. /**
  22019. * Gets the xyz component (input)
  22020. */
  22021. get xyzIn(): NodeMaterialConnectionPoint;
  22022. /**
  22023. * Gets the xy component (input)
  22024. */
  22025. get xyIn(): NodeMaterialConnectionPoint;
  22026. /**
  22027. * Gets the x component (input)
  22028. */
  22029. get x(): NodeMaterialConnectionPoint;
  22030. /**
  22031. * Gets the y component (input)
  22032. */
  22033. get y(): NodeMaterialConnectionPoint;
  22034. /**
  22035. * Gets the z component (input)
  22036. */
  22037. get z(): NodeMaterialConnectionPoint;
  22038. /**
  22039. * Gets the w component (input)
  22040. */
  22041. get w(): NodeMaterialConnectionPoint;
  22042. /**
  22043. * Gets the xyzw component (output)
  22044. */
  22045. get xyzw(): NodeMaterialConnectionPoint;
  22046. /**
  22047. * Gets the xyz component (output)
  22048. */
  22049. get xyzOut(): NodeMaterialConnectionPoint;
  22050. /**
  22051. * Gets the xy component (output)
  22052. */
  22053. get xyOut(): NodeMaterialConnectionPoint;
  22054. /**
  22055. * Gets the xy component (output)
  22056. * @deprecated Please use xyOut instead.
  22057. */
  22058. get xy(): NodeMaterialConnectionPoint;
  22059. /**
  22060. * Gets the xyz component (output)
  22061. * @deprecated Please use xyzOut instead.
  22062. */
  22063. get xyz(): NodeMaterialConnectionPoint;
  22064. protected _buildBlock(state: NodeMaterialBuildState): this;
  22065. }
  22066. }
  22067. declare module BABYLON {
  22068. /**
  22069. * Block used to remap a float from a range to a new one
  22070. */
  22071. export class RemapBlock extends NodeMaterialBlock {
  22072. /**
  22073. * Gets or sets the source range
  22074. */
  22075. sourceRange: Vector2;
  22076. /**
  22077. * Gets or sets the target range
  22078. */
  22079. targetRange: Vector2;
  22080. /**
  22081. * Creates a new RemapBlock
  22082. * @param name defines the block name
  22083. */
  22084. constructor(name: string);
  22085. /**
  22086. * Gets the current class name
  22087. * @returns the class name
  22088. */
  22089. getClassName(): string;
  22090. /**
  22091. * Gets the input component
  22092. */
  22093. get input(): NodeMaterialConnectionPoint;
  22094. /**
  22095. * Gets the source min input component
  22096. */
  22097. get sourceMin(): NodeMaterialConnectionPoint;
  22098. /**
  22099. * Gets the source max input component
  22100. */
  22101. get sourceMax(): NodeMaterialConnectionPoint;
  22102. /**
  22103. * Gets the target min input component
  22104. */
  22105. get targetMin(): NodeMaterialConnectionPoint;
  22106. /**
  22107. * Gets the target max input component
  22108. */
  22109. get targetMax(): NodeMaterialConnectionPoint;
  22110. /**
  22111. * Gets the output component
  22112. */
  22113. get output(): NodeMaterialConnectionPoint;
  22114. protected _buildBlock(state: NodeMaterialBuildState): this;
  22115. protected _dumpPropertiesCode(): string;
  22116. serialize(): any;
  22117. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22118. }
  22119. }
  22120. declare module BABYLON {
  22121. /**
  22122. * Block used to multiply 2 values
  22123. */
  22124. export class MultiplyBlock extends NodeMaterialBlock {
  22125. /**
  22126. * Creates a new MultiplyBlock
  22127. * @param name defines the block name
  22128. */
  22129. constructor(name: string);
  22130. /**
  22131. * Gets the current class name
  22132. * @returns the class name
  22133. */
  22134. getClassName(): string;
  22135. /**
  22136. * Gets the left operand input component
  22137. */
  22138. get left(): NodeMaterialConnectionPoint;
  22139. /**
  22140. * Gets the right operand input component
  22141. */
  22142. get right(): NodeMaterialConnectionPoint;
  22143. /**
  22144. * Gets the output component
  22145. */
  22146. get output(): NodeMaterialConnectionPoint;
  22147. protected _buildBlock(state: NodeMaterialBuildState): this;
  22148. }
  22149. }
  22150. declare module BABYLON {
  22151. /**
  22152. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22153. */
  22154. export class ColorSplitterBlock extends NodeMaterialBlock {
  22155. /**
  22156. * Create a new ColorSplitterBlock
  22157. * @param name defines the block name
  22158. */
  22159. constructor(name: string);
  22160. /**
  22161. * Gets the current class name
  22162. * @returns the class name
  22163. */
  22164. getClassName(): string;
  22165. /**
  22166. * Gets the rgba component (input)
  22167. */
  22168. get rgba(): NodeMaterialConnectionPoint;
  22169. /**
  22170. * Gets the rgb component (input)
  22171. */
  22172. get rgbIn(): NodeMaterialConnectionPoint;
  22173. /**
  22174. * Gets the rgb component (output)
  22175. */
  22176. get rgbOut(): NodeMaterialConnectionPoint;
  22177. /**
  22178. * Gets the r component (output)
  22179. */
  22180. get r(): NodeMaterialConnectionPoint;
  22181. /**
  22182. * Gets the g component (output)
  22183. */
  22184. get g(): NodeMaterialConnectionPoint;
  22185. /**
  22186. * Gets the b component (output)
  22187. */
  22188. get b(): NodeMaterialConnectionPoint;
  22189. /**
  22190. * Gets the a component (output)
  22191. */
  22192. get a(): NodeMaterialConnectionPoint;
  22193. protected _inputRename(name: string): string;
  22194. protected _outputRename(name: string): string;
  22195. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22196. }
  22197. }
  22198. declare module BABYLON {
  22199. /**
  22200. * Interface used to configure the node material editor
  22201. */
  22202. export interface INodeMaterialEditorOptions {
  22203. /** Define the URl to load node editor script */
  22204. editorURL?: string;
  22205. }
  22206. /** @hidden */
  22207. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22208. NORMAL: boolean;
  22209. TANGENT: boolean;
  22210. UV1: boolean;
  22211. /** BONES */
  22212. NUM_BONE_INFLUENCERS: number;
  22213. BonesPerMesh: number;
  22214. BONETEXTURE: boolean;
  22215. /** MORPH TARGETS */
  22216. MORPHTARGETS: boolean;
  22217. MORPHTARGETS_NORMAL: boolean;
  22218. MORPHTARGETS_TANGENT: boolean;
  22219. MORPHTARGETS_UV: boolean;
  22220. NUM_MORPH_INFLUENCERS: number;
  22221. /** IMAGE PROCESSING */
  22222. IMAGEPROCESSING: boolean;
  22223. VIGNETTE: boolean;
  22224. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22225. VIGNETTEBLENDMODEOPAQUE: boolean;
  22226. TONEMAPPING: boolean;
  22227. TONEMAPPING_ACES: boolean;
  22228. CONTRAST: boolean;
  22229. EXPOSURE: boolean;
  22230. COLORCURVES: boolean;
  22231. COLORGRADING: boolean;
  22232. COLORGRADING3D: boolean;
  22233. SAMPLER3DGREENDEPTH: boolean;
  22234. SAMPLER3DBGRMAP: boolean;
  22235. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22236. /** MISC. */
  22237. BUMPDIRECTUV: number;
  22238. constructor();
  22239. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22240. }
  22241. /**
  22242. * Class used to configure NodeMaterial
  22243. */
  22244. export interface INodeMaterialOptions {
  22245. /**
  22246. * Defines if blocks should emit comments
  22247. */
  22248. emitComments: boolean;
  22249. }
  22250. /**
  22251. * Class used to create a node based material built by assembling shader blocks
  22252. */
  22253. export class NodeMaterial extends PushMaterial {
  22254. private static _BuildIdGenerator;
  22255. private _options;
  22256. private _vertexCompilationState;
  22257. private _fragmentCompilationState;
  22258. private _sharedData;
  22259. private _buildId;
  22260. private _buildWasSuccessful;
  22261. private _cachedWorldViewMatrix;
  22262. private _cachedWorldViewProjectionMatrix;
  22263. private _optimizers;
  22264. private _animationFrame;
  22265. /** Define the Url to load node editor script */
  22266. static EditorURL: string;
  22267. /** Define the Url to load snippets */
  22268. static SnippetUrl: string;
  22269. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22270. static IgnoreTexturesAtLoadTime: boolean;
  22271. private BJSNODEMATERIALEDITOR;
  22272. /** Get the inspector from bundle or global */
  22273. private _getGlobalNodeMaterialEditor;
  22274. /**
  22275. * Snippet ID if the material was created from the snippet server
  22276. */
  22277. snippetId: string;
  22278. /**
  22279. * Gets or sets data used by visual editor
  22280. * @see https://nme.babylonjs.com
  22281. */
  22282. editorData: any;
  22283. /**
  22284. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  22285. */
  22286. ignoreAlpha: boolean;
  22287. /**
  22288. * Defines the maximum number of lights that can be used in the material
  22289. */
  22290. maxSimultaneousLights: number;
  22291. /**
  22292. * Observable raised when the material is built
  22293. */
  22294. onBuildObservable: Observable<NodeMaterial>;
  22295. /**
  22296. * Gets or sets the root nodes of the material vertex shader
  22297. */
  22298. _vertexOutputNodes: NodeMaterialBlock[];
  22299. /**
  22300. * Gets or sets the root nodes of the material fragment (pixel) shader
  22301. */
  22302. _fragmentOutputNodes: NodeMaterialBlock[];
  22303. /** Gets or sets options to control the node material overall behavior */
  22304. get options(): INodeMaterialOptions;
  22305. set options(options: INodeMaterialOptions);
  22306. /**
  22307. * Default configuration related to image processing available in the standard Material.
  22308. */
  22309. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22310. /**
  22311. * Gets the image processing configuration used either in this material.
  22312. */
  22313. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22314. /**
  22315. * Sets the Default image processing configuration used either in the this material.
  22316. *
  22317. * If sets to null, the scene one is in use.
  22318. */
  22319. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22320. /**
  22321. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22322. */
  22323. attachedBlocks: NodeMaterialBlock[];
  22324. /**
  22325. * Specifies the mode of the node material
  22326. * @hidden
  22327. */
  22328. _mode: NodeMaterialModes;
  22329. /**
  22330. * Gets the mode property
  22331. */
  22332. get mode(): NodeMaterialModes;
  22333. /**
  22334. * Create a new node based material
  22335. * @param name defines the material name
  22336. * @param scene defines the hosting scene
  22337. * @param options defines creation option
  22338. */
  22339. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22340. /**
  22341. * Gets the current class name of the material e.g. "NodeMaterial"
  22342. * @returns the class name
  22343. */
  22344. getClassName(): string;
  22345. /**
  22346. * Keep track of the image processing observer to allow dispose and replace.
  22347. */
  22348. private _imageProcessingObserver;
  22349. /**
  22350. * Attaches a new image processing configuration to the Standard Material.
  22351. * @param configuration
  22352. */
  22353. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22354. /**
  22355. * Get a block by its name
  22356. * @param name defines the name of the block to retrieve
  22357. * @returns the required block or null if not found
  22358. */
  22359. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22360. /**
  22361. * Get a block by its name
  22362. * @param predicate defines the predicate used to find the good candidate
  22363. * @returns the required block or null if not found
  22364. */
  22365. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22366. /**
  22367. * Get an input block by its name
  22368. * @param predicate defines the predicate used to find the good candidate
  22369. * @returns the required input block or null if not found
  22370. */
  22371. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22372. /**
  22373. * Gets the list of input blocks attached to this material
  22374. * @returns an array of InputBlocks
  22375. */
  22376. getInputBlocks(): InputBlock[];
  22377. /**
  22378. * Adds a new optimizer to the list of optimizers
  22379. * @param optimizer defines the optimizers to add
  22380. * @returns the current material
  22381. */
  22382. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22383. /**
  22384. * Remove an optimizer from the list of optimizers
  22385. * @param optimizer defines the optimizers to remove
  22386. * @returns the current material
  22387. */
  22388. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22389. /**
  22390. * Add a new block to the list of output nodes
  22391. * @param node defines the node to add
  22392. * @returns the current material
  22393. */
  22394. addOutputNode(node: NodeMaterialBlock): this;
  22395. /**
  22396. * Remove a block from the list of root nodes
  22397. * @param node defines the node to remove
  22398. * @returns the current material
  22399. */
  22400. removeOutputNode(node: NodeMaterialBlock): this;
  22401. private _addVertexOutputNode;
  22402. private _removeVertexOutputNode;
  22403. private _addFragmentOutputNode;
  22404. private _removeFragmentOutputNode;
  22405. /**
  22406. * Specifies if the material will require alpha blending
  22407. * @returns a boolean specifying if alpha blending is needed
  22408. */
  22409. needAlphaBlending(): boolean;
  22410. /**
  22411. * Specifies if this material should be rendered in alpha test mode
  22412. * @returns a boolean specifying if an alpha test is needed.
  22413. */
  22414. needAlphaTesting(): boolean;
  22415. private _initializeBlock;
  22416. private _resetDualBlocks;
  22417. /**
  22418. * Remove a block from the current node material
  22419. * @param block defines the block to remove
  22420. */
  22421. removeBlock(block: NodeMaterialBlock): void;
  22422. /**
  22423. * Build the material and generates the inner effect
  22424. * @param verbose defines if the build should log activity
  22425. */
  22426. build(verbose?: boolean): void;
  22427. /**
  22428. * Runs an otpimization phase to try to improve the shader code
  22429. */
  22430. optimize(): void;
  22431. private _prepareDefinesForAttributes;
  22432. /**
  22433. * Create a post process from the material
  22434. * @param camera The camera to apply the render pass to.
  22435. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22436. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22437. * @param engine The engine which the post process will be applied. (default: current engine)
  22438. * @param reusable If the post process can be reused on the same frame. (default: false)
  22439. * @param textureType Type of textures used when performing the post process. (default: 0)
  22440. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22441. * @returns the post process created
  22442. */
  22443. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22444. /**
  22445. * Create the post process effect from the material
  22446. * @param postProcess The post process to create the effect for
  22447. */
  22448. createEffectForPostProcess(postProcess: PostProcess): void;
  22449. private _createEffectOrPostProcess;
  22450. private _createEffectForParticles;
  22451. /**
  22452. * Create the effect to be used as the custom effect for a particle system
  22453. * @param particleSystem Particle system to create the effect for
  22454. * @param onCompiled defines a function to call when the effect creation is successful
  22455. * @param onError defines a function to call when the effect creation has failed
  22456. */
  22457. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22458. private _processDefines;
  22459. /**
  22460. * Get if the submesh is ready to be used and all its information available.
  22461. * Child classes can use it to update shaders
  22462. * @param mesh defines the mesh to check
  22463. * @param subMesh defines which submesh to check
  22464. * @param useInstances specifies that instances should be used
  22465. * @returns a boolean indicating that the submesh is ready or not
  22466. */
  22467. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22468. /**
  22469. * Get a string representing the shaders built by the current node graph
  22470. */
  22471. get compiledShaders(): string;
  22472. /**
  22473. * Binds the world matrix to the material
  22474. * @param world defines the world transformation matrix
  22475. */
  22476. bindOnlyWorldMatrix(world: Matrix): void;
  22477. /**
  22478. * Binds the submesh to this material by preparing the effect and shader to draw
  22479. * @param world defines the world transformation matrix
  22480. * @param mesh defines the mesh containing the submesh
  22481. * @param subMesh defines the submesh to bind the material to
  22482. */
  22483. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22484. /**
  22485. * Gets the active textures from the material
  22486. * @returns an array of textures
  22487. */
  22488. getActiveTextures(): BaseTexture[];
  22489. /**
  22490. * Gets the list of texture blocks
  22491. * @returns an array of texture blocks
  22492. */
  22493. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22494. /**
  22495. * Specifies if the material uses a texture
  22496. * @param texture defines the texture to check against the material
  22497. * @returns a boolean specifying if the material uses the texture
  22498. */
  22499. hasTexture(texture: BaseTexture): boolean;
  22500. /**
  22501. * Disposes the material
  22502. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22503. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22504. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22505. */
  22506. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22507. /** Creates the node editor window. */
  22508. private _createNodeEditor;
  22509. /**
  22510. * Launch the node material editor
  22511. * @param config Define the configuration of the editor
  22512. * @return a promise fulfilled when the node editor is visible
  22513. */
  22514. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22515. /**
  22516. * Clear the current material
  22517. */
  22518. clear(): void;
  22519. /**
  22520. * Clear the current material and set it to a default state
  22521. */
  22522. setToDefault(): void;
  22523. /**
  22524. * Clear the current material and set it to a default state for post process
  22525. */
  22526. setToDefaultPostProcess(): void;
  22527. /**
  22528. * Clear the current material and set it to a default state for particle
  22529. */
  22530. setToDefaultParticle(): void;
  22531. /**
  22532. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22533. * @param url defines the url to load from
  22534. * @returns a promise that will fullfil when the material is fully loaded
  22535. */
  22536. loadAsync(url: string): Promise<void>;
  22537. private _gatherBlocks;
  22538. /**
  22539. * Generate a string containing the code declaration required to create an equivalent of this material
  22540. * @returns a string
  22541. */
  22542. generateCode(): string;
  22543. /**
  22544. * Serializes this material in a JSON representation
  22545. * @returns the serialized material object
  22546. */
  22547. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22548. private _restoreConnections;
  22549. /**
  22550. * Clear the current graph and load a new one from a serialization object
  22551. * @param source defines the JSON representation of the material
  22552. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22553. * @param merge defines whether or not the source must be merged or replace the current content
  22554. */
  22555. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22556. /**
  22557. * Makes a duplicate of the current material.
  22558. * @param name - name to use for the new material.
  22559. */
  22560. clone(name: string): NodeMaterial;
  22561. /**
  22562. * Creates a node material from parsed material data
  22563. * @param source defines the JSON representation of the material
  22564. * @param scene defines the hosting scene
  22565. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22566. * @returns a new node material
  22567. */
  22568. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22569. /**
  22570. * Creates a node material from a snippet saved in a remote file
  22571. * @param name defines the name of the material to create
  22572. * @param url defines the url to load from
  22573. * @param scene defines the hosting scene
  22574. * @returns a promise that will resolve to the new node material
  22575. */
  22576. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22577. /**
  22578. * Creates a node material from a snippet saved by the node material editor
  22579. * @param snippetId defines the snippet to load
  22580. * @param scene defines the hosting scene
  22581. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22582. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22583. * @returns a promise that will resolve to the new node material
  22584. */
  22585. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22586. /**
  22587. * Creates a new node material set to default basic configuration
  22588. * @param name defines the name of the material
  22589. * @param scene defines the hosting scene
  22590. * @returns a new NodeMaterial
  22591. */
  22592. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22593. }
  22594. }
  22595. declare module BABYLON {
  22596. /**
  22597. * Size options for a post process
  22598. */
  22599. export type PostProcessOptions = {
  22600. width: number;
  22601. height: number;
  22602. };
  22603. /**
  22604. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22605. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22606. */
  22607. export class PostProcess {
  22608. /**
  22609. * Gets or sets the unique id of the post process
  22610. */
  22611. uniqueId: number;
  22612. /** Name of the PostProcess. */
  22613. name: string;
  22614. /**
  22615. * Width of the texture to apply the post process on
  22616. */
  22617. width: number;
  22618. /**
  22619. * Height of the texture to apply the post process on
  22620. */
  22621. height: number;
  22622. /**
  22623. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22624. */
  22625. nodeMaterialSource: Nullable<NodeMaterial>;
  22626. /**
  22627. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22628. * @hidden
  22629. */
  22630. _outputTexture: Nullable<InternalTexture>;
  22631. /**
  22632. * Sampling mode used by the shader
  22633. * See https://doc.babylonjs.com/classes/3.1/texture
  22634. */
  22635. renderTargetSamplingMode: number;
  22636. /**
  22637. * Clear color to use when screen clearing
  22638. */
  22639. clearColor: Color4;
  22640. /**
  22641. * If the buffer needs to be cleared before applying the post process. (default: true)
  22642. * Should be set to false if shader will overwrite all previous pixels.
  22643. */
  22644. autoClear: boolean;
  22645. /**
  22646. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22647. */
  22648. alphaMode: number;
  22649. /**
  22650. * Sets the setAlphaBlendConstants of the babylon engine
  22651. */
  22652. alphaConstants: Color4;
  22653. /**
  22654. * Animations to be used for the post processing
  22655. */
  22656. animations: Animation[];
  22657. /**
  22658. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22659. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22660. */
  22661. enablePixelPerfectMode: boolean;
  22662. /**
  22663. * Force the postprocess to be applied without taking in account viewport
  22664. */
  22665. forceFullscreenViewport: boolean;
  22666. /**
  22667. * List of inspectable custom properties (used by the Inspector)
  22668. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22669. */
  22670. inspectableCustomProperties: IInspectable[];
  22671. /**
  22672. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22673. *
  22674. * | Value | Type | Description |
  22675. * | ----- | ----------------------------------- | ----------- |
  22676. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22677. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22678. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22679. *
  22680. */
  22681. scaleMode: number;
  22682. /**
  22683. * Force textures to be a power of two (default: false)
  22684. */
  22685. alwaysForcePOT: boolean;
  22686. private _samples;
  22687. /**
  22688. * Number of sample textures (default: 1)
  22689. */
  22690. get samples(): number;
  22691. set samples(n: number);
  22692. /**
  22693. * Modify the scale of the post process to be the same as the viewport (default: false)
  22694. */
  22695. adaptScaleToCurrentViewport: boolean;
  22696. private _camera;
  22697. protected _scene: Scene;
  22698. private _engine;
  22699. private _options;
  22700. private _reusable;
  22701. private _textureType;
  22702. private _textureFormat;
  22703. /**
  22704. * Smart array of input and output textures for the post process.
  22705. * @hidden
  22706. */
  22707. _textures: SmartArray<InternalTexture>;
  22708. /**
  22709. * The index in _textures that corresponds to the output texture.
  22710. * @hidden
  22711. */
  22712. _currentRenderTextureInd: number;
  22713. private _effect;
  22714. private _samplers;
  22715. private _fragmentUrl;
  22716. private _vertexUrl;
  22717. private _parameters;
  22718. private _scaleRatio;
  22719. protected _indexParameters: any;
  22720. private _shareOutputWithPostProcess;
  22721. private _texelSize;
  22722. private _forcedOutputTexture;
  22723. /**
  22724. * Returns the fragment url or shader name used in the post process.
  22725. * @returns the fragment url or name in the shader store.
  22726. */
  22727. getEffectName(): string;
  22728. /**
  22729. * An event triggered when the postprocess is activated.
  22730. */
  22731. onActivateObservable: Observable<Camera>;
  22732. private _onActivateObserver;
  22733. /**
  22734. * A function that is added to the onActivateObservable
  22735. */
  22736. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22737. /**
  22738. * An event triggered when the postprocess changes its size.
  22739. */
  22740. onSizeChangedObservable: Observable<PostProcess>;
  22741. private _onSizeChangedObserver;
  22742. /**
  22743. * A function that is added to the onSizeChangedObservable
  22744. */
  22745. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22746. /**
  22747. * An event triggered when the postprocess applies its effect.
  22748. */
  22749. onApplyObservable: Observable<Effect>;
  22750. private _onApplyObserver;
  22751. /**
  22752. * A function that is added to the onApplyObservable
  22753. */
  22754. set onApply(callback: (effect: Effect) => void);
  22755. /**
  22756. * An event triggered before rendering the postprocess
  22757. */
  22758. onBeforeRenderObservable: Observable<Effect>;
  22759. private _onBeforeRenderObserver;
  22760. /**
  22761. * A function that is added to the onBeforeRenderObservable
  22762. */
  22763. set onBeforeRender(callback: (effect: Effect) => void);
  22764. /**
  22765. * An event triggered after rendering the postprocess
  22766. */
  22767. onAfterRenderObservable: Observable<Effect>;
  22768. private _onAfterRenderObserver;
  22769. /**
  22770. * A function that is added to the onAfterRenderObservable
  22771. */
  22772. set onAfterRender(callback: (efect: Effect) => void);
  22773. /**
  22774. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  22775. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22776. */
  22777. get inputTexture(): InternalTexture;
  22778. set inputTexture(value: InternalTexture);
  22779. /**
  22780. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22781. * the only way to unset it is to use this function to restore its internal state
  22782. */
  22783. restoreDefaultInputTexture(): void;
  22784. /**
  22785. * Gets the camera which post process is applied to.
  22786. * @returns The camera the post process is applied to.
  22787. */
  22788. getCamera(): Camera;
  22789. /**
  22790. * Gets the texel size of the postprocess.
  22791. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22792. */
  22793. get texelSize(): Vector2;
  22794. /**
  22795. * Creates a new instance PostProcess
  22796. * @param name The name of the PostProcess.
  22797. * @param fragmentUrl The url of the fragment shader to be used.
  22798. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22799. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22800. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22801. * @param camera The camera to apply the render pass to.
  22802. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22803. * @param engine The engine which the post process will be applied. (default: current engine)
  22804. * @param reusable If the post process can be reused on the same frame. (default: false)
  22805. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22806. * @param textureType Type of textures used when performing the post process. (default: 0)
  22807. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22808. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  22809. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22810. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22811. */
  22812. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  22813. /**
  22814. * Gets a string identifying the name of the class
  22815. * @returns "PostProcess" string
  22816. */
  22817. getClassName(): string;
  22818. /**
  22819. * Gets the engine which this post process belongs to.
  22820. * @returns The engine the post process was enabled with.
  22821. */
  22822. getEngine(): Engine;
  22823. /**
  22824. * The effect that is created when initializing the post process.
  22825. * @returns The created effect corresponding the the postprocess.
  22826. */
  22827. getEffect(): Effect;
  22828. /**
  22829. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22830. * @param postProcess The post process to share the output with.
  22831. * @returns This post process.
  22832. */
  22833. shareOutputWith(postProcess: PostProcess): PostProcess;
  22834. /**
  22835. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22836. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22837. */
  22838. useOwnOutput(): void;
  22839. /**
  22840. * Updates the effect with the current post process compile time values and recompiles the shader.
  22841. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22842. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22843. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22844. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  22845. * @param onCompiled Called when the shader has been compiled.
  22846. * @param onError Called if there is an error when compiling a shader.
  22847. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22848. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22849. */
  22850. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  22851. /**
  22852. * The post process is reusable if it can be used multiple times within one frame.
  22853. * @returns If the post process is reusable
  22854. */
  22855. isReusable(): boolean;
  22856. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22857. markTextureDirty(): void;
  22858. /**
  22859. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22860. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  22861. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22862. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22863. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22864. * @returns The target texture that was bound to be written to.
  22865. */
  22866. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22867. /**
  22868. * If the post process is supported.
  22869. */
  22870. get isSupported(): boolean;
  22871. /**
  22872. * The aspect ratio of the output texture.
  22873. */
  22874. get aspectRatio(): number;
  22875. /**
  22876. * Get a value indicating if the post-process is ready to be used
  22877. * @returns true if the post-process is ready (shader is compiled)
  22878. */
  22879. isReady(): boolean;
  22880. /**
  22881. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22882. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22883. */
  22884. apply(): Nullable<Effect>;
  22885. private _disposeTextures;
  22886. /**
  22887. * Disposes the post process.
  22888. * @param camera The camera to dispose the post process on.
  22889. */
  22890. dispose(camera?: Camera): void;
  22891. /**
  22892. * Serializes the particle system to a JSON object
  22893. * @returns the JSON object
  22894. */
  22895. serialize(): any;
  22896. /**
  22897. * Creates a material from parsed material data
  22898. * @param parsedPostProcess defines parsed post process data
  22899. * @param scene defines the hosting scene
  22900. * @param rootUrl defines the root URL to use to load textures
  22901. * @returns a new post process
  22902. */
  22903. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22904. }
  22905. }
  22906. declare module BABYLON {
  22907. /** @hidden */
  22908. export var kernelBlurVaryingDeclaration: {
  22909. name: string;
  22910. shader: string;
  22911. };
  22912. }
  22913. declare module BABYLON {
  22914. /** @hidden */
  22915. export var kernelBlurFragment: {
  22916. name: string;
  22917. shader: string;
  22918. };
  22919. }
  22920. declare module BABYLON {
  22921. /** @hidden */
  22922. export var kernelBlurFragment2: {
  22923. name: string;
  22924. shader: string;
  22925. };
  22926. }
  22927. declare module BABYLON {
  22928. /** @hidden */
  22929. export var kernelBlurPixelShader: {
  22930. name: string;
  22931. shader: string;
  22932. };
  22933. }
  22934. declare module BABYLON {
  22935. /** @hidden */
  22936. export var kernelBlurVertex: {
  22937. name: string;
  22938. shader: string;
  22939. };
  22940. }
  22941. declare module BABYLON {
  22942. /** @hidden */
  22943. export var kernelBlurVertexShader: {
  22944. name: string;
  22945. shader: string;
  22946. };
  22947. }
  22948. declare module BABYLON {
  22949. /**
  22950. * The Blur Post Process which blurs an image based on a kernel and direction.
  22951. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22952. */
  22953. export class BlurPostProcess extends PostProcess {
  22954. private blockCompilation;
  22955. protected _kernel: number;
  22956. protected _idealKernel: number;
  22957. protected _packedFloat: boolean;
  22958. private _staticDefines;
  22959. /** The direction in which to blur the image. */
  22960. direction: Vector2;
  22961. /**
  22962. * Sets the length in pixels of the blur sample region
  22963. */
  22964. set kernel(v: number);
  22965. /**
  22966. * Gets the length in pixels of the blur sample region
  22967. */
  22968. get kernel(): number;
  22969. /**
  22970. * Sets wether or not the blur needs to unpack/repack floats
  22971. */
  22972. set packedFloat(v: boolean);
  22973. /**
  22974. * Gets wether or not the blur is unpacking/repacking floats
  22975. */
  22976. get packedFloat(): boolean;
  22977. /**
  22978. * Gets a string identifying the name of the class
  22979. * @returns "BlurPostProcess" string
  22980. */
  22981. getClassName(): string;
  22982. /**
  22983. * Creates a new instance BlurPostProcess
  22984. * @param name The name of the effect.
  22985. * @param direction The direction in which to blur the image.
  22986. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  22987. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22988. * @param camera The camera to apply the render pass to.
  22989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22990. * @param engine The engine which the post process will be applied. (default: current engine)
  22991. * @param reusable If the post process can be reused on the same frame. (default: false)
  22992. * @param textureType Type of textures used when performing the post process. (default: 0)
  22993. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  22994. */
  22995. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22996. /**
  22997. * Updates the effect with the current post process compile time values and recompiles the shader.
  22998. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22999. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23000. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23001. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  23002. * @param onCompiled Called when the shader has been compiled.
  23003. * @param onError Called if there is an error when compiling a shader.
  23004. */
  23005. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23006. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23007. /**
  23008. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23009. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23010. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23011. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23012. * The gaps between physical kernels are compensated for in the weighting of the samples
  23013. * @param idealKernel Ideal blur kernel.
  23014. * @return Nearest best kernel.
  23015. */
  23016. protected _nearestBestKernel(idealKernel: number): number;
  23017. /**
  23018. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23019. * @param x The point on the Gaussian distribution to sample.
  23020. * @return the value of the Gaussian function at x.
  23021. */
  23022. protected _gaussianWeight(x: number): number;
  23023. /**
  23024. * Generates a string that can be used as a floating point number in GLSL.
  23025. * @param x Value to print.
  23026. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23027. * @return GLSL float string.
  23028. */
  23029. protected _glslFloat(x: number, decimalFigures?: number): string;
  23030. /** @hidden */
  23031. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23032. }
  23033. }
  23034. declare module BABYLON {
  23035. /**
  23036. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23037. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23038. * You can then easily use it as a reflectionTexture on a flat surface.
  23039. * In case the surface is not a plane, please consider relying on reflection probes.
  23040. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23041. */
  23042. export class MirrorTexture extends RenderTargetTexture {
  23043. private scene;
  23044. /**
  23045. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23046. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  23047. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23048. */
  23049. mirrorPlane: Plane;
  23050. /**
  23051. * Define the blur ratio used to blur the reflection if needed.
  23052. */
  23053. set blurRatio(value: number);
  23054. get blurRatio(): number;
  23055. /**
  23056. * Define the adaptive blur kernel used to blur the reflection if needed.
  23057. * This will autocompute the closest best match for the `blurKernel`
  23058. */
  23059. set adaptiveBlurKernel(value: number);
  23060. /**
  23061. * Define the blur kernel used to blur the reflection if needed.
  23062. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23063. */
  23064. set blurKernel(value: number);
  23065. /**
  23066. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23067. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23068. */
  23069. set blurKernelX(value: number);
  23070. get blurKernelX(): number;
  23071. /**
  23072. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23073. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23074. */
  23075. set blurKernelY(value: number);
  23076. get blurKernelY(): number;
  23077. private _autoComputeBlurKernel;
  23078. protected _onRatioRescale(): void;
  23079. private _updateGammaSpace;
  23080. private _imageProcessingConfigChangeObserver;
  23081. private _transformMatrix;
  23082. private _mirrorMatrix;
  23083. private _savedViewMatrix;
  23084. private _blurX;
  23085. private _blurY;
  23086. private _adaptiveBlurKernel;
  23087. private _blurKernelX;
  23088. private _blurKernelY;
  23089. private _blurRatio;
  23090. /**
  23091. * Instantiates a Mirror Texture.
  23092. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23093. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23094. * You can then easily use it as a reflectionTexture on a flat surface.
  23095. * In case the surface is not a plane, please consider relying on reflection probes.
  23096. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23097. * @param name
  23098. * @param size
  23099. * @param scene
  23100. * @param generateMipMaps
  23101. * @param type
  23102. * @param samplingMode
  23103. * @param generateDepthBuffer
  23104. */
  23105. constructor(name: string, size: number | {
  23106. width: number;
  23107. height: number;
  23108. } | {
  23109. ratio: number;
  23110. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23111. private _preparePostProcesses;
  23112. /**
  23113. * Clone the mirror texture.
  23114. * @returns the cloned texture
  23115. */
  23116. clone(): MirrorTexture;
  23117. /**
  23118. * Serialize the texture to a JSON representation you could use in Parse later on
  23119. * @returns the serialized JSON representation
  23120. */
  23121. serialize(): any;
  23122. /**
  23123. * Dispose the texture and release its associated resources.
  23124. */
  23125. dispose(): void;
  23126. }
  23127. }
  23128. declare module BABYLON {
  23129. /**
  23130. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23131. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23132. */
  23133. export class Texture extends BaseTexture {
  23134. /**
  23135. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23136. */
  23137. static SerializeBuffers: boolean;
  23138. /** @hidden */
  23139. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23140. /** @hidden */
  23141. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23142. /** @hidden */
  23143. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23144. /** nearest is mag = nearest and min = nearest and mip = linear */
  23145. static readonly NEAREST_SAMPLINGMODE: number;
  23146. /** nearest is mag = nearest and min = nearest and mip = linear */
  23147. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23148. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23149. static readonly BILINEAR_SAMPLINGMODE: number;
  23150. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23151. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23152. /** Trilinear is mag = linear and min = linear and mip = linear */
  23153. static readonly TRILINEAR_SAMPLINGMODE: number;
  23154. /** Trilinear is mag = linear and min = linear and mip = linear */
  23155. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23156. /** mag = nearest and min = nearest and mip = nearest */
  23157. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23158. /** mag = nearest and min = linear and mip = nearest */
  23159. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23160. /** mag = nearest and min = linear and mip = linear */
  23161. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23162. /** mag = nearest and min = linear and mip = none */
  23163. static readonly NEAREST_LINEAR: number;
  23164. /** mag = nearest and min = nearest and mip = none */
  23165. static readonly NEAREST_NEAREST: number;
  23166. /** mag = linear and min = nearest and mip = nearest */
  23167. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23168. /** mag = linear and min = nearest and mip = linear */
  23169. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23170. /** mag = linear and min = linear and mip = none */
  23171. static readonly LINEAR_LINEAR: number;
  23172. /** mag = linear and min = nearest and mip = none */
  23173. static readonly LINEAR_NEAREST: number;
  23174. /** Explicit coordinates mode */
  23175. static readonly EXPLICIT_MODE: number;
  23176. /** Spherical coordinates mode */
  23177. static readonly SPHERICAL_MODE: number;
  23178. /** Planar coordinates mode */
  23179. static readonly PLANAR_MODE: number;
  23180. /** Cubic coordinates mode */
  23181. static readonly CUBIC_MODE: number;
  23182. /** Projection coordinates mode */
  23183. static readonly PROJECTION_MODE: number;
  23184. /** Inverse Cubic coordinates mode */
  23185. static readonly SKYBOX_MODE: number;
  23186. /** Inverse Cubic coordinates mode */
  23187. static readonly INVCUBIC_MODE: number;
  23188. /** Equirectangular coordinates mode */
  23189. static readonly EQUIRECTANGULAR_MODE: number;
  23190. /** Equirectangular Fixed coordinates mode */
  23191. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23192. /** Equirectangular Fixed Mirrored coordinates mode */
  23193. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23194. /** Texture is not repeating outside of 0..1 UVs */
  23195. static readonly CLAMP_ADDRESSMODE: number;
  23196. /** Texture is repeating outside of 0..1 UVs */
  23197. static readonly WRAP_ADDRESSMODE: number;
  23198. /** Texture is repeating and mirrored */
  23199. static readonly MIRROR_ADDRESSMODE: number;
  23200. /**
  23201. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  23202. */
  23203. static UseSerializedUrlIfAny: boolean;
  23204. /**
  23205. * Define the url of the texture.
  23206. */
  23207. url: Nullable<string>;
  23208. /**
  23209. * Define an offset on the texture to offset the u coordinates of the UVs
  23210. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23211. */
  23212. uOffset: number;
  23213. /**
  23214. * Define an offset on the texture to offset the v coordinates of the UVs
  23215. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23216. */
  23217. vOffset: number;
  23218. /**
  23219. * Define an offset on the texture to scale the u coordinates of the UVs
  23220. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23221. */
  23222. uScale: number;
  23223. /**
  23224. * Define an offset on the texture to scale the v coordinates of the UVs
  23225. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23226. */
  23227. vScale: number;
  23228. /**
  23229. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23230. * @see https://doc.babylonjs.com/how_to/more_materials
  23231. */
  23232. uAng: number;
  23233. /**
  23234. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23235. * @see https://doc.babylonjs.com/how_to/more_materials
  23236. */
  23237. vAng: number;
  23238. /**
  23239. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23240. * @see https://doc.babylonjs.com/how_to/more_materials
  23241. */
  23242. wAng: number;
  23243. /**
  23244. * Defines the center of rotation (U)
  23245. */
  23246. uRotationCenter: number;
  23247. /**
  23248. * Defines the center of rotation (V)
  23249. */
  23250. vRotationCenter: number;
  23251. /**
  23252. * Defines the center of rotation (W)
  23253. */
  23254. wRotationCenter: number;
  23255. /**
  23256. * Are mip maps generated for this texture or not.
  23257. */
  23258. get noMipmap(): boolean;
  23259. /**
  23260. * List of inspectable custom properties (used by the Inspector)
  23261. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23262. */
  23263. inspectableCustomProperties: Nullable<IInspectable[]>;
  23264. private _noMipmap;
  23265. /** @hidden */
  23266. _invertY: boolean;
  23267. private _rowGenerationMatrix;
  23268. private _cachedTextureMatrix;
  23269. private _projectionModeMatrix;
  23270. private _t0;
  23271. private _t1;
  23272. private _t2;
  23273. private _cachedUOffset;
  23274. private _cachedVOffset;
  23275. private _cachedUScale;
  23276. private _cachedVScale;
  23277. private _cachedUAng;
  23278. private _cachedVAng;
  23279. private _cachedWAng;
  23280. private _cachedProjectionMatrixId;
  23281. private _cachedCoordinatesMode;
  23282. /** @hidden */
  23283. protected _initialSamplingMode: number;
  23284. /** @hidden */
  23285. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23286. private _deleteBuffer;
  23287. protected _format: Nullable<number>;
  23288. private _delayedOnLoad;
  23289. private _delayedOnError;
  23290. private _mimeType?;
  23291. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23292. get mimeType(): string | undefined;
  23293. /**
  23294. * Observable triggered once the texture has been loaded.
  23295. */
  23296. onLoadObservable: Observable<Texture>;
  23297. protected _isBlocking: boolean;
  23298. /**
  23299. * Is the texture preventing material to render while loading.
  23300. * If false, a default texture will be used instead of the loading one during the preparation step.
  23301. */
  23302. set isBlocking(value: boolean);
  23303. get isBlocking(): boolean;
  23304. /**
  23305. * Get the current sampling mode associated with the texture.
  23306. */
  23307. get samplingMode(): number;
  23308. /**
  23309. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23310. */
  23311. get invertY(): boolean;
  23312. /**
  23313. * Instantiates a new texture.
  23314. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23315. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23316. * @param url defines the url of the picture to load as a texture
  23317. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23318. * @param noMipmap defines if the texture will require mip maps or not
  23319. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23320. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23321. * @param onLoad defines a callback triggered when the texture has been loaded
  23322. * @param onError defines a callback triggered when an error occurred during the loading session
  23323. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23324. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23325. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23326. * @param mimeType defines an optional mime type information
  23327. */
  23328. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  23329. /**
  23330. * Update the url (and optional buffer) of this texture if url was null during construction.
  23331. * @param url the url of the texture
  23332. * @param buffer the buffer of the texture (defaults to null)
  23333. * @param onLoad callback called when the texture is loaded (defaults to null)
  23334. */
  23335. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23336. /**
  23337. * Finish the loading sequence of a texture flagged as delayed load.
  23338. * @hidden
  23339. */
  23340. delayLoad(): void;
  23341. private _prepareRowForTextureGeneration;
  23342. /**
  23343. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23344. * @returns the transform matrix of the texture.
  23345. */
  23346. getTextureMatrix(uBase?: number): Matrix;
  23347. /**
  23348. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23349. * @returns The reflection texture transform
  23350. */
  23351. getReflectionTextureMatrix(): Matrix;
  23352. /**
  23353. * Clones the texture.
  23354. * @returns the cloned texture
  23355. */
  23356. clone(): Texture;
  23357. /**
  23358. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23359. * @returns The JSON representation of the texture
  23360. */
  23361. serialize(): any;
  23362. /**
  23363. * Get the current class name of the texture useful for serialization or dynamic coding.
  23364. * @returns "Texture"
  23365. */
  23366. getClassName(): string;
  23367. /**
  23368. * Dispose the texture and release its associated resources.
  23369. */
  23370. dispose(): void;
  23371. /**
  23372. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23373. * @param parsedTexture Define the JSON representation of the texture
  23374. * @param scene Define the scene the parsed texture should be instantiated in
  23375. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23376. * @returns The parsed texture if successful
  23377. */
  23378. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23379. /**
  23380. * Creates a texture from its base 64 representation.
  23381. * @param data Define the base64 payload without the data: prefix
  23382. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23383. * @param scene Define the scene the texture should belong to
  23384. * @param noMipmap Forces the texture to not create mip map information if true
  23385. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23386. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23387. * @param onLoad define a callback triggered when the texture has been loaded
  23388. * @param onError define a callback triggered when an error occurred during the loading session
  23389. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23390. * @returns the created texture
  23391. */
  23392. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23393. /**
  23394. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23395. * @param data Define the base64 payload without the data: prefix
  23396. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23397. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23398. * @param scene Define the scene the texture should belong to
  23399. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23400. * @param noMipmap Forces the texture to not create mip map information if true
  23401. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23402. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23403. * @param onLoad define a callback triggered when the texture has been loaded
  23404. * @param onError define a callback triggered when an error occurred during the loading session
  23405. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23406. * @returns the created texture
  23407. */
  23408. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  23409. }
  23410. }
  23411. declare module BABYLON {
  23412. /**
  23413. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23414. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23415. */
  23416. export class PostProcessManager {
  23417. private _scene;
  23418. private _indexBuffer;
  23419. private _vertexBuffers;
  23420. /**
  23421. * Creates a new instance PostProcess
  23422. * @param scene The scene that the post process is associated with.
  23423. */
  23424. constructor(scene: Scene);
  23425. private _prepareBuffers;
  23426. private _buildIndexBuffer;
  23427. /**
  23428. * Rebuilds the vertex buffers of the manager.
  23429. * @hidden
  23430. */
  23431. _rebuild(): void;
  23432. /**
  23433. * Prepares a frame to be run through a post process.
  23434. * @param sourceTexture The input texture to the post procesess. (default: null)
  23435. * @param postProcesses An array of post processes to be run. (default: null)
  23436. * @returns True if the post processes were able to be run.
  23437. * @hidden
  23438. */
  23439. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23440. /**
  23441. * Manually render a set of post processes to a texture.
  23442. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23443. * @param postProcesses An array of post processes to be run.
  23444. * @param targetTexture The target texture to render to.
  23445. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23446. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23447. * @param lodLevel defines which lod of the texture to render to
  23448. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23449. */
  23450. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23451. /**
  23452. * Finalize the result of the output of the postprocesses.
  23453. * @param doNotPresent If true the result will not be displayed to the screen.
  23454. * @param targetTexture The target texture to render to.
  23455. * @param faceIndex The index of the face to bind the target texture to.
  23456. * @param postProcesses The array of post processes to render.
  23457. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23458. * @hidden
  23459. */
  23460. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23461. /**
  23462. * Disposes of the post process manager.
  23463. */
  23464. dispose(): void;
  23465. }
  23466. }
  23467. declare module BABYLON {
  23468. /**
  23469. * This Helps creating a texture that will be created from a camera in your scene.
  23470. * It is basically a dynamic texture that could be used to create special effects for instance.
  23471. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23472. */
  23473. export class RenderTargetTexture extends Texture {
  23474. /**
  23475. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23476. */
  23477. static readonly REFRESHRATE_RENDER_ONCE: number;
  23478. /**
  23479. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23480. */
  23481. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23482. /**
  23483. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23484. * the central point of your effect and can save a lot of performances.
  23485. */
  23486. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23487. /**
  23488. * Use this predicate to dynamically define the list of mesh you want to render.
  23489. * If set, the renderList property will be overwritten.
  23490. */
  23491. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23492. private _renderList;
  23493. /**
  23494. * Use this list to define the list of mesh you want to render.
  23495. */
  23496. get renderList(): Nullable<Array<AbstractMesh>>;
  23497. set renderList(value: Nullable<Array<AbstractMesh>>);
  23498. /**
  23499. * Use this function to overload the renderList array at rendering time.
  23500. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23501. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23502. * the cube (if the RTT is a cube, else layerOrFace=0).
  23503. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23504. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23505. * hold dummy elements!
  23506. */
  23507. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23508. private _hookArray;
  23509. /**
  23510. * Define if particles should be rendered in your texture.
  23511. */
  23512. renderParticles: boolean;
  23513. /**
  23514. * Define if sprites should be rendered in your texture.
  23515. */
  23516. renderSprites: boolean;
  23517. /**
  23518. * Define the camera used to render the texture.
  23519. */
  23520. activeCamera: Nullable<Camera>;
  23521. /**
  23522. * Override the mesh isReady function with your own one.
  23523. */
  23524. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23525. /**
  23526. * Override the render function of the texture with your own one.
  23527. */
  23528. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23529. /**
  23530. * Define if camera post processes should be use while rendering the texture.
  23531. */
  23532. useCameraPostProcesses: boolean;
  23533. /**
  23534. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23535. */
  23536. ignoreCameraViewport: boolean;
  23537. private _postProcessManager;
  23538. private _postProcesses;
  23539. private _resizeObserver;
  23540. /**
  23541. * An event triggered when the texture is unbind.
  23542. */
  23543. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23544. /**
  23545. * An event triggered when the texture is unbind.
  23546. */
  23547. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23548. private _onAfterUnbindObserver;
  23549. /**
  23550. * Set a after unbind callback in the texture.
  23551. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23552. */
  23553. set onAfterUnbind(callback: () => void);
  23554. /**
  23555. * An event triggered before rendering the texture
  23556. */
  23557. onBeforeRenderObservable: Observable<number>;
  23558. private _onBeforeRenderObserver;
  23559. /**
  23560. * Set a before render callback in the texture.
  23561. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23562. */
  23563. set onBeforeRender(callback: (faceIndex: number) => void);
  23564. /**
  23565. * An event triggered after rendering the texture
  23566. */
  23567. onAfterRenderObservable: Observable<number>;
  23568. private _onAfterRenderObserver;
  23569. /**
  23570. * Set a after render callback in the texture.
  23571. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23572. */
  23573. set onAfterRender(callback: (faceIndex: number) => void);
  23574. /**
  23575. * An event triggered after the texture clear
  23576. */
  23577. onClearObservable: Observable<Engine>;
  23578. private _onClearObserver;
  23579. /**
  23580. * Set a clear callback in the texture.
  23581. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23582. */
  23583. set onClear(callback: (Engine: Engine) => void);
  23584. /**
  23585. * An event triggered when the texture is resized.
  23586. */
  23587. onResizeObservable: Observable<RenderTargetTexture>;
  23588. /**
  23589. * Define the clear color of the Render Target if it should be different from the scene.
  23590. */
  23591. clearColor: Color4;
  23592. protected _size: number | {
  23593. width: number;
  23594. height: number;
  23595. layers?: number;
  23596. };
  23597. protected _initialSizeParameter: number | {
  23598. width: number;
  23599. height: number;
  23600. } | {
  23601. ratio: number;
  23602. };
  23603. protected _sizeRatio: Nullable<number>;
  23604. /** @hidden */
  23605. _generateMipMaps: boolean;
  23606. protected _renderingManager: RenderingManager;
  23607. /** @hidden */
  23608. _waitingRenderList?: string[];
  23609. protected _doNotChangeAspectRatio: boolean;
  23610. protected _currentRefreshId: number;
  23611. protected _refreshRate: number;
  23612. protected _textureMatrix: Matrix;
  23613. protected _samples: number;
  23614. protected _renderTargetOptions: RenderTargetCreationOptions;
  23615. /**
  23616. * Gets render target creation options that were used.
  23617. */
  23618. get renderTargetOptions(): RenderTargetCreationOptions;
  23619. protected _onRatioRescale(): void;
  23620. /**
  23621. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23622. * It must define where the camera used to render the texture is set
  23623. */
  23624. boundingBoxPosition: Vector3;
  23625. private _boundingBoxSize;
  23626. /**
  23627. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23628. * When defined, the cubemap will switch to local mode
  23629. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23630. * @example https://www.babylonjs-playground.com/#RNASML
  23631. */
  23632. set boundingBoxSize(value: Vector3);
  23633. get boundingBoxSize(): Vector3;
  23634. /**
  23635. * In case the RTT has been created with a depth texture, get the associated
  23636. * depth texture.
  23637. * Otherwise, return null.
  23638. */
  23639. get depthStencilTexture(): Nullable<InternalTexture>;
  23640. /**
  23641. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23642. * or used a shadow, depth texture...
  23643. * @param name The friendly name of the texture
  23644. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  23645. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23646. * @param generateMipMaps True if mip maps need to be generated after render.
  23647. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23648. * @param type The type of the buffer in the RTT (int, half float, float...)
  23649. * @param isCube True if a cube texture needs to be created
  23650. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23651. * @param generateDepthBuffer True to generate a depth buffer
  23652. * @param generateStencilBuffer True to generate a stencil buffer
  23653. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23654. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23655. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23656. */
  23657. constructor(name: string, size: number | {
  23658. width: number;
  23659. height: number;
  23660. layers?: number;
  23661. } | {
  23662. ratio: number;
  23663. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23664. /**
  23665. * Creates a depth stencil texture.
  23666. * This is only available in WebGL 2 or with the depth texture extension available.
  23667. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23668. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23669. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23670. */
  23671. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23672. private _processSizeParameter;
  23673. /**
  23674. * Define the number of samples to use in case of MSAA.
  23675. * It defaults to one meaning no MSAA has been enabled.
  23676. */
  23677. get samples(): number;
  23678. set samples(value: number);
  23679. /**
  23680. * Resets the refresh counter of the texture and start bak from scratch.
  23681. * Could be useful to regenerate the texture if it is setup to render only once.
  23682. */
  23683. resetRefreshCounter(): void;
  23684. /**
  23685. * Define the refresh rate of the texture or the rendering frequency.
  23686. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23687. */
  23688. get refreshRate(): number;
  23689. set refreshRate(value: number);
  23690. /**
  23691. * Adds a post process to the render target rendering passes.
  23692. * @param postProcess define the post process to add
  23693. */
  23694. addPostProcess(postProcess: PostProcess): void;
  23695. /**
  23696. * Clear all the post processes attached to the render target
  23697. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23698. */
  23699. clearPostProcesses(dispose?: boolean): void;
  23700. /**
  23701. * Remove one of the post process from the list of attached post processes to the texture
  23702. * @param postProcess define the post process to remove from the list
  23703. */
  23704. removePostProcess(postProcess: PostProcess): void;
  23705. /** @hidden */
  23706. _shouldRender(): boolean;
  23707. /**
  23708. * Gets the actual render size of the texture.
  23709. * @returns the width of the render size
  23710. */
  23711. getRenderSize(): number;
  23712. /**
  23713. * Gets the actual render width of the texture.
  23714. * @returns the width of the render size
  23715. */
  23716. getRenderWidth(): number;
  23717. /**
  23718. * Gets the actual render height of the texture.
  23719. * @returns the height of the render size
  23720. */
  23721. getRenderHeight(): number;
  23722. /**
  23723. * Gets the actual number of layers of the texture.
  23724. * @returns the number of layers
  23725. */
  23726. getRenderLayers(): number;
  23727. /**
  23728. * Get if the texture can be rescaled or not.
  23729. */
  23730. get canRescale(): boolean;
  23731. /**
  23732. * Resize the texture using a ratio.
  23733. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23734. */
  23735. scale(ratio: number): void;
  23736. /**
  23737. * Get the texture reflection matrix used to rotate/transform the reflection.
  23738. * @returns the reflection matrix
  23739. */
  23740. getReflectionTextureMatrix(): Matrix;
  23741. /**
  23742. * Resize the texture to a new desired size.
  23743. * Be carrefull as it will recreate all the data in the new texture.
  23744. * @param size Define the new size. It can be:
  23745. * - a number for squared texture,
  23746. * - an object containing { width: number, height: number }
  23747. * - or an object containing a ratio { ratio: number }
  23748. */
  23749. resize(size: number | {
  23750. width: number;
  23751. height: number;
  23752. } | {
  23753. ratio: number;
  23754. }): void;
  23755. private _defaultRenderListPrepared;
  23756. /**
  23757. * Renders all the objects from the render list into the texture.
  23758. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23759. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23760. */
  23761. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23762. private _bestReflectionRenderTargetDimension;
  23763. private _prepareRenderingManager;
  23764. /**
  23765. * @hidden
  23766. * @param faceIndex face index to bind to if this is a cubetexture
  23767. * @param layer defines the index of the texture to bind in the array
  23768. */
  23769. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23770. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23771. private renderToTarget;
  23772. /**
  23773. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23774. * This allowed control for front to back rendering or reversly depending of the special needs.
  23775. *
  23776. * @param renderingGroupId The rendering group id corresponding to its index
  23777. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23778. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23779. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23780. */
  23781. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  23782. /**
  23783. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23784. *
  23785. * @param renderingGroupId The rendering group id corresponding to its index
  23786. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23787. */
  23788. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23789. /**
  23790. * Clones the texture.
  23791. * @returns the cloned texture
  23792. */
  23793. clone(): RenderTargetTexture;
  23794. /**
  23795. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23796. * @returns The JSON representation of the texture
  23797. */
  23798. serialize(): any;
  23799. /**
  23800. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23801. */
  23802. disposeFramebufferObjects(): void;
  23803. /**
  23804. * Dispose the texture and release its associated resources.
  23805. */
  23806. dispose(): void;
  23807. /** @hidden */
  23808. _rebuild(): void;
  23809. /**
  23810. * Clear the info related to rendering groups preventing retention point in material dispose.
  23811. */
  23812. freeRenderingGroups(): void;
  23813. /**
  23814. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23815. * @returns the view count
  23816. */
  23817. getViewCount(): number;
  23818. }
  23819. }
  23820. declare module BABYLON {
  23821. /**
  23822. * Class used to manipulate GUIDs
  23823. */
  23824. export class GUID {
  23825. /**
  23826. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23827. * Be aware Math.random() could cause collisions, but:
  23828. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  23829. * @returns a pseudo random id
  23830. */
  23831. static RandomId(): string;
  23832. }
  23833. }
  23834. declare module BABYLON {
  23835. /**
  23836. * Options to be used when creating a shadow depth material
  23837. */
  23838. export interface IIOptionShadowDepthMaterial {
  23839. /** Variables in the vertex shader code that need to have their names remapped.
  23840. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23841. * "var_name" should be either: worldPos or vNormalW
  23842. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23843. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23844. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23845. */
  23846. remappedVariables?: string[];
  23847. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23848. standalone?: boolean;
  23849. }
  23850. /**
  23851. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23852. */
  23853. export class ShadowDepthWrapper {
  23854. private _scene;
  23855. private _options?;
  23856. private _baseMaterial;
  23857. private _onEffectCreatedObserver;
  23858. private _subMeshToEffect;
  23859. private _subMeshToDepthEffect;
  23860. private _meshes;
  23861. /** @hidden */
  23862. _matriceNames: any;
  23863. /** Gets the standalone status of the wrapper */
  23864. get standalone(): boolean;
  23865. /** Gets the base material the wrapper is built upon */
  23866. get baseMaterial(): Material;
  23867. /**
  23868. * Instantiate a new shadow depth wrapper.
  23869. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23870. * generate the shadow depth map. For more information, please refer to the documentation:
  23871. * https://doc.babylonjs.com/babylon101/shadows
  23872. * @param baseMaterial Material to wrap
  23873. * @param scene Define the scene the material belongs to
  23874. * @param options Options used to create the wrapper
  23875. */
  23876. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23877. /**
  23878. * Gets the effect to use to generate the depth map
  23879. * @param subMesh subMesh to get the effect for
  23880. * @param shadowGenerator shadow generator to get the effect for
  23881. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23882. */
  23883. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23884. /**
  23885. * Specifies that the submesh is ready to be used for depth rendering
  23886. * @param subMesh submesh to check
  23887. * @param defines the list of defines to take into account when checking the effect
  23888. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23889. * @param useInstances specifies that instances should be used
  23890. * @returns a boolean indicating that the submesh is ready or not
  23891. */
  23892. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23893. /**
  23894. * Disposes the resources
  23895. */
  23896. dispose(): void;
  23897. private _makeEffect;
  23898. }
  23899. }
  23900. declare module BABYLON {
  23901. interface ThinEngine {
  23902. /**
  23903. * Unbind a list of render target textures from the webGL context
  23904. * This is used only when drawBuffer extension or webGL2 are active
  23905. * @param textures defines the render target textures to unbind
  23906. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23907. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23908. */
  23909. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23910. /**
  23911. * Create a multi render target texture
  23912. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23913. * @param size defines the size of the texture
  23914. * @param options defines the creation options
  23915. * @returns the cube texture as an InternalTexture
  23916. */
  23917. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23918. /**
  23919. * Update the sample count for a given multiple render target texture
  23920. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23921. * @param textures defines the textures to update
  23922. * @param samples defines the sample count to set
  23923. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23924. */
  23925. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23926. /**
  23927. * Select a subsets of attachments to draw to.
  23928. * @param attachments gl attachments
  23929. */
  23930. bindAttachments(attachments: number[]): void;
  23931. }
  23932. }
  23933. declare module BABYLON {
  23934. /**
  23935. * Creation options of the multi render target texture.
  23936. */
  23937. export interface IMultiRenderTargetOptions {
  23938. /**
  23939. * Define if the texture needs to create mip maps after render.
  23940. */
  23941. generateMipMaps?: boolean;
  23942. /**
  23943. * Define the types of all the draw buffers we want to create
  23944. */
  23945. types?: number[];
  23946. /**
  23947. * Define the sampling modes of all the draw buffers we want to create
  23948. */
  23949. samplingModes?: number[];
  23950. /**
  23951. * Define if a depth buffer is required
  23952. */
  23953. generateDepthBuffer?: boolean;
  23954. /**
  23955. * Define if a stencil buffer is required
  23956. */
  23957. generateStencilBuffer?: boolean;
  23958. /**
  23959. * Define if a depth texture is required instead of a depth buffer
  23960. */
  23961. generateDepthTexture?: boolean;
  23962. /**
  23963. * Define the number of desired draw buffers
  23964. */
  23965. textureCount?: number;
  23966. /**
  23967. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23968. */
  23969. doNotChangeAspectRatio?: boolean;
  23970. /**
  23971. * Define the default type of the buffers we are creating
  23972. */
  23973. defaultType?: number;
  23974. }
  23975. /**
  23976. * A multi render target, like a render target provides the ability to render to a texture.
  23977. * Unlike the render target, it can render to several draw buffers in one draw.
  23978. * This is specially interesting in deferred rendering or for any effects requiring more than
  23979. * just one color from a single pass.
  23980. */
  23981. export class MultiRenderTarget extends RenderTargetTexture {
  23982. private _internalTextures;
  23983. private _textures;
  23984. private _multiRenderTargetOptions;
  23985. private _count;
  23986. /**
  23987. * Get if draw buffers are currently supported by the used hardware and browser.
  23988. */
  23989. get isSupported(): boolean;
  23990. /**
  23991. * Get the list of textures generated by the multi render target.
  23992. */
  23993. get textures(): Texture[];
  23994. /**
  23995. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23996. */
  23997. get count(): number;
  23998. /**
  23999. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24000. */
  24001. get depthTexture(): Texture;
  24002. /**
  24003. * Set the wrapping mode on U of all the textures we are rendering to.
  24004. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24005. */
  24006. set wrapU(wrap: number);
  24007. /**
  24008. * Set the wrapping mode on V of all the textures we are rendering to.
  24009. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24010. */
  24011. set wrapV(wrap: number);
  24012. /**
  24013. * Instantiate a new multi render target texture.
  24014. * A multi render target, like a render target provides the ability to render to a texture.
  24015. * Unlike the render target, it can render to several draw buffers in one draw.
  24016. * This is specially interesting in deferred rendering or for any effects requiring more than
  24017. * just one color from a single pass.
  24018. * @param name Define the name of the texture
  24019. * @param size Define the size of the buffers to render to
  24020. * @param count Define the number of target we are rendering into
  24021. * @param scene Define the scene the texture belongs to
  24022. * @param options Define the options used to create the multi render target
  24023. */
  24024. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24025. /** @hidden */
  24026. _rebuild(): void;
  24027. private _createInternalTextures;
  24028. private _createTextures;
  24029. /**
  24030. * Define the number of samples used if MSAA is enabled.
  24031. */
  24032. get samples(): number;
  24033. set samples(value: number);
  24034. /**
  24035. * Resize all the textures in the multi render target.
  24036. * Be carrefull as it will recreate all the data in the new texture.
  24037. * @param size Define the new size
  24038. */
  24039. resize(size: any): void;
  24040. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24041. /**
  24042. * Dispose the render targets and their associated resources
  24043. */
  24044. dispose(): void;
  24045. /**
  24046. * Release all the underlying texture used as draw buffers.
  24047. */
  24048. releaseInternalTextures(): void;
  24049. }
  24050. }
  24051. declare module BABYLON {
  24052. /** @hidden */
  24053. export var imageProcessingPixelShader: {
  24054. name: string;
  24055. shader: string;
  24056. };
  24057. }
  24058. declare module BABYLON {
  24059. /**
  24060. * ImageProcessingPostProcess
  24061. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24062. */
  24063. export class ImageProcessingPostProcess extends PostProcess {
  24064. /**
  24065. * Default configuration related to image processing available in the PBR Material.
  24066. */
  24067. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24068. /**
  24069. * Gets the image processing configuration used either in this material.
  24070. */
  24071. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24072. /**
  24073. * Sets the Default image processing configuration used either in the this material.
  24074. *
  24075. * If sets to null, the scene one is in use.
  24076. */
  24077. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24078. /**
  24079. * Keep track of the image processing observer to allow dispose and replace.
  24080. */
  24081. private _imageProcessingObserver;
  24082. /**
  24083. * Attaches a new image processing configuration to the PBR Material.
  24084. * @param configuration
  24085. */
  24086. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24087. /**
  24088. * If the post process is supported.
  24089. */
  24090. get isSupported(): boolean;
  24091. /**
  24092. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24093. */
  24094. get colorCurves(): Nullable<ColorCurves>;
  24095. /**
  24096. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24097. */
  24098. set colorCurves(value: Nullable<ColorCurves>);
  24099. /**
  24100. * Gets wether the color curves effect is enabled.
  24101. */
  24102. get colorCurvesEnabled(): boolean;
  24103. /**
  24104. * Sets wether the color curves effect is enabled.
  24105. */
  24106. set colorCurvesEnabled(value: boolean);
  24107. /**
  24108. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24109. */
  24110. get colorGradingTexture(): Nullable<BaseTexture>;
  24111. /**
  24112. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24113. */
  24114. set colorGradingTexture(value: Nullable<BaseTexture>);
  24115. /**
  24116. * Gets wether the color grading effect is enabled.
  24117. */
  24118. get colorGradingEnabled(): boolean;
  24119. /**
  24120. * Gets wether the color grading effect is enabled.
  24121. */
  24122. set colorGradingEnabled(value: boolean);
  24123. /**
  24124. * Gets exposure used in the effect.
  24125. */
  24126. get exposure(): number;
  24127. /**
  24128. * Sets exposure used in the effect.
  24129. */
  24130. set exposure(value: number);
  24131. /**
  24132. * Gets wether tonemapping is enabled or not.
  24133. */
  24134. get toneMappingEnabled(): boolean;
  24135. /**
  24136. * Sets wether tonemapping is enabled or not
  24137. */
  24138. set toneMappingEnabled(value: boolean);
  24139. /**
  24140. * Gets the type of tone mapping effect.
  24141. */
  24142. get toneMappingType(): number;
  24143. /**
  24144. * Sets the type of tone mapping effect.
  24145. */
  24146. set toneMappingType(value: number);
  24147. /**
  24148. * Gets contrast used in the effect.
  24149. */
  24150. get contrast(): number;
  24151. /**
  24152. * Sets contrast used in the effect.
  24153. */
  24154. set contrast(value: number);
  24155. /**
  24156. * Gets Vignette stretch size.
  24157. */
  24158. get vignetteStretch(): number;
  24159. /**
  24160. * Sets Vignette stretch size.
  24161. */
  24162. set vignetteStretch(value: number);
  24163. /**
  24164. * Gets Vignette centre X Offset.
  24165. */
  24166. get vignetteCentreX(): number;
  24167. /**
  24168. * Sets Vignette centre X Offset.
  24169. */
  24170. set vignetteCentreX(value: number);
  24171. /**
  24172. * Gets Vignette centre Y Offset.
  24173. */
  24174. get vignetteCentreY(): number;
  24175. /**
  24176. * Sets Vignette centre Y Offset.
  24177. */
  24178. set vignetteCentreY(value: number);
  24179. /**
  24180. * Gets Vignette weight or intensity of the vignette effect.
  24181. */
  24182. get vignetteWeight(): number;
  24183. /**
  24184. * Sets Vignette weight or intensity of the vignette effect.
  24185. */
  24186. set vignetteWeight(value: number);
  24187. /**
  24188. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24189. * if vignetteEnabled is set to true.
  24190. */
  24191. get vignetteColor(): Color4;
  24192. /**
  24193. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24194. * if vignetteEnabled is set to true.
  24195. */
  24196. set vignetteColor(value: Color4);
  24197. /**
  24198. * Gets Camera field of view used by the Vignette effect.
  24199. */
  24200. get vignetteCameraFov(): number;
  24201. /**
  24202. * Sets Camera field of view used by the Vignette effect.
  24203. */
  24204. set vignetteCameraFov(value: number);
  24205. /**
  24206. * Gets the vignette blend mode allowing different kind of effect.
  24207. */
  24208. get vignetteBlendMode(): number;
  24209. /**
  24210. * Sets the vignette blend mode allowing different kind of effect.
  24211. */
  24212. set vignetteBlendMode(value: number);
  24213. /**
  24214. * Gets wether the vignette effect is enabled.
  24215. */
  24216. get vignetteEnabled(): boolean;
  24217. /**
  24218. * Sets wether the vignette effect is enabled.
  24219. */
  24220. set vignetteEnabled(value: boolean);
  24221. private _fromLinearSpace;
  24222. /**
  24223. * Gets wether the input of the processing is in Gamma or Linear Space.
  24224. */
  24225. get fromLinearSpace(): boolean;
  24226. /**
  24227. * Sets wether the input of the processing is in Gamma or Linear Space.
  24228. */
  24229. set fromLinearSpace(value: boolean);
  24230. /**
  24231. * Defines cache preventing GC.
  24232. */
  24233. private _defines;
  24234. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24235. /**
  24236. * "ImageProcessingPostProcess"
  24237. * @returns "ImageProcessingPostProcess"
  24238. */
  24239. getClassName(): string;
  24240. /**
  24241. * @hidden
  24242. */
  24243. _updateParameters(): void;
  24244. dispose(camera?: Camera): void;
  24245. }
  24246. }
  24247. declare module BABYLON {
  24248. /** @hidden */
  24249. export var fibonacci: {
  24250. name: string;
  24251. shader: string;
  24252. };
  24253. }
  24254. declare module BABYLON {
  24255. /** @hidden */
  24256. export var subSurfaceScatteringFunctions: {
  24257. name: string;
  24258. shader: string;
  24259. };
  24260. }
  24261. declare module BABYLON {
  24262. /** @hidden */
  24263. export var diffusionProfile: {
  24264. name: string;
  24265. shader: string;
  24266. };
  24267. }
  24268. declare module BABYLON {
  24269. /** @hidden */
  24270. export var subSurfaceScatteringPixelShader: {
  24271. name: string;
  24272. shader: string;
  24273. };
  24274. }
  24275. declare module BABYLON {
  24276. /**
  24277. * Sub surface scattering post process
  24278. */
  24279. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24280. /**
  24281. * Gets a string identifying the name of the class
  24282. * @returns "SubSurfaceScatteringPostProcess" string
  24283. */
  24284. getClassName(): string;
  24285. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24286. }
  24287. }
  24288. declare module BABYLON {
  24289. /**
  24290. * Interface for defining prepass effects in the prepass post-process pipeline
  24291. */
  24292. export interface PrePassEffectConfiguration {
  24293. /**
  24294. * Post process to attach for this effect
  24295. */
  24296. postProcess: PostProcess;
  24297. /**
  24298. * Is the effect enabled
  24299. */
  24300. enabled: boolean;
  24301. /**
  24302. * Disposes the effect configuration
  24303. */
  24304. dispose(): void;
  24305. /**
  24306. * Disposes the effect configuration
  24307. */
  24308. createPostProcess: () => PostProcess;
  24309. }
  24310. }
  24311. declare module BABYLON {
  24312. /**
  24313. * Contains all parameters needed for the prepass to perform
  24314. * screen space subsurface scattering
  24315. */
  24316. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24317. private _ssDiffusionS;
  24318. private _ssFilterRadii;
  24319. private _ssDiffusionD;
  24320. /**
  24321. * Post process to attach for screen space subsurface scattering
  24322. */
  24323. postProcess: SubSurfaceScatteringPostProcess;
  24324. /**
  24325. * Diffusion profile color for subsurface scattering
  24326. */
  24327. get ssDiffusionS(): number[];
  24328. /**
  24329. * Diffusion profile max color channel value for subsurface scattering
  24330. */
  24331. get ssDiffusionD(): number[];
  24332. /**
  24333. * Diffusion profile filter radius for subsurface scattering
  24334. */
  24335. get ssFilterRadii(): number[];
  24336. /**
  24337. * Is subsurface enabled
  24338. */
  24339. enabled: boolean;
  24340. /**
  24341. * Diffusion profile colors for subsurface scattering
  24342. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24343. * See ...
  24344. * Note that you can only store up to 5 of them
  24345. */
  24346. ssDiffusionProfileColors: Color3[];
  24347. /**
  24348. * Defines the ratio real world => scene units.
  24349. * Used for subsurface scattering
  24350. */
  24351. metersPerUnit: number;
  24352. private _scene;
  24353. /**
  24354. * Builds a subsurface configuration object
  24355. * @param scene The scene
  24356. */
  24357. constructor(scene: Scene);
  24358. /**
  24359. * Adds a new diffusion profile.
  24360. * Useful for more realistic subsurface scattering on diverse materials.
  24361. * @param color The color of the diffusion profile. Should be the average color of the material.
  24362. * @return The index of the diffusion profile for the material subsurface configuration
  24363. */
  24364. addDiffusionProfile(color: Color3): number;
  24365. /**
  24366. * Creates the sss post process
  24367. * @return The created post process
  24368. */
  24369. createPostProcess(): SubSurfaceScatteringPostProcess;
  24370. /**
  24371. * Deletes all diffusion profiles.
  24372. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24373. */
  24374. clearAllDiffusionProfiles(): void;
  24375. /**
  24376. * Disposes this object
  24377. */
  24378. dispose(): void;
  24379. /**
  24380. * @hidden
  24381. * https://zero-radiance.github.io/post/sampling-diffusion/
  24382. *
  24383. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24384. * ------------------------------------------------------------------------------------
  24385. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24386. * PDF[r, phi, s] = r * R[r, phi, s]
  24387. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24388. * ------------------------------------------------------------------------------------
  24389. * We importance sample the color channel with the widest scattering distance.
  24390. */
  24391. getDiffusionProfileParameters(color: Color3): number;
  24392. /**
  24393. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24394. * 'u' is the random number (the value of the CDF): [0, 1).
  24395. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24396. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24397. */
  24398. private _sampleBurleyDiffusionProfile;
  24399. }
  24400. }
  24401. declare module BABYLON {
  24402. /**
  24403. * Renders a pre pass of the scene
  24404. * This means every mesh in the scene will be rendered to a render target texture
  24405. * And then this texture will be composited to the rendering canvas with post processes
  24406. * It is necessary for effects like subsurface scattering or deferred shading
  24407. */
  24408. export class PrePassRenderer {
  24409. /** @hidden */
  24410. static _SceneComponentInitialization: (scene: Scene) => void;
  24411. private _scene;
  24412. private _engine;
  24413. private _isDirty;
  24414. /**
  24415. * Number of textures in the multi render target texture where the scene is directly rendered
  24416. */
  24417. readonly mrtCount: number;
  24418. /**
  24419. * The render target where the scene is directly rendered
  24420. */
  24421. prePassRT: MultiRenderTarget;
  24422. private _mrtTypes;
  24423. private _multiRenderAttachments;
  24424. private _defaultAttachments;
  24425. private _clearAttachments;
  24426. private _postProcesses;
  24427. private readonly _clearColor;
  24428. /**
  24429. * Image processing post process for composition
  24430. */
  24431. imageProcessingPostProcess: ImageProcessingPostProcess;
  24432. /**
  24433. * Configuration for sub surface scattering post process
  24434. */
  24435. subSurfaceConfiguration: SubSurfaceConfiguration;
  24436. /**
  24437. * Should materials render their geometry on the MRT
  24438. */
  24439. materialsShouldRenderGeometry: boolean;
  24440. /**
  24441. * Should materials render the irradiance information on the MRT
  24442. */
  24443. materialsShouldRenderIrradiance: boolean;
  24444. private _enabled;
  24445. /**
  24446. * Indicates if the prepass is enabled
  24447. */
  24448. get enabled(): boolean;
  24449. /**
  24450. * How many samples are used for MSAA of the scene render target
  24451. */
  24452. get samples(): number;
  24453. set samples(n: number);
  24454. /**
  24455. * Instanciates a prepass renderer
  24456. * @param scene The scene
  24457. */
  24458. constructor(scene: Scene);
  24459. private _initializeAttachments;
  24460. private _createCompositionEffect;
  24461. /**
  24462. * Indicates if rendering a prepass is supported
  24463. */
  24464. get isSupported(): boolean;
  24465. /**
  24466. * Sets the proper output textures to draw in the engine.
  24467. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24468. */
  24469. bindAttachmentsForEffect(effect: Effect): void;
  24470. /**
  24471. * @hidden
  24472. */
  24473. _beforeCameraDraw(): void;
  24474. /**
  24475. * @hidden
  24476. */
  24477. _afterCameraDraw(): void;
  24478. private _checkRTSize;
  24479. private _bindFrameBuffer;
  24480. /**
  24481. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24482. */
  24483. clear(): void;
  24484. private _setState;
  24485. private _enable;
  24486. private _disable;
  24487. private _resetPostProcessChain;
  24488. private _bindPostProcessChain;
  24489. /**
  24490. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24491. */
  24492. markAsDirty(): void;
  24493. private _update;
  24494. /**
  24495. * Disposes the prepass renderer.
  24496. */
  24497. dispose(): void;
  24498. }
  24499. }
  24500. declare module BABYLON {
  24501. /**
  24502. * Options for compiling materials.
  24503. */
  24504. export interface IMaterialCompilationOptions {
  24505. /**
  24506. * Defines whether clip planes are enabled.
  24507. */
  24508. clipPlane: boolean;
  24509. /**
  24510. * Defines whether instances are enabled.
  24511. */
  24512. useInstances: boolean;
  24513. }
  24514. /**
  24515. * Options passed when calling customShaderNameResolve
  24516. */
  24517. export interface ICustomShaderNameResolveOptions {
  24518. /**
  24519. * If provided, will be called two times with the vertex and fragment code so that this code can be updated before it is compiled by the GPU
  24520. */
  24521. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24522. }
  24523. /**
  24524. * Base class for the main features of a material in Babylon.js
  24525. */
  24526. export class Material implements IAnimatable {
  24527. /**
  24528. * Returns the triangle fill mode
  24529. */
  24530. static readonly TriangleFillMode: number;
  24531. /**
  24532. * Returns the wireframe mode
  24533. */
  24534. static readonly WireFrameFillMode: number;
  24535. /**
  24536. * Returns the point fill mode
  24537. */
  24538. static readonly PointFillMode: number;
  24539. /**
  24540. * Returns the point list draw mode
  24541. */
  24542. static readonly PointListDrawMode: number;
  24543. /**
  24544. * Returns the line list draw mode
  24545. */
  24546. static readonly LineListDrawMode: number;
  24547. /**
  24548. * Returns the line loop draw mode
  24549. */
  24550. static readonly LineLoopDrawMode: number;
  24551. /**
  24552. * Returns the line strip draw mode
  24553. */
  24554. static readonly LineStripDrawMode: number;
  24555. /**
  24556. * Returns the triangle strip draw mode
  24557. */
  24558. static readonly TriangleStripDrawMode: number;
  24559. /**
  24560. * Returns the triangle fan draw mode
  24561. */
  24562. static readonly TriangleFanDrawMode: number;
  24563. /**
  24564. * Stores the clock-wise side orientation
  24565. */
  24566. static readonly ClockWiseSideOrientation: number;
  24567. /**
  24568. * Stores the counter clock-wise side orientation
  24569. */
  24570. static readonly CounterClockWiseSideOrientation: number;
  24571. /**
  24572. * The dirty texture flag value
  24573. */
  24574. static readonly TextureDirtyFlag: number;
  24575. /**
  24576. * The dirty light flag value
  24577. */
  24578. static readonly LightDirtyFlag: number;
  24579. /**
  24580. * The dirty fresnel flag value
  24581. */
  24582. static readonly FresnelDirtyFlag: number;
  24583. /**
  24584. * The dirty attribute flag value
  24585. */
  24586. static readonly AttributesDirtyFlag: number;
  24587. /**
  24588. * The dirty misc flag value
  24589. */
  24590. static readonly MiscDirtyFlag: number;
  24591. /**
  24592. * The all dirty flag value
  24593. */
  24594. static readonly AllDirtyFlag: number;
  24595. /**
  24596. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24597. */
  24598. static readonly MATERIAL_OPAQUE: number;
  24599. /**
  24600. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24601. */
  24602. static readonly MATERIAL_ALPHATEST: number;
  24603. /**
  24604. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24605. */
  24606. static readonly MATERIAL_ALPHABLEND: number;
  24607. /**
  24608. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24609. * They are also discarded below the alpha cutoff threshold to improve performances.
  24610. */
  24611. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24612. /**
  24613. * The Whiteout method is used to blend normals.
  24614. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24615. */
  24616. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24617. /**
  24618. * The Reoriented Normal Mapping method is used to blend normals.
  24619. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24620. */
  24621. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24622. /**
  24623. * Custom callback helping to override the default shader used in the material.
  24624. */
  24625. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24626. /**
  24627. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24628. */
  24629. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24630. /**
  24631. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24632. * This means that the material can keep using a previous shader while a new one is being compiled.
  24633. * This is mostly used when shader parallel compilation is supported (true by default)
  24634. */
  24635. allowShaderHotSwapping: boolean;
  24636. /**
  24637. * The ID of the material
  24638. */
  24639. id: string;
  24640. /**
  24641. * Gets or sets the unique id of the material
  24642. */
  24643. uniqueId: number;
  24644. /**
  24645. * The name of the material
  24646. */
  24647. name: string;
  24648. /**
  24649. * Gets or sets user defined metadata
  24650. */
  24651. metadata: any;
  24652. /**
  24653. * For internal use only. Please do not use.
  24654. */
  24655. reservedDataStore: any;
  24656. /**
  24657. * Specifies if the ready state should be checked on each call
  24658. */
  24659. checkReadyOnEveryCall: boolean;
  24660. /**
  24661. * Specifies if the ready state should be checked once
  24662. */
  24663. checkReadyOnlyOnce: boolean;
  24664. /**
  24665. * The state of the material
  24666. */
  24667. state: string;
  24668. /**
  24669. * If the material can be rendered to several textures with MRT extension
  24670. */
  24671. get canRenderToMRT(): boolean;
  24672. /**
  24673. * The alpha value of the material
  24674. */
  24675. protected _alpha: number;
  24676. /**
  24677. * List of inspectable custom properties (used by the Inspector)
  24678. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24679. */
  24680. inspectableCustomProperties: IInspectable[];
  24681. /**
  24682. * Sets the alpha value of the material
  24683. */
  24684. set alpha(value: number);
  24685. /**
  24686. * Gets the alpha value of the material
  24687. */
  24688. get alpha(): number;
  24689. /**
  24690. * Specifies if back face culling is enabled
  24691. */
  24692. protected _backFaceCulling: boolean;
  24693. /**
  24694. * Sets the back-face culling state
  24695. */
  24696. set backFaceCulling(value: boolean);
  24697. /**
  24698. * Gets the back-face culling state
  24699. */
  24700. get backFaceCulling(): boolean;
  24701. /**
  24702. * Stores the value for side orientation
  24703. */
  24704. sideOrientation: number;
  24705. /**
  24706. * Callback triggered when the material is compiled
  24707. */
  24708. onCompiled: Nullable<(effect: Effect) => void>;
  24709. /**
  24710. * Callback triggered when an error occurs
  24711. */
  24712. onError: Nullable<(effect: Effect, errors: string) => void>;
  24713. /**
  24714. * Callback triggered to get the render target textures
  24715. */
  24716. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24717. /**
  24718. * Gets a boolean indicating that current material needs to register RTT
  24719. */
  24720. get hasRenderTargetTextures(): boolean;
  24721. /**
  24722. * Specifies if the material should be serialized
  24723. */
  24724. doNotSerialize: boolean;
  24725. /**
  24726. * @hidden
  24727. */
  24728. _storeEffectOnSubMeshes: boolean;
  24729. /**
  24730. * Stores the animations for the material
  24731. */
  24732. animations: Nullable<Array<Animation>>;
  24733. /**
  24734. * An event triggered when the material is disposed
  24735. */
  24736. onDisposeObservable: Observable<Material>;
  24737. /**
  24738. * An observer which watches for dispose events
  24739. */
  24740. private _onDisposeObserver;
  24741. private _onUnBindObservable;
  24742. /**
  24743. * Called during a dispose event
  24744. */
  24745. set onDispose(callback: () => void);
  24746. private _onBindObservable;
  24747. /**
  24748. * An event triggered when the material is bound
  24749. */
  24750. get onBindObservable(): Observable<AbstractMesh>;
  24751. /**
  24752. * An observer which watches for bind events
  24753. */
  24754. private _onBindObserver;
  24755. /**
  24756. * Called during a bind event
  24757. */
  24758. set onBind(callback: (Mesh: AbstractMesh) => void);
  24759. /**
  24760. * An event triggered when the material is unbound
  24761. */
  24762. get onUnBindObservable(): Observable<Material>;
  24763. protected _onEffectCreatedObservable: Nullable<Observable<{
  24764. effect: Effect;
  24765. subMesh: Nullable<SubMesh>;
  24766. }>>;
  24767. /**
  24768. * An event triggered when the effect is (re)created
  24769. */
  24770. get onEffectCreatedObservable(): Observable<{
  24771. effect: Effect;
  24772. subMesh: Nullable<SubMesh>;
  24773. }>;
  24774. /**
  24775. * Stores the value of the alpha mode
  24776. */
  24777. private _alphaMode;
  24778. /**
  24779. * Sets the value of the alpha mode.
  24780. *
  24781. * | Value | Type | Description |
  24782. * | --- | --- | --- |
  24783. * | 0 | ALPHA_DISABLE | |
  24784. * | 1 | ALPHA_ADD | |
  24785. * | 2 | ALPHA_COMBINE | |
  24786. * | 3 | ALPHA_SUBTRACT | |
  24787. * | 4 | ALPHA_MULTIPLY | |
  24788. * | 5 | ALPHA_MAXIMIZED | |
  24789. * | 6 | ALPHA_ONEONE | |
  24790. * | 7 | ALPHA_PREMULTIPLIED | |
  24791. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24792. * | 9 | ALPHA_INTERPOLATE | |
  24793. * | 10 | ALPHA_SCREENMODE | |
  24794. *
  24795. */
  24796. set alphaMode(value: number);
  24797. /**
  24798. * Gets the value of the alpha mode
  24799. */
  24800. get alphaMode(): number;
  24801. /**
  24802. * Stores the state of the need depth pre-pass value
  24803. */
  24804. private _needDepthPrePass;
  24805. /**
  24806. * Sets the need depth pre-pass value
  24807. */
  24808. set needDepthPrePass(value: boolean);
  24809. /**
  24810. * Gets the depth pre-pass value
  24811. */
  24812. get needDepthPrePass(): boolean;
  24813. /**
  24814. * Specifies if depth writing should be disabled
  24815. */
  24816. disableDepthWrite: boolean;
  24817. /**
  24818. * Specifies if color writing should be disabled
  24819. */
  24820. disableColorWrite: boolean;
  24821. /**
  24822. * Specifies if depth writing should be forced
  24823. */
  24824. forceDepthWrite: boolean;
  24825. /**
  24826. * Specifies the depth function that should be used. 0 means the default engine function
  24827. */
  24828. depthFunction: number;
  24829. /**
  24830. * Specifies if there should be a separate pass for culling
  24831. */
  24832. separateCullingPass: boolean;
  24833. /**
  24834. * Stores the state specifing if fog should be enabled
  24835. */
  24836. private _fogEnabled;
  24837. /**
  24838. * Sets the state for enabling fog
  24839. */
  24840. set fogEnabled(value: boolean);
  24841. /**
  24842. * Gets the value of the fog enabled state
  24843. */
  24844. get fogEnabled(): boolean;
  24845. /**
  24846. * Stores the size of points
  24847. */
  24848. pointSize: number;
  24849. /**
  24850. * Stores the z offset value
  24851. */
  24852. zOffset: number;
  24853. get wireframe(): boolean;
  24854. /**
  24855. * Sets the state of wireframe mode
  24856. */
  24857. set wireframe(value: boolean);
  24858. /**
  24859. * Gets the value specifying if point clouds are enabled
  24860. */
  24861. get pointsCloud(): boolean;
  24862. /**
  24863. * Sets the state of point cloud mode
  24864. */
  24865. set pointsCloud(value: boolean);
  24866. /**
  24867. * Gets the material fill mode
  24868. */
  24869. get fillMode(): number;
  24870. /**
  24871. * Sets the material fill mode
  24872. */
  24873. set fillMode(value: number);
  24874. /**
  24875. * @hidden
  24876. * Stores the effects for the material
  24877. */
  24878. _effect: Nullable<Effect>;
  24879. /**
  24880. * Specifies if uniform buffers should be used
  24881. */
  24882. private _useUBO;
  24883. /**
  24884. * Stores a reference to the scene
  24885. */
  24886. private _scene;
  24887. /**
  24888. * Stores the fill mode state
  24889. */
  24890. private _fillMode;
  24891. /**
  24892. * Specifies if the depth write state should be cached
  24893. */
  24894. private _cachedDepthWriteState;
  24895. /**
  24896. * Specifies if the color write state should be cached
  24897. */
  24898. private _cachedColorWriteState;
  24899. /**
  24900. * Specifies if the depth function state should be cached
  24901. */
  24902. private _cachedDepthFunctionState;
  24903. /**
  24904. * Stores the uniform buffer
  24905. */
  24906. protected _uniformBuffer: UniformBuffer;
  24907. /** @hidden */
  24908. _indexInSceneMaterialArray: number;
  24909. /** @hidden */
  24910. meshMap: Nullable<{
  24911. [id: string]: AbstractMesh | undefined;
  24912. }>;
  24913. /**
  24914. * Creates a material instance
  24915. * @param name defines the name of the material
  24916. * @param scene defines the scene to reference
  24917. * @param doNotAdd specifies if the material should be added to the scene
  24918. */
  24919. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24920. /**
  24921. * Returns a string representation of the current material
  24922. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24923. * @returns a string with material information
  24924. */
  24925. toString(fullDetails?: boolean): string;
  24926. /**
  24927. * Gets the class name of the material
  24928. * @returns a string with the class name of the material
  24929. */
  24930. getClassName(): string;
  24931. /**
  24932. * Specifies if updates for the material been locked
  24933. */
  24934. get isFrozen(): boolean;
  24935. /**
  24936. * Locks updates for the material
  24937. */
  24938. freeze(): void;
  24939. /**
  24940. * Unlocks updates for the material
  24941. */
  24942. unfreeze(): void;
  24943. /**
  24944. * Specifies if the material is ready to be used
  24945. * @param mesh defines the mesh to check
  24946. * @param useInstances specifies if instances should be used
  24947. * @returns a boolean indicating if the material is ready to be used
  24948. */
  24949. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24950. /**
  24951. * Specifies that the submesh is ready to be used
  24952. * @param mesh defines the mesh to check
  24953. * @param subMesh defines which submesh to check
  24954. * @param useInstances specifies that instances should be used
  24955. * @returns a boolean indicating that the submesh is ready or not
  24956. */
  24957. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24958. /**
  24959. * Returns the material effect
  24960. * @returns the effect associated with the material
  24961. */
  24962. getEffect(): Nullable<Effect>;
  24963. /**
  24964. * Returns the current scene
  24965. * @returns a Scene
  24966. */
  24967. getScene(): Scene;
  24968. /**
  24969. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24970. */
  24971. protected _forceAlphaTest: boolean;
  24972. /**
  24973. * The transparency mode of the material.
  24974. */
  24975. protected _transparencyMode: Nullable<number>;
  24976. /**
  24977. * Gets the current transparency mode.
  24978. */
  24979. get transparencyMode(): Nullable<number>;
  24980. /**
  24981. * Sets the transparency mode of the material.
  24982. *
  24983. * | Value | Type | Description |
  24984. * | ----- | ----------------------------------- | ----------- |
  24985. * | 0 | OPAQUE | |
  24986. * | 1 | ALPHATEST | |
  24987. * | 2 | ALPHABLEND | |
  24988. * | 3 | ALPHATESTANDBLEND | |
  24989. *
  24990. */
  24991. set transparencyMode(value: Nullable<number>);
  24992. /**
  24993. * Returns true if alpha blending should be disabled.
  24994. */
  24995. protected get _disableAlphaBlending(): boolean;
  24996. /**
  24997. * Specifies whether or not this material should be rendered in alpha blend mode.
  24998. * @returns a boolean specifying if alpha blending is needed
  24999. */
  25000. needAlphaBlending(): boolean;
  25001. /**
  25002. * Specifies if the mesh will require alpha blending
  25003. * @param mesh defines the mesh to check
  25004. * @returns a boolean specifying if alpha blending is needed for the mesh
  25005. */
  25006. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25007. /**
  25008. * Specifies whether or not this material should be rendered in alpha test mode.
  25009. * @returns a boolean specifying if an alpha test is needed.
  25010. */
  25011. needAlphaTesting(): boolean;
  25012. /**
  25013. * Specifies if material alpha testing should be turned on for the mesh
  25014. * @param mesh defines the mesh to check
  25015. */
  25016. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25017. /**
  25018. * Gets the texture used for the alpha test
  25019. * @returns the texture to use for alpha testing
  25020. */
  25021. getAlphaTestTexture(): Nullable<BaseTexture>;
  25022. /**
  25023. * Marks the material to indicate that it needs to be re-calculated
  25024. */
  25025. markDirty(): void;
  25026. /** @hidden */
  25027. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25028. /**
  25029. * Binds the material to the mesh
  25030. * @param world defines the world transformation matrix
  25031. * @param mesh defines the mesh to bind the material to
  25032. */
  25033. bind(world: Matrix, mesh?: Mesh): void;
  25034. /**
  25035. * Binds the submesh to the material
  25036. * @param world defines the world transformation matrix
  25037. * @param mesh defines the mesh containing the submesh
  25038. * @param subMesh defines the submesh to bind the material to
  25039. */
  25040. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25041. /**
  25042. * Binds the world matrix to the material
  25043. * @param world defines the world transformation matrix
  25044. */
  25045. bindOnlyWorldMatrix(world: Matrix): void;
  25046. /**
  25047. * Binds the scene's uniform buffer to the effect.
  25048. * @param effect defines the effect to bind to the scene uniform buffer
  25049. * @param sceneUbo defines the uniform buffer storing scene data
  25050. */
  25051. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25052. /**
  25053. * Binds the view matrix to the effect
  25054. * @param effect defines the effect to bind the view matrix to
  25055. */
  25056. bindView(effect: Effect): void;
  25057. /**
  25058. * Binds the view projection matrix to the effect
  25059. * @param effect defines the effect to bind the view projection matrix to
  25060. */
  25061. bindViewProjection(effect: Effect): void;
  25062. /**
  25063. * Processes to execute after binding the material to a mesh
  25064. * @param mesh defines the rendered mesh
  25065. */
  25066. protected _afterBind(mesh?: Mesh): void;
  25067. /**
  25068. * Unbinds the material from the mesh
  25069. */
  25070. unbind(): void;
  25071. /**
  25072. * Gets the active textures from the material
  25073. * @returns an array of textures
  25074. */
  25075. getActiveTextures(): BaseTexture[];
  25076. /**
  25077. * Specifies if the material uses a texture
  25078. * @param texture defines the texture to check against the material
  25079. * @returns a boolean specifying if the material uses the texture
  25080. */
  25081. hasTexture(texture: BaseTexture): boolean;
  25082. /**
  25083. * Makes a duplicate of the material, and gives it a new name
  25084. * @param name defines the new name for the duplicated material
  25085. * @returns the cloned material
  25086. */
  25087. clone(name: string): Nullable<Material>;
  25088. /**
  25089. * Gets the meshes bound to the material
  25090. * @returns an array of meshes bound to the material
  25091. */
  25092. getBindedMeshes(): AbstractMesh[];
  25093. /**
  25094. * Force shader compilation
  25095. * @param mesh defines the mesh associated with this material
  25096. * @param onCompiled defines a function to execute once the material is compiled
  25097. * @param options defines the options to configure the compilation
  25098. * @param onError defines a function to execute if the material fails compiling
  25099. */
  25100. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25101. /**
  25102. * Force shader compilation
  25103. * @param mesh defines the mesh that will use this material
  25104. * @param options defines additional options for compiling the shaders
  25105. * @returns a promise that resolves when the compilation completes
  25106. */
  25107. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25108. private static readonly _AllDirtyCallBack;
  25109. private static readonly _ImageProcessingDirtyCallBack;
  25110. private static readonly _TextureDirtyCallBack;
  25111. private static readonly _FresnelDirtyCallBack;
  25112. private static readonly _MiscDirtyCallBack;
  25113. private static readonly _LightsDirtyCallBack;
  25114. private static readonly _AttributeDirtyCallBack;
  25115. private static _FresnelAndMiscDirtyCallBack;
  25116. private static _TextureAndMiscDirtyCallBack;
  25117. private static readonly _DirtyCallbackArray;
  25118. private static readonly _RunDirtyCallBacks;
  25119. /**
  25120. * Marks a define in the material to indicate that it needs to be re-computed
  25121. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25122. */
  25123. markAsDirty(flag: number): void;
  25124. /**
  25125. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25126. * @param func defines a function which checks material defines against the submeshes
  25127. */
  25128. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25129. /**
  25130. * Indicates that the scene should check if the rendering now needs a prepass
  25131. */
  25132. protected _markScenePrePassDirty(): void;
  25133. /**
  25134. * Indicates that we need to re-calculated for all submeshes
  25135. */
  25136. protected _markAllSubMeshesAsAllDirty(): void;
  25137. /**
  25138. * Indicates that image processing needs to be re-calculated for all submeshes
  25139. */
  25140. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25141. /**
  25142. * Indicates that textures need to be re-calculated for all submeshes
  25143. */
  25144. protected _markAllSubMeshesAsTexturesDirty(): void;
  25145. /**
  25146. * Indicates that fresnel needs to be re-calculated for all submeshes
  25147. */
  25148. protected _markAllSubMeshesAsFresnelDirty(): void;
  25149. /**
  25150. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25151. */
  25152. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25153. /**
  25154. * Indicates that lights need to be re-calculated for all submeshes
  25155. */
  25156. protected _markAllSubMeshesAsLightsDirty(): void;
  25157. /**
  25158. * Indicates that attributes need to be re-calculated for all submeshes
  25159. */
  25160. protected _markAllSubMeshesAsAttributesDirty(): void;
  25161. /**
  25162. * Indicates that misc needs to be re-calculated for all submeshes
  25163. */
  25164. protected _markAllSubMeshesAsMiscDirty(): void;
  25165. /**
  25166. * Indicates that textures and misc need to be re-calculated for all submeshes
  25167. */
  25168. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25169. /**
  25170. * Sets the required values to the prepass renderer.
  25171. * @param prePassRenderer defines the prepass renderer to setup.
  25172. * @returns true if the pre pass is needed.
  25173. */
  25174. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25175. /**
  25176. * Disposes the material
  25177. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25178. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25179. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25180. */
  25181. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25182. /** @hidden */
  25183. private releaseVertexArrayObject;
  25184. /**
  25185. * Serializes this material
  25186. * @returns the serialized material object
  25187. */
  25188. serialize(): any;
  25189. /**
  25190. * Creates a material from parsed material data
  25191. * @param parsedMaterial defines parsed material data
  25192. * @param scene defines the hosting scene
  25193. * @param rootUrl defines the root URL to use to load textures
  25194. * @returns a new material
  25195. */
  25196. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25197. }
  25198. }
  25199. declare module BABYLON {
  25200. /**
  25201. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25202. * separate meshes. This can be use to improve performances.
  25203. * @see https://doc.babylonjs.com/how_to/multi_materials
  25204. */
  25205. export class MultiMaterial extends Material {
  25206. private _subMaterials;
  25207. /**
  25208. * Gets or Sets the list of Materials used within the multi material.
  25209. * They need to be ordered according to the submeshes order in the associated mesh
  25210. */
  25211. get subMaterials(): Nullable<Material>[];
  25212. set subMaterials(value: Nullable<Material>[]);
  25213. /**
  25214. * Function used to align with Node.getChildren()
  25215. * @returns the list of Materials used within the multi material
  25216. */
  25217. getChildren(): Nullable<Material>[];
  25218. /**
  25219. * Instantiates a new Multi Material
  25220. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25221. * separate meshes. This can be use to improve performances.
  25222. * @see https://doc.babylonjs.com/how_to/multi_materials
  25223. * @param name Define the name in the scene
  25224. * @param scene Define the scene the material belongs to
  25225. */
  25226. constructor(name: string, scene: Scene);
  25227. private _hookArray;
  25228. /**
  25229. * Get one of the submaterial by its index in the submaterials array
  25230. * @param index The index to look the sub material at
  25231. * @returns The Material if the index has been defined
  25232. */
  25233. getSubMaterial(index: number): Nullable<Material>;
  25234. /**
  25235. * Get the list of active textures for the whole sub materials list.
  25236. * @returns All the textures that will be used during the rendering
  25237. */
  25238. getActiveTextures(): BaseTexture[];
  25239. /**
  25240. * Gets the current class name of the material e.g. "MultiMaterial"
  25241. * Mainly use in serialization.
  25242. * @returns the class name
  25243. */
  25244. getClassName(): string;
  25245. /**
  25246. * Checks if the material is ready to render the requested sub mesh
  25247. * @param mesh Define the mesh the submesh belongs to
  25248. * @param subMesh Define the sub mesh to look readyness for
  25249. * @param useInstances Define whether or not the material is used with instances
  25250. * @returns true if ready, otherwise false
  25251. */
  25252. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25253. /**
  25254. * Clones the current material and its related sub materials
  25255. * @param name Define the name of the newly cloned material
  25256. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25257. * @returns the cloned material
  25258. */
  25259. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25260. /**
  25261. * Serializes the materials into a JSON representation.
  25262. * @returns the JSON representation
  25263. */
  25264. serialize(): any;
  25265. /**
  25266. * Dispose the material and release its associated resources
  25267. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  25268. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  25269. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  25270. */
  25271. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25272. /**
  25273. * Creates a MultiMaterial from parsed MultiMaterial data.
  25274. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25275. * @param scene defines the hosting scene
  25276. * @returns a new MultiMaterial
  25277. */
  25278. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25279. }
  25280. }
  25281. declare module BABYLON {
  25282. /**
  25283. * Defines a subdivision inside a mesh
  25284. */
  25285. export class SubMesh implements ICullable {
  25286. /** the material index to use */
  25287. materialIndex: number;
  25288. /** vertex index start */
  25289. verticesStart: number;
  25290. /** vertices count */
  25291. verticesCount: number;
  25292. /** index start */
  25293. indexStart: number;
  25294. /** indices count */
  25295. indexCount: number;
  25296. /** @hidden */
  25297. _materialDefines: Nullable<MaterialDefines>;
  25298. /** @hidden */
  25299. _materialEffect: Nullable<Effect>;
  25300. /** @hidden */
  25301. _effectOverride: Nullable<Effect>;
  25302. /**
  25303. * Gets material defines used by the effect associated to the sub mesh
  25304. */
  25305. get materialDefines(): Nullable<MaterialDefines>;
  25306. /**
  25307. * Sets material defines used by the effect associated to the sub mesh
  25308. */
  25309. set materialDefines(defines: Nullable<MaterialDefines>);
  25310. /**
  25311. * Gets associated effect
  25312. */
  25313. get effect(): Nullable<Effect>;
  25314. /**
  25315. * Sets associated effect (effect used to render this submesh)
  25316. * @param effect defines the effect to associate with
  25317. * @param defines defines the set of defines used to compile this effect
  25318. */
  25319. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25320. /** @hidden */
  25321. _linesIndexCount: number;
  25322. private _mesh;
  25323. private _renderingMesh;
  25324. private _boundingInfo;
  25325. private _linesIndexBuffer;
  25326. /** @hidden */
  25327. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25328. /** @hidden */
  25329. _trianglePlanes: Plane[];
  25330. /** @hidden */
  25331. _lastColliderTransformMatrix: Nullable<Matrix>;
  25332. /** @hidden */
  25333. _renderId: number;
  25334. /** @hidden */
  25335. _alphaIndex: number;
  25336. /** @hidden */
  25337. _distanceToCamera: number;
  25338. /** @hidden */
  25339. _id: number;
  25340. private _currentMaterial;
  25341. /**
  25342. * Add a new submesh to a mesh
  25343. * @param materialIndex defines the material index to use
  25344. * @param verticesStart defines vertex index start
  25345. * @param verticesCount defines vertices count
  25346. * @param indexStart defines index start
  25347. * @param indexCount defines indices count
  25348. * @param mesh defines the parent mesh
  25349. * @param renderingMesh defines an optional rendering mesh
  25350. * @param createBoundingBox defines if bounding box should be created for this submesh
  25351. * @returns the new submesh
  25352. */
  25353. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25354. /**
  25355. * Creates a new submesh
  25356. * @param materialIndex defines the material index to use
  25357. * @param verticesStart defines vertex index start
  25358. * @param verticesCount defines vertices count
  25359. * @param indexStart defines index start
  25360. * @param indexCount defines indices count
  25361. * @param mesh defines the parent mesh
  25362. * @param renderingMesh defines an optional rendering mesh
  25363. * @param createBoundingBox defines if bounding box should be created for this submesh
  25364. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25365. */
  25366. constructor(
  25367. /** the material index to use */
  25368. materialIndex: number,
  25369. /** vertex index start */
  25370. verticesStart: number,
  25371. /** vertices count */
  25372. verticesCount: number,
  25373. /** index start */
  25374. indexStart: number,
  25375. /** indices count */
  25376. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25377. /**
  25378. * Returns true if this submesh covers the entire parent mesh
  25379. * @ignorenaming
  25380. */
  25381. get IsGlobal(): boolean;
  25382. /**
  25383. * Returns the submesh BoudingInfo object
  25384. * @returns current bounding info (or mesh's one if the submesh is global)
  25385. */
  25386. getBoundingInfo(): BoundingInfo;
  25387. /**
  25388. * Sets the submesh BoundingInfo
  25389. * @param boundingInfo defines the new bounding info to use
  25390. * @returns the SubMesh
  25391. */
  25392. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25393. /**
  25394. * Returns the mesh of the current submesh
  25395. * @return the parent mesh
  25396. */
  25397. getMesh(): AbstractMesh;
  25398. /**
  25399. * Returns the rendering mesh of the submesh
  25400. * @returns the rendering mesh (could be different from parent mesh)
  25401. */
  25402. getRenderingMesh(): Mesh;
  25403. /**
  25404. * Returns the replacement mesh of the submesh
  25405. * @returns the replacement mesh (could be different from parent mesh)
  25406. */
  25407. getReplacementMesh(): Nullable<AbstractMesh>;
  25408. /**
  25409. * Returns the effective mesh of the submesh
  25410. * @returns the effective mesh (could be different from parent mesh)
  25411. */
  25412. getEffectiveMesh(): AbstractMesh;
  25413. /**
  25414. * Returns the submesh material
  25415. * @returns null or the current material
  25416. */
  25417. getMaterial(): Nullable<Material>;
  25418. private _IsMultiMaterial;
  25419. /**
  25420. * Sets a new updated BoundingInfo object to the submesh
  25421. * @param data defines an optional position array to use to determine the bounding info
  25422. * @returns the SubMesh
  25423. */
  25424. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25425. /** @hidden */
  25426. _checkCollision(collider: Collider): boolean;
  25427. /**
  25428. * Updates the submesh BoundingInfo
  25429. * @param world defines the world matrix to use to update the bounding info
  25430. * @returns the submesh
  25431. */
  25432. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25433. /**
  25434. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25435. * @param frustumPlanes defines the frustum planes
  25436. * @returns true if the submesh is intersecting with the frustum
  25437. */
  25438. isInFrustum(frustumPlanes: Plane[]): boolean;
  25439. /**
  25440. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25441. * @param frustumPlanes defines the frustum planes
  25442. * @returns true if the submesh is inside the frustum
  25443. */
  25444. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25445. /**
  25446. * Renders the submesh
  25447. * @param enableAlphaMode defines if alpha needs to be used
  25448. * @returns the submesh
  25449. */
  25450. render(enableAlphaMode: boolean): SubMesh;
  25451. /**
  25452. * @hidden
  25453. */
  25454. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25455. /**
  25456. * Checks if the submesh intersects with a ray
  25457. * @param ray defines the ray to test
  25458. * @returns true is the passed ray intersects the submesh bounding box
  25459. */
  25460. canIntersects(ray: Ray): boolean;
  25461. /**
  25462. * Intersects current submesh with a ray
  25463. * @param ray defines the ray to test
  25464. * @param positions defines mesh's positions array
  25465. * @param indices defines mesh's indices array
  25466. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25467. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25468. * @returns intersection info or null if no intersection
  25469. */
  25470. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25471. /** @hidden */
  25472. private _intersectLines;
  25473. /** @hidden */
  25474. private _intersectUnIndexedLines;
  25475. /** @hidden */
  25476. private _intersectTriangles;
  25477. /** @hidden */
  25478. private _intersectUnIndexedTriangles;
  25479. /** @hidden */
  25480. _rebuild(): void;
  25481. /**
  25482. * Creates a new submesh from the passed mesh
  25483. * @param newMesh defines the new hosting mesh
  25484. * @param newRenderingMesh defines an optional rendering mesh
  25485. * @returns the new submesh
  25486. */
  25487. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25488. /**
  25489. * Release associated resources
  25490. */
  25491. dispose(): void;
  25492. /**
  25493. * Gets the class name
  25494. * @returns the string "SubMesh".
  25495. */
  25496. getClassName(): string;
  25497. /**
  25498. * Creates a new submesh from indices data
  25499. * @param materialIndex the index of the main mesh material
  25500. * @param startIndex the index where to start the copy in the mesh indices array
  25501. * @param indexCount the number of indices to copy then from the startIndex
  25502. * @param mesh the main mesh to create the submesh from
  25503. * @param renderingMesh the optional rendering mesh
  25504. * @returns a new submesh
  25505. */
  25506. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25507. }
  25508. }
  25509. declare module BABYLON {
  25510. /**
  25511. * Class used to represent data loading progression
  25512. */
  25513. export class SceneLoaderFlags {
  25514. private static _ForceFullSceneLoadingForIncremental;
  25515. private static _ShowLoadingScreen;
  25516. private static _CleanBoneMatrixWeights;
  25517. private static _loggingLevel;
  25518. /**
  25519. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25520. */
  25521. static get ForceFullSceneLoadingForIncremental(): boolean;
  25522. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25523. /**
  25524. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25525. */
  25526. static get ShowLoadingScreen(): boolean;
  25527. static set ShowLoadingScreen(value: boolean);
  25528. /**
  25529. * Defines the current logging level (while loading the scene)
  25530. * @ignorenaming
  25531. */
  25532. static get loggingLevel(): number;
  25533. static set loggingLevel(value: number);
  25534. /**
  25535. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25536. */
  25537. static get CleanBoneMatrixWeights(): boolean;
  25538. static set CleanBoneMatrixWeights(value: boolean);
  25539. }
  25540. }
  25541. declare module BABYLON {
  25542. /**
  25543. * Class used to store geometry data (vertex buffers + index buffer)
  25544. */
  25545. export class Geometry implements IGetSetVerticesData {
  25546. /**
  25547. * Gets or sets the ID of the geometry
  25548. */
  25549. id: string;
  25550. /**
  25551. * Gets or sets the unique ID of the geometry
  25552. */
  25553. uniqueId: number;
  25554. /**
  25555. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25556. */
  25557. delayLoadState: number;
  25558. /**
  25559. * Gets the file containing the data to load when running in delay load state
  25560. */
  25561. delayLoadingFile: Nullable<string>;
  25562. /**
  25563. * Callback called when the geometry is updated
  25564. */
  25565. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25566. private _scene;
  25567. private _engine;
  25568. private _meshes;
  25569. private _totalVertices;
  25570. /** @hidden */
  25571. _indices: IndicesArray;
  25572. /** @hidden */
  25573. _vertexBuffers: {
  25574. [key: string]: VertexBuffer;
  25575. };
  25576. private _isDisposed;
  25577. private _extend;
  25578. private _boundingBias;
  25579. /** @hidden */
  25580. _delayInfo: Array<string>;
  25581. private _indexBuffer;
  25582. private _indexBufferIsUpdatable;
  25583. /** @hidden */
  25584. _boundingInfo: Nullable<BoundingInfo>;
  25585. /** @hidden */
  25586. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25587. /** @hidden */
  25588. _softwareSkinningFrameId: number;
  25589. private _vertexArrayObjects;
  25590. private _updatable;
  25591. /** @hidden */
  25592. _positions: Nullable<Vector3[]>;
  25593. /**
  25594. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  25595. */
  25596. get boundingBias(): Vector2;
  25597. /**
  25598. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  25599. */
  25600. set boundingBias(value: Vector2);
  25601. /**
  25602. * Static function used to attach a new empty geometry to a mesh
  25603. * @param mesh defines the mesh to attach the geometry to
  25604. * @returns the new Geometry
  25605. */
  25606. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25607. /** Get the list of meshes using this geometry */
  25608. get meshes(): Mesh[];
  25609. /**
  25610. * If set to true (false by defaut), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  25611. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25612. */
  25613. useBoundingInfoFromGeometry: boolean;
  25614. /**
  25615. * Creates a new geometry
  25616. * @param id defines the unique ID
  25617. * @param scene defines the hosting scene
  25618. * @param vertexData defines the VertexData used to get geometry data
  25619. * @param updatable defines if geometry must be updatable (false by default)
  25620. * @param mesh defines the mesh that will be associated with the geometry
  25621. */
  25622. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25623. /**
  25624. * Gets the current extend of the geometry
  25625. */
  25626. get extend(): {
  25627. minimum: Vector3;
  25628. maximum: Vector3;
  25629. };
  25630. /**
  25631. * Gets the hosting scene
  25632. * @returns the hosting Scene
  25633. */
  25634. getScene(): Scene;
  25635. /**
  25636. * Gets the hosting engine
  25637. * @returns the hosting Engine
  25638. */
  25639. getEngine(): Engine;
  25640. /**
  25641. * Defines if the geometry is ready to use
  25642. * @returns true if the geometry is ready to be used
  25643. */
  25644. isReady(): boolean;
  25645. /**
  25646. * Gets a value indicating that the geometry should not be serialized
  25647. */
  25648. get doNotSerialize(): boolean;
  25649. /** @hidden */
  25650. _rebuild(): void;
  25651. /**
  25652. * Affects all geometry data in one call
  25653. * @param vertexData defines the geometry data
  25654. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25655. */
  25656. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25657. /**
  25658. * Set specific vertex data
  25659. * @param kind defines the data kind (Position, normal, etc...)
  25660. * @param data defines the vertex data to use
  25661. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25662. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25663. */
  25664. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25665. /**
  25666. * Removes a specific vertex data
  25667. * @param kind defines the data kind (Position, normal, etc...)
  25668. */
  25669. removeVerticesData(kind: string): void;
  25670. /**
  25671. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25672. * @param buffer defines the vertex buffer to use
  25673. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25674. */
  25675. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25676. /**
  25677. * Update a specific vertex buffer
  25678. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25679. * It will do nothing if the buffer is not updatable
  25680. * @param kind defines the data kind (Position, normal, etc...)
  25681. * @param data defines the data to use
  25682. * @param offset defines the offset in the target buffer where to store the data
  25683. * @param useBytes set to true if the offset is in bytes
  25684. */
  25685. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25686. /**
  25687. * Update a specific vertex buffer
  25688. * This function will create a new buffer if the current one is not updatable
  25689. * @param kind defines the data kind (Position, normal, etc...)
  25690. * @param data defines the data to use
  25691. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25692. */
  25693. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25694. private _updateBoundingInfo;
  25695. /** @hidden */
  25696. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25697. /**
  25698. * Gets total number of vertices
  25699. * @returns the total number of vertices
  25700. */
  25701. getTotalVertices(): number;
  25702. /**
  25703. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25704. * @param kind defines the data kind (Position, normal, etc...)
  25705. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25706. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25707. * @returns a float array containing vertex data
  25708. */
  25709. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25710. /**
  25711. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25712. * @param kind defines the data kind (Position, normal, etc...)
  25713. * @returns true if the vertex buffer with the specified kind is updatable
  25714. */
  25715. isVertexBufferUpdatable(kind: string): boolean;
  25716. /**
  25717. * Gets a specific vertex buffer
  25718. * @param kind defines the data kind (Position, normal, etc...)
  25719. * @returns a VertexBuffer
  25720. */
  25721. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25722. /**
  25723. * Returns all vertex buffers
  25724. * @return an object holding all vertex buffers indexed by kind
  25725. */
  25726. getVertexBuffers(): Nullable<{
  25727. [key: string]: VertexBuffer;
  25728. }>;
  25729. /**
  25730. * Gets a boolean indicating if specific vertex buffer is present
  25731. * @param kind defines the data kind (Position, normal, etc...)
  25732. * @returns true if data is present
  25733. */
  25734. isVerticesDataPresent(kind: string): boolean;
  25735. /**
  25736. * Gets a list of all attached data kinds (Position, normal, etc...)
  25737. * @returns a list of string containing all kinds
  25738. */
  25739. getVerticesDataKinds(): string[];
  25740. /**
  25741. * Update index buffer
  25742. * @param indices defines the indices to store in the index buffer
  25743. * @param offset defines the offset in the target buffer where to store the data
  25744. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  25745. */
  25746. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25747. /**
  25748. * Creates a new index buffer
  25749. * @param indices defines the indices to store in the index buffer
  25750. * @param totalVertices defines the total number of vertices (could be null)
  25751. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25752. */
  25753. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25754. /**
  25755. * Return the total number of indices
  25756. * @returns the total number of indices
  25757. */
  25758. getTotalIndices(): number;
  25759. /**
  25760. * Gets the index buffer array
  25761. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25762. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25763. * @returns the index buffer array
  25764. */
  25765. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25766. /**
  25767. * Gets the index buffer
  25768. * @return the index buffer
  25769. */
  25770. getIndexBuffer(): Nullable<DataBuffer>;
  25771. /** @hidden */
  25772. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25773. /**
  25774. * Release the associated resources for a specific mesh
  25775. * @param mesh defines the source mesh
  25776. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25777. */
  25778. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25779. /**
  25780. * Apply current geometry to a given mesh
  25781. * @param mesh defines the mesh to apply geometry to
  25782. */
  25783. applyToMesh(mesh: Mesh): void;
  25784. private _updateExtend;
  25785. private _applyToMesh;
  25786. private notifyUpdate;
  25787. /**
  25788. * Load the geometry if it was flagged as delay loaded
  25789. * @param scene defines the hosting scene
  25790. * @param onLoaded defines a callback called when the geometry is loaded
  25791. */
  25792. load(scene: Scene, onLoaded?: () => void): void;
  25793. private _queueLoad;
  25794. /**
  25795. * Invert the geometry to move from a right handed system to a left handed one.
  25796. */
  25797. toLeftHanded(): void;
  25798. /** @hidden */
  25799. _resetPointsArrayCache(): void;
  25800. /** @hidden */
  25801. _generatePointsArray(): boolean;
  25802. /**
  25803. * Gets a value indicating if the geometry is disposed
  25804. * @returns true if the geometry was disposed
  25805. */
  25806. isDisposed(): boolean;
  25807. private _disposeVertexArrayObjects;
  25808. /**
  25809. * Free all associated resources
  25810. */
  25811. dispose(): void;
  25812. /**
  25813. * Clone the current geometry into a new geometry
  25814. * @param id defines the unique ID of the new geometry
  25815. * @returns a new geometry object
  25816. */
  25817. copy(id: string): Geometry;
  25818. /**
  25819. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25820. * @return a JSON representation of the current geometry data (without the vertices data)
  25821. */
  25822. serialize(): any;
  25823. private toNumberArray;
  25824. /**
  25825. * Serialize all vertices data into a JSON oject
  25826. * @returns a JSON representation of the current geometry data
  25827. */
  25828. serializeVerticeData(): any;
  25829. /**
  25830. * Extracts a clone of a mesh geometry
  25831. * @param mesh defines the source mesh
  25832. * @param id defines the unique ID of the new geometry object
  25833. * @returns the new geometry object
  25834. */
  25835. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25836. /**
  25837. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25838. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25839. * Be aware Math.random() could cause collisions, but:
  25840. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  25841. * @returns a string containing a new GUID
  25842. */
  25843. static RandomId(): string;
  25844. /** @hidden */
  25845. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25846. private static _CleanMatricesWeights;
  25847. /**
  25848. * Create a new geometry from persisted data (Using .babylon file format)
  25849. * @param parsedVertexData defines the persisted data
  25850. * @param scene defines the hosting scene
  25851. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25852. * @returns the new geometry object
  25853. */
  25854. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25855. }
  25856. }
  25857. declare module BABYLON {
  25858. /**
  25859. * Define an interface for all classes that will get and set the data on vertices
  25860. */
  25861. export interface IGetSetVerticesData {
  25862. /**
  25863. * Gets a boolean indicating if specific vertex data is present
  25864. * @param kind defines the vertex data kind to use
  25865. * @returns true is data kind is present
  25866. */
  25867. isVerticesDataPresent(kind: string): boolean;
  25868. /**
  25869. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25870. * @param kind defines the data kind (Position, normal, etc...)
  25871. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25872. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25873. * @returns a float array containing vertex data
  25874. */
  25875. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25876. /**
  25877. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25878. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  25879. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25880. * @returns the indices array or an empty array if the mesh has no geometry
  25881. */
  25882. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25883. /**
  25884. * Set specific vertex data
  25885. * @param kind defines the data kind (Position, normal, etc...)
  25886. * @param data defines the vertex data to use
  25887. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25888. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25889. */
  25890. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25891. /**
  25892. * Update a specific associated vertex buffer
  25893. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25894. * - VertexBuffer.PositionKind
  25895. * - VertexBuffer.UVKind
  25896. * - VertexBuffer.UV2Kind
  25897. * - VertexBuffer.UV3Kind
  25898. * - VertexBuffer.UV4Kind
  25899. * - VertexBuffer.UV5Kind
  25900. * - VertexBuffer.UV6Kind
  25901. * - VertexBuffer.ColorKind
  25902. * - VertexBuffer.MatricesIndicesKind
  25903. * - VertexBuffer.MatricesIndicesExtraKind
  25904. * - VertexBuffer.MatricesWeightsKind
  25905. * - VertexBuffer.MatricesWeightsExtraKind
  25906. * @param data defines the data source
  25907. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25908. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  25909. */
  25910. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25911. /**
  25912. * Creates a new index buffer
  25913. * @param indices defines the indices to store in the index buffer
  25914. * @param totalVertices defines the total number of vertices (could be null)
  25915. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25916. */
  25917. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25918. }
  25919. /**
  25920. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25921. */
  25922. export class VertexData {
  25923. /**
  25924. * Mesh side orientation : usually the external or front surface
  25925. */
  25926. static readonly FRONTSIDE: number;
  25927. /**
  25928. * Mesh side orientation : usually the internal or back surface
  25929. */
  25930. static readonly BACKSIDE: number;
  25931. /**
  25932. * Mesh side orientation : both internal and external or front and back surfaces
  25933. */
  25934. static readonly DOUBLESIDE: number;
  25935. /**
  25936. * Mesh side orientation : by default, `FRONTSIDE`
  25937. */
  25938. static readonly DEFAULTSIDE: number;
  25939. /**
  25940. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25941. */
  25942. positions: Nullable<FloatArray>;
  25943. /**
  25944. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25945. */
  25946. normals: Nullable<FloatArray>;
  25947. /**
  25948. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25949. */
  25950. tangents: Nullable<FloatArray>;
  25951. /**
  25952. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25953. */
  25954. uvs: Nullable<FloatArray>;
  25955. /**
  25956. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25957. */
  25958. uvs2: Nullable<FloatArray>;
  25959. /**
  25960. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25961. */
  25962. uvs3: Nullable<FloatArray>;
  25963. /**
  25964. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25965. */
  25966. uvs4: Nullable<FloatArray>;
  25967. /**
  25968. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25969. */
  25970. uvs5: Nullable<FloatArray>;
  25971. /**
  25972. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25973. */
  25974. uvs6: Nullable<FloatArray>;
  25975. /**
  25976. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25977. */
  25978. colors: Nullable<FloatArray>;
  25979. /**
  25980. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  25981. */
  25982. matricesIndices: Nullable<FloatArray>;
  25983. /**
  25984. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25985. */
  25986. matricesWeights: Nullable<FloatArray>;
  25987. /**
  25988. * An array extending the number of possible indices
  25989. */
  25990. matricesIndicesExtra: Nullable<FloatArray>;
  25991. /**
  25992. * An array extending the number of possible weights when the number of indices is extended
  25993. */
  25994. matricesWeightsExtra: Nullable<FloatArray>;
  25995. /**
  25996. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25997. */
  25998. indices: Nullable<IndicesArray>;
  25999. /**
  26000. * Uses the passed data array to set the set the values for the specified kind of data
  26001. * @param data a linear array of floating numbers
  26002. * @param kind the type of data that is being set, eg positions, colors etc
  26003. */
  26004. set(data: FloatArray, kind: string): void;
  26005. /**
  26006. * Associates the vertexData to the passed Mesh.
  26007. * Sets it as updatable or not (default `false`)
  26008. * @param mesh the mesh the vertexData is applied to
  26009. * @param updatable when used and having the value true allows new data to update the vertexData
  26010. * @returns the VertexData
  26011. */
  26012. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26013. /**
  26014. * Associates the vertexData to the passed Geometry.
  26015. * Sets it as updatable or not (default `false`)
  26016. * @param geometry the geometry the vertexData is applied to
  26017. * @param updatable when used and having the value true allows new data to update the vertexData
  26018. * @returns VertexData
  26019. */
  26020. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26021. /**
  26022. * Updates the associated mesh
  26023. * @param mesh the mesh to be updated
  26024. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26025. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  26026. * @returns VertexData
  26027. */
  26028. updateMesh(mesh: Mesh): VertexData;
  26029. /**
  26030. * Updates the associated geometry
  26031. * @param geometry the geometry to be updated
  26032. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26033. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  26034. * @returns VertexData.
  26035. */
  26036. updateGeometry(geometry: Geometry): VertexData;
  26037. private _applyTo;
  26038. private _update;
  26039. /**
  26040. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26041. * @param matrix the transforming matrix
  26042. * @returns the VertexData
  26043. */
  26044. transform(matrix: Matrix): VertexData;
  26045. /**
  26046. * Merges the passed VertexData into the current one
  26047. * @param other the VertexData to be merged into the current one
  26048. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26049. * @returns the modified VertexData
  26050. */
  26051. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26052. private _mergeElement;
  26053. private _validate;
  26054. /**
  26055. * Serializes the VertexData
  26056. * @returns a serialized object
  26057. */
  26058. serialize(): any;
  26059. /**
  26060. * Extracts the vertexData from a mesh
  26061. * @param mesh the mesh from which to extract the VertexData
  26062. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26063. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26064. * @returns the object VertexData associated to the passed mesh
  26065. */
  26066. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26067. /**
  26068. * Extracts the vertexData from the geometry
  26069. * @param geometry the geometry from which to extract the VertexData
  26070. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26071. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26072. * @returns the object VertexData associated to the passed mesh
  26073. */
  26074. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26075. private static _ExtractFrom;
  26076. /**
  26077. * Creates the VertexData for a Ribbon
  26078. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26079. * * pathArray array of paths, each of which an array of successive Vector3
  26080. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26081. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26082. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  26083. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26084. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26085. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26086. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26087. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26088. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26089. * @returns the VertexData of the ribbon
  26090. */
  26091. static CreateRibbon(options: {
  26092. pathArray: Vector3[][];
  26093. closeArray?: boolean;
  26094. closePath?: boolean;
  26095. offset?: number;
  26096. sideOrientation?: number;
  26097. frontUVs?: Vector4;
  26098. backUVs?: Vector4;
  26099. invertUV?: boolean;
  26100. uvs?: Vector2[];
  26101. colors?: Color4[];
  26102. }): VertexData;
  26103. /**
  26104. * Creates the VertexData for a box
  26105. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26106. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26107. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26108. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26109. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26110. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26111. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26112. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26113. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26114. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26115. * @returns the VertexData of the box
  26116. */
  26117. static CreateBox(options: {
  26118. size?: number;
  26119. width?: number;
  26120. height?: number;
  26121. depth?: number;
  26122. faceUV?: Vector4[];
  26123. faceColors?: Color4[];
  26124. sideOrientation?: number;
  26125. frontUVs?: Vector4;
  26126. backUVs?: Vector4;
  26127. }): VertexData;
  26128. /**
  26129. * Creates the VertexData for a tiled box
  26130. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26131. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26132. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26133. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26134. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26135. * @returns the VertexData of the box
  26136. */
  26137. static CreateTiledBox(options: {
  26138. pattern?: number;
  26139. width?: number;
  26140. height?: number;
  26141. depth?: number;
  26142. tileSize?: number;
  26143. tileWidth?: number;
  26144. tileHeight?: number;
  26145. alignHorizontal?: number;
  26146. alignVertical?: number;
  26147. faceUV?: Vector4[];
  26148. faceColors?: Color4[];
  26149. sideOrientation?: number;
  26150. }): VertexData;
  26151. /**
  26152. * Creates the VertexData for a tiled plane
  26153. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26154. * * pattern a limited pattern arrangement depending on the number
  26155. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26156. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26157. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26158. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26159. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26160. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26161. * @returns the VertexData of the tiled plane
  26162. */
  26163. static CreateTiledPlane(options: {
  26164. pattern?: number;
  26165. tileSize?: number;
  26166. tileWidth?: number;
  26167. tileHeight?: number;
  26168. size?: number;
  26169. width?: number;
  26170. height?: number;
  26171. alignHorizontal?: number;
  26172. alignVertical?: number;
  26173. sideOrientation?: number;
  26174. frontUVs?: Vector4;
  26175. backUVs?: Vector4;
  26176. }): VertexData;
  26177. /**
  26178. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26179. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26180. * * segments sets the number of horizontal strips optional, default 32
  26181. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26182. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26183. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26184. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26185. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  26186. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  26187. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26188. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26189. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26190. * @returns the VertexData of the ellipsoid
  26191. */
  26192. static CreateSphere(options: {
  26193. segments?: number;
  26194. diameter?: number;
  26195. diameterX?: number;
  26196. diameterY?: number;
  26197. diameterZ?: number;
  26198. arc?: number;
  26199. slice?: number;
  26200. sideOrientation?: number;
  26201. frontUVs?: Vector4;
  26202. backUVs?: Vector4;
  26203. }): VertexData;
  26204. /**
  26205. * Creates the VertexData for a cylinder, cone or prism
  26206. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26207. * * height sets the height (y direction) of the cylinder, optional, default 2
  26208. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26209. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26210. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26211. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26212. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26213. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  26214. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26215. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26216. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26217. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26218. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26219. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26220. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26221. * @returns the VertexData of the cylinder, cone or prism
  26222. */
  26223. static CreateCylinder(options: {
  26224. height?: number;
  26225. diameterTop?: number;
  26226. diameterBottom?: number;
  26227. diameter?: number;
  26228. tessellation?: number;
  26229. subdivisions?: number;
  26230. arc?: number;
  26231. faceColors?: Color4[];
  26232. faceUV?: Vector4[];
  26233. hasRings?: boolean;
  26234. enclose?: boolean;
  26235. sideOrientation?: number;
  26236. frontUVs?: Vector4;
  26237. backUVs?: Vector4;
  26238. }): VertexData;
  26239. /**
  26240. * Creates the VertexData for a torus
  26241. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26242. * * diameter the diameter of the torus, optional default 1
  26243. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26244. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26245. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26246. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26247. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26248. * @returns the VertexData of the torus
  26249. */
  26250. static CreateTorus(options: {
  26251. diameter?: number;
  26252. thickness?: number;
  26253. tessellation?: number;
  26254. sideOrientation?: number;
  26255. frontUVs?: Vector4;
  26256. backUVs?: Vector4;
  26257. }): VertexData;
  26258. /**
  26259. * Creates the VertexData of the LineSystem
  26260. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26261. * - lines an array of lines, each line being an array of successive Vector3
  26262. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26263. * @returns the VertexData of the LineSystem
  26264. */
  26265. static CreateLineSystem(options: {
  26266. lines: Vector3[][];
  26267. colors?: Nullable<Color4[][]>;
  26268. }): VertexData;
  26269. /**
  26270. * Create the VertexData for a DashedLines
  26271. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26272. * - points an array successive Vector3
  26273. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26274. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26275. * - dashNb the intended total number of dashes, optional, default 200
  26276. * @returns the VertexData for the DashedLines
  26277. */
  26278. static CreateDashedLines(options: {
  26279. points: Vector3[];
  26280. dashSize?: number;
  26281. gapSize?: number;
  26282. dashNb?: number;
  26283. }): VertexData;
  26284. /**
  26285. * Creates the VertexData for a Ground
  26286. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26287. * - width the width (x direction) of the ground, optional, default 1
  26288. * - height the height (z direction) of the ground, optional, default 1
  26289. * - subdivisions the number of subdivisions per side, optional, default 1
  26290. * @returns the VertexData of the Ground
  26291. */
  26292. static CreateGround(options: {
  26293. width?: number;
  26294. height?: number;
  26295. subdivisions?: number;
  26296. subdivisionsX?: number;
  26297. subdivisionsY?: number;
  26298. }): VertexData;
  26299. /**
  26300. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26301. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26302. * * xmin the ground minimum X coordinate, optional, default -1
  26303. * * zmin the ground minimum Z coordinate, optional, default -1
  26304. * * xmax the ground maximum X coordinate, optional, default 1
  26305. * * zmax the ground maximum Z coordinate, optional, default 1
  26306. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  26307. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  26308. * @returns the VertexData of the TiledGround
  26309. */
  26310. static CreateTiledGround(options: {
  26311. xmin: number;
  26312. zmin: number;
  26313. xmax: number;
  26314. zmax: number;
  26315. subdivisions?: {
  26316. w: number;
  26317. h: number;
  26318. };
  26319. precision?: {
  26320. w: number;
  26321. h: number;
  26322. };
  26323. }): VertexData;
  26324. /**
  26325. * Creates the VertexData of the Ground designed from a heightmap
  26326. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26327. * * width the width (x direction) of the ground
  26328. * * height the height (z direction) of the ground
  26329. * * subdivisions the number of subdivisions per side
  26330. * * minHeight the minimum altitude on the ground, optional, default 0
  26331. * * maxHeight the maximum altitude on the ground, optional default 1
  26332. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26333. * * buffer the array holding the image color data
  26334. * * bufferWidth the width of image
  26335. * * bufferHeight the height of image
  26336. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26337. * @returns the VertexData of the Ground designed from a heightmap
  26338. */
  26339. static CreateGroundFromHeightMap(options: {
  26340. width: number;
  26341. height: number;
  26342. subdivisions: number;
  26343. minHeight: number;
  26344. maxHeight: number;
  26345. colorFilter: Color3;
  26346. buffer: Uint8Array;
  26347. bufferWidth: number;
  26348. bufferHeight: number;
  26349. alphaFilter: number;
  26350. }): VertexData;
  26351. /**
  26352. * Creates the VertexData for a Plane
  26353. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26354. * * size sets the width and height of the plane to the value of size, optional default 1
  26355. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26356. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26357. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26358. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26359. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26360. * @returns the VertexData of the box
  26361. */
  26362. static CreatePlane(options: {
  26363. size?: number;
  26364. width?: number;
  26365. height?: number;
  26366. sideOrientation?: number;
  26367. frontUVs?: Vector4;
  26368. backUVs?: Vector4;
  26369. }): VertexData;
  26370. /**
  26371. * Creates the VertexData of the Disc or regular Polygon
  26372. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26373. * * radius the radius of the disc, optional default 0.5
  26374. * * tessellation the number of polygon sides, optional, default 64
  26375. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  26376. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26377. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26378. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26379. * @returns the VertexData of the box
  26380. */
  26381. static CreateDisc(options: {
  26382. radius?: number;
  26383. tessellation?: number;
  26384. arc?: number;
  26385. sideOrientation?: number;
  26386. frontUVs?: Vector4;
  26387. backUVs?: Vector4;
  26388. }): VertexData;
  26389. /**
  26390. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26391. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26392. * @param polygon a mesh built from polygonTriangulation.build()
  26393. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26394. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26395. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26396. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26397. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26398. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26399. * @returns the VertexData of the Polygon
  26400. */
  26401. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26402. /**
  26403. * Creates the VertexData of the IcoSphere
  26404. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26405. * * radius the radius of the IcoSphere, optional default 1
  26406. * * radiusX allows stretching in the x direction, optional, default radius
  26407. * * radiusY allows stretching in the y direction, optional, default radius
  26408. * * radiusZ allows stretching in the z direction, optional, default radius
  26409. * * flat when true creates a flat shaded mesh, optional, default true
  26410. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26411. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26412. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26413. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26414. * @returns the VertexData of the IcoSphere
  26415. */
  26416. static CreateIcoSphere(options: {
  26417. radius?: number;
  26418. radiusX?: number;
  26419. radiusY?: number;
  26420. radiusZ?: number;
  26421. flat?: boolean;
  26422. subdivisions?: number;
  26423. sideOrientation?: number;
  26424. frontUVs?: Vector4;
  26425. backUVs?: Vector4;
  26426. }): VertexData;
  26427. /**
  26428. * Creates the VertexData for a Polyhedron
  26429. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26430. * * type provided types are:
  26431. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26432. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  26433. * * size the size of the IcoSphere, optional default 1
  26434. * * sizeX allows stretching in the x direction, optional, default size
  26435. * * sizeY allows stretching in the y direction, optional, default size
  26436. * * sizeZ allows stretching in the z direction, optional, default size
  26437. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  26438. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26439. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26440. * * flat when true creates a flat shaded mesh, optional, default true
  26441. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26442. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26443. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26444. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26445. * @returns the VertexData of the Polyhedron
  26446. */
  26447. static CreatePolyhedron(options: {
  26448. type?: number;
  26449. size?: number;
  26450. sizeX?: number;
  26451. sizeY?: number;
  26452. sizeZ?: number;
  26453. custom?: any;
  26454. faceUV?: Vector4[];
  26455. faceColors?: Color4[];
  26456. flat?: boolean;
  26457. sideOrientation?: number;
  26458. frontUVs?: Vector4;
  26459. backUVs?: Vector4;
  26460. }): VertexData;
  26461. /**
  26462. * Creates the VertexData for a TorusKnot
  26463. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26464. * * radius the radius of the torus knot, optional, default 2
  26465. * * tube the thickness of the tube, optional, default 0.5
  26466. * * radialSegments the number of sides on each tube segments, optional, default 32
  26467. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26468. * * p the number of windings around the z axis, optional, default 2
  26469. * * q the number of windings around the x axis, optional, default 3
  26470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26471. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26472. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26473. * @returns the VertexData of the Torus Knot
  26474. */
  26475. static CreateTorusKnot(options: {
  26476. radius?: number;
  26477. tube?: number;
  26478. radialSegments?: number;
  26479. tubularSegments?: number;
  26480. p?: number;
  26481. q?: number;
  26482. sideOrientation?: number;
  26483. frontUVs?: Vector4;
  26484. backUVs?: Vector4;
  26485. }): VertexData;
  26486. /**
  26487. * Compute normals for given positions and indices
  26488. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26489. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26490. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26491. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26492. * * facetNormals : optional array of facet normals (vector3)
  26493. * * facetPositions : optional array of facet positions (vector3)
  26494. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26495. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26496. * * bInfo : optional bounding info, required for facetPartitioning computation
  26497. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26498. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26499. * * useRightHandedSystem: optional boolean to for right handed system computation
  26500. * * depthSort : optional boolean to enable the facet depth sort computation
  26501. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26502. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26503. */
  26504. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26505. facetNormals?: any;
  26506. facetPositions?: any;
  26507. facetPartitioning?: any;
  26508. ratio?: number;
  26509. bInfo?: any;
  26510. bbSize?: Vector3;
  26511. subDiv?: any;
  26512. useRightHandedSystem?: boolean;
  26513. depthSort?: boolean;
  26514. distanceTo?: Vector3;
  26515. depthSortedFacets?: any;
  26516. }): void;
  26517. /** @hidden */
  26518. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26519. /**
  26520. * Applies VertexData created from the imported parameters to the geometry
  26521. * @param parsedVertexData the parsed data from an imported file
  26522. * @param geometry the geometry to apply the VertexData to
  26523. */
  26524. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26525. }
  26526. }
  26527. declare module BABYLON {
  26528. /**
  26529. * Defines a target to use with MorphTargetManager
  26530. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26531. */
  26532. export class MorphTarget implements IAnimatable {
  26533. /** defines the name of the target */
  26534. name: string;
  26535. /**
  26536. * Gets or sets the list of animations
  26537. */
  26538. animations: Animation[];
  26539. private _scene;
  26540. private _positions;
  26541. private _normals;
  26542. private _tangents;
  26543. private _uvs;
  26544. private _influence;
  26545. private _uniqueId;
  26546. /**
  26547. * Observable raised when the influence changes
  26548. */
  26549. onInfluenceChanged: Observable<boolean>;
  26550. /** @hidden */
  26551. _onDataLayoutChanged: Observable<void>;
  26552. /**
  26553. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26554. */
  26555. get influence(): number;
  26556. set influence(influence: number);
  26557. /**
  26558. * Gets or sets the id of the morph Target
  26559. */
  26560. id: string;
  26561. private _animationPropertiesOverride;
  26562. /**
  26563. * Gets or sets the animation properties override
  26564. */
  26565. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26566. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26567. /**
  26568. * Creates a new MorphTarget
  26569. * @param name defines the name of the target
  26570. * @param influence defines the influence to use
  26571. * @param scene defines the scene the morphtarget belongs to
  26572. */
  26573. constructor(
  26574. /** defines the name of the target */
  26575. name: string, influence?: number, scene?: Nullable<Scene>);
  26576. /**
  26577. * Gets the unique ID of this manager
  26578. */
  26579. get uniqueId(): number;
  26580. /**
  26581. * Gets a boolean defining if the target contains position data
  26582. */
  26583. get hasPositions(): boolean;
  26584. /**
  26585. * Gets a boolean defining if the target contains normal data
  26586. */
  26587. get hasNormals(): boolean;
  26588. /**
  26589. * Gets a boolean defining if the target contains tangent data
  26590. */
  26591. get hasTangents(): boolean;
  26592. /**
  26593. * Gets a boolean defining if the target contains texture coordinates data
  26594. */
  26595. get hasUVs(): boolean;
  26596. /**
  26597. * Affects position data to this target
  26598. * @param data defines the position data to use
  26599. */
  26600. setPositions(data: Nullable<FloatArray>): void;
  26601. /**
  26602. * Gets the position data stored in this target
  26603. * @returns a FloatArray containing the position data (or null if not present)
  26604. */
  26605. getPositions(): Nullable<FloatArray>;
  26606. /**
  26607. * Affects normal data to this target
  26608. * @param data defines the normal data to use
  26609. */
  26610. setNormals(data: Nullable<FloatArray>): void;
  26611. /**
  26612. * Gets the normal data stored in this target
  26613. * @returns a FloatArray containing the normal data (or null if not present)
  26614. */
  26615. getNormals(): Nullable<FloatArray>;
  26616. /**
  26617. * Affects tangent data to this target
  26618. * @param data defines the tangent data to use
  26619. */
  26620. setTangents(data: Nullable<FloatArray>): void;
  26621. /**
  26622. * Gets the tangent data stored in this target
  26623. * @returns a FloatArray containing the tangent data (or null if not present)
  26624. */
  26625. getTangents(): Nullable<FloatArray>;
  26626. /**
  26627. * Affects texture coordinates data to this target
  26628. * @param data defines the texture coordinates data to use
  26629. */
  26630. setUVs(data: Nullable<FloatArray>): void;
  26631. /**
  26632. * Gets the texture coordinates data stored in this target
  26633. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26634. */
  26635. getUVs(): Nullable<FloatArray>;
  26636. /**
  26637. * Clone the current target
  26638. * @returns a new MorphTarget
  26639. */
  26640. clone(): MorphTarget;
  26641. /**
  26642. * Serializes the current target into a Serialization object
  26643. * @returns the serialized object
  26644. */
  26645. serialize(): any;
  26646. /**
  26647. * Returns the string "MorphTarget"
  26648. * @returns "MorphTarget"
  26649. */
  26650. getClassName(): string;
  26651. /**
  26652. * Creates a new target from serialized data
  26653. * @param serializationObject defines the serialized data to use
  26654. * @returns a new MorphTarget
  26655. */
  26656. static Parse(serializationObject: any): MorphTarget;
  26657. /**
  26658. * Creates a MorphTarget from mesh data
  26659. * @param mesh defines the source mesh
  26660. * @param name defines the name to use for the new target
  26661. * @param influence defines the influence to attach to the target
  26662. * @returns a new MorphTarget
  26663. */
  26664. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26665. }
  26666. }
  26667. declare module BABYLON {
  26668. /**
  26669. * This class is used to deform meshes using morphing between different targets
  26670. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26671. */
  26672. export class MorphTargetManager {
  26673. private _targets;
  26674. private _targetInfluenceChangedObservers;
  26675. private _targetDataLayoutChangedObservers;
  26676. private _activeTargets;
  26677. private _scene;
  26678. private _influences;
  26679. private _supportsNormals;
  26680. private _supportsTangents;
  26681. private _supportsUVs;
  26682. private _vertexCount;
  26683. private _uniqueId;
  26684. private _tempInfluences;
  26685. /**
  26686. * Gets or sets a boolean indicating if normals must be morphed
  26687. */
  26688. enableNormalMorphing: boolean;
  26689. /**
  26690. * Gets or sets a boolean indicating if tangents must be morphed
  26691. */
  26692. enableTangentMorphing: boolean;
  26693. /**
  26694. * Gets or sets a boolean indicating if UV must be morphed
  26695. */
  26696. enableUVMorphing: boolean;
  26697. /**
  26698. * Creates a new MorphTargetManager
  26699. * @param scene defines the current scene
  26700. */
  26701. constructor(scene?: Nullable<Scene>);
  26702. /**
  26703. * Gets the unique ID of this manager
  26704. */
  26705. get uniqueId(): number;
  26706. /**
  26707. * Gets the number of vertices handled by this manager
  26708. */
  26709. get vertexCount(): number;
  26710. /**
  26711. * Gets a boolean indicating if this manager supports morphing of normals
  26712. */
  26713. get supportsNormals(): boolean;
  26714. /**
  26715. * Gets a boolean indicating if this manager supports morphing of tangents
  26716. */
  26717. get supportsTangents(): boolean;
  26718. /**
  26719. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26720. */
  26721. get supportsUVs(): boolean;
  26722. /**
  26723. * Gets the number of targets stored in this manager
  26724. */
  26725. get numTargets(): number;
  26726. /**
  26727. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26728. */
  26729. get numInfluencers(): number;
  26730. /**
  26731. * Gets the list of influences (one per target)
  26732. */
  26733. get influences(): Float32Array;
  26734. /**
  26735. * Gets the active target at specified index. An active target is a target with an influence > 0
  26736. * @param index defines the index to check
  26737. * @returns the requested target
  26738. */
  26739. getActiveTarget(index: number): MorphTarget;
  26740. /**
  26741. * Gets the target at specified index
  26742. * @param index defines the index to check
  26743. * @returns the requested target
  26744. */
  26745. getTarget(index: number): MorphTarget;
  26746. /**
  26747. * Add a new target to this manager
  26748. * @param target defines the target to add
  26749. */
  26750. addTarget(target: MorphTarget): void;
  26751. /**
  26752. * Removes a target from the manager
  26753. * @param target defines the target to remove
  26754. */
  26755. removeTarget(target: MorphTarget): void;
  26756. /**
  26757. * Clone the current manager
  26758. * @returns a new MorphTargetManager
  26759. */
  26760. clone(): MorphTargetManager;
  26761. /**
  26762. * Serializes the current manager into a Serialization object
  26763. * @returns the serialized object
  26764. */
  26765. serialize(): any;
  26766. private _syncActiveTargets;
  26767. /**
  26768. * Syncrhonize the targets with all the meshes using this morph target manager
  26769. */
  26770. synchronize(): void;
  26771. /**
  26772. * Creates a new MorphTargetManager from serialized data
  26773. * @param serializationObject defines the serialized data
  26774. * @param scene defines the hosting scene
  26775. * @returns the new MorphTargetManager
  26776. */
  26777. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26778. }
  26779. }
  26780. declare module BABYLON {
  26781. /**
  26782. * Class used to represent a specific level of detail of a mesh
  26783. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26784. */
  26785. export class MeshLODLevel {
  26786. /** Defines the distance where this level should start being displayed */
  26787. distance: number;
  26788. /** Defines the mesh to use to render this level */
  26789. mesh: Nullable<Mesh>;
  26790. /**
  26791. * Creates a new LOD level
  26792. * @param distance defines the distance where this level should star being displayed
  26793. * @param mesh defines the mesh to use to render this level
  26794. */
  26795. constructor(
  26796. /** Defines the distance where this level should start being displayed */
  26797. distance: number,
  26798. /** Defines the mesh to use to render this level */
  26799. mesh: Nullable<Mesh>);
  26800. }
  26801. }
  26802. declare module BABYLON {
  26803. /**
  26804. * Helper class used to generate a canvas to manipulate images
  26805. */
  26806. export class CanvasGenerator {
  26807. /**
  26808. * Create a new canvas (or offscreen canvas depending on the context)
  26809. * @param width defines the expected width
  26810. * @param height defines the expected height
  26811. * @return a new canvas or offscreen canvas
  26812. */
  26813. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26814. }
  26815. }
  26816. declare module BABYLON {
  26817. /**
  26818. * Mesh representing the gorund
  26819. */
  26820. export class GroundMesh extends Mesh {
  26821. /** If octree should be generated */
  26822. generateOctree: boolean;
  26823. private _heightQuads;
  26824. /** @hidden */
  26825. _subdivisionsX: number;
  26826. /** @hidden */
  26827. _subdivisionsY: number;
  26828. /** @hidden */
  26829. _width: number;
  26830. /** @hidden */
  26831. _height: number;
  26832. /** @hidden */
  26833. _minX: number;
  26834. /** @hidden */
  26835. _maxX: number;
  26836. /** @hidden */
  26837. _minZ: number;
  26838. /** @hidden */
  26839. _maxZ: number;
  26840. constructor(name: string, scene: Scene);
  26841. /**
  26842. * "GroundMesh"
  26843. * @returns "GroundMesh"
  26844. */
  26845. getClassName(): string;
  26846. /**
  26847. * The minimum of x and y subdivisions
  26848. */
  26849. get subdivisions(): number;
  26850. /**
  26851. * X subdivisions
  26852. */
  26853. get subdivisionsX(): number;
  26854. /**
  26855. * Y subdivisions
  26856. */
  26857. get subdivisionsY(): number;
  26858. /**
  26859. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26860. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26861. * @param chunksCount the number of subdivisions for x and y
  26862. * @param octreeBlocksSize (Default: 32)
  26863. */
  26864. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26865. /**
  26866. * Returns a height (y) value in the Worl system :
  26867. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26868. * @param x x coordinate
  26869. * @param z z coordinate
  26870. * @returns the ground y position if (x, z) are outside the ground surface.
  26871. */
  26872. getHeightAtCoordinates(x: number, z: number): number;
  26873. /**
  26874. * Returns a normalized vector (Vector3) orthogonal to the ground
  26875. * at the ground coordinates (x, z) expressed in the World system.
  26876. * @param x x coordinate
  26877. * @param z z coordinate
  26878. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26879. */
  26880. getNormalAtCoordinates(x: number, z: number): Vector3;
  26881. /**
  26882. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26883. * at the ground coordinates (x, z) expressed in the World system.
  26884. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26885. * @param x x coordinate
  26886. * @param z z coordinate
  26887. * @param ref vector to store the result
  26888. * @returns the GroundMesh.
  26889. */
  26890. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26891. /**
  26892. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26893. * if the ground has been updated.
  26894. * This can be used in the render loop.
  26895. * @returns the GroundMesh.
  26896. */
  26897. updateCoordinateHeights(): GroundMesh;
  26898. private _getFacetAt;
  26899. private _initHeightQuads;
  26900. private _computeHeightQuads;
  26901. /**
  26902. * Serializes this ground mesh
  26903. * @param serializationObject object to write serialization to
  26904. */
  26905. serialize(serializationObject: any): void;
  26906. /**
  26907. * Parses a serialized ground mesh
  26908. * @param parsedMesh the serialized mesh
  26909. * @param scene the scene to create the ground mesh in
  26910. * @returns the created ground mesh
  26911. */
  26912. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26913. }
  26914. }
  26915. declare module BABYLON {
  26916. /**
  26917. * Interface for Physics-Joint data
  26918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26919. */
  26920. export interface PhysicsJointData {
  26921. /**
  26922. * The main pivot of the joint
  26923. */
  26924. mainPivot?: Vector3;
  26925. /**
  26926. * The connected pivot of the joint
  26927. */
  26928. connectedPivot?: Vector3;
  26929. /**
  26930. * The main axis of the joint
  26931. */
  26932. mainAxis?: Vector3;
  26933. /**
  26934. * The connected axis of the joint
  26935. */
  26936. connectedAxis?: Vector3;
  26937. /**
  26938. * The collision of the joint
  26939. */
  26940. collision?: boolean;
  26941. /**
  26942. * Native Oimo/Cannon/Energy data
  26943. */
  26944. nativeParams?: any;
  26945. }
  26946. /**
  26947. * This is a holder class for the physics joint created by the physics plugin
  26948. * It holds a set of functions to control the underlying joint
  26949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26950. */
  26951. export class PhysicsJoint {
  26952. /**
  26953. * The type of the physics joint
  26954. */
  26955. type: number;
  26956. /**
  26957. * The data for the physics joint
  26958. */
  26959. jointData: PhysicsJointData;
  26960. private _physicsJoint;
  26961. protected _physicsPlugin: IPhysicsEnginePlugin;
  26962. /**
  26963. * Initializes the physics joint
  26964. * @param type The type of the physics joint
  26965. * @param jointData The data for the physics joint
  26966. */
  26967. constructor(
  26968. /**
  26969. * The type of the physics joint
  26970. */
  26971. type: number,
  26972. /**
  26973. * The data for the physics joint
  26974. */
  26975. jointData: PhysicsJointData);
  26976. /**
  26977. * Gets the physics joint
  26978. */
  26979. get physicsJoint(): any;
  26980. /**
  26981. * Sets the physics joint
  26982. */
  26983. set physicsJoint(newJoint: any);
  26984. /**
  26985. * Sets the physics plugin
  26986. */
  26987. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26988. /**
  26989. * Execute a function that is physics-plugin specific.
  26990. * @param {Function} func the function that will be executed.
  26991. * It accepts two parameters: the physics world and the physics joint
  26992. */
  26993. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26994. /**
  26995. * Distance-Joint type
  26996. */
  26997. static DistanceJoint: number;
  26998. /**
  26999. * Hinge-Joint type
  27000. */
  27001. static HingeJoint: number;
  27002. /**
  27003. * Ball-and-Socket joint type
  27004. */
  27005. static BallAndSocketJoint: number;
  27006. /**
  27007. * Wheel-Joint type
  27008. */
  27009. static WheelJoint: number;
  27010. /**
  27011. * Slider-Joint type
  27012. */
  27013. static SliderJoint: number;
  27014. /**
  27015. * Prismatic-Joint type
  27016. */
  27017. static PrismaticJoint: number;
  27018. /**
  27019. * Universal-Joint type
  27020. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27021. */
  27022. static UniversalJoint: number;
  27023. /**
  27024. * Hinge-Joint 2 type
  27025. */
  27026. static Hinge2Joint: number;
  27027. /**
  27028. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27029. */
  27030. static PointToPointJoint: number;
  27031. /**
  27032. * Spring-Joint type
  27033. */
  27034. static SpringJoint: number;
  27035. /**
  27036. * Lock-Joint type
  27037. */
  27038. static LockJoint: number;
  27039. }
  27040. /**
  27041. * A class representing a physics distance joint
  27042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27043. */
  27044. export class DistanceJoint extends PhysicsJoint {
  27045. /**
  27046. *
  27047. * @param jointData The data for the Distance-Joint
  27048. */
  27049. constructor(jointData: DistanceJointData);
  27050. /**
  27051. * Update the predefined distance.
  27052. * @param maxDistance The maximum preferred distance
  27053. * @param minDistance The minimum preferred distance
  27054. */
  27055. updateDistance(maxDistance: number, minDistance?: number): void;
  27056. }
  27057. /**
  27058. * Represents a Motor-Enabled Joint
  27059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27060. */
  27061. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27062. /**
  27063. * Initializes the Motor-Enabled Joint
  27064. * @param type The type of the joint
  27065. * @param jointData The physica joint data for the joint
  27066. */
  27067. constructor(type: number, jointData: PhysicsJointData);
  27068. /**
  27069. * Set the motor values.
  27070. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27071. * @param force the force to apply
  27072. * @param maxForce max force for this motor.
  27073. */
  27074. setMotor(force?: number, maxForce?: number): void;
  27075. /**
  27076. * Set the motor's limits.
  27077. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27078. * @param upperLimit The upper limit of the motor
  27079. * @param lowerLimit The lower limit of the motor
  27080. */
  27081. setLimit(upperLimit: number, lowerLimit?: number): void;
  27082. }
  27083. /**
  27084. * This class represents a single physics Hinge-Joint
  27085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27086. */
  27087. export class HingeJoint extends MotorEnabledJoint {
  27088. /**
  27089. * Initializes the Hinge-Joint
  27090. * @param jointData The joint data for the Hinge-Joint
  27091. */
  27092. constructor(jointData: PhysicsJointData);
  27093. /**
  27094. * Set the motor values.
  27095. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27096. * @param {number} force the force to apply
  27097. * @param {number} maxForce max force for this motor.
  27098. */
  27099. setMotor(force?: number, maxForce?: number): void;
  27100. /**
  27101. * Set the motor's limits.
  27102. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27103. * @param upperLimit The upper limit of the motor
  27104. * @param lowerLimit The lower limit of the motor
  27105. */
  27106. setLimit(upperLimit: number, lowerLimit?: number): void;
  27107. }
  27108. /**
  27109. * This class represents a dual hinge physics joint (same as wheel joint)
  27110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27111. */
  27112. export class Hinge2Joint extends MotorEnabledJoint {
  27113. /**
  27114. * Initializes the Hinge2-Joint
  27115. * @param jointData The joint data for the Hinge2-Joint
  27116. */
  27117. constructor(jointData: PhysicsJointData);
  27118. /**
  27119. * Set the motor values.
  27120. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27121. * @param {number} targetSpeed the speed the motor is to reach
  27122. * @param {number} maxForce max force for this motor.
  27123. * @param {motorIndex} the motor's index, 0 or 1.
  27124. */
  27125. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27126. /**
  27127. * Set the motor limits.
  27128. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27129. * @param {number} upperLimit the upper limit
  27130. * @param {number} lowerLimit lower limit
  27131. * @param {motorIndex} the motor's index, 0 or 1.
  27132. */
  27133. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27134. }
  27135. /**
  27136. * Interface for a motor enabled joint
  27137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27138. */
  27139. export interface IMotorEnabledJoint {
  27140. /**
  27141. * Physics joint
  27142. */
  27143. physicsJoint: any;
  27144. /**
  27145. * Sets the motor of the motor-enabled joint
  27146. * @param force The force of the motor
  27147. * @param maxForce The maximum force of the motor
  27148. * @param motorIndex The index of the motor
  27149. */
  27150. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27151. /**
  27152. * Sets the limit of the motor
  27153. * @param upperLimit The upper limit of the motor
  27154. * @param lowerLimit The lower limit of the motor
  27155. * @param motorIndex The index of the motor
  27156. */
  27157. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27158. }
  27159. /**
  27160. * Joint data for a Distance-Joint
  27161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27162. */
  27163. export interface DistanceJointData extends PhysicsJointData {
  27164. /**
  27165. * Max distance the 2 joint objects can be apart
  27166. */
  27167. maxDistance: number;
  27168. }
  27169. /**
  27170. * Joint data from a spring joint
  27171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27172. */
  27173. export interface SpringJointData extends PhysicsJointData {
  27174. /**
  27175. * Length of the spring
  27176. */
  27177. length: number;
  27178. /**
  27179. * Stiffness of the spring
  27180. */
  27181. stiffness: number;
  27182. /**
  27183. * Damping of the spring
  27184. */
  27185. damping: number;
  27186. /** this callback will be called when applying the force to the impostors. */
  27187. forceApplicationCallback: () => void;
  27188. }
  27189. }
  27190. declare module BABYLON {
  27191. /**
  27192. * Holds the data for the raycast result
  27193. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27194. */
  27195. export class PhysicsRaycastResult {
  27196. private _hasHit;
  27197. private _hitDistance;
  27198. private _hitNormalWorld;
  27199. private _hitPointWorld;
  27200. private _rayFromWorld;
  27201. private _rayToWorld;
  27202. /**
  27203. * Gets if there was a hit
  27204. */
  27205. get hasHit(): boolean;
  27206. /**
  27207. * Gets the distance from the hit
  27208. */
  27209. get hitDistance(): number;
  27210. /**
  27211. * Gets the hit normal/direction in the world
  27212. */
  27213. get hitNormalWorld(): Vector3;
  27214. /**
  27215. * Gets the hit point in the world
  27216. */
  27217. get hitPointWorld(): Vector3;
  27218. /**
  27219. * Gets the ray "start point" of the ray in the world
  27220. */
  27221. get rayFromWorld(): Vector3;
  27222. /**
  27223. * Gets the ray "end point" of the ray in the world
  27224. */
  27225. get rayToWorld(): Vector3;
  27226. /**
  27227. * Sets the hit data (normal & point in world space)
  27228. * @param hitNormalWorld defines the normal in world space
  27229. * @param hitPointWorld defines the point in world space
  27230. */
  27231. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27232. /**
  27233. * Sets the distance from the start point to the hit point
  27234. * @param distance
  27235. */
  27236. setHitDistance(distance: number): void;
  27237. /**
  27238. * Calculates the distance manually
  27239. */
  27240. calculateHitDistance(): void;
  27241. /**
  27242. * Resets all the values to default
  27243. * @param from The from point on world space
  27244. * @param to The to point on world space
  27245. */
  27246. reset(from?: Vector3, to?: Vector3): void;
  27247. }
  27248. /**
  27249. * Interface for the size containing width and height
  27250. */
  27251. interface IXYZ {
  27252. /**
  27253. * X
  27254. */
  27255. x: number;
  27256. /**
  27257. * Y
  27258. */
  27259. y: number;
  27260. /**
  27261. * Z
  27262. */
  27263. z: number;
  27264. }
  27265. }
  27266. declare module BABYLON {
  27267. /**
  27268. * Interface used to describe a physics joint
  27269. */
  27270. export interface PhysicsImpostorJoint {
  27271. /** Defines the main impostor to which the joint is linked */
  27272. mainImpostor: PhysicsImpostor;
  27273. /** Defines the impostor that is connected to the main impostor using this joint */
  27274. connectedImpostor: PhysicsImpostor;
  27275. /** Defines the joint itself */
  27276. joint: PhysicsJoint;
  27277. }
  27278. /** @hidden */
  27279. export interface IPhysicsEnginePlugin {
  27280. world: any;
  27281. name: string;
  27282. setGravity(gravity: Vector3): void;
  27283. setTimeStep(timeStep: number): void;
  27284. getTimeStep(): number;
  27285. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27286. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27287. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27288. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27289. removePhysicsBody(impostor: PhysicsImpostor): void;
  27290. generateJoint(joint: PhysicsImpostorJoint): void;
  27291. removeJoint(joint: PhysicsImpostorJoint): void;
  27292. isSupported(): boolean;
  27293. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27294. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27295. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27296. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27297. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27298. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27299. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27300. getBodyMass(impostor: PhysicsImpostor): number;
  27301. getBodyFriction(impostor: PhysicsImpostor): number;
  27302. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27303. getBodyRestitution(impostor: PhysicsImpostor): number;
  27304. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27305. getBodyPressure?(impostor: PhysicsImpostor): number;
  27306. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27307. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27308. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27309. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27310. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27311. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27312. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27313. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27314. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27315. sleepBody(impostor: PhysicsImpostor): void;
  27316. wakeUpBody(impostor: PhysicsImpostor): void;
  27317. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27318. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27319. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27320. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27321. getRadius(impostor: PhysicsImpostor): number;
  27322. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27323. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27324. dispose(): void;
  27325. }
  27326. /**
  27327. * Interface used to define a physics engine
  27328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27329. */
  27330. export interface IPhysicsEngine {
  27331. /**
  27332. * Gets the gravity vector used by the simulation
  27333. */
  27334. gravity: Vector3;
  27335. /**
  27336. * Sets the gravity vector used by the simulation
  27337. * @param gravity defines the gravity vector to use
  27338. */
  27339. setGravity(gravity: Vector3): void;
  27340. /**
  27341. * Set the time step of the physics engine.
  27342. * Default is 1/60.
  27343. * To slow it down, enter 1/600 for example.
  27344. * To speed it up, 1/30
  27345. * @param newTimeStep the new timestep to apply to this world.
  27346. */
  27347. setTimeStep(newTimeStep: number): void;
  27348. /**
  27349. * Get the time step of the physics engine.
  27350. * @returns the current time step
  27351. */
  27352. getTimeStep(): number;
  27353. /**
  27354. * Set the sub time step of the physics engine.
  27355. * Default is 0 meaning there is no sub steps
  27356. * To increase physics resolution precision, set a small value (like 1 ms)
  27357. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27358. */
  27359. setSubTimeStep(subTimeStep: number): void;
  27360. /**
  27361. * Get the sub time step of the physics engine.
  27362. * @returns the current sub time step
  27363. */
  27364. getSubTimeStep(): number;
  27365. /**
  27366. * Release all resources
  27367. */
  27368. dispose(): void;
  27369. /**
  27370. * Gets the name of the current physics plugin
  27371. * @returns the name of the plugin
  27372. */
  27373. getPhysicsPluginName(): string;
  27374. /**
  27375. * Adding a new impostor for the impostor tracking.
  27376. * This will be done by the impostor itself.
  27377. * @param impostor the impostor to add
  27378. */
  27379. addImpostor(impostor: PhysicsImpostor): void;
  27380. /**
  27381. * Remove an impostor from the engine.
  27382. * This impostor and its mesh will not longer be updated by the physics engine.
  27383. * @param impostor the impostor to remove
  27384. */
  27385. removeImpostor(impostor: PhysicsImpostor): void;
  27386. /**
  27387. * Add a joint to the physics engine
  27388. * @param mainImpostor defines the main impostor to which the joint is added.
  27389. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27390. * @param joint defines the joint that will connect both impostors.
  27391. */
  27392. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27393. /**
  27394. * Removes a joint from the simulation
  27395. * @param mainImpostor defines the impostor used with the joint
  27396. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27397. * @param joint defines the joint to remove
  27398. */
  27399. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27400. /**
  27401. * Gets the current plugin used to run the simulation
  27402. * @returns current plugin
  27403. */
  27404. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27405. /**
  27406. * Gets the list of physic impostors
  27407. * @returns an array of PhysicsImpostor
  27408. */
  27409. getImpostors(): Array<PhysicsImpostor>;
  27410. /**
  27411. * Gets the impostor for a physics enabled object
  27412. * @param object defines the object impersonated by the impostor
  27413. * @returns the PhysicsImpostor or null if not found
  27414. */
  27415. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27416. /**
  27417. * Gets the impostor for a physics body object
  27418. * @param body defines physics body used by the impostor
  27419. * @returns the PhysicsImpostor or null if not found
  27420. */
  27421. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27422. /**
  27423. * Does a raycast in the physics world
  27424. * @param from when should the ray start?
  27425. * @param to when should the ray end?
  27426. * @returns PhysicsRaycastResult
  27427. */
  27428. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27429. /**
  27430. * Called by the scene. No need to call it.
  27431. * @param delta defines the timespam between frames
  27432. */
  27433. _step(delta: number): void;
  27434. }
  27435. }
  27436. declare module BABYLON {
  27437. /**
  27438. * The interface for the physics imposter parameters
  27439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27440. */
  27441. export interface PhysicsImpostorParameters {
  27442. /**
  27443. * The mass of the physics imposter
  27444. */
  27445. mass: number;
  27446. /**
  27447. * The friction of the physics imposter
  27448. */
  27449. friction?: number;
  27450. /**
  27451. * The coefficient of restitution of the physics imposter
  27452. */
  27453. restitution?: number;
  27454. /**
  27455. * The native options of the physics imposter
  27456. */
  27457. nativeOptions?: any;
  27458. /**
  27459. * Specifies if the parent should be ignored
  27460. */
  27461. ignoreParent?: boolean;
  27462. /**
  27463. * Specifies if bi-directional transformations should be disabled
  27464. */
  27465. disableBidirectionalTransformation?: boolean;
  27466. /**
  27467. * The pressure inside the physics imposter, soft object only
  27468. */
  27469. pressure?: number;
  27470. /**
  27471. * The stiffness the physics imposter, soft object only
  27472. */
  27473. stiffness?: number;
  27474. /**
  27475. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27476. */
  27477. velocityIterations?: number;
  27478. /**
  27479. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27480. */
  27481. positionIterations?: number;
  27482. /**
  27483. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27484. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27485. * Add to fix multiple points
  27486. */
  27487. fixedPoints?: number;
  27488. /**
  27489. * The collision margin around a soft object
  27490. */
  27491. margin?: number;
  27492. /**
  27493. * The collision margin around a soft object
  27494. */
  27495. damping?: number;
  27496. /**
  27497. * The path for a rope based on an extrusion
  27498. */
  27499. path?: any;
  27500. /**
  27501. * The shape of an extrusion used for a rope based on an extrusion
  27502. */
  27503. shape?: any;
  27504. }
  27505. /**
  27506. * Interface for a physics-enabled object
  27507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27508. */
  27509. export interface IPhysicsEnabledObject {
  27510. /**
  27511. * The position of the physics-enabled object
  27512. */
  27513. position: Vector3;
  27514. /**
  27515. * The rotation of the physics-enabled object
  27516. */
  27517. rotationQuaternion: Nullable<Quaternion>;
  27518. /**
  27519. * The scale of the physics-enabled object
  27520. */
  27521. scaling: Vector3;
  27522. /**
  27523. * The rotation of the physics-enabled object
  27524. */
  27525. rotation?: Vector3;
  27526. /**
  27527. * The parent of the physics-enabled object
  27528. */
  27529. parent?: any;
  27530. /**
  27531. * The bounding info of the physics-enabled object
  27532. * @returns The bounding info of the physics-enabled object
  27533. */
  27534. getBoundingInfo(): BoundingInfo;
  27535. /**
  27536. * Computes the world matrix
  27537. * @param force Specifies if the world matrix should be computed by force
  27538. * @returns A world matrix
  27539. */
  27540. computeWorldMatrix(force: boolean): Matrix;
  27541. /**
  27542. * Gets the world matrix
  27543. * @returns A world matrix
  27544. */
  27545. getWorldMatrix?(): Matrix;
  27546. /**
  27547. * Gets the child meshes
  27548. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27549. * @returns An array of abstract meshes
  27550. */
  27551. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27552. /**
  27553. * Gets the vertex data
  27554. * @param kind The type of vertex data
  27555. * @returns A nullable array of numbers, or a float32 array
  27556. */
  27557. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27558. /**
  27559. * Gets the indices from the mesh
  27560. * @returns A nullable array of index arrays
  27561. */
  27562. getIndices?(): Nullable<IndicesArray>;
  27563. /**
  27564. * Gets the scene from the mesh
  27565. * @returns the indices array or null
  27566. */
  27567. getScene?(): Scene;
  27568. /**
  27569. * Gets the absolute position from the mesh
  27570. * @returns the absolute position
  27571. */
  27572. getAbsolutePosition(): Vector3;
  27573. /**
  27574. * Gets the absolute pivot point from the mesh
  27575. * @returns the absolute pivot point
  27576. */
  27577. getAbsolutePivotPoint(): Vector3;
  27578. /**
  27579. * Rotates the mesh
  27580. * @param axis The axis of rotation
  27581. * @param amount The amount of rotation
  27582. * @param space The space of the rotation
  27583. * @returns The rotation transform node
  27584. */
  27585. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27586. /**
  27587. * Translates the mesh
  27588. * @param axis The axis of translation
  27589. * @param distance The distance of translation
  27590. * @param space The space of the translation
  27591. * @returns The transform node
  27592. */
  27593. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27594. /**
  27595. * Sets the absolute position of the mesh
  27596. * @param absolutePosition The absolute position of the mesh
  27597. * @returns The transform node
  27598. */
  27599. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27600. /**
  27601. * Gets the class name of the mesh
  27602. * @returns The class name
  27603. */
  27604. getClassName(): string;
  27605. }
  27606. /**
  27607. * Represents a physics imposter
  27608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27609. */
  27610. export class PhysicsImpostor {
  27611. /**
  27612. * The physics-enabled object used as the physics imposter
  27613. */
  27614. object: IPhysicsEnabledObject;
  27615. /**
  27616. * The type of the physics imposter
  27617. */
  27618. type: number;
  27619. private _options;
  27620. private _scene?;
  27621. /**
  27622. * The default object size of the imposter
  27623. */
  27624. static DEFAULT_OBJECT_SIZE: Vector3;
  27625. /**
  27626. * The identity quaternion of the imposter
  27627. */
  27628. static IDENTITY_QUATERNION: Quaternion;
  27629. /** @hidden */
  27630. _pluginData: any;
  27631. private _physicsEngine;
  27632. private _physicsBody;
  27633. private _bodyUpdateRequired;
  27634. private _onBeforePhysicsStepCallbacks;
  27635. private _onAfterPhysicsStepCallbacks;
  27636. /** @hidden */
  27637. _onPhysicsCollideCallbacks: Array<{
  27638. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27639. otherImpostors: Array<PhysicsImpostor>;
  27640. }>;
  27641. private _deltaPosition;
  27642. private _deltaRotation;
  27643. private _deltaRotationConjugated;
  27644. /** @hidden */
  27645. _isFromLine: boolean;
  27646. private _parent;
  27647. private _isDisposed;
  27648. private static _tmpVecs;
  27649. private static _tmpQuat;
  27650. /**
  27651. * Specifies if the physics imposter is disposed
  27652. */
  27653. get isDisposed(): boolean;
  27654. /**
  27655. * Gets the mass of the physics imposter
  27656. */
  27657. get mass(): number;
  27658. set mass(value: number);
  27659. /**
  27660. * Gets the coefficient of friction
  27661. */
  27662. get friction(): number;
  27663. /**
  27664. * Sets the coefficient of friction
  27665. */
  27666. set friction(value: number);
  27667. /**
  27668. * Gets the coefficient of restitution
  27669. */
  27670. get restitution(): number;
  27671. /**
  27672. * Sets the coefficient of restitution
  27673. */
  27674. set restitution(value: number);
  27675. /**
  27676. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27677. */
  27678. get pressure(): number;
  27679. /**
  27680. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27681. */
  27682. set pressure(value: number);
  27683. /**
  27684. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27685. */
  27686. get stiffness(): number;
  27687. /**
  27688. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27689. */
  27690. set stiffness(value: number);
  27691. /**
  27692. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27693. */
  27694. get velocityIterations(): number;
  27695. /**
  27696. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27697. */
  27698. set velocityIterations(value: number);
  27699. /**
  27700. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27701. */
  27702. get positionIterations(): number;
  27703. /**
  27704. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27705. */
  27706. set positionIterations(value: number);
  27707. /**
  27708. * The unique id of the physics imposter
  27709. * set by the physics engine when adding this impostor to the array
  27710. */
  27711. uniqueId: number;
  27712. /**
  27713. * @hidden
  27714. */
  27715. soft: boolean;
  27716. /**
  27717. * @hidden
  27718. */
  27719. segments: number;
  27720. private _joints;
  27721. /**
  27722. * Initializes the physics imposter
  27723. * @param object The physics-enabled object used as the physics imposter
  27724. * @param type The type of the physics imposter
  27725. * @param _options The options for the physics imposter
  27726. * @param _scene The Babylon scene
  27727. */
  27728. constructor(
  27729. /**
  27730. * The physics-enabled object used as the physics imposter
  27731. */
  27732. object: IPhysicsEnabledObject,
  27733. /**
  27734. * The type of the physics imposter
  27735. */
  27736. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27737. /**
  27738. * This function will completly initialize this impostor.
  27739. * It will create a new body - but only if this mesh has no parent.
  27740. * If it has, this impostor will not be used other than to define the impostor
  27741. * of the child mesh.
  27742. * @hidden
  27743. */
  27744. _init(): void;
  27745. private _getPhysicsParent;
  27746. /**
  27747. * Should a new body be generated.
  27748. * @returns boolean specifying if body initialization is required
  27749. */
  27750. isBodyInitRequired(): boolean;
  27751. /**
  27752. * Sets the updated scaling
  27753. * @param updated Specifies if the scaling is updated
  27754. */
  27755. setScalingUpdated(): void;
  27756. /**
  27757. * Force a regeneration of this or the parent's impostor's body.
  27758. * Use under cautious - This will remove all joints already implemented.
  27759. */
  27760. forceUpdate(): void;
  27761. /**
  27762. * Gets the body that holds this impostor. Either its own, or its parent.
  27763. */
  27764. get physicsBody(): any;
  27765. /**
  27766. * Get the parent of the physics imposter
  27767. * @returns Physics imposter or null
  27768. */
  27769. get parent(): Nullable<PhysicsImpostor>;
  27770. /**
  27771. * Sets the parent of the physics imposter
  27772. */
  27773. set parent(value: Nullable<PhysicsImpostor>);
  27774. /**
  27775. * Set the physics body. Used mainly by the physics engine/plugin
  27776. */
  27777. set physicsBody(physicsBody: any);
  27778. /**
  27779. * Resets the update flags
  27780. */
  27781. resetUpdateFlags(): void;
  27782. /**
  27783. * Gets the object extend size
  27784. * @returns the object extend size
  27785. */
  27786. getObjectExtendSize(): Vector3;
  27787. /**
  27788. * Gets the object center
  27789. * @returns The object center
  27790. */
  27791. getObjectCenter(): Vector3;
  27792. /**
  27793. * Get a specific parameter from the options parameters
  27794. * @param paramName The object parameter name
  27795. * @returns The object parameter
  27796. */
  27797. getParam(paramName: string): any;
  27798. /**
  27799. * Sets a specific parameter in the options given to the physics plugin
  27800. * @param paramName The parameter name
  27801. * @param value The value of the parameter
  27802. */
  27803. setParam(paramName: string, value: number): void;
  27804. /**
  27805. * Specifically change the body's mass option. Won't recreate the physics body object
  27806. * @param mass The mass of the physics imposter
  27807. */
  27808. setMass(mass: number): void;
  27809. /**
  27810. * Gets the linear velocity
  27811. * @returns linear velocity or null
  27812. */
  27813. getLinearVelocity(): Nullable<Vector3>;
  27814. /**
  27815. * Sets the linear velocity
  27816. * @param velocity linear velocity or null
  27817. */
  27818. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27819. /**
  27820. * Gets the angular velocity
  27821. * @returns angular velocity or null
  27822. */
  27823. getAngularVelocity(): Nullable<Vector3>;
  27824. /**
  27825. * Sets the angular velocity
  27826. * @param velocity The velocity or null
  27827. */
  27828. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27829. /**
  27830. * Execute a function with the physics plugin native code
  27831. * Provide a function the will have two variables - the world object and the physics body object
  27832. * @param func The function to execute with the physics plugin native code
  27833. */
  27834. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27835. /**
  27836. * Register a function that will be executed before the physics world is stepping forward
  27837. * @param func The function to execute before the physics world is stepped forward
  27838. */
  27839. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27840. /**
  27841. * Unregister a function that will be executed before the physics world is stepping forward
  27842. * @param func The function to execute before the physics world is stepped forward
  27843. */
  27844. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27845. /**
  27846. * Register a function that will be executed after the physics step
  27847. * @param func The function to execute after physics step
  27848. */
  27849. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27850. /**
  27851. * Unregisters a function that will be executed after the physics step
  27852. * @param func The function to execute after physics step
  27853. */
  27854. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27855. /**
  27856. * register a function that will be executed when this impostor collides against a different body
  27857. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27858. * @param func Callback that is executed on collision
  27859. */
  27860. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27861. /**
  27862. * Unregisters the physics imposter on contact
  27863. * @param collideAgainst The physics object to collide against
  27864. * @param func Callback to execute on collision
  27865. */
  27866. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27867. private _tmpQuat;
  27868. private _tmpQuat2;
  27869. /**
  27870. * Get the parent rotation
  27871. * @returns The parent rotation
  27872. */
  27873. getParentsRotation(): Quaternion;
  27874. /**
  27875. * this function is executed by the physics engine.
  27876. */
  27877. beforeStep: () => void;
  27878. /**
  27879. * this function is executed by the physics engine
  27880. */
  27881. afterStep: () => void;
  27882. /**
  27883. * Legacy collision detection event support
  27884. */
  27885. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27886. /**
  27887. * event and body object due to cannon's event-based architecture.
  27888. */
  27889. onCollide: (e: {
  27890. body: any;
  27891. }) => void;
  27892. /**
  27893. * Apply a force
  27894. * @param force The force to apply
  27895. * @param contactPoint The contact point for the force
  27896. * @returns The physics imposter
  27897. */
  27898. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27899. /**
  27900. * Apply an impulse
  27901. * @param force The impulse force
  27902. * @param contactPoint The contact point for the impulse force
  27903. * @returns The physics imposter
  27904. */
  27905. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27906. /**
  27907. * A help function to create a joint
  27908. * @param otherImpostor A physics imposter used to create a joint
  27909. * @param jointType The type of joint
  27910. * @param jointData The data for the joint
  27911. * @returns The physics imposter
  27912. */
  27913. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27914. /**
  27915. * Add a joint to this impostor with a different impostor
  27916. * @param otherImpostor A physics imposter used to add a joint
  27917. * @param joint The joint to add
  27918. * @returns The physics imposter
  27919. */
  27920. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27921. /**
  27922. * Add an anchor to a cloth impostor
  27923. * @param otherImpostor rigid impostor to anchor to
  27924. * @param width ratio across width from 0 to 1
  27925. * @param height ratio up height from 0 to 1
  27926. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27927. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27928. * @returns impostor the soft imposter
  27929. */
  27930. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27931. /**
  27932. * Add a hook to a rope impostor
  27933. * @param otherImpostor rigid impostor to anchor to
  27934. * @param length ratio across rope from 0 to 1
  27935. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27936. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27937. * @returns impostor the rope imposter
  27938. */
  27939. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27940. /**
  27941. * Will keep this body still, in a sleep mode.
  27942. * @returns the physics imposter
  27943. */
  27944. sleep(): PhysicsImpostor;
  27945. /**
  27946. * Wake the body up.
  27947. * @returns The physics imposter
  27948. */
  27949. wakeUp(): PhysicsImpostor;
  27950. /**
  27951. * Clones the physics imposter
  27952. * @param newObject The physics imposter clones to this physics-enabled object
  27953. * @returns A nullable physics imposter
  27954. */
  27955. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27956. /**
  27957. * Disposes the physics imposter
  27958. */
  27959. dispose(): void;
  27960. /**
  27961. * Sets the delta position
  27962. * @param position The delta position amount
  27963. */
  27964. setDeltaPosition(position: Vector3): void;
  27965. /**
  27966. * Sets the delta rotation
  27967. * @param rotation The delta rotation amount
  27968. */
  27969. setDeltaRotation(rotation: Quaternion): void;
  27970. /**
  27971. * Gets the box size of the physics imposter and stores the result in the input parameter
  27972. * @param result Stores the box size
  27973. * @returns The physics imposter
  27974. */
  27975. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27976. /**
  27977. * Gets the radius of the physics imposter
  27978. * @returns Radius of the physics imposter
  27979. */
  27980. getRadius(): number;
  27981. /**
  27982. * Sync a bone with this impostor
  27983. * @param bone The bone to sync to the impostor.
  27984. * @param boneMesh The mesh that the bone is influencing.
  27985. * @param jointPivot The pivot of the joint / bone in local space.
  27986. * @param distToJoint Optional distance from the impostor to the joint.
  27987. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27988. */
  27989. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27990. /**
  27991. * Sync impostor to a bone
  27992. * @param bone The bone that the impostor will be synced to.
  27993. * @param boneMesh The mesh that the bone is influencing.
  27994. * @param jointPivot The pivot of the joint / bone in local space.
  27995. * @param distToJoint Optional distance from the impostor to the joint.
  27996. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27997. * @param boneAxis Optional vector3 axis the bone is aligned with
  27998. */
  27999. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28000. /**
  28001. * No-Imposter type
  28002. */
  28003. static NoImpostor: number;
  28004. /**
  28005. * Sphere-Imposter type
  28006. */
  28007. static SphereImpostor: number;
  28008. /**
  28009. * Box-Imposter type
  28010. */
  28011. static BoxImpostor: number;
  28012. /**
  28013. * Plane-Imposter type
  28014. */
  28015. static PlaneImpostor: number;
  28016. /**
  28017. * Mesh-imposter type
  28018. */
  28019. static MeshImpostor: number;
  28020. /**
  28021. * Capsule-Impostor type (Ammo.js plugin only)
  28022. */
  28023. static CapsuleImpostor: number;
  28024. /**
  28025. * Cylinder-Imposter type
  28026. */
  28027. static CylinderImpostor: number;
  28028. /**
  28029. * Particle-Imposter type
  28030. */
  28031. static ParticleImpostor: number;
  28032. /**
  28033. * Heightmap-Imposter type
  28034. */
  28035. static HeightmapImpostor: number;
  28036. /**
  28037. * ConvexHull-Impostor type (Ammo.js plugin only)
  28038. */
  28039. static ConvexHullImpostor: number;
  28040. /**
  28041. * Custom-Imposter type (Ammo.js plugin only)
  28042. */
  28043. static CustomImpostor: number;
  28044. /**
  28045. * Rope-Imposter type
  28046. */
  28047. static RopeImpostor: number;
  28048. /**
  28049. * Cloth-Imposter type
  28050. */
  28051. static ClothImpostor: number;
  28052. /**
  28053. * Softbody-Imposter type
  28054. */
  28055. static SoftbodyImpostor: number;
  28056. }
  28057. }
  28058. declare module BABYLON {
  28059. /**
  28060. * @hidden
  28061. **/
  28062. export class _CreationDataStorage {
  28063. closePath?: boolean;
  28064. closeArray?: boolean;
  28065. idx: number[];
  28066. dashSize: number;
  28067. gapSize: number;
  28068. path3D: Path3D;
  28069. pathArray: Vector3[][];
  28070. arc: number;
  28071. radius: number;
  28072. cap: number;
  28073. tessellation: number;
  28074. }
  28075. /**
  28076. * @hidden
  28077. **/
  28078. class _InstanceDataStorage {
  28079. visibleInstances: any;
  28080. batchCache: _InstancesBatch;
  28081. instancesBufferSize: number;
  28082. instancesBuffer: Nullable<Buffer>;
  28083. instancesData: Float32Array;
  28084. overridenInstanceCount: number;
  28085. isFrozen: boolean;
  28086. previousBatch: Nullable<_InstancesBatch>;
  28087. hardwareInstancedRendering: boolean;
  28088. sideOrientation: number;
  28089. manualUpdate: boolean;
  28090. }
  28091. /**
  28092. * @hidden
  28093. **/
  28094. export class _InstancesBatch {
  28095. mustReturn: boolean;
  28096. visibleInstances: Nullable<InstancedMesh[]>[];
  28097. renderSelf: boolean[];
  28098. hardwareInstancedRendering: boolean[];
  28099. }
  28100. /**
  28101. * @hidden
  28102. **/
  28103. class _ThinInstanceDataStorage {
  28104. instancesCount: number;
  28105. matrixBuffer: Nullable<Buffer>;
  28106. matrixBufferSize: number;
  28107. matrixData: Nullable<Float32Array>;
  28108. boundingVectors: Array<Vector3>;
  28109. worldMatrices: Nullable<Matrix[]>;
  28110. }
  28111. /**
  28112. * Class used to represent renderable models
  28113. */
  28114. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28115. /**
  28116. * Mesh side orientation : usually the external or front surface
  28117. */
  28118. static readonly FRONTSIDE: number;
  28119. /**
  28120. * Mesh side orientation : usually the internal or back surface
  28121. */
  28122. static readonly BACKSIDE: number;
  28123. /**
  28124. * Mesh side orientation : both internal and external or front and back surfaces
  28125. */
  28126. static readonly DOUBLESIDE: number;
  28127. /**
  28128. * Mesh side orientation : by default, `FRONTSIDE`
  28129. */
  28130. static readonly DEFAULTSIDE: number;
  28131. /**
  28132. * Mesh cap setting : no cap
  28133. */
  28134. static readonly NO_CAP: number;
  28135. /**
  28136. * Mesh cap setting : one cap at the beginning of the mesh
  28137. */
  28138. static readonly CAP_START: number;
  28139. /**
  28140. * Mesh cap setting : one cap at the end of the mesh
  28141. */
  28142. static readonly CAP_END: number;
  28143. /**
  28144. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28145. */
  28146. static readonly CAP_ALL: number;
  28147. /**
  28148. * Mesh pattern setting : no flip or rotate
  28149. */
  28150. static readonly NO_FLIP: number;
  28151. /**
  28152. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28153. */
  28154. static readonly FLIP_TILE: number;
  28155. /**
  28156. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28157. */
  28158. static readonly ROTATE_TILE: number;
  28159. /**
  28160. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28161. */
  28162. static readonly FLIP_ROW: number;
  28163. /**
  28164. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28165. */
  28166. static readonly ROTATE_ROW: number;
  28167. /**
  28168. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28169. */
  28170. static readonly FLIP_N_ROTATE_TILE: number;
  28171. /**
  28172. * Mesh pattern setting : rotate pattern and rotate
  28173. */
  28174. static readonly FLIP_N_ROTATE_ROW: number;
  28175. /**
  28176. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28177. */
  28178. static readonly CENTER: number;
  28179. /**
  28180. * Mesh tile positioning : part tiles on left
  28181. */
  28182. static readonly LEFT: number;
  28183. /**
  28184. * Mesh tile positioning : part tiles on right
  28185. */
  28186. static readonly RIGHT: number;
  28187. /**
  28188. * Mesh tile positioning : part tiles on top
  28189. */
  28190. static readonly TOP: number;
  28191. /**
  28192. * Mesh tile positioning : part tiles on bottom
  28193. */
  28194. static readonly BOTTOM: number;
  28195. /**
  28196. * Gets the default side orientation.
  28197. * @param orientation the orientation to value to attempt to get
  28198. * @returns the default orientation
  28199. * @hidden
  28200. */
  28201. static _GetDefaultSideOrientation(orientation?: number): number;
  28202. private _internalMeshDataInfo;
  28203. get computeBonesUsingShaders(): boolean;
  28204. set computeBonesUsingShaders(value: boolean);
  28205. /**
  28206. * An event triggered before rendering the mesh
  28207. */
  28208. get onBeforeRenderObservable(): Observable<Mesh>;
  28209. /**
  28210. * An event triggered before binding the mesh
  28211. */
  28212. get onBeforeBindObservable(): Observable<Mesh>;
  28213. /**
  28214. * An event triggered after rendering the mesh
  28215. */
  28216. get onAfterRenderObservable(): Observable<Mesh>;
  28217. /**
  28218. * An event triggered before drawing the mesh
  28219. */
  28220. get onBeforeDrawObservable(): Observable<Mesh>;
  28221. private _onBeforeDrawObserver;
  28222. /**
  28223. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28224. */
  28225. set onBeforeDraw(callback: () => void);
  28226. get hasInstances(): boolean;
  28227. get hasThinInstances(): boolean;
  28228. /**
  28229. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28230. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28231. */
  28232. delayLoadState: number;
  28233. /**
  28234. * Gets the list of instances created from this mesh
  28235. * it is not supposed to be modified manually.
  28236. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28237. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28238. */
  28239. instances: InstancedMesh[];
  28240. /**
  28241. * Gets the file containing delay loading data for this mesh
  28242. */
  28243. delayLoadingFile: string;
  28244. /** @hidden */
  28245. _binaryInfo: any;
  28246. /**
  28247. * User defined function used to change how LOD level selection is done
  28248. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28249. */
  28250. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28251. /**
  28252. * Gets or sets the morph target manager
  28253. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28254. */
  28255. get morphTargetManager(): Nullable<MorphTargetManager>;
  28256. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28257. /** @hidden */
  28258. _creationDataStorage: Nullable<_CreationDataStorage>;
  28259. /** @hidden */
  28260. _geometry: Nullable<Geometry>;
  28261. /** @hidden */
  28262. _delayInfo: Array<string>;
  28263. /** @hidden */
  28264. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28265. /** @hidden */
  28266. _instanceDataStorage: _InstanceDataStorage;
  28267. /** @hidden */
  28268. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28269. private _effectiveMaterial;
  28270. /** @hidden */
  28271. _shouldGenerateFlatShading: boolean;
  28272. /** @hidden */
  28273. _originalBuilderSideOrientation: number;
  28274. /**
  28275. * Use this property to change the original side orientation defined at construction time
  28276. */
  28277. overrideMaterialSideOrientation: Nullable<number>;
  28278. /**
  28279. * Gets the source mesh (the one used to clone this one from)
  28280. */
  28281. get source(): Nullable<Mesh>;
  28282. /**
  28283. * Gets the list of clones of this mesh
  28284. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  28285. * Note that useClonedMeshMap=true is the default setting
  28286. */
  28287. get cloneMeshMap(): Nullable<{
  28288. [id: string]: Mesh | undefined;
  28289. }>;
  28290. /**
  28291. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28292. */
  28293. get isUnIndexed(): boolean;
  28294. set isUnIndexed(value: boolean);
  28295. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28296. get worldMatrixInstancedBuffer(): Float32Array;
  28297. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28298. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28299. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28300. /**
  28301. * @constructor
  28302. * @param name The value used by scene.getMeshByName() to do a lookup.
  28303. * @param scene The scene to add this mesh to.
  28304. * @param parent The parent of this mesh, if it has one
  28305. * @param source An optional Mesh from which geometry is shared, cloned.
  28306. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28307. * When false, achieved by calling a clone(), also passing False.
  28308. * This will make creation of children, recursive.
  28309. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28310. */
  28311. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28312. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28313. doNotInstantiate: boolean;
  28314. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28315. /**
  28316. * Gets the class name
  28317. * @returns the string "Mesh".
  28318. */
  28319. getClassName(): string;
  28320. /** @hidden */
  28321. get _isMesh(): boolean;
  28322. /**
  28323. * Returns a description of this mesh
  28324. * @param fullDetails define if full details about this mesh must be used
  28325. * @returns a descriptive string representing this mesh
  28326. */
  28327. toString(fullDetails?: boolean): string;
  28328. /** @hidden */
  28329. _unBindEffect(): void;
  28330. /**
  28331. * Gets a boolean indicating if this mesh has LOD
  28332. */
  28333. get hasLODLevels(): boolean;
  28334. /**
  28335. * Gets the list of MeshLODLevel associated with the current mesh
  28336. * @returns an array of MeshLODLevel
  28337. */
  28338. getLODLevels(): MeshLODLevel[];
  28339. private _sortLODLevels;
  28340. /**
  28341. * Add a mesh as LOD level triggered at the given distance.
  28342. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28343. * @param distance The distance from the center of the object to show this level
  28344. * @param mesh The mesh to be added as LOD level (can be null)
  28345. * @return This mesh (for chaining)
  28346. */
  28347. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28348. /**
  28349. * Returns the LOD level mesh at the passed distance or null if not found.
  28350. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28351. * @param distance The distance from the center of the object to show this level
  28352. * @returns a Mesh or `null`
  28353. */
  28354. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28355. /**
  28356. * Remove a mesh from the LOD array
  28357. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28358. * @param mesh defines the mesh to be removed
  28359. * @return This mesh (for chaining)
  28360. */
  28361. removeLODLevel(mesh: Mesh): Mesh;
  28362. /**
  28363. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28364. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28365. * @param camera defines the camera to use to compute distance
  28366. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28367. * @return This mesh (for chaining)
  28368. */
  28369. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28370. /**
  28371. * Gets the mesh internal Geometry object
  28372. */
  28373. get geometry(): Nullable<Geometry>;
  28374. /**
  28375. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28376. * @returns the total number of vertices
  28377. */
  28378. getTotalVertices(): number;
  28379. /**
  28380. * Returns the content of an associated vertex buffer
  28381. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28382. * - VertexBuffer.PositionKind
  28383. * - VertexBuffer.UVKind
  28384. * - VertexBuffer.UV2Kind
  28385. * - VertexBuffer.UV3Kind
  28386. * - VertexBuffer.UV4Kind
  28387. * - VertexBuffer.UV5Kind
  28388. * - VertexBuffer.UV6Kind
  28389. * - VertexBuffer.ColorKind
  28390. * - VertexBuffer.MatricesIndicesKind
  28391. * - VertexBuffer.MatricesIndicesExtraKind
  28392. * - VertexBuffer.MatricesWeightsKind
  28393. * - VertexBuffer.MatricesWeightsExtraKind
  28394. * @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
  28395. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28396. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28397. */
  28398. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28399. /**
  28400. * Returns the mesh VertexBuffer object from the requested `kind`
  28401. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28402. * - VertexBuffer.PositionKind
  28403. * - VertexBuffer.NormalKind
  28404. * - VertexBuffer.UVKind
  28405. * - VertexBuffer.UV2Kind
  28406. * - VertexBuffer.UV3Kind
  28407. * - VertexBuffer.UV4Kind
  28408. * - VertexBuffer.UV5Kind
  28409. * - VertexBuffer.UV6Kind
  28410. * - VertexBuffer.ColorKind
  28411. * - VertexBuffer.MatricesIndicesKind
  28412. * - VertexBuffer.MatricesIndicesExtraKind
  28413. * - VertexBuffer.MatricesWeightsKind
  28414. * - VertexBuffer.MatricesWeightsExtraKind
  28415. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28416. */
  28417. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28418. /**
  28419. * Tests if a specific vertex buffer is associated with this mesh
  28420. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28421. * - VertexBuffer.PositionKind
  28422. * - VertexBuffer.NormalKind
  28423. * - VertexBuffer.UVKind
  28424. * - VertexBuffer.UV2Kind
  28425. * - VertexBuffer.UV3Kind
  28426. * - VertexBuffer.UV4Kind
  28427. * - VertexBuffer.UV5Kind
  28428. * - VertexBuffer.UV6Kind
  28429. * - VertexBuffer.ColorKind
  28430. * - VertexBuffer.MatricesIndicesKind
  28431. * - VertexBuffer.MatricesIndicesExtraKind
  28432. * - VertexBuffer.MatricesWeightsKind
  28433. * - VertexBuffer.MatricesWeightsExtraKind
  28434. * @returns a boolean
  28435. */
  28436. isVerticesDataPresent(kind: string): boolean;
  28437. /**
  28438. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28439. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28440. * - VertexBuffer.PositionKind
  28441. * - VertexBuffer.UVKind
  28442. * - VertexBuffer.UV2Kind
  28443. * - VertexBuffer.UV3Kind
  28444. * - VertexBuffer.UV4Kind
  28445. * - VertexBuffer.UV5Kind
  28446. * - VertexBuffer.UV6Kind
  28447. * - VertexBuffer.ColorKind
  28448. * - VertexBuffer.MatricesIndicesKind
  28449. * - VertexBuffer.MatricesIndicesExtraKind
  28450. * - VertexBuffer.MatricesWeightsKind
  28451. * - VertexBuffer.MatricesWeightsExtraKind
  28452. * @returns a boolean
  28453. */
  28454. isVertexBufferUpdatable(kind: string): boolean;
  28455. /**
  28456. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28457. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28458. * - VertexBuffer.PositionKind
  28459. * - VertexBuffer.NormalKind
  28460. * - VertexBuffer.UVKind
  28461. * - VertexBuffer.UV2Kind
  28462. * - VertexBuffer.UV3Kind
  28463. * - VertexBuffer.UV4Kind
  28464. * - VertexBuffer.UV5Kind
  28465. * - VertexBuffer.UV6Kind
  28466. * - VertexBuffer.ColorKind
  28467. * - VertexBuffer.MatricesIndicesKind
  28468. * - VertexBuffer.MatricesIndicesExtraKind
  28469. * - VertexBuffer.MatricesWeightsKind
  28470. * - VertexBuffer.MatricesWeightsExtraKind
  28471. * @returns an array of strings
  28472. */
  28473. getVerticesDataKinds(): string[];
  28474. /**
  28475. * Returns a positive integer : the total number of indices in this mesh geometry.
  28476. * @returns the numner of indices or zero if the mesh has no geometry.
  28477. */
  28478. getTotalIndices(): number;
  28479. /**
  28480. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28481. * @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.
  28482. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28483. * @returns the indices array or an empty array if the mesh has no geometry
  28484. */
  28485. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28486. get isBlocked(): boolean;
  28487. /**
  28488. * Determine if the current mesh is ready to be rendered
  28489. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28490. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28491. * @returns true if all associated assets are ready (material, textures, shaders)
  28492. */
  28493. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28494. /**
  28495. * 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.
  28496. */
  28497. get areNormalsFrozen(): boolean;
  28498. /**
  28499. * 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.
  28500. * @returns the current mesh
  28501. */
  28502. freezeNormals(): Mesh;
  28503. /**
  28504. * 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
  28505. * @returns the current mesh
  28506. */
  28507. unfreezeNormals(): Mesh;
  28508. /**
  28509. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28510. */
  28511. set overridenInstanceCount(count: number);
  28512. /** @hidden */
  28513. _preActivate(): Mesh;
  28514. /** @hidden */
  28515. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28516. /** @hidden */
  28517. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28518. protected _afterComputeWorldMatrix(): void;
  28519. /** @hidden */
  28520. _postActivate(): void;
  28521. /**
  28522. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28523. * This means the mesh underlying bounding box and sphere are recomputed.
  28524. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28525. * @returns the current mesh
  28526. */
  28527. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28528. /** @hidden */
  28529. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28530. /**
  28531. * This function will subdivide the mesh into multiple submeshes
  28532. * @param count defines the expected number of submeshes
  28533. */
  28534. subdivide(count: number): void;
  28535. /**
  28536. * Copy a FloatArray into a specific associated vertex buffer
  28537. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28538. * - VertexBuffer.PositionKind
  28539. * - VertexBuffer.UVKind
  28540. * - VertexBuffer.UV2Kind
  28541. * - VertexBuffer.UV3Kind
  28542. * - VertexBuffer.UV4Kind
  28543. * - VertexBuffer.UV5Kind
  28544. * - VertexBuffer.UV6Kind
  28545. * - VertexBuffer.ColorKind
  28546. * - VertexBuffer.MatricesIndicesKind
  28547. * - VertexBuffer.MatricesIndicesExtraKind
  28548. * - VertexBuffer.MatricesWeightsKind
  28549. * - VertexBuffer.MatricesWeightsExtraKind
  28550. * @param data defines the data source
  28551. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28552. * @param stride defines the data stride size (can be null)
  28553. * @returns the current mesh
  28554. */
  28555. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28556. /**
  28557. * Delete a vertex buffer associated with this mesh
  28558. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28559. * - VertexBuffer.PositionKind
  28560. * - VertexBuffer.UVKind
  28561. * - VertexBuffer.UV2Kind
  28562. * - VertexBuffer.UV3Kind
  28563. * - VertexBuffer.UV4Kind
  28564. * - VertexBuffer.UV5Kind
  28565. * - VertexBuffer.UV6Kind
  28566. * - VertexBuffer.ColorKind
  28567. * - VertexBuffer.MatricesIndicesKind
  28568. * - VertexBuffer.MatricesIndicesExtraKind
  28569. * - VertexBuffer.MatricesWeightsKind
  28570. * - VertexBuffer.MatricesWeightsExtraKind
  28571. */
  28572. removeVerticesData(kind: string): void;
  28573. /**
  28574. * Flags an associated vertex buffer as updatable
  28575. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28576. * - VertexBuffer.PositionKind
  28577. * - VertexBuffer.UVKind
  28578. * - VertexBuffer.UV2Kind
  28579. * - VertexBuffer.UV3Kind
  28580. * - VertexBuffer.UV4Kind
  28581. * - VertexBuffer.UV5Kind
  28582. * - VertexBuffer.UV6Kind
  28583. * - VertexBuffer.ColorKind
  28584. * - VertexBuffer.MatricesIndicesKind
  28585. * - VertexBuffer.MatricesIndicesExtraKind
  28586. * - VertexBuffer.MatricesWeightsKind
  28587. * - VertexBuffer.MatricesWeightsExtraKind
  28588. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28589. */
  28590. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28591. /**
  28592. * Sets the mesh global Vertex Buffer
  28593. * @param buffer defines the buffer to use
  28594. * @returns the current mesh
  28595. */
  28596. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28597. /**
  28598. * Update a specific associated vertex buffer
  28599. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28600. * - VertexBuffer.PositionKind
  28601. * - VertexBuffer.UVKind
  28602. * - VertexBuffer.UV2Kind
  28603. * - VertexBuffer.UV3Kind
  28604. * - VertexBuffer.UV4Kind
  28605. * - VertexBuffer.UV5Kind
  28606. * - VertexBuffer.UV6Kind
  28607. * - VertexBuffer.ColorKind
  28608. * - VertexBuffer.MatricesIndicesKind
  28609. * - VertexBuffer.MatricesIndicesExtraKind
  28610. * - VertexBuffer.MatricesWeightsKind
  28611. * - VertexBuffer.MatricesWeightsExtraKind
  28612. * @param data defines the data source
  28613. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28614. * @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)
  28615. * @returns the current mesh
  28616. */
  28617. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28618. /**
  28619. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28620. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28621. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28622. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28623. * @returns the current mesh
  28624. */
  28625. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28626. /**
  28627. * Creates a un-shared specific occurence of the geometry for the mesh.
  28628. * @returns the current mesh
  28629. */
  28630. makeGeometryUnique(): Mesh;
  28631. /**
  28632. * Set the index buffer of this mesh
  28633. * @param indices defines the source data
  28634. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28635. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28636. * @returns the current mesh
  28637. */
  28638. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28639. /**
  28640. * Update the current index buffer
  28641. * @param indices defines the source data
  28642. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28643. * @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)
  28644. * @returns the current mesh
  28645. */
  28646. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28647. /**
  28648. * Invert the geometry to move from a right handed system to a left handed one.
  28649. * @returns the current mesh
  28650. */
  28651. toLeftHanded(): Mesh;
  28652. /** @hidden */
  28653. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28654. /** @hidden */
  28655. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28656. /**
  28657. * Registers for this mesh a javascript function called just before the rendering process
  28658. * @param func defines the function to call before rendering this mesh
  28659. * @returns the current mesh
  28660. */
  28661. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28662. /**
  28663. * Disposes a previously registered javascript function called before the rendering
  28664. * @param func defines the function to remove
  28665. * @returns the current mesh
  28666. */
  28667. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28668. /**
  28669. * Registers for this mesh a javascript function called just after the rendering is complete
  28670. * @param func defines the function to call after rendering this mesh
  28671. * @returns the current mesh
  28672. */
  28673. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28674. /**
  28675. * Disposes a previously registered javascript function called after the rendering.
  28676. * @param func defines the function to remove
  28677. * @returns the current mesh
  28678. */
  28679. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28680. /** @hidden */
  28681. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28682. /** @hidden */
  28683. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28684. /** @hidden */
  28685. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28686. /** @hidden */
  28687. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28688. /** @hidden */
  28689. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28690. /** @hidden */
  28691. _rebuild(): void;
  28692. /** @hidden */
  28693. _freeze(): void;
  28694. /** @hidden */
  28695. _unFreeze(): void;
  28696. /**
  28697. * 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
  28698. * @param subMesh defines the subMesh to render
  28699. * @param enableAlphaMode defines if alpha mode can be changed
  28700. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28701. * @returns the current mesh
  28702. */
  28703. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28704. private _onBeforeDraw;
  28705. /**
  28706. * Renormalize the mesh and patch it up if there are no weights
  28707. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28708. * However in the case of zero weights then we set just a single influence to 1.
  28709. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28710. */
  28711. cleanMatrixWeights(): void;
  28712. private normalizeSkinFourWeights;
  28713. private normalizeSkinWeightsAndExtra;
  28714. /**
  28715. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28716. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28717. * the user know there was an issue with importing the mesh
  28718. * @returns a validation object with skinned, valid and report string
  28719. */
  28720. validateSkinning(): {
  28721. skinned: boolean;
  28722. valid: boolean;
  28723. report: string;
  28724. };
  28725. /** @hidden */
  28726. _checkDelayState(): Mesh;
  28727. private _queueLoad;
  28728. /**
  28729. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28730. * A mesh is in the frustum if its bounding box intersects the frustum
  28731. * @param frustumPlanes defines the frustum to test
  28732. * @returns true if the mesh is in the frustum planes
  28733. */
  28734. isInFrustum(frustumPlanes: Plane[]): boolean;
  28735. /**
  28736. * Sets the mesh material by the material or multiMaterial `id` property
  28737. * @param id is a string identifying the material or the multiMaterial
  28738. * @returns the current mesh
  28739. */
  28740. setMaterialByID(id: string): Mesh;
  28741. /**
  28742. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28743. * @returns an array of IAnimatable
  28744. */
  28745. getAnimatables(): IAnimatable[];
  28746. /**
  28747. * Modifies the mesh geometry according to the passed transformation matrix.
  28748. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28749. * The mesh normals are modified using the same transformation.
  28750. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28751. * @param transform defines the transform matrix to use
  28752. * @see https://doc.babylonjs.com/resources/baking_transformations
  28753. * @returns the current mesh
  28754. */
  28755. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28756. /**
  28757. * Modifies the mesh geometry according to its own current World Matrix.
  28758. * The mesh World Matrix is then reset.
  28759. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28760. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28761. * @see https://doc.babylonjs.com/resources/baking_transformations
  28762. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28763. * @returns the current mesh
  28764. */
  28765. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28766. /** @hidden */
  28767. get _positions(): Nullable<Vector3[]>;
  28768. /** @hidden */
  28769. _resetPointsArrayCache(): Mesh;
  28770. /** @hidden */
  28771. _generatePointsArray(): boolean;
  28772. /**
  28773. * Returns a new Mesh object generated from the current mesh properties.
  28774. * This method must not get confused with createInstance()
  28775. * @param name is a string, the name given to the new mesh
  28776. * @param newParent can be any Node object (default `null`)
  28777. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28778. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28779. * @returns a new mesh
  28780. */
  28781. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28782. /**
  28783. * Releases resources associated with this mesh.
  28784. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28785. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28786. */
  28787. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28788. /** @hidden */
  28789. _disposeInstanceSpecificData(): void;
  28790. /** @hidden */
  28791. _disposeThinInstanceSpecificData(): void;
  28792. /**
  28793. * Modifies the mesh geometry according to a displacement map.
  28794. * 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.
  28795. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28796. * @param url is a string, the URL from the image file is to be downloaded.
  28797. * @param minHeight is the lower limit of the displacement.
  28798. * @param maxHeight is the upper limit of the displacement.
  28799. * @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.
  28800. * @param uvOffset is an optional vector2 used to offset UV.
  28801. * @param uvScale is an optional vector2 used to scale UV.
  28802. * @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.
  28803. * @returns the Mesh.
  28804. */
  28805. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28806. /**
  28807. * Modifies the mesh geometry according to a displacementMap buffer.
  28808. * 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.
  28809. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28810. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28811. * @param heightMapWidth is the width of the buffer image.
  28812. * @param heightMapHeight is the height of the buffer image.
  28813. * @param minHeight is the lower limit of the displacement.
  28814. * @param maxHeight is the upper limit of the displacement.
  28815. * @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.
  28816. * @param uvOffset is an optional vector2 used to offset UV.
  28817. * @param uvScale is an optional vector2 used to scale UV.
  28818. * @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.
  28819. * @returns the Mesh.
  28820. */
  28821. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28822. /**
  28823. * Modify the mesh to get a flat shading rendering.
  28824. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28825. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28826. * @returns current mesh
  28827. */
  28828. convertToFlatShadedMesh(): Mesh;
  28829. /**
  28830. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28831. * In other words, more vertices, no more indices and a single bigger VBO.
  28832. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28833. * @returns current mesh
  28834. */
  28835. convertToUnIndexedMesh(): Mesh;
  28836. /**
  28837. * Inverses facet orientations.
  28838. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28839. * @param flipNormals will also inverts the normals
  28840. * @returns current mesh
  28841. */
  28842. flipFaces(flipNormals?: boolean): Mesh;
  28843. /**
  28844. * Increase the number of facets and hence vertices in a mesh
  28845. * Vertex normals are interpolated from existing vertex normals
  28846. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28847. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28848. */
  28849. increaseVertices(numberPerEdge: number): void;
  28850. /**
  28851. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28852. * This will undo any application of covertToFlatShadedMesh
  28853. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28854. */
  28855. forceSharedVertices(): void;
  28856. /** @hidden */
  28857. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28858. /** @hidden */
  28859. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28860. /**
  28861. * Creates a new InstancedMesh object from the mesh model.
  28862. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28863. * @param name defines the name of the new instance
  28864. * @returns a new InstancedMesh
  28865. */
  28866. createInstance(name: string): InstancedMesh;
  28867. /**
  28868. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28869. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28870. * @returns the current mesh
  28871. */
  28872. synchronizeInstances(): Mesh;
  28873. /**
  28874. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28875. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28876. * This should be used together with the simplification to avoid disappearing triangles.
  28877. * @param successCallback an optional success callback to be called after the optimization finished.
  28878. * @returns the current mesh
  28879. */
  28880. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28881. /**
  28882. * Serialize current mesh
  28883. * @param serializationObject defines the object which will receive the serialization data
  28884. */
  28885. serialize(serializationObject: any): void;
  28886. /** @hidden */
  28887. _syncGeometryWithMorphTargetManager(): void;
  28888. /** @hidden */
  28889. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28890. /**
  28891. * Returns a new Mesh object parsed from the source provided.
  28892. * @param parsedMesh is the source
  28893. * @param scene defines the hosting scene
  28894. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28895. * @returns a new Mesh
  28896. */
  28897. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28898. /**
  28899. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28900. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28901. * @param name defines the name of the mesh to create
  28902. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28903. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28904. * @param closePath creates a seam between the first and the last points of each path of the path array
  28905. * @param offset is taken in account only if the `pathArray` is containing a single path
  28906. * @param scene defines the hosting scene
  28907. * @param updatable defines if the mesh must be flagged as updatable
  28908. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28909. * @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)
  28910. * @returns a new Mesh
  28911. */
  28912. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28913. /**
  28914. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28915. * @param name defines the name of the mesh to create
  28916. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28917. * @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
  28918. * @param scene defines the hosting scene
  28919. * @param updatable defines if the mesh must be flagged as updatable
  28920. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28921. * @returns a new Mesh
  28922. */
  28923. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28924. /**
  28925. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28926. * @param name defines the name of the mesh to create
  28927. * @param size sets the size (float) of each box side (default 1)
  28928. * @param scene defines the hosting scene
  28929. * @param updatable defines if the mesh must be flagged as updatable
  28930. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28931. * @returns a new Mesh
  28932. */
  28933. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28934. /**
  28935. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28936. * @param name defines the name of the mesh to create
  28937. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28938. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28939. * @param scene defines the hosting scene
  28940. * @param updatable defines if the mesh must be flagged as updatable
  28941. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28942. * @returns a new Mesh
  28943. */
  28944. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28945. /**
  28946. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28947. * @param name defines the name of the mesh to create
  28948. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28949. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28950. * @param scene defines the hosting scene
  28951. * @returns a new Mesh
  28952. */
  28953. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28954. /**
  28955. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28956. * @param name defines the name of the mesh to create
  28957. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28958. * @param diameterTop set the top cap diameter (floats, default 1)
  28959. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28960. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28961. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28962. * @param scene defines the hosting scene
  28963. * @param updatable defines if the mesh must be flagged as updatable
  28964. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28965. * @returns a new Mesh
  28966. */
  28967. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28968. /**
  28969. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28970. * @param name defines the name of the mesh to create
  28971. * @param diameter sets the diameter size (float) of the torus (default 1)
  28972. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28973. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28974. * @param scene defines the hosting scene
  28975. * @param updatable defines if the mesh must be flagged as updatable
  28976. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28977. * @returns a new Mesh
  28978. */
  28979. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28980. /**
  28981. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28982. * @param name defines the name of the mesh to create
  28983. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28984. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28985. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28986. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28987. * @param p the number of windings on X axis (positive integers, default 2)
  28988. * @param q the number of windings on Y axis (positive integers, default 3)
  28989. * @param scene defines the hosting scene
  28990. * @param updatable defines if the mesh must be flagged as updatable
  28991. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28992. * @returns a new Mesh
  28993. */
  28994. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28995. /**
  28996. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28997. * @param name defines the name of the mesh to create
  28998. * @param points is an array successive Vector3
  28999. * @param scene defines the hosting scene
  29000. * @param updatable defines if the mesh must be flagged as updatable
  29001. * @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).
  29002. * @returns a new Mesh
  29003. */
  29004. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29005. /**
  29006. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29007. * @param name defines the name of the mesh to create
  29008. * @param points is an array successive Vector3
  29009. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29010. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29011. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29012. * @param scene defines the hosting scene
  29013. * @param updatable defines if the mesh must be flagged as updatable
  29014. * @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)
  29015. * @returns a new Mesh
  29016. */
  29017. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29018. /**
  29019. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29020. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29021. * 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.
  29022. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29023. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29024. * Remember you can only change the shape positions, not their number when updating a polygon.
  29025. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29026. * @param name defines the name of the mesh to create
  29027. * @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
  29028. * @param scene defines the hosting scene
  29029. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29030. * @param updatable defines if the mesh must be flagged as updatable
  29031. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29032. * @param earcutInjection can be used to inject your own earcut reference
  29033. * @returns a new Mesh
  29034. */
  29035. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29036. /**
  29037. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29038. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29039. * @param name defines the name of the mesh to create
  29040. * @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
  29041. * @param depth defines the height of extrusion
  29042. * @param scene defines the hosting scene
  29043. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29044. * @param updatable defines if the mesh must be flagged as updatable
  29045. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29046. * @param earcutInjection can be used to inject your own earcut reference
  29047. * @returns a new Mesh
  29048. */
  29049. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29050. /**
  29051. * Creates an extruded shape mesh.
  29052. * 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
  29053. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29054. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29055. * @param name defines the name of the mesh to create
  29056. * @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
  29057. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29058. * @param scale is the value to scale the shape
  29059. * @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
  29060. * @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
  29061. * @param scene defines the hosting scene
  29062. * @param updatable defines if the mesh must be flagged as updatable
  29063. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29064. * @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)
  29065. * @returns a new Mesh
  29066. */
  29067. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29068. /**
  29069. * Creates an custom extruded shape mesh.
  29070. * The custom extrusion is a parametric shape.
  29071. * It has no predefined shape. Its final shape will depend on the input parameters.
  29072. * Please consider using the same method from the MeshBuilder class instead
  29073. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29074. * @param name defines the name of the mesh to create
  29075. * @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
  29076. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29077. * @param scaleFunction is a custom Javascript function called on each path point
  29078. * @param rotationFunction is a custom Javascript function called on each path point
  29079. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29080. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29081. * @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
  29082. * @param scene defines the hosting scene
  29083. * @param updatable defines if the mesh must be flagged as updatable
  29084. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29085. * @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)
  29086. * @returns a new Mesh
  29087. */
  29088. 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;
  29089. /**
  29090. * Creates lathe mesh.
  29091. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29092. * Please consider using the same method from the MeshBuilder class instead
  29093. * @param name defines the name of the mesh to create
  29094. * @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
  29095. * @param radius is the radius value of the lathe
  29096. * @param tessellation is the side number of the lathe.
  29097. * @param scene defines the hosting scene
  29098. * @param updatable defines if the mesh must be flagged as updatable
  29099. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29100. * @returns a new Mesh
  29101. */
  29102. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29103. /**
  29104. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29105. * @param name defines the name of the mesh to create
  29106. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29107. * @param scene defines the hosting scene
  29108. * @param updatable defines if the mesh must be flagged as updatable
  29109. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29110. * @returns a new Mesh
  29111. */
  29112. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29113. /**
  29114. * Creates a ground mesh.
  29115. * Please consider using the same method from the MeshBuilder class instead
  29116. * @param name defines the name of the mesh to create
  29117. * @param width set the width of the ground
  29118. * @param height set the height of the ground
  29119. * @param subdivisions sets the number of subdivisions per side
  29120. * @param scene defines the hosting scene
  29121. * @param updatable defines if the mesh must be flagged as updatable
  29122. * @returns a new Mesh
  29123. */
  29124. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29125. /**
  29126. * Creates a tiled ground mesh.
  29127. * Please consider using the same method from the MeshBuilder class instead
  29128. * @param name defines the name of the mesh to create
  29129. * @param xmin set the ground minimum X coordinate
  29130. * @param zmin set the ground minimum Y coordinate
  29131. * @param xmax set the ground maximum X coordinate
  29132. * @param zmax set the ground maximum Z coordinate
  29133. * @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
  29134. * @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
  29135. * @param scene defines the hosting scene
  29136. * @param updatable defines if the mesh must be flagged as updatable
  29137. * @returns a new Mesh
  29138. */
  29139. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29140. w: number;
  29141. h: number;
  29142. }, precision: {
  29143. w: number;
  29144. h: number;
  29145. }, scene: Scene, updatable?: boolean): Mesh;
  29146. /**
  29147. * Creates a ground mesh from a height map.
  29148. * Please consider using the same method from the MeshBuilder class instead
  29149. * @see https://doc.babylonjs.com/babylon101/height_map
  29150. * @param name defines the name of the mesh to create
  29151. * @param url sets the URL of the height map image resource
  29152. * @param width set the ground width size
  29153. * @param height set the ground height size
  29154. * @param subdivisions sets the number of subdivision per side
  29155. * @param minHeight is the minimum altitude on the ground
  29156. * @param maxHeight is the maximum altitude on the ground
  29157. * @param scene defines the hosting scene
  29158. * @param updatable defines if the mesh must be flagged as updatable
  29159. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29160. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29161. * @returns a new Mesh
  29162. */
  29163. 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;
  29164. /**
  29165. * Creates a tube mesh.
  29166. * The tube is a parametric shape.
  29167. * It has no predefined shape. Its final shape will depend on the input parameters.
  29168. * Please consider using the same method from the MeshBuilder class instead
  29169. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29170. * @param name defines the name of the mesh to create
  29171. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29172. * @param radius sets the tube radius size
  29173. * @param tessellation is the number of sides on the tubular surface
  29174. * @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
  29175. * @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
  29176. * @param scene defines the hosting scene
  29177. * @param updatable defines if the mesh must be flagged as updatable
  29178. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29179. * @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)
  29180. * @returns a new Mesh
  29181. */
  29182. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29183. (i: number, distance: number): number;
  29184. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29185. /**
  29186. * Creates a polyhedron mesh.
  29187. * Please consider using the same method from the MeshBuilder class instead.
  29188. * * 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
  29189. * * The parameter `size` (positive float, default 1) sets the polygon size
  29190. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29191. * * 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`
  29192. * * 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
  29193. * * 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)`)
  29194. * * 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
  29195. * * 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
  29196. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29197. * * 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
  29198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29199. * @param name defines the name of the mesh to create
  29200. * @param options defines the options used to create the mesh
  29201. * @param scene defines the hosting scene
  29202. * @returns a new Mesh
  29203. */
  29204. static CreatePolyhedron(name: string, options: {
  29205. type?: number;
  29206. size?: number;
  29207. sizeX?: number;
  29208. sizeY?: number;
  29209. sizeZ?: number;
  29210. custom?: any;
  29211. faceUV?: Vector4[];
  29212. faceColors?: Color4[];
  29213. updatable?: boolean;
  29214. sideOrientation?: number;
  29215. }, scene: Scene): Mesh;
  29216. /**
  29217. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29218. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29219. * * 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`)
  29220. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29221. * * 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
  29222. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29223. * * 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
  29224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29225. * @param name defines the name of the mesh
  29226. * @param options defines the options used to create the mesh
  29227. * @param scene defines the hosting scene
  29228. * @returns a new Mesh
  29229. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29230. */
  29231. static CreateIcoSphere(name: string, options: {
  29232. radius?: number;
  29233. flat?: boolean;
  29234. subdivisions?: number;
  29235. sideOrientation?: number;
  29236. updatable?: boolean;
  29237. }, scene: Scene): Mesh;
  29238. /**
  29239. * Creates a decal mesh.
  29240. * Please consider using the same method from the MeshBuilder class instead.
  29241. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29242. * @param name defines the name of the mesh
  29243. * @param sourceMesh defines the mesh receiving the decal
  29244. * @param position sets the position of the decal in world coordinates
  29245. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29246. * @param size sets the decal scaling
  29247. * @param angle sets the angle to rotate the decal
  29248. * @returns a new Mesh
  29249. */
  29250. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29251. /**
  29252. * Prepare internal position array for software CPU skinning
  29253. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29254. */
  29255. setPositionsForCPUSkinning(): Float32Array;
  29256. /**
  29257. * Prepare internal normal array for software CPU skinning
  29258. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29259. */
  29260. setNormalsForCPUSkinning(): Float32Array;
  29261. /**
  29262. * Updates the vertex buffer by applying transformation from the bones
  29263. * @param skeleton defines the skeleton to apply to current mesh
  29264. * @returns the current mesh
  29265. */
  29266. applySkeleton(skeleton: Skeleton): Mesh;
  29267. /**
  29268. * 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
  29269. * @param meshes defines the list of meshes to scan
  29270. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29271. */
  29272. static MinMax(meshes: AbstractMesh[]): {
  29273. min: Vector3;
  29274. max: Vector3;
  29275. };
  29276. /**
  29277. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29278. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29279. * @returns a vector3
  29280. */
  29281. static Center(meshesOrMinMaxVector: {
  29282. min: Vector3;
  29283. max: Vector3;
  29284. } | AbstractMesh[]): Vector3;
  29285. /**
  29286. * Merge the array of meshes into a single mesh for performance reasons.
  29287. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29288. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29289. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29290. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29291. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29292. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29293. * @returns a new mesh
  29294. */
  29295. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29296. /** @hidden */
  29297. addInstance(instance: InstancedMesh): void;
  29298. /** @hidden */
  29299. removeInstance(instance: InstancedMesh): void;
  29300. }
  29301. }
  29302. declare module BABYLON {
  29303. /**
  29304. * This is the base class of all the camera used in the application.
  29305. * @see https://doc.babylonjs.com/features/cameras
  29306. */
  29307. export class Camera extends Node {
  29308. /** @hidden */
  29309. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29310. /**
  29311. * This is the default projection mode used by the cameras.
  29312. * It helps recreating a feeling of perspective and better appreciate depth.
  29313. * This is the best way to simulate real life cameras.
  29314. */
  29315. static readonly PERSPECTIVE_CAMERA: number;
  29316. /**
  29317. * This helps creating camera with an orthographic mode.
  29318. * 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.
  29319. */
  29320. static readonly ORTHOGRAPHIC_CAMERA: number;
  29321. /**
  29322. * This is the default FOV mode for perspective cameras.
  29323. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29324. */
  29325. static readonly FOVMODE_VERTICAL_FIXED: number;
  29326. /**
  29327. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29328. */
  29329. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29330. /**
  29331. * This specifies ther is no need for a camera rig.
  29332. * Basically only one eye is rendered corresponding to the camera.
  29333. */
  29334. static readonly RIG_MODE_NONE: number;
  29335. /**
  29336. * Simulates a camera Rig with one blue eye and one red eye.
  29337. * This can be use with 3d blue and red glasses.
  29338. */
  29339. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29340. /**
  29341. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29342. */
  29343. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29344. /**
  29345. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29346. */
  29347. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29348. /**
  29349. * Defines that both eyes of the camera will be rendered over under each other.
  29350. */
  29351. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29352. /**
  29353. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29354. */
  29355. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29356. /**
  29357. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29358. */
  29359. static readonly RIG_MODE_VR: number;
  29360. /**
  29361. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29362. */
  29363. static readonly RIG_MODE_WEBVR: number;
  29364. /**
  29365. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29366. */
  29367. static readonly RIG_MODE_CUSTOM: number;
  29368. /**
  29369. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29370. */
  29371. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29372. /**
  29373. * Define the input manager associated with the camera.
  29374. */
  29375. inputs: CameraInputsManager<Camera>;
  29376. /** @hidden */
  29377. _position: Vector3;
  29378. /**
  29379. * Define the current local position of the camera in the scene
  29380. */
  29381. get position(): Vector3;
  29382. set position(newPosition: Vector3);
  29383. protected _upVector: Vector3;
  29384. /**
  29385. * The vector the camera should consider as up.
  29386. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29387. */
  29388. set upVector(vec: Vector3);
  29389. get upVector(): Vector3;
  29390. /**
  29391. * Define the current limit on the left side for an orthographic camera
  29392. * In scene unit
  29393. */
  29394. orthoLeft: Nullable<number>;
  29395. /**
  29396. * Define the current limit on the right side for an orthographic camera
  29397. * In scene unit
  29398. */
  29399. orthoRight: Nullable<number>;
  29400. /**
  29401. * Define the current limit on the bottom side for an orthographic camera
  29402. * In scene unit
  29403. */
  29404. orthoBottom: Nullable<number>;
  29405. /**
  29406. * Define the current limit on the top side for an orthographic camera
  29407. * In scene unit
  29408. */
  29409. orthoTop: Nullable<number>;
  29410. /**
  29411. * Field Of View is set in Radians. (default is 0.8)
  29412. */
  29413. fov: number;
  29414. /**
  29415. * Define the minimum distance the camera can see from.
  29416. * This is important to note that the depth buffer are not infinite and the closer it starts
  29417. * the more your scene might encounter depth fighting issue.
  29418. */
  29419. minZ: number;
  29420. /**
  29421. * Define the maximum distance the camera can see to.
  29422. * This is important to note that the depth buffer are not infinite and the further it end
  29423. * the more your scene might encounter depth fighting issue.
  29424. */
  29425. maxZ: number;
  29426. /**
  29427. * Define the default inertia of the camera.
  29428. * This helps giving a smooth feeling to the camera movement.
  29429. */
  29430. inertia: number;
  29431. /**
  29432. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29433. */
  29434. mode: number;
  29435. /**
  29436. * Define whether the camera is intermediate.
  29437. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29438. */
  29439. isIntermediate: boolean;
  29440. /**
  29441. * Define the viewport of the camera.
  29442. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29443. */
  29444. viewport: Viewport;
  29445. /**
  29446. * Restricts the camera to viewing objects with the same layerMask.
  29447. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29448. */
  29449. layerMask: number;
  29450. /**
  29451. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29452. */
  29453. fovMode: number;
  29454. /**
  29455. * Rig mode of the camera.
  29456. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29457. * This is normally controlled byt the camera themselves as internal use.
  29458. */
  29459. cameraRigMode: number;
  29460. /**
  29461. * Defines the distance between both "eyes" in case of a RIG
  29462. */
  29463. interaxialDistance: number;
  29464. /**
  29465. * Defines if stereoscopic rendering is done side by side or over under.
  29466. */
  29467. isStereoscopicSideBySide: boolean;
  29468. /**
  29469. * 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
  29470. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29471. * else in the scene. (Eg. security camera)
  29472. *
  29473. * 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)
  29474. */
  29475. customRenderTargets: RenderTargetTexture[];
  29476. /**
  29477. * When set, the camera will render to this render target instead of the default canvas
  29478. *
  29479. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29480. */
  29481. outputRenderTarget: Nullable<RenderTargetTexture>;
  29482. /**
  29483. * Observable triggered when the camera view matrix has changed.
  29484. */
  29485. onViewMatrixChangedObservable: Observable<Camera>;
  29486. /**
  29487. * Observable triggered when the camera Projection matrix has changed.
  29488. */
  29489. onProjectionMatrixChangedObservable: Observable<Camera>;
  29490. /**
  29491. * Observable triggered when the inputs have been processed.
  29492. */
  29493. onAfterCheckInputsObservable: Observable<Camera>;
  29494. /**
  29495. * Observable triggered when reset has been called and applied to the camera.
  29496. */
  29497. onRestoreStateObservable: Observable<Camera>;
  29498. /**
  29499. * Is this camera a part of a rig system?
  29500. */
  29501. isRigCamera: boolean;
  29502. /**
  29503. * If isRigCamera set to true this will be set with the parent camera.
  29504. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29505. */
  29506. rigParent?: Camera;
  29507. /** @hidden */
  29508. _cameraRigParams: any;
  29509. /** @hidden */
  29510. _rigCameras: Camera[];
  29511. /** @hidden */
  29512. _rigPostProcess: Nullable<PostProcess>;
  29513. protected _webvrViewMatrix: Matrix;
  29514. /** @hidden */
  29515. _skipRendering: boolean;
  29516. /** @hidden */
  29517. _projectionMatrix: Matrix;
  29518. /** @hidden */
  29519. _postProcesses: Nullable<PostProcess>[];
  29520. /** @hidden */
  29521. _activeMeshes: SmartArray<AbstractMesh>;
  29522. protected _globalPosition: Vector3;
  29523. /** @hidden */
  29524. _computedViewMatrix: Matrix;
  29525. private _doNotComputeProjectionMatrix;
  29526. private _transformMatrix;
  29527. private _frustumPlanes;
  29528. private _refreshFrustumPlanes;
  29529. private _storedFov;
  29530. private _stateStored;
  29531. /**
  29532. * Instantiates a new camera object.
  29533. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29534. * @see https://doc.babylonjs.com/features/cameras
  29535. * @param name Defines the name of the camera in the scene
  29536. * @param position Defines the position of the camera
  29537. * @param scene Defines the scene the camera belongs too
  29538. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29539. */
  29540. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29541. /**
  29542. * Store current camera state (fov, position, etc..)
  29543. * @returns the camera
  29544. */
  29545. storeState(): Camera;
  29546. /**
  29547. * Restores the camera state values if it has been stored. You must call storeState() first
  29548. */
  29549. protected _restoreStateValues(): boolean;
  29550. /**
  29551. * Restored camera state. You must call storeState() first.
  29552. * @returns true if restored and false otherwise
  29553. */
  29554. restoreState(): boolean;
  29555. /**
  29556. * Gets the class name of the camera.
  29557. * @returns the class name
  29558. */
  29559. getClassName(): string;
  29560. /** @hidden */
  29561. readonly _isCamera: boolean;
  29562. /**
  29563. * Gets a string representation of the camera useful for debug purpose.
  29564. * @param fullDetails Defines that a more verboe level of logging is required
  29565. * @returns the string representation
  29566. */
  29567. toString(fullDetails?: boolean): string;
  29568. /**
  29569. * Gets the current world space position of the camera.
  29570. */
  29571. get globalPosition(): Vector3;
  29572. /**
  29573. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29574. * @returns the active meshe list
  29575. */
  29576. getActiveMeshes(): SmartArray<AbstractMesh>;
  29577. /**
  29578. * Check whether a mesh is part of the current active mesh list of the camera
  29579. * @param mesh Defines the mesh to check
  29580. * @returns true if active, false otherwise
  29581. */
  29582. isActiveMesh(mesh: Mesh): boolean;
  29583. /**
  29584. * Is this camera ready to be used/rendered
  29585. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29586. * @return true if the camera is ready
  29587. */
  29588. isReady(completeCheck?: boolean): boolean;
  29589. /** @hidden */
  29590. _initCache(): void;
  29591. /** @hidden */
  29592. _updateCache(ignoreParentClass?: boolean): void;
  29593. /** @hidden */
  29594. _isSynchronized(): boolean;
  29595. /** @hidden */
  29596. _isSynchronizedViewMatrix(): boolean;
  29597. /** @hidden */
  29598. _isSynchronizedProjectionMatrix(): boolean;
  29599. /**
  29600. * Attach the input controls to a specific dom element to get the input from.
  29601. * @param element Defines the element the controls should be listened from
  29602. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29603. */
  29604. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29605. /**
  29606. * Detach the current controls from the specified dom element.
  29607. * @param element Defines the element to stop listening the inputs from
  29608. */
  29609. detachControl(element: HTMLElement): void;
  29610. /**
  29611. * Update the camera state according to the different inputs gathered during the frame.
  29612. */
  29613. update(): void;
  29614. /** @hidden */
  29615. _checkInputs(): void;
  29616. /** @hidden */
  29617. get rigCameras(): Camera[];
  29618. /**
  29619. * Gets the post process used by the rig cameras
  29620. */
  29621. get rigPostProcess(): Nullable<PostProcess>;
  29622. /**
  29623. * Internal, gets the first post proces.
  29624. * @returns the first post process to be run on this camera.
  29625. */
  29626. _getFirstPostProcess(): Nullable<PostProcess>;
  29627. private _cascadePostProcessesToRigCams;
  29628. /**
  29629. * Attach a post process to the camera.
  29630. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29631. * @param postProcess The post process to attach to the camera
  29632. * @param insertAt The position of the post process in case several of them are in use in the scene
  29633. * @returns the position the post process has been inserted at
  29634. */
  29635. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29636. /**
  29637. * Detach a post process to the camera.
  29638. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29639. * @param postProcess The post process to detach from the camera
  29640. */
  29641. detachPostProcess(postProcess: PostProcess): void;
  29642. /**
  29643. * Gets the current world matrix of the camera
  29644. */
  29645. getWorldMatrix(): Matrix;
  29646. /** @hidden */
  29647. _getViewMatrix(): Matrix;
  29648. /**
  29649. * Gets the current view matrix of the camera.
  29650. * @param force forces the camera to recompute the matrix without looking at the cached state
  29651. * @returns the view matrix
  29652. */
  29653. getViewMatrix(force?: boolean): Matrix;
  29654. /**
  29655. * Freeze the projection matrix.
  29656. * It will prevent the cache check of the camera projection compute and can speed up perf
  29657. * if no parameter of the camera are meant to change
  29658. * @param projection Defines manually a projection if necessary
  29659. */
  29660. freezeProjectionMatrix(projection?: Matrix): void;
  29661. /**
  29662. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29663. */
  29664. unfreezeProjectionMatrix(): void;
  29665. /**
  29666. * Gets the current projection matrix of the camera.
  29667. * @param force forces the camera to recompute the matrix without looking at the cached state
  29668. * @returns the projection matrix
  29669. */
  29670. getProjectionMatrix(force?: boolean): Matrix;
  29671. /**
  29672. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29673. * @returns a Matrix
  29674. */
  29675. getTransformationMatrix(): Matrix;
  29676. private _updateFrustumPlanes;
  29677. /**
  29678. * Checks if a cullable object (mesh...) is in the camera frustum
  29679. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29680. * @param target The object to check
  29681. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29682. * @returns true if the object is in frustum otherwise false
  29683. */
  29684. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29685. /**
  29686. * Checks if a cullable object (mesh...) is in the camera frustum
  29687. * Unlike isInFrustum this cheks the full bounding box
  29688. * @param target The object to check
  29689. * @returns true if the object is in frustum otherwise false
  29690. */
  29691. isCompletelyInFrustum(target: ICullable): boolean;
  29692. /**
  29693. * Gets a ray in the forward direction from the camera.
  29694. * @param length Defines the length of the ray to create
  29695. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29696. * @param origin Defines the start point of the ray which defaults to the camera position
  29697. * @returns the forward ray
  29698. */
  29699. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29700. /**
  29701. * Gets a ray in the forward direction from the camera.
  29702. * @param refRay the ray to (re)use when setting the values
  29703. * @param length Defines the length of the ray to create
  29704. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29705. * @param origin Defines the start point of the ray which defaults to the camera position
  29706. * @returns the forward ray
  29707. */
  29708. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29709. /**
  29710. * Releases resources associated with this node.
  29711. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29712. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29713. */
  29714. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29715. /** @hidden */
  29716. _isLeftCamera: boolean;
  29717. /**
  29718. * Gets the left camera of a rig setup in case of Rigged Camera
  29719. */
  29720. get isLeftCamera(): boolean;
  29721. /** @hidden */
  29722. _isRightCamera: boolean;
  29723. /**
  29724. * Gets the right camera of a rig setup in case of Rigged Camera
  29725. */
  29726. get isRightCamera(): boolean;
  29727. /**
  29728. * Gets the left camera of a rig setup in case of Rigged Camera
  29729. */
  29730. get leftCamera(): Nullable<FreeCamera>;
  29731. /**
  29732. * Gets the right camera of a rig setup in case of Rigged Camera
  29733. */
  29734. get rightCamera(): Nullable<FreeCamera>;
  29735. /**
  29736. * Gets the left camera target of a rig setup in case of Rigged Camera
  29737. * @returns the target position
  29738. */
  29739. getLeftTarget(): Nullable<Vector3>;
  29740. /**
  29741. * Gets the right camera target of a rig setup in case of Rigged Camera
  29742. * @returns the target position
  29743. */
  29744. getRightTarget(): Nullable<Vector3>;
  29745. /**
  29746. * @hidden
  29747. */
  29748. setCameraRigMode(mode: number, rigParams: any): void;
  29749. /** @hidden */
  29750. static _setStereoscopicRigMode(camera: Camera): void;
  29751. /** @hidden */
  29752. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29753. /** @hidden */
  29754. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29755. /** @hidden */
  29756. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29757. /** @hidden */
  29758. _getVRProjectionMatrix(): Matrix;
  29759. protected _updateCameraRotationMatrix(): void;
  29760. protected _updateWebVRCameraRotationMatrix(): void;
  29761. /**
  29762. * This function MUST be overwritten by the different WebVR cameras available.
  29763. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29764. * @hidden
  29765. */
  29766. _getWebVRProjectionMatrix(): Matrix;
  29767. /**
  29768. * This function MUST be overwritten by the different WebVR cameras available.
  29769. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29770. * @hidden
  29771. */
  29772. _getWebVRViewMatrix(): Matrix;
  29773. /** @hidden */
  29774. setCameraRigParameter(name: string, value: any): void;
  29775. /**
  29776. * needs to be overridden by children so sub has required properties to be copied
  29777. * @hidden
  29778. */
  29779. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29780. /**
  29781. * May need to be overridden by children
  29782. * @hidden
  29783. */
  29784. _updateRigCameras(): void;
  29785. /** @hidden */
  29786. _setupInputs(): void;
  29787. /**
  29788. * Serialiaze the camera setup to a json represention
  29789. * @returns the JSON representation
  29790. */
  29791. serialize(): any;
  29792. /**
  29793. * Clones the current camera.
  29794. * @param name The cloned camera name
  29795. * @returns the cloned camera
  29796. */
  29797. clone(name: string): Camera;
  29798. /**
  29799. * Gets the direction of the camera relative to a given local axis.
  29800. * @param localAxis Defines the reference axis to provide a relative direction.
  29801. * @return the direction
  29802. */
  29803. getDirection(localAxis: Vector3): Vector3;
  29804. /**
  29805. * Returns the current camera absolute rotation
  29806. */
  29807. get absoluteRotation(): Quaternion;
  29808. /**
  29809. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29810. * @param localAxis Defines the reference axis to provide a relative direction.
  29811. * @param result Defines the vector to store the result in
  29812. */
  29813. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29814. /**
  29815. * Gets a camera constructor for a given camera type
  29816. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29817. * @param name The name of the camera the result will be able to instantiate
  29818. * @param scene The scene the result will construct the camera in
  29819. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29820. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29821. * @returns a factory method to construc the camera
  29822. */
  29823. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29824. /**
  29825. * Compute the world matrix of the camera.
  29826. * @returns the camera world matrix
  29827. */
  29828. computeWorldMatrix(): Matrix;
  29829. /**
  29830. * Parse a JSON and creates the camera from the parsed information
  29831. * @param parsedCamera The JSON to parse
  29832. * @param scene The scene to instantiate the camera in
  29833. * @returns the newly constructed camera
  29834. */
  29835. static Parse(parsedCamera: any, scene: Scene): Camera;
  29836. }
  29837. }
  29838. declare module BABYLON {
  29839. /**
  29840. * Class containing static functions to help procedurally build meshes
  29841. */
  29842. export class DiscBuilder {
  29843. /**
  29844. * Creates a plane polygonal mesh. By default, this is a disc
  29845. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29846. * * 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
  29847. * * 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
  29848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29849. * * 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
  29850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29851. * @param name defines the name of the mesh
  29852. * @param options defines the options used to create the mesh
  29853. * @param scene defines the hosting scene
  29854. * @returns the plane polygonal mesh
  29855. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29856. */
  29857. static CreateDisc(name: string, options: {
  29858. radius?: number;
  29859. tessellation?: number;
  29860. arc?: number;
  29861. updatable?: boolean;
  29862. sideOrientation?: number;
  29863. frontUVs?: Vector4;
  29864. backUVs?: Vector4;
  29865. }, scene?: Nullable<Scene>): Mesh;
  29866. }
  29867. }
  29868. declare module BABYLON {
  29869. /**
  29870. * Options to be used when creating a FresnelParameters.
  29871. */
  29872. export type IFresnelParametersCreationOptions = {
  29873. /**
  29874. * Define the color used on edges (grazing angle)
  29875. */
  29876. leftColor?: Color3;
  29877. /**
  29878. * Define the color used on center
  29879. */
  29880. rightColor?: Color3;
  29881. /**
  29882. * Define bias applied to computed fresnel term
  29883. */
  29884. bias?: number;
  29885. /**
  29886. * Defined the power exponent applied to fresnel term
  29887. */
  29888. power?: number;
  29889. /**
  29890. * Define if the fresnel effect is enable or not.
  29891. */
  29892. isEnabled?: boolean;
  29893. };
  29894. /**
  29895. * Serialized format for FresnelParameters.
  29896. */
  29897. export type IFresnelParametersSerialized = {
  29898. /**
  29899. * Define the color used on edges (grazing angle) [as an array]
  29900. */
  29901. leftColor: number[];
  29902. /**
  29903. * Define the color used on center [as an array]
  29904. */
  29905. rightColor: number[];
  29906. /**
  29907. * Define bias applied to computed fresnel term
  29908. */
  29909. bias: number;
  29910. /**
  29911. * Defined the power exponent applied to fresnel term
  29912. */
  29913. power?: number;
  29914. /**
  29915. * Define if the fresnel effect is enable or not.
  29916. */
  29917. isEnabled: boolean;
  29918. };
  29919. /**
  29920. * This represents all the required information to add a fresnel effect on a material:
  29921. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29922. */
  29923. export class FresnelParameters {
  29924. private _isEnabled;
  29925. /**
  29926. * Define if the fresnel effect is enable or not.
  29927. */
  29928. get isEnabled(): boolean;
  29929. set isEnabled(value: boolean);
  29930. /**
  29931. * Define the color used on edges (grazing angle)
  29932. */
  29933. leftColor: Color3;
  29934. /**
  29935. * Define the color used on center
  29936. */
  29937. rightColor: Color3;
  29938. /**
  29939. * Define bias applied to computed fresnel term
  29940. */
  29941. bias: number;
  29942. /**
  29943. * Defined the power exponent applied to fresnel term
  29944. */
  29945. power: number;
  29946. /**
  29947. * Creates a new FresnelParameters object.
  29948. *
  29949. * @param options provide your own settings to optionally to override defaults
  29950. */
  29951. constructor(options?: IFresnelParametersCreationOptions);
  29952. /**
  29953. * Clones the current fresnel and its valuues
  29954. * @returns a clone fresnel configuration
  29955. */
  29956. clone(): FresnelParameters;
  29957. /**
  29958. * Determines equality between FresnelParameters objects
  29959. * @param otherFresnelParameters defines the second operand
  29960. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29961. */
  29962. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29963. /**
  29964. * Serializes the current fresnel parameters to a JSON representation.
  29965. * @return the JSON serialization
  29966. */
  29967. serialize(): IFresnelParametersSerialized;
  29968. /**
  29969. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29970. * @param parsedFresnelParameters Define the JSON representation
  29971. * @returns the parsed parameters
  29972. */
  29973. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29974. }
  29975. }
  29976. declare module BABYLON {
  29977. /**
  29978. * This groups all the flags used to control the materials channel.
  29979. */
  29980. export class MaterialFlags {
  29981. private static _DiffuseTextureEnabled;
  29982. /**
  29983. * Are diffuse textures enabled in the application.
  29984. */
  29985. static get DiffuseTextureEnabled(): boolean;
  29986. static set DiffuseTextureEnabled(value: boolean);
  29987. private static _DetailTextureEnabled;
  29988. /**
  29989. * Are detail textures enabled in the application.
  29990. */
  29991. static get DetailTextureEnabled(): boolean;
  29992. static set DetailTextureEnabled(value: boolean);
  29993. private static _AmbientTextureEnabled;
  29994. /**
  29995. * Are ambient textures enabled in the application.
  29996. */
  29997. static get AmbientTextureEnabled(): boolean;
  29998. static set AmbientTextureEnabled(value: boolean);
  29999. private static _OpacityTextureEnabled;
  30000. /**
  30001. * Are opacity textures enabled in the application.
  30002. */
  30003. static get OpacityTextureEnabled(): boolean;
  30004. static set OpacityTextureEnabled(value: boolean);
  30005. private static _ReflectionTextureEnabled;
  30006. /**
  30007. * Are reflection textures enabled in the application.
  30008. */
  30009. static get ReflectionTextureEnabled(): boolean;
  30010. static set ReflectionTextureEnabled(value: boolean);
  30011. private static _EmissiveTextureEnabled;
  30012. /**
  30013. * Are emissive textures enabled in the application.
  30014. */
  30015. static get EmissiveTextureEnabled(): boolean;
  30016. static set EmissiveTextureEnabled(value: boolean);
  30017. private static _SpecularTextureEnabled;
  30018. /**
  30019. * Are specular textures enabled in the application.
  30020. */
  30021. static get SpecularTextureEnabled(): boolean;
  30022. static set SpecularTextureEnabled(value: boolean);
  30023. private static _BumpTextureEnabled;
  30024. /**
  30025. * Are bump textures enabled in the application.
  30026. */
  30027. static get BumpTextureEnabled(): boolean;
  30028. static set BumpTextureEnabled(value: boolean);
  30029. private static _LightmapTextureEnabled;
  30030. /**
  30031. * Are lightmap textures enabled in the application.
  30032. */
  30033. static get LightmapTextureEnabled(): boolean;
  30034. static set LightmapTextureEnabled(value: boolean);
  30035. private static _RefractionTextureEnabled;
  30036. /**
  30037. * Are refraction textures enabled in the application.
  30038. */
  30039. static get RefractionTextureEnabled(): boolean;
  30040. static set RefractionTextureEnabled(value: boolean);
  30041. private static _ColorGradingTextureEnabled;
  30042. /**
  30043. * Are color grading textures enabled in the application.
  30044. */
  30045. static get ColorGradingTextureEnabled(): boolean;
  30046. static set ColorGradingTextureEnabled(value: boolean);
  30047. private static _FresnelEnabled;
  30048. /**
  30049. * Are fresnels enabled in the application.
  30050. */
  30051. static get FresnelEnabled(): boolean;
  30052. static set FresnelEnabled(value: boolean);
  30053. private static _ClearCoatTextureEnabled;
  30054. /**
  30055. * Are clear coat textures enabled in the application.
  30056. */
  30057. static get ClearCoatTextureEnabled(): boolean;
  30058. static set ClearCoatTextureEnabled(value: boolean);
  30059. private static _ClearCoatBumpTextureEnabled;
  30060. /**
  30061. * Are clear coat bump textures enabled in the application.
  30062. */
  30063. static get ClearCoatBumpTextureEnabled(): boolean;
  30064. static set ClearCoatBumpTextureEnabled(value: boolean);
  30065. private static _ClearCoatTintTextureEnabled;
  30066. /**
  30067. * Are clear coat tint textures enabled in the application.
  30068. */
  30069. static get ClearCoatTintTextureEnabled(): boolean;
  30070. static set ClearCoatTintTextureEnabled(value: boolean);
  30071. private static _SheenTextureEnabled;
  30072. /**
  30073. * Are sheen textures enabled in the application.
  30074. */
  30075. static get SheenTextureEnabled(): boolean;
  30076. static set SheenTextureEnabled(value: boolean);
  30077. private static _AnisotropicTextureEnabled;
  30078. /**
  30079. * Are anisotropic textures enabled in the application.
  30080. */
  30081. static get AnisotropicTextureEnabled(): boolean;
  30082. static set AnisotropicTextureEnabled(value: boolean);
  30083. private static _ThicknessTextureEnabled;
  30084. /**
  30085. * Are thickness textures enabled in the application.
  30086. */
  30087. static get ThicknessTextureEnabled(): boolean;
  30088. static set ThicknessTextureEnabled(value: boolean);
  30089. }
  30090. }
  30091. declare module BABYLON {
  30092. /** @hidden */
  30093. export var defaultFragmentDeclaration: {
  30094. name: string;
  30095. shader: string;
  30096. };
  30097. }
  30098. declare module BABYLON {
  30099. /** @hidden */
  30100. export var defaultUboDeclaration: {
  30101. name: string;
  30102. shader: string;
  30103. };
  30104. }
  30105. declare module BABYLON {
  30106. /** @hidden */
  30107. export var prePassDeclaration: {
  30108. name: string;
  30109. shader: string;
  30110. };
  30111. }
  30112. declare module BABYLON {
  30113. /** @hidden */
  30114. export var lightFragmentDeclaration: {
  30115. name: string;
  30116. shader: string;
  30117. };
  30118. }
  30119. declare module BABYLON {
  30120. /** @hidden */
  30121. export var lightUboDeclaration: {
  30122. name: string;
  30123. shader: string;
  30124. };
  30125. }
  30126. declare module BABYLON {
  30127. /** @hidden */
  30128. export var lightsFragmentFunctions: {
  30129. name: string;
  30130. shader: string;
  30131. };
  30132. }
  30133. declare module BABYLON {
  30134. /** @hidden */
  30135. export var shadowsFragmentFunctions: {
  30136. name: string;
  30137. shader: string;
  30138. };
  30139. }
  30140. declare module BABYLON {
  30141. /** @hidden */
  30142. export var fresnelFunction: {
  30143. name: string;
  30144. shader: string;
  30145. };
  30146. }
  30147. declare module BABYLON {
  30148. /** @hidden */
  30149. export var bumpFragmentMainFunctions: {
  30150. name: string;
  30151. shader: string;
  30152. };
  30153. }
  30154. declare module BABYLON {
  30155. /** @hidden */
  30156. export var bumpFragmentFunctions: {
  30157. name: string;
  30158. shader: string;
  30159. };
  30160. }
  30161. declare module BABYLON {
  30162. /** @hidden */
  30163. export var logDepthDeclaration: {
  30164. name: string;
  30165. shader: string;
  30166. };
  30167. }
  30168. declare module BABYLON {
  30169. /** @hidden */
  30170. export var bumpFragment: {
  30171. name: string;
  30172. shader: string;
  30173. };
  30174. }
  30175. declare module BABYLON {
  30176. /** @hidden */
  30177. export var depthPrePass: {
  30178. name: string;
  30179. shader: string;
  30180. };
  30181. }
  30182. declare module BABYLON {
  30183. /** @hidden */
  30184. export var lightFragment: {
  30185. name: string;
  30186. shader: string;
  30187. };
  30188. }
  30189. declare module BABYLON {
  30190. /** @hidden */
  30191. export var logDepthFragment: {
  30192. name: string;
  30193. shader: string;
  30194. };
  30195. }
  30196. declare module BABYLON {
  30197. /** @hidden */
  30198. export var defaultPixelShader: {
  30199. name: string;
  30200. shader: string;
  30201. };
  30202. }
  30203. declare module BABYLON {
  30204. /** @hidden */
  30205. export var defaultVertexDeclaration: {
  30206. name: string;
  30207. shader: string;
  30208. };
  30209. }
  30210. declare module BABYLON {
  30211. /** @hidden */
  30212. export var bumpVertexDeclaration: {
  30213. name: string;
  30214. shader: string;
  30215. };
  30216. }
  30217. declare module BABYLON {
  30218. /** @hidden */
  30219. export var bumpVertex: {
  30220. name: string;
  30221. shader: string;
  30222. };
  30223. }
  30224. declare module BABYLON {
  30225. /** @hidden */
  30226. export var fogVertex: {
  30227. name: string;
  30228. shader: string;
  30229. };
  30230. }
  30231. declare module BABYLON {
  30232. /** @hidden */
  30233. export var shadowsVertex: {
  30234. name: string;
  30235. shader: string;
  30236. };
  30237. }
  30238. declare module BABYLON {
  30239. /** @hidden */
  30240. export var pointCloudVertex: {
  30241. name: string;
  30242. shader: string;
  30243. };
  30244. }
  30245. declare module BABYLON {
  30246. /** @hidden */
  30247. export var logDepthVertex: {
  30248. name: string;
  30249. shader: string;
  30250. };
  30251. }
  30252. declare module BABYLON {
  30253. /** @hidden */
  30254. export var defaultVertexShader: {
  30255. name: string;
  30256. shader: string;
  30257. };
  30258. }
  30259. declare module BABYLON {
  30260. /**
  30261. * @hidden
  30262. */
  30263. export interface IMaterialDetailMapDefines {
  30264. DETAIL: boolean;
  30265. DETAILDIRECTUV: number;
  30266. DETAIL_NORMALBLENDMETHOD: number;
  30267. /** @hidden */
  30268. _areTexturesDirty: boolean;
  30269. }
  30270. /**
  30271. * Define the code related to the detail map parameters of a material
  30272. *
  30273. * Inspired from:
  30274. * 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
  30275. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30276. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30277. */
  30278. export class DetailMapConfiguration {
  30279. private _texture;
  30280. /**
  30281. * The detail texture of the material.
  30282. */
  30283. texture: Nullable<BaseTexture>;
  30284. /**
  30285. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30286. * Bigger values mean stronger blending
  30287. */
  30288. diffuseBlendLevel: number;
  30289. /**
  30290. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30291. * Bigger values mean stronger blending. Only used with PBR materials
  30292. */
  30293. roughnessBlendLevel: number;
  30294. /**
  30295. * Defines how strong the bump effect from the detail map is
  30296. * Bigger values mean stronger effect
  30297. */
  30298. bumpLevel: number;
  30299. private _normalBlendMethod;
  30300. /**
  30301. * The method used to blend the bump and detail normals together
  30302. */
  30303. normalBlendMethod: number;
  30304. private _isEnabled;
  30305. /**
  30306. * Enable or disable the detail map on this material
  30307. */
  30308. isEnabled: boolean;
  30309. /** @hidden */
  30310. private _internalMarkAllSubMeshesAsTexturesDirty;
  30311. /** @hidden */
  30312. _markAllSubMeshesAsTexturesDirty(): void;
  30313. /**
  30314. * Instantiate a new detail map
  30315. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30316. */
  30317. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30318. /**
  30319. * Gets whether the submesh is ready to be used or not.
  30320. * @param defines the list of "defines" to update.
  30321. * @param scene defines the scene the material belongs to.
  30322. * @returns - boolean indicating that the submesh is ready or not.
  30323. */
  30324. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30325. /**
  30326. * Update the defines for detail map usage
  30327. * @param defines the list of "defines" to update.
  30328. * @param scene defines the scene the material belongs to.
  30329. */
  30330. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30331. /**
  30332. * Binds the material data.
  30333. * @param uniformBuffer defines the Uniform buffer to fill in.
  30334. * @param scene defines the scene the material belongs to.
  30335. * @param isFrozen defines whether the material is frozen or not.
  30336. */
  30337. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30338. /**
  30339. * Checks to see if a texture is used in the material.
  30340. * @param texture - Base texture to use.
  30341. * @returns - Boolean specifying if a texture is used in the material.
  30342. */
  30343. hasTexture(texture: BaseTexture): boolean;
  30344. /**
  30345. * Returns an array of the actively used textures.
  30346. * @param activeTextures Array of BaseTextures
  30347. */
  30348. getActiveTextures(activeTextures: BaseTexture[]): void;
  30349. /**
  30350. * Returns the animatable textures.
  30351. * @param animatables Array of animatable textures.
  30352. */
  30353. getAnimatables(animatables: IAnimatable[]): void;
  30354. /**
  30355. * Disposes the resources of the material.
  30356. * @param forceDisposeTextures - Forces the disposal of all textures.
  30357. */
  30358. dispose(forceDisposeTextures?: boolean): void;
  30359. /**
  30360. * Get the current class name useful for serialization or dynamic coding.
  30361. * @returns "DetailMap"
  30362. */
  30363. getClassName(): string;
  30364. /**
  30365. * Add the required uniforms to the current list.
  30366. * @param uniforms defines the current uniform list.
  30367. */
  30368. static AddUniforms(uniforms: string[]): void;
  30369. /**
  30370. * Add the required samplers to the current list.
  30371. * @param samplers defines the current sampler list.
  30372. */
  30373. static AddSamplers(samplers: string[]): void;
  30374. /**
  30375. * Add the required uniforms to the current buffer.
  30376. * @param uniformBuffer defines the current uniform buffer.
  30377. */
  30378. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30379. /**
  30380. * Makes a duplicate of the current instance into another one.
  30381. * @param detailMap define the instance where to copy the info
  30382. */
  30383. copyTo(detailMap: DetailMapConfiguration): void;
  30384. /**
  30385. * Serializes this detail map instance
  30386. * @returns - An object with the serialized instance.
  30387. */
  30388. serialize(): any;
  30389. /**
  30390. * Parses a detail map setting from a serialized object.
  30391. * @param source - Serialized object.
  30392. * @param scene Defines the scene we are parsing for
  30393. * @param rootUrl Defines the rootUrl to load from
  30394. */
  30395. parse(source: any, scene: Scene, rootUrl: string): void;
  30396. }
  30397. }
  30398. declare module BABYLON {
  30399. /** @hidden */
  30400. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30401. MAINUV1: boolean;
  30402. MAINUV2: boolean;
  30403. DIFFUSE: boolean;
  30404. DIFFUSEDIRECTUV: number;
  30405. DETAIL: boolean;
  30406. DETAILDIRECTUV: number;
  30407. DETAIL_NORMALBLENDMETHOD: number;
  30408. AMBIENT: boolean;
  30409. AMBIENTDIRECTUV: number;
  30410. OPACITY: boolean;
  30411. OPACITYDIRECTUV: number;
  30412. OPACITYRGB: boolean;
  30413. REFLECTION: boolean;
  30414. EMISSIVE: boolean;
  30415. EMISSIVEDIRECTUV: number;
  30416. SPECULAR: boolean;
  30417. SPECULARDIRECTUV: number;
  30418. BUMP: boolean;
  30419. BUMPDIRECTUV: number;
  30420. PARALLAX: boolean;
  30421. PARALLAXOCCLUSION: boolean;
  30422. SPECULAROVERALPHA: boolean;
  30423. CLIPPLANE: boolean;
  30424. CLIPPLANE2: boolean;
  30425. CLIPPLANE3: boolean;
  30426. CLIPPLANE4: boolean;
  30427. CLIPPLANE5: boolean;
  30428. CLIPPLANE6: boolean;
  30429. ALPHATEST: boolean;
  30430. DEPTHPREPASS: boolean;
  30431. ALPHAFROMDIFFUSE: boolean;
  30432. POINTSIZE: boolean;
  30433. FOG: boolean;
  30434. SPECULARTERM: boolean;
  30435. DIFFUSEFRESNEL: boolean;
  30436. OPACITYFRESNEL: boolean;
  30437. REFLECTIONFRESNEL: boolean;
  30438. REFRACTIONFRESNEL: boolean;
  30439. EMISSIVEFRESNEL: boolean;
  30440. FRESNEL: boolean;
  30441. NORMAL: boolean;
  30442. UV1: boolean;
  30443. UV2: boolean;
  30444. VERTEXCOLOR: boolean;
  30445. VERTEXALPHA: boolean;
  30446. NUM_BONE_INFLUENCERS: number;
  30447. BonesPerMesh: number;
  30448. BONETEXTURE: boolean;
  30449. INSTANCES: boolean;
  30450. THIN_INSTANCES: boolean;
  30451. GLOSSINESS: boolean;
  30452. ROUGHNESS: boolean;
  30453. EMISSIVEASILLUMINATION: boolean;
  30454. LINKEMISSIVEWITHDIFFUSE: boolean;
  30455. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30456. LIGHTMAP: boolean;
  30457. LIGHTMAPDIRECTUV: number;
  30458. OBJECTSPACE_NORMALMAP: boolean;
  30459. USELIGHTMAPASSHADOWMAP: boolean;
  30460. REFLECTIONMAP_3D: boolean;
  30461. REFLECTIONMAP_SPHERICAL: boolean;
  30462. REFLECTIONMAP_PLANAR: boolean;
  30463. REFLECTIONMAP_CUBIC: boolean;
  30464. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30465. REFLECTIONMAP_PROJECTION: boolean;
  30466. REFLECTIONMAP_SKYBOX: boolean;
  30467. REFLECTIONMAP_EXPLICIT: boolean;
  30468. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30469. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30470. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30471. INVERTCUBICMAP: boolean;
  30472. LOGARITHMICDEPTH: boolean;
  30473. REFRACTION: boolean;
  30474. REFRACTIONMAP_3D: boolean;
  30475. REFLECTIONOVERALPHA: boolean;
  30476. TWOSIDEDLIGHTING: boolean;
  30477. SHADOWFLOAT: boolean;
  30478. MORPHTARGETS: boolean;
  30479. MORPHTARGETS_NORMAL: boolean;
  30480. MORPHTARGETS_TANGENT: boolean;
  30481. MORPHTARGETS_UV: boolean;
  30482. NUM_MORPH_INFLUENCERS: number;
  30483. NONUNIFORMSCALING: boolean;
  30484. PREMULTIPLYALPHA: boolean;
  30485. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30486. ALPHABLEND: boolean;
  30487. PREPASS: boolean;
  30488. SCENE_MRT_COUNT: number;
  30489. RGBDLIGHTMAP: boolean;
  30490. RGBDREFLECTION: boolean;
  30491. RGBDREFRACTION: boolean;
  30492. IMAGEPROCESSING: boolean;
  30493. VIGNETTE: boolean;
  30494. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30495. VIGNETTEBLENDMODEOPAQUE: boolean;
  30496. TONEMAPPING: boolean;
  30497. TONEMAPPING_ACES: boolean;
  30498. CONTRAST: boolean;
  30499. COLORCURVES: boolean;
  30500. COLORGRADING: boolean;
  30501. COLORGRADING3D: boolean;
  30502. SAMPLER3DGREENDEPTH: boolean;
  30503. SAMPLER3DBGRMAP: boolean;
  30504. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30505. MULTIVIEW: boolean;
  30506. /**
  30507. * If the reflection texture on this material is in linear color space
  30508. * @hidden
  30509. */
  30510. IS_REFLECTION_LINEAR: boolean;
  30511. /**
  30512. * If the refraction texture on this material is in linear color space
  30513. * @hidden
  30514. */
  30515. IS_REFRACTION_LINEAR: boolean;
  30516. EXPOSURE: boolean;
  30517. constructor();
  30518. setReflectionMode(modeToEnable: string): void;
  30519. }
  30520. /**
  30521. * This is the default material used in Babylon. It is the best trade off between quality
  30522. * and performances.
  30523. * @see https://doc.babylonjs.com/babylon101/materials
  30524. */
  30525. export class StandardMaterial extends PushMaterial {
  30526. private _diffuseTexture;
  30527. /**
  30528. * The basic texture of the material as viewed under a light.
  30529. */
  30530. diffuseTexture: Nullable<BaseTexture>;
  30531. private _ambientTexture;
  30532. /**
  30533. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30534. */
  30535. ambientTexture: Nullable<BaseTexture>;
  30536. private _opacityTexture;
  30537. /**
  30538. * Define the transparency of the material from a texture.
  30539. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30540. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30541. */
  30542. opacityTexture: Nullable<BaseTexture>;
  30543. private _reflectionTexture;
  30544. /**
  30545. * Define the texture used to display the reflection.
  30546. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30547. */
  30548. reflectionTexture: Nullable<BaseTexture>;
  30549. private _emissiveTexture;
  30550. /**
  30551. * Define texture of the material as if self lit.
  30552. * This will be mixed in the final result even in the absence of light.
  30553. */
  30554. emissiveTexture: Nullable<BaseTexture>;
  30555. private _specularTexture;
  30556. /**
  30557. * Define how the color and intensity of the highlight given by the light in the material.
  30558. */
  30559. specularTexture: Nullable<BaseTexture>;
  30560. private _bumpTexture;
  30561. /**
  30562. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30563. * 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.
  30564. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30565. */
  30566. bumpTexture: Nullable<BaseTexture>;
  30567. private _lightmapTexture;
  30568. /**
  30569. * Complex lighting can be computationally expensive to compute at runtime.
  30570. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30571. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30572. */
  30573. lightmapTexture: Nullable<BaseTexture>;
  30574. private _refractionTexture;
  30575. /**
  30576. * Define the texture used to display the refraction.
  30577. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30578. */
  30579. refractionTexture: Nullable<BaseTexture>;
  30580. /**
  30581. * The color of the material lit by the environmental background lighting.
  30582. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30583. */
  30584. ambientColor: Color3;
  30585. /**
  30586. * The basic color of the material as viewed under a light.
  30587. */
  30588. diffuseColor: Color3;
  30589. /**
  30590. * Define how the color and intensity of the highlight given by the light in the material.
  30591. */
  30592. specularColor: Color3;
  30593. /**
  30594. * Define the color of the material as if self lit.
  30595. * This will be mixed in the final result even in the absence of light.
  30596. */
  30597. emissiveColor: Color3;
  30598. /**
  30599. * Defines how sharp are the highlights in the material.
  30600. * The bigger the value the sharper giving a more glossy feeling to the result.
  30601. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30602. */
  30603. specularPower: number;
  30604. private _useAlphaFromDiffuseTexture;
  30605. /**
  30606. * Does the transparency come from the diffuse texture alpha channel.
  30607. */
  30608. useAlphaFromDiffuseTexture: boolean;
  30609. private _useEmissiveAsIllumination;
  30610. /**
  30611. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30612. */
  30613. useEmissiveAsIllumination: boolean;
  30614. private _linkEmissiveWithDiffuse;
  30615. /**
  30616. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30617. * the emissive level when the final color is close to one.
  30618. */
  30619. linkEmissiveWithDiffuse: boolean;
  30620. private _useSpecularOverAlpha;
  30621. /**
  30622. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30623. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30624. */
  30625. useSpecularOverAlpha: boolean;
  30626. private _useReflectionOverAlpha;
  30627. /**
  30628. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30629. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30630. */
  30631. useReflectionOverAlpha: boolean;
  30632. private _disableLighting;
  30633. /**
  30634. * Does lights from the scene impacts this material.
  30635. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30636. */
  30637. disableLighting: boolean;
  30638. private _useObjectSpaceNormalMap;
  30639. /**
  30640. * Allows using an object space normal map (instead of tangent space).
  30641. */
  30642. useObjectSpaceNormalMap: boolean;
  30643. private _useParallax;
  30644. /**
  30645. * Is parallax enabled or not.
  30646. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30647. */
  30648. useParallax: boolean;
  30649. private _useParallaxOcclusion;
  30650. /**
  30651. * Is parallax occlusion enabled or not.
  30652. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30653. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30654. */
  30655. useParallaxOcclusion: boolean;
  30656. /**
  30657. * 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.
  30658. */
  30659. parallaxScaleBias: number;
  30660. private _roughness;
  30661. /**
  30662. * Helps to define how blurry the reflections should appears in the material.
  30663. */
  30664. roughness: number;
  30665. /**
  30666. * In case of refraction, define the value of the index of refraction.
  30667. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30668. */
  30669. indexOfRefraction: number;
  30670. /**
  30671. * Invert the refraction texture alongside the y axis.
  30672. * It can be useful with procedural textures or probe for instance.
  30673. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30674. */
  30675. invertRefractionY: boolean;
  30676. /**
  30677. * Defines the alpha limits in alpha test mode.
  30678. */
  30679. alphaCutOff: number;
  30680. private _useLightmapAsShadowmap;
  30681. /**
  30682. * In case of light mapping, define whether the map contains light or shadow informations.
  30683. */
  30684. useLightmapAsShadowmap: boolean;
  30685. private _diffuseFresnelParameters;
  30686. /**
  30687. * Define the diffuse fresnel parameters of the material.
  30688. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30689. */
  30690. diffuseFresnelParameters: FresnelParameters;
  30691. private _opacityFresnelParameters;
  30692. /**
  30693. * Define the opacity fresnel parameters of the material.
  30694. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30695. */
  30696. opacityFresnelParameters: FresnelParameters;
  30697. private _reflectionFresnelParameters;
  30698. /**
  30699. * Define the reflection fresnel parameters of the material.
  30700. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30701. */
  30702. reflectionFresnelParameters: FresnelParameters;
  30703. private _refractionFresnelParameters;
  30704. /**
  30705. * Define the refraction fresnel parameters of the material.
  30706. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30707. */
  30708. refractionFresnelParameters: FresnelParameters;
  30709. private _emissiveFresnelParameters;
  30710. /**
  30711. * Define the emissive fresnel parameters of the material.
  30712. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30713. */
  30714. emissiveFresnelParameters: FresnelParameters;
  30715. private _useReflectionFresnelFromSpecular;
  30716. /**
  30717. * If true automatically deducts the fresnels values from the material specularity.
  30718. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30719. */
  30720. useReflectionFresnelFromSpecular: boolean;
  30721. private _useGlossinessFromSpecularMapAlpha;
  30722. /**
  30723. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30724. */
  30725. useGlossinessFromSpecularMapAlpha: boolean;
  30726. private _maxSimultaneousLights;
  30727. /**
  30728. * Defines the maximum number of lights that can be used in the material
  30729. */
  30730. maxSimultaneousLights: number;
  30731. private _invertNormalMapX;
  30732. /**
  30733. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30734. */
  30735. invertNormalMapX: boolean;
  30736. private _invertNormalMapY;
  30737. /**
  30738. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30739. */
  30740. invertNormalMapY: boolean;
  30741. private _twoSidedLighting;
  30742. /**
  30743. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30744. */
  30745. twoSidedLighting: boolean;
  30746. /**
  30747. * Default configuration related to image processing available in the standard Material.
  30748. */
  30749. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30750. /**
  30751. * Gets the image processing configuration used either in this material.
  30752. */
  30753. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30754. /**
  30755. * Sets the Default image processing configuration used either in the this material.
  30756. *
  30757. * If sets to null, the scene one is in use.
  30758. */
  30759. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30760. /**
  30761. * Keep track of the image processing observer to allow dispose and replace.
  30762. */
  30763. private _imageProcessingObserver;
  30764. /**
  30765. * Attaches a new image processing configuration to the Standard Material.
  30766. * @param configuration
  30767. */
  30768. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30769. /**
  30770. * Gets wether the color curves effect is enabled.
  30771. */
  30772. get cameraColorCurvesEnabled(): boolean;
  30773. /**
  30774. * Sets wether the color curves effect is enabled.
  30775. */
  30776. set cameraColorCurvesEnabled(value: boolean);
  30777. /**
  30778. * Gets wether the color grading effect is enabled.
  30779. */
  30780. get cameraColorGradingEnabled(): boolean;
  30781. /**
  30782. * Gets wether the color grading effect is enabled.
  30783. */
  30784. set cameraColorGradingEnabled(value: boolean);
  30785. /**
  30786. * Gets wether tonemapping is enabled or not.
  30787. */
  30788. get cameraToneMappingEnabled(): boolean;
  30789. /**
  30790. * Sets wether tonemapping is enabled or not
  30791. */
  30792. set cameraToneMappingEnabled(value: boolean);
  30793. /**
  30794. * The camera exposure used on this material.
  30795. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30796. * This corresponds to a photographic exposure.
  30797. */
  30798. get cameraExposure(): number;
  30799. /**
  30800. * The camera exposure used on this material.
  30801. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30802. * This corresponds to a photographic exposure.
  30803. */
  30804. set cameraExposure(value: number);
  30805. /**
  30806. * Gets The camera contrast used on this material.
  30807. */
  30808. get cameraContrast(): number;
  30809. /**
  30810. * Sets The camera contrast used on this material.
  30811. */
  30812. set cameraContrast(value: number);
  30813. /**
  30814. * Gets the Color Grading 2D Lookup Texture.
  30815. */
  30816. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30817. /**
  30818. * Sets the Color Grading 2D Lookup Texture.
  30819. */
  30820. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30821. /**
  30822. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30823. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30824. * 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;
  30825. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30826. */
  30827. get cameraColorCurves(): Nullable<ColorCurves>;
  30828. /**
  30829. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30830. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30831. * 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;
  30832. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30833. */
  30834. set cameraColorCurves(value: Nullable<ColorCurves>);
  30835. /**
  30836. * Can this material render to several textures at once
  30837. */
  30838. get canRenderToMRT(): boolean;
  30839. /**
  30840. * Defines the detail map parameters for the material.
  30841. */
  30842. readonly detailMap: DetailMapConfiguration;
  30843. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30844. protected _worldViewProjectionMatrix: Matrix;
  30845. protected _globalAmbientColor: Color3;
  30846. protected _useLogarithmicDepth: boolean;
  30847. protected _rebuildInParallel: boolean;
  30848. /**
  30849. * Instantiates a new standard material.
  30850. * This is the default material used in Babylon. It is the best trade off between quality
  30851. * and performances.
  30852. * @see https://doc.babylonjs.com/babylon101/materials
  30853. * @param name Define the name of the material in the scene
  30854. * @param scene Define the scene the material belong to
  30855. */
  30856. constructor(name: string, scene: Scene);
  30857. /**
  30858. * Gets a boolean indicating that current material needs to register RTT
  30859. */
  30860. get hasRenderTargetTextures(): boolean;
  30861. /**
  30862. * Gets the current class name of the material e.g. "StandardMaterial"
  30863. * Mainly use in serialization.
  30864. * @returns the class name
  30865. */
  30866. getClassName(): string;
  30867. /**
  30868. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30869. * You can try switching to logarithmic depth.
  30870. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30871. */
  30872. get useLogarithmicDepth(): boolean;
  30873. set useLogarithmicDepth(value: boolean);
  30874. /**
  30875. * Specifies if the material will require alpha blending
  30876. * @returns a boolean specifying if alpha blending is needed
  30877. */
  30878. needAlphaBlending(): boolean;
  30879. /**
  30880. * Specifies if this material should be rendered in alpha test mode
  30881. * @returns a boolean specifying if an alpha test is needed.
  30882. */
  30883. needAlphaTesting(): boolean;
  30884. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30885. /**
  30886. * Get the texture used for alpha test purpose.
  30887. * @returns the diffuse texture in case of the standard material.
  30888. */
  30889. getAlphaTestTexture(): Nullable<BaseTexture>;
  30890. /**
  30891. * Get if the submesh is ready to be used and all its information available.
  30892. * Child classes can use it to update shaders
  30893. * @param mesh defines the mesh to check
  30894. * @param subMesh defines which submesh to check
  30895. * @param useInstances specifies that instances should be used
  30896. * @returns a boolean indicating that the submesh is ready or not
  30897. */
  30898. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30899. /**
  30900. * Builds the material UBO layouts.
  30901. * Used internally during the effect preparation.
  30902. */
  30903. buildUniformLayout(): void;
  30904. /**
  30905. * Unbinds the material from the mesh
  30906. */
  30907. unbind(): void;
  30908. /**
  30909. * Binds the submesh to this material by preparing the effect and shader to draw
  30910. * @param world defines the world transformation matrix
  30911. * @param mesh defines the mesh containing the submesh
  30912. * @param subMesh defines the submesh to bind the material to
  30913. */
  30914. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30915. /**
  30916. * Get the list of animatables in the material.
  30917. * @returns the list of animatables object used in the material
  30918. */
  30919. getAnimatables(): IAnimatable[];
  30920. /**
  30921. * Gets the active textures from the material
  30922. * @returns an array of textures
  30923. */
  30924. getActiveTextures(): BaseTexture[];
  30925. /**
  30926. * Specifies if the material uses a texture
  30927. * @param texture defines the texture to check against the material
  30928. * @returns a boolean specifying if the material uses the texture
  30929. */
  30930. hasTexture(texture: BaseTexture): boolean;
  30931. /**
  30932. * Disposes the material
  30933. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30934. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30935. */
  30936. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30937. /**
  30938. * Makes a duplicate of the material, and gives it a new name
  30939. * @param name defines the new name for the duplicated material
  30940. * @returns the cloned material
  30941. */
  30942. clone(name: string): StandardMaterial;
  30943. /**
  30944. * Serializes this material in a JSON representation
  30945. * @returns the serialized material object
  30946. */
  30947. serialize(): any;
  30948. /**
  30949. * Creates a standard material from parsed material data
  30950. * @param source defines the JSON representation of the material
  30951. * @param scene defines the hosting scene
  30952. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30953. * @returns a new standard material
  30954. */
  30955. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30956. /**
  30957. * Are diffuse textures enabled in the application.
  30958. */
  30959. static get DiffuseTextureEnabled(): boolean;
  30960. static set DiffuseTextureEnabled(value: boolean);
  30961. /**
  30962. * Are detail textures enabled in the application.
  30963. */
  30964. static get DetailTextureEnabled(): boolean;
  30965. static set DetailTextureEnabled(value: boolean);
  30966. /**
  30967. * Are ambient textures enabled in the application.
  30968. */
  30969. static get AmbientTextureEnabled(): boolean;
  30970. static set AmbientTextureEnabled(value: boolean);
  30971. /**
  30972. * Are opacity textures enabled in the application.
  30973. */
  30974. static get OpacityTextureEnabled(): boolean;
  30975. static set OpacityTextureEnabled(value: boolean);
  30976. /**
  30977. * Are reflection textures enabled in the application.
  30978. */
  30979. static get ReflectionTextureEnabled(): boolean;
  30980. static set ReflectionTextureEnabled(value: boolean);
  30981. /**
  30982. * Are emissive textures enabled in the application.
  30983. */
  30984. static get EmissiveTextureEnabled(): boolean;
  30985. static set EmissiveTextureEnabled(value: boolean);
  30986. /**
  30987. * Are specular textures enabled in the application.
  30988. */
  30989. static get SpecularTextureEnabled(): boolean;
  30990. static set SpecularTextureEnabled(value: boolean);
  30991. /**
  30992. * Are bump textures enabled in the application.
  30993. */
  30994. static get BumpTextureEnabled(): boolean;
  30995. static set BumpTextureEnabled(value: boolean);
  30996. /**
  30997. * Are lightmap textures enabled in the application.
  30998. */
  30999. static get LightmapTextureEnabled(): boolean;
  31000. static set LightmapTextureEnabled(value: boolean);
  31001. /**
  31002. * Are refraction textures enabled in the application.
  31003. */
  31004. static get RefractionTextureEnabled(): boolean;
  31005. static set RefractionTextureEnabled(value: boolean);
  31006. /**
  31007. * Are color grading textures enabled in the application.
  31008. */
  31009. static get ColorGradingTextureEnabled(): boolean;
  31010. static set ColorGradingTextureEnabled(value: boolean);
  31011. /**
  31012. * Are fresnels enabled in the application.
  31013. */
  31014. static get FresnelEnabled(): boolean;
  31015. static set FresnelEnabled(value: boolean);
  31016. }
  31017. }
  31018. declare module BABYLON {
  31019. /**
  31020. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31021. *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.
  31022. * The SPS is also a particle system. It provides some methods to manage the particles.
  31023. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31024. *
  31025. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31026. */
  31027. export class SolidParticleSystem implements IDisposable {
  31028. /**
  31029. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31030. * Example : var p = SPS.particles[i];
  31031. */
  31032. particles: SolidParticle[];
  31033. /**
  31034. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31035. */
  31036. nbParticles: number;
  31037. /**
  31038. * If the particles must ever face the camera (default false). Useful for planar particles.
  31039. */
  31040. billboard: boolean;
  31041. /**
  31042. * Recompute normals when adding a shape
  31043. */
  31044. recomputeNormals: boolean;
  31045. /**
  31046. * This a counter ofr your own usage. It's not set by any SPS functions.
  31047. */
  31048. counter: number;
  31049. /**
  31050. * The SPS name. This name is also given to the underlying mesh.
  31051. */
  31052. name: string;
  31053. /**
  31054. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31055. */
  31056. mesh: Mesh;
  31057. /**
  31058. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31059. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31060. */
  31061. vars: any;
  31062. /**
  31063. * This array is populated when the SPS is set as 'pickable'.
  31064. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31065. * Each element of this array is an object `{idx: int, faceId: int}`.
  31066. * `idx` is the picked particle index in the `SPS.particles` array
  31067. * `faceId` is the picked face index counted within this particle.
  31068. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31069. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31070. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31071. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31072. */
  31073. pickedParticles: {
  31074. idx: number;
  31075. faceId: number;
  31076. }[];
  31077. /**
  31078. * This array is populated when the SPS is set as 'pickable'
  31079. * Each key of this array is a submesh index.
  31080. * Each element of this array is a second array defined like this :
  31081. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31082. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31083. * `idx` is the picked particle index in the `SPS.particles` array
  31084. * `faceId` is the picked face index counted within this particle.
  31085. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31086. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31087. */
  31088. pickedBySubMesh: {
  31089. idx: number;
  31090. faceId: number;
  31091. }[][];
  31092. /**
  31093. * This array is populated when `enableDepthSort` is set to true.
  31094. * Each element of this array is an instance of the class DepthSortedParticle.
  31095. */
  31096. depthSortedParticles: DepthSortedParticle[];
  31097. /**
  31098. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31099. * @hidden
  31100. */
  31101. _bSphereOnly: boolean;
  31102. /**
  31103. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31104. * @hidden
  31105. */
  31106. _bSphereRadiusFactor: number;
  31107. private _scene;
  31108. private _positions;
  31109. private _indices;
  31110. private _normals;
  31111. private _colors;
  31112. private _uvs;
  31113. private _indices32;
  31114. private _positions32;
  31115. private _normals32;
  31116. private _fixedNormal32;
  31117. private _colors32;
  31118. private _uvs32;
  31119. private _index;
  31120. private _updatable;
  31121. private _pickable;
  31122. private _isVisibilityBoxLocked;
  31123. private _alwaysVisible;
  31124. private _depthSort;
  31125. private _expandable;
  31126. private _shapeCounter;
  31127. private _copy;
  31128. private _color;
  31129. private _computeParticleColor;
  31130. private _computeParticleTexture;
  31131. private _computeParticleRotation;
  31132. private _computeParticleVertex;
  31133. private _computeBoundingBox;
  31134. private _depthSortParticles;
  31135. private _camera;
  31136. private _mustUnrotateFixedNormals;
  31137. private _particlesIntersect;
  31138. private _needs32Bits;
  31139. private _isNotBuilt;
  31140. private _lastParticleId;
  31141. private _idxOfId;
  31142. private _multimaterialEnabled;
  31143. private _useModelMaterial;
  31144. private _indicesByMaterial;
  31145. private _materialIndexes;
  31146. private _depthSortFunction;
  31147. private _materialSortFunction;
  31148. private _materials;
  31149. private _multimaterial;
  31150. private _materialIndexesById;
  31151. private _defaultMaterial;
  31152. private _autoUpdateSubMeshes;
  31153. private _tmpVertex;
  31154. /**
  31155. * Creates a SPS (Solid Particle System) object.
  31156. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31157. * @param scene (Scene) is the scene in which the SPS is added.
  31158. * @param options defines the options of the sps e.g.
  31159. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31160. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31161. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31162. * * 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.
  31163. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31164. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31165. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31166. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31167. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31168. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31169. */
  31170. constructor(name: string, scene: Scene, options?: {
  31171. updatable?: boolean;
  31172. isPickable?: boolean;
  31173. enableDepthSort?: boolean;
  31174. particleIntersection?: boolean;
  31175. boundingSphereOnly?: boolean;
  31176. bSphereRadiusFactor?: number;
  31177. expandable?: boolean;
  31178. useModelMaterial?: boolean;
  31179. enableMultiMaterial?: boolean;
  31180. });
  31181. /**
  31182. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31183. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31184. * @returns the created mesh
  31185. */
  31186. buildMesh(): Mesh;
  31187. /**
  31188. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31189. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31190. * Thus the particles generated from `digest()` have their property `position` set yet.
  31191. * @param mesh ( Mesh ) is the mesh to be digested
  31192. * @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
  31193. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31194. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31195. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31196. * @returns the current SPS
  31197. */
  31198. digest(mesh: Mesh, options?: {
  31199. facetNb?: number;
  31200. number?: number;
  31201. delta?: number;
  31202. storage?: [];
  31203. }): SolidParticleSystem;
  31204. /**
  31205. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31206. * @hidden
  31207. */
  31208. private _unrotateFixedNormals;
  31209. /**
  31210. * Resets the temporary working copy particle
  31211. * @hidden
  31212. */
  31213. private _resetCopy;
  31214. /**
  31215. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31216. * @param p the current index in the positions array to be updated
  31217. * @param ind the current index in the indices array
  31218. * @param shape a Vector3 array, the shape geometry
  31219. * @param positions the positions array to be updated
  31220. * @param meshInd the shape indices array
  31221. * @param indices the indices array to be updated
  31222. * @param meshUV the shape uv array
  31223. * @param uvs the uv array to be updated
  31224. * @param meshCol the shape color array
  31225. * @param colors the color array to be updated
  31226. * @param meshNor the shape normals array
  31227. * @param normals the normals array to be updated
  31228. * @param idx the particle index
  31229. * @param idxInShape the particle index in its shape
  31230. * @param options the addShape() method passed options
  31231. * @model the particle model
  31232. * @hidden
  31233. */
  31234. private _meshBuilder;
  31235. /**
  31236. * Returns a shape Vector3 array from positions float array
  31237. * @param positions float array
  31238. * @returns a vector3 array
  31239. * @hidden
  31240. */
  31241. private _posToShape;
  31242. /**
  31243. * Returns a shapeUV array from a float uvs (array deep copy)
  31244. * @param uvs as a float array
  31245. * @returns a shapeUV array
  31246. * @hidden
  31247. */
  31248. private _uvsToShapeUV;
  31249. /**
  31250. * Adds a new particle object in the particles array
  31251. * @param idx particle index in particles array
  31252. * @param id particle id
  31253. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31254. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31255. * @param model particle ModelShape object
  31256. * @param shapeId model shape identifier
  31257. * @param idxInShape index of the particle in the current model
  31258. * @param bInfo model bounding info object
  31259. * @param storage target storage array, if any
  31260. * @hidden
  31261. */
  31262. private _addParticle;
  31263. /**
  31264. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31265. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31266. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31267. * @param nb (positive integer) the number of particles to be created from this model
  31268. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31269. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31270. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31271. * @returns the number of shapes in the system
  31272. */
  31273. addShape(mesh: Mesh, nb: number, options?: {
  31274. positionFunction?: any;
  31275. vertexFunction?: any;
  31276. storage?: [];
  31277. }): number;
  31278. /**
  31279. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31280. * @hidden
  31281. */
  31282. private _rebuildParticle;
  31283. /**
  31284. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31285. * @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.
  31286. * @returns the SPS.
  31287. */
  31288. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31289. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31290. * Returns an array with the removed particles.
  31291. * 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.
  31292. * The SPS can't be empty so at least one particle needs to remain in place.
  31293. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31294. * @param start index of the first particle to remove
  31295. * @param end index of the last particle to remove (included)
  31296. * @returns an array populated with the removed particles
  31297. */
  31298. removeParticles(start: number, end: number): SolidParticle[];
  31299. /**
  31300. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31301. * @param solidParticleArray an array populated with Solid Particles objects
  31302. * @returns the SPS
  31303. */
  31304. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31305. /**
  31306. * Creates a new particle and modifies the SPS mesh geometry :
  31307. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31308. * - calls _addParticle() to populate the particle array
  31309. * factorized code from addShape() and insertParticlesFromArray()
  31310. * @param idx particle index in the particles array
  31311. * @param i particle index in its shape
  31312. * @param modelShape particle ModelShape object
  31313. * @param shape shape vertex array
  31314. * @param meshInd shape indices array
  31315. * @param meshUV shape uv array
  31316. * @param meshCol shape color array
  31317. * @param meshNor shape normals array
  31318. * @param bbInfo shape bounding info
  31319. * @param storage target particle storage
  31320. * @options addShape() passed options
  31321. * @hidden
  31322. */
  31323. private _insertNewParticle;
  31324. /**
  31325. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31326. * This method calls `updateParticle()` for each particle of the SPS.
  31327. * For an animated SPS, it is usually called within the render loop.
  31328. * 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.
  31329. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31330. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31331. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31332. * @returns the SPS.
  31333. */
  31334. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31335. /**
  31336. * Disposes the SPS.
  31337. */
  31338. dispose(): void;
  31339. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31340. * idx is the particle index in the SPS
  31341. * faceId is the picked face index counted within this particle.
  31342. * Returns null if the pickInfo can't identify a picked particle.
  31343. * @param pickingInfo (PickingInfo object)
  31344. * @returns {idx: number, faceId: number} or null
  31345. */
  31346. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31347. idx: number;
  31348. faceId: number;
  31349. }>;
  31350. /**
  31351. * Returns a SolidParticle object from its identifier : particle.id
  31352. * @param id (integer) the particle Id
  31353. * @returns the searched particle or null if not found in the SPS.
  31354. */
  31355. getParticleById(id: number): Nullable<SolidParticle>;
  31356. /**
  31357. * Returns a new array populated with the particles having the passed shapeId.
  31358. * @param shapeId (integer) the shape identifier
  31359. * @returns a new solid particle array
  31360. */
  31361. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31362. /**
  31363. * Populates the passed array "ref" with the particles having the passed shapeId.
  31364. * @param shapeId the shape identifier
  31365. * @returns the SPS
  31366. * @param ref
  31367. */
  31368. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31369. /**
  31370. * Computes the required SubMeshes according the materials assigned to the particles.
  31371. * @returns the solid particle system.
  31372. * Does nothing if called before the SPS mesh is built.
  31373. */
  31374. computeSubMeshes(): SolidParticleSystem;
  31375. /**
  31376. * Sorts the solid particles by material when MultiMaterial is enabled.
  31377. * Updates the indices32 array.
  31378. * Updates the indicesByMaterial array.
  31379. * Updates the mesh indices array.
  31380. * @returns the SPS
  31381. * @hidden
  31382. */
  31383. private _sortParticlesByMaterial;
  31384. /**
  31385. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31386. * @hidden
  31387. */
  31388. private _setMaterialIndexesById;
  31389. /**
  31390. * Returns an array with unique values of Materials from the passed array
  31391. * @param array the material array to be checked and filtered
  31392. * @hidden
  31393. */
  31394. private _filterUniqueMaterialId;
  31395. /**
  31396. * Sets a new Standard Material as _defaultMaterial if not already set.
  31397. * @hidden
  31398. */
  31399. private _setDefaultMaterial;
  31400. /**
  31401. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31402. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31403. * @returns the SPS.
  31404. */
  31405. refreshVisibleSize(): SolidParticleSystem;
  31406. /**
  31407. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31408. * @param size the size (float) of the visibility box
  31409. * note : this doesn't lock the SPS mesh bounding box.
  31410. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31411. */
  31412. setVisibilityBox(size: number): void;
  31413. /**
  31414. * Gets whether the SPS as always visible or not
  31415. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31416. */
  31417. get isAlwaysVisible(): boolean;
  31418. /**
  31419. * Sets the SPS as always visible or not
  31420. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31421. */
  31422. set isAlwaysVisible(val: boolean);
  31423. /**
  31424. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31425. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31426. */
  31427. set isVisibilityBoxLocked(val: boolean);
  31428. /**
  31429. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31430. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31431. */
  31432. get isVisibilityBoxLocked(): boolean;
  31433. /**
  31434. * Tells to `setParticles()` to compute the particle rotations or not.
  31435. * Default value : true. The SPS is faster when it's set to false.
  31436. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31437. */
  31438. set computeParticleRotation(val: boolean);
  31439. /**
  31440. * Tells to `setParticles()` to compute the particle colors or not.
  31441. * Default value : true. The SPS is faster when it's set to false.
  31442. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31443. */
  31444. set computeParticleColor(val: boolean);
  31445. set computeParticleTexture(val: boolean);
  31446. /**
  31447. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31448. * Default value : false. The SPS is faster when it's set to false.
  31449. * Note : the particle custom vertex positions aren't stored values.
  31450. */
  31451. set computeParticleVertex(val: boolean);
  31452. /**
  31453. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31454. */
  31455. set computeBoundingBox(val: boolean);
  31456. /**
  31457. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31458. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31459. * Default : `true`
  31460. */
  31461. set depthSortParticles(val: boolean);
  31462. /**
  31463. * Gets if `setParticles()` computes the particle rotations or not.
  31464. * Default value : true. The SPS is faster when it's set to false.
  31465. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31466. */
  31467. get computeParticleRotation(): boolean;
  31468. /**
  31469. * Gets if `setParticles()` computes the particle colors or not.
  31470. * Default value : true. The SPS is faster when it's set to false.
  31471. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31472. */
  31473. get computeParticleColor(): boolean;
  31474. /**
  31475. * Gets if `setParticles()` computes the particle textures or not.
  31476. * Default value : true. The SPS is faster when it's set to false.
  31477. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31478. */
  31479. get computeParticleTexture(): boolean;
  31480. /**
  31481. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31482. * Default value : false. The SPS is faster when it's set to false.
  31483. * Note : the particle custom vertex positions aren't stored values.
  31484. */
  31485. get computeParticleVertex(): boolean;
  31486. /**
  31487. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31488. */
  31489. get computeBoundingBox(): boolean;
  31490. /**
  31491. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31492. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31493. * Default : `true`
  31494. */
  31495. get depthSortParticles(): boolean;
  31496. /**
  31497. * Gets if the SPS is created as expandable at construction time.
  31498. * Default : `false`
  31499. */
  31500. get expandable(): boolean;
  31501. /**
  31502. * Gets if the SPS supports the Multi Materials
  31503. */
  31504. get multimaterialEnabled(): boolean;
  31505. /**
  31506. * Gets if the SPS uses the model materials for its own multimaterial.
  31507. */
  31508. get useModelMaterial(): boolean;
  31509. /**
  31510. * The SPS used material array.
  31511. */
  31512. get materials(): Material[];
  31513. /**
  31514. * Sets the SPS MultiMaterial from the passed materials.
  31515. * Note : the passed array is internally copied and not used then by reference.
  31516. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31517. */
  31518. setMultiMaterial(materials: Material[]): void;
  31519. /**
  31520. * The SPS computed multimaterial object
  31521. */
  31522. get multimaterial(): MultiMaterial;
  31523. set multimaterial(mm: MultiMaterial);
  31524. /**
  31525. * If the subMeshes must be updated on the next call to setParticles()
  31526. */
  31527. get autoUpdateSubMeshes(): boolean;
  31528. set autoUpdateSubMeshes(val: boolean);
  31529. /**
  31530. * This function does nothing. It may be overwritten to set all the particle first values.
  31531. * The SPS doesn't call this function, you may have to call it by your own.
  31532. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31533. */
  31534. initParticles(): void;
  31535. /**
  31536. * This function does nothing. It may be overwritten to recycle a particle.
  31537. * The SPS doesn't call this function, you may have to call it by your own.
  31538. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31539. * @param particle The particle to recycle
  31540. * @returns the recycled particle
  31541. */
  31542. recycleParticle(particle: SolidParticle): SolidParticle;
  31543. /**
  31544. * Updates a particle : this function should be overwritten by the user.
  31545. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31546. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31547. * @example : just set a particle position or velocity and recycle conditions
  31548. * @param particle The particle to update
  31549. * @returns the updated particle
  31550. */
  31551. updateParticle(particle: SolidParticle): SolidParticle;
  31552. /**
  31553. * Updates a vertex of a particle : it can be overwritten by the user.
  31554. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31555. * @param particle the current particle
  31556. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31557. * @param pt the index of the current vertex in the particle shape
  31558. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31559. * @example : just set a vertex particle position or color
  31560. * @returns the sps
  31561. */
  31562. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31563. /**
  31564. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31565. * This does nothing and may be overwritten by the user.
  31566. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31567. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31568. * @param update the boolean update value actually passed to setParticles()
  31569. */
  31570. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31571. /**
  31572. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31573. * This will be passed three parameters.
  31574. * This does nothing and may be overwritten by the user.
  31575. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31576. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31577. * @param update the boolean update value actually passed to setParticles()
  31578. */
  31579. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31580. }
  31581. }
  31582. declare module BABYLON {
  31583. /**
  31584. * Represents one particle of a solid particle system.
  31585. */
  31586. export class SolidParticle {
  31587. /**
  31588. * particle global index
  31589. */
  31590. idx: number;
  31591. /**
  31592. * particle identifier
  31593. */
  31594. id: number;
  31595. /**
  31596. * The color of the particle
  31597. */
  31598. color: Nullable<Color4>;
  31599. /**
  31600. * The world space position of the particle.
  31601. */
  31602. position: Vector3;
  31603. /**
  31604. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31605. */
  31606. rotation: Vector3;
  31607. /**
  31608. * The world space rotation quaternion of the particle.
  31609. */
  31610. rotationQuaternion: Nullable<Quaternion>;
  31611. /**
  31612. * The scaling of the particle.
  31613. */
  31614. scaling: Vector3;
  31615. /**
  31616. * The uvs of the particle.
  31617. */
  31618. uvs: Vector4;
  31619. /**
  31620. * The current speed of the particle.
  31621. */
  31622. velocity: Vector3;
  31623. /**
  31624. * The pivot point in the particle local space.
  31625. */
  31626. pivot: Vector3;
  31627. /**
  31628. * Must the particle be translated from its pivot point in its local space ?
  31629. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31630. * Default : false
  31631. */
  31632. translateFromPivot: boolean;
  31633. /**
  31634. * Is the particle active or not ?
  31635. */
  31636. alive: boolean;
  31637. /**
  31638. * Is the particle visible or not ?
  31639. */
  31640. isVisible: boolean;
  31641. /**
  31642. * Index of this particle in the global "positions" array (Internal use)
  31643. * @hidden
  31644. */
  31645. _pos: number;
  31646. /**
  31647. * @hidden Index of this particle in the global "indices" array (Internal use)
  31648. */
  31649. _ind: number;
  31650. /**
  31651. * @hidden ModelShape of this particle (Internal use)
  31652. */
  31653. _model: ModelShape;
  31654. /**
  31655. * ModelShape id of this particle
  31656. */
  31657. shapeId: number;
  31658. /**
  31659. * Index of the particle in its shape id
  31660. */
  31661. idxInShape: number;
  31662. /**
  31663. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31664. */
  31665. _modelBoundingInfo: BoundingInfo;
  31666. /**
  31667. * @hidden Particle BoundingInfo object (Internal use)
  31668. */
  31669. _boundingInfo: BoundingInfo;
  31670. /**
  31671. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31672. */
  31673. _sps: SolidParticleSystem;
  31674. /**
  31675. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31676. */
  31677. _stillInvisible: boolean;
  31678. /**
  31679. * @hidden Last computed particle rotation matrix
  31680. */
  31681. _rotationMatrix: number[];
  31682. /**
  31683. * Parent particle Id, if any.
  31684. * Default null.
  31685. */
  31686. parentId: Nullable<number>;
  31687. /**
  31688. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31689. */
  31690. materialIndex: Nullable<number>;
  31691. /**
  31692. * Custom object or properties.
  31693. */
  31694. props: Nullable<any>;
  31695. /**
  31696. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31697. * The possible values are :
  31698. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31699. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31700. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31701. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31702. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31703. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31704. * */
  31705. cullingStrategy: number;
  31706. /**
  31707. * @hidden Internal global position in the SPS.
  31708. */
  31709. _globalPosition: Vector3;
  31710. /**
  31711. * Creates a Solid Particle object.
  31712. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31713. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31714. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31715. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31716. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31717. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31718. * @param shapeId (integer) is the model shape identifier in the SPS.
  31719. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31720. * @param sps defines the sps it is associated to
  31721. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31722. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31723. */
  31724. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31725. /**
  31726. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31727. * @param target the particle target
  31728. * @returns the current particle
  31729. */
  31730. copyToRef(target: SolidParticle): SolidParticle;
  31731. /**
  31732. * Legacy support, changed scale to scaling
  31733. */
  31734. get scale(): Vector3;
  31735. /**
  31736. * Legacy support, changed scale to scaling
  31737. */
  31738. set scale(scale: Vector3);
  31739. /**
  31740. * Legacy support, changed quaternion to rotationQuaternion
  31741. */
  31742. get quaternion(): Nullable<Quaternion>;
  31743. /**
  31744. * Legacy support, changed quaternion to rotationQuaternion
  31745. */
  31746. set quaternion(q: Nullable<Quaternion>);
  31747. /**
  31748. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31749. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31750. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31751. * @returns true if it intersects
  31752. */
  31753. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31754. /**
  31755. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31756. * A particle is in the frustum if its bounding box intersects the frustum
  31757. * @param frustumPlanes defines the frustum to test
  31758. * @returns true if the particle is in the frustum planes
  31759. */
  31760. isInFrustum(frustumPlanes: Plane[]): boolean;
  31761. /**
  31762. * get the rotation matrix of the particle
  31763. * @hidden
  31764. */
  31765. getRotationMatrix(m: Matrix): void;
  31766. }
  31767. /**
  31768. * Represents the shape of the model used by one particle of a solid particle system.
  31769. * SPS internal tool, don't use it manually.
  31770. */
  31771. export class ModelShape {
  31772. /**
  31773. * The shape id
  31774. * @hidden
  31775. */
  31776. shapeID: number;
  31777. /**
  31778. * flat array of model positions (internal use)
  31779. * @hidden
  31780. */
  31781. _shape: Vector3[];
  31782. /**
  31783. * flat array of model UVs (internal use)
  31784. * @hidden
  31785. */
  31786. _shapeUV: number[];
  31787. /**
  31788. * color array of the model
  31789. * @hidden
  31790. */
  31791. _shapeColors: number[];
  31792. /**
  31793. * indices array of the model
  31794. * @hidden
  31795. */
  31796. _indices: number[];
  31797. /**
  31798. * normals array of the model
  31799. * @hidden
  31800. */
  31801. _normals: number[];
  31802. /**
  31803. * length of the shape in the model indices array (internal use)
  31804. * @hidden
  31805. */
  31806. _indicesLength: number;
  31807. /**
  31808. * Custom position function (internal use)
  31809. * @hidden
  31810. */
  31811. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31812. /**
  31813. * Custom vertex function (internal use)
  31814. * @hidden
  31815. */
  31816. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31817. /**
  31818. * Model material (internal use)
  31819. * @hidden
  31820. */
  31821. _material: Nullable<Material>;
  31822. /**
  31823. * 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.
  31824. * SPS internal tool, don't use it manually.
  31825. * @hidden
  31826. */
  31827. 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>);
  31828. }
  31829. /**
  31830. * Represents a Depth Sorted Particle in the solid particle system.
  31831. * @hidden
  31832. */
  31833. export class DepthSortedParticle {
  31834. /**
  31835. * Particle index
  31836. */
  31837. idx: number;
  31838. /**
  31839. * Index of the particle in the "indices" array
  31840. */
  31841. ind: number;
  31842. /**
  31843. * Length of the particle shape in the "indices" array
  31844. */
  31845. indicesLength: number;
  31846. /**
  31847. * Squared distance from the particle to the camera
  31848. */
  31849. sqDistance: number;
  31850. /**
  31851. * Material index when used with MultiMaterials
  31852. */
  31853. materialIndex: number;
  31854. /**
  31855. * Creates a new sorted particle
  31856. * @param materialIndex
  31857. */
  31858. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31859. }
  31860. /**
  31861. * Represents a solid particle vertex
  31862. */
  31863. export class SolidParticleVertex {
  31864. /**
  31865. * Vertex position
  31866. */
  31867. position: Vector3;
  31868. /**
  31869. * Vertex color
  31870. */
  31871. color: Color4;
  31872. /**
  31873. * Vertex UV
  31874. */
  31875. uv: Vector2;
  31876. /**
  31877. * Creates a new solid particle vertex
  31878. */
  31879. constructor();
  31880. /** Vertex x coordinate */
  31881. get x(): number;
  31882. set x(val: number);
  31883. /** Vertex y coordinate */
  31884. get y(): number;
  31885. set y(val: number);
  31886. /** Vertex z coordinate */
  31887. get z(): number;
  31888. set z(val: number);
  31889. }
  31890. }
  31891. declare module BABYLON {
  31892. /**
  31893. * @hidden
  31894. */
  31895. export class _MeshCollisionData {
  31896. _checkCollisions: boolean;
  31897. _collisionMask: number;
  31898. _collisionGroup: number;
  31899. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31900. _collider: Nullable<Collider>;
  31901. _oldPositionForCollisions: Vector3;
  31902. _diffPositionForCollisions: Vector3;
  31903. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31904. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31905. }
  31906. }
  31907. declare module BABYLON {
  31908. /** @hidden */
  31909. class _FacetDataStorage {
  31910. facetPositions: Vector3[];
  31911. facetNormals: Vector3[];
  31912. facetPartitioning: number[][];
  31913. facetNb: number;
  31914. partitioningSubdivisions: number;
  31915. partitioningBBoxRatio: number;
  31916. facetDataEnabled: boolean;
  31917. facetParameters: any;
  31918. bbSize: Vector3;
  31919. subDiv: {
  31920. max: number;
  31921. X: number;
  31922. Y: number;
  31923. Z: number;
  31924. };
  31925. facetDepthSort: boolean;
  31926. facetDepthSortEnabled: boolean;
  31927. depthSortedIndices: IndicesArray;
  31928. depthSortedFacets: {
  31929. ind: number;
  31930. sqDistance: number;
  31931. }[];
  31932. facetDepthSortFunction: (f1: {
  31933. ind: number;
  31934. sqDistance: number;
  31935. }, f2: {
  31936. ind: number;
  31937. sqDistance: number;
  31938. }) => number;
  31939. facetDepthSortFrom: Vector3;
  31940. facetDepthSortOrigin: Vector3;
  31941. invertedMatrix: Matrix;
  31942. }
  31943. /**
  31944. * @hidden
  31945. **/
  31946. class _InternalAbstractMeshDataInfo {
  31947. _hasVertexAlpha: boolean;
  31948. _useVertexColors: boolean;
  31949. _numBoneInfluencers: number;
  31950. _applyFog: boolean;
  31951. _receiveShadows: boolean;
  31952. _facetData: _FacetDataStorage;
  31953. _visibility: number;
  31954. _skeleton: Nullable<Skeleton>;
  31955. _layerMask: number;
  31956. _computeBonesUsingShaders: boolean;
  31957. _isActive: boolean;
  31958. _onlyForInstances: boolean;
  31959. _isActiveIntermediate: boolean;
  31960. _onlyForInstancesIntermediate: boolean;
  31961. _actAsRegularMesh: boolean;
  31962. }
  31963. /**
  31964. * Class used to store all common mesh properties
  31965. */
  31966. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31967. /** No occlusion */
  31968. static OCCLUSION_TYPE_NONE: number;
  31969. /** Occlusion set to optimisitic */
  31970. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31971. /** Occlusion set to strict */
  31972. static OCCLUSION_TYPE_STRICT: number;
  31973. /** Use an accurante occlusion algorithm */
  31974. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31975. /** Use a conservative occlusion algorithm */
  31976. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31977. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31978. * Test order :
  31979. * Is the bounding sphere outside the frustum ?
  31980. * If not, are the bounding box vertices outside the frustum ?
  31981. * It not, then the cullable object is in the frustum.
  31982. */
  31983. static readonly CULLINGSTRATEGY_STANDARD: number;
  31984. /** Culling strategy : Bounding Sphere Only.
  31985. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31986. * It's also less accurate than the standard because some not visible objects can still be selected.
  31987. * Test : is the bounding sphere outside the frustum ?
  31988. * If not, then the cullable object is in the frustum.
  31989. */
  31990. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31991. /** Culling strategy : Optimistic Inclusion.
  31992. * This in an inclusion test first, then the standard exclusion test.
  31993. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31994. * 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.
  31995. * Anyway, it's as accurate as the standard strategy.
  31996. * Test :
  31997. * Is the cullable object bounding sphere center in the frustum ?
  31998. * If not, apply the default culling strategy.
  31999. */
  32000. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32001. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32002. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32003. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32004. * 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.
  32005. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32006. * Test :
  32007. * Is the cullable object bounding sphere center in the frustum ?
  32008. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32009. */
  32010. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32011. /**
  32012. * No billboard
  32013. */
  32014. static get BILLBOARDMODE_NONE(): number;
  32015. /** Billboard on X axis */
  32016. static get BILLBOARDMODE_X(): number;
  32017. /** Billboard on Y axis */
  32018. static get BILLBOARDMODE_Y(): number;
  32019. /** Billboard on Z axis */
  32020. static get BILLBOARDMODE_Z(): number;
  32021. /** Billboard on all axes */
  32022. static get BILLBOARDMODE_ALL(): number;
  32023. /** Billboard on using position instead of orientation */
  32024. static get BILLBOARDMODE_USE_POSITION(): number;
  32025. /** @hidden */
  32026. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32027. /**
  32028. * The culling strategy to use to check whether the mesh must be rendered or not.
  32029. * This value can be changed at any time and will be used on the next render mesh selection.
  32030. * The possible values are :
  32031. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32032. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32033. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32034. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32035. * Please read each static variable documentation to get details about the culling process.
  32036. * */
  32037. cullingStrategy: number;
  32038. /**
  32039. * Gets the number of facets in the mesh
  32040. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32041. */
  32042. get facetNb(): number;
  32043. /**
  32044. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32045. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32046. */
  32047. get partitioningSubdivisions(): number;
  32048. set partitioningSubdivisions(nb: number);
  32049. /**
  32050. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32051. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32052. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32053. */
  32054. get partitioningBBoxRatio(): number;
  32055. set partitioningBBoxRatio(ratio: number);
  32056. /**
  32057. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32058. * Works only for updatable meshes.
  32059. * Doesn't work with multi-materials
  32060. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32061. */
  32062. get mustDepthSortFacets(): boolean;
  32063. set mustDepthSortFacets(sort: boolean);
  32064. /**
  32065. * The location (Vector3) where the facet depth sort must be computed from.
  32066. * By default, the active camera position.
  32067. * Used only when facet depth sort is enabled
  32068. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32069. */
  32070. get facetDepthSortFrom(): Vector3;
  32071. set facetDepthSortFrom(location: Vector3);
  32072. /**
  32073. * gets a boolean indicating if facetData is enabled
  32074. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32075. */
  32076. get isFacetDataEnabled(): boolean;
  32077. /** @hidden */
  32078. _updateNonUniformScalingState(value: boolean): boolean;
  32079. /**
  32080. * An event triggered when this mesh collides with another one
  32081. */
  32082. onCollideObservable: Observable<AbstractMesh>;
  32083. /** Set a function to call when this mesh collides with another one */
  32084. set onCollide(callback: () => void);
  32085. /**
  32086. * An event triggered when the collision's position changes
  32087. */
  32088. onCollisionPositionChangeObservable: Observable<Vector3>;
  32089. /** Set a function to call when the collision's position changes */
  32090. set onCollisionPositionChange(callback: () => void);
  32091. /**
  32092. * An event triggered when material is changed
  32093. */
  32094. onMaterialChangedObservable: Observable<AbstractMesh>;
  32095. /**
  32096. * Gets or sets the orientation for POV movement & rotation
  32097. */
  32098. definedFacingForward: boolean;
  32099. /** @hidden */
  32100. _occlusionQuery: Nullable<WebGLQuery>;
  32101. /** @hidden */
  32102. _renderingGroup: Nullable<RenderingGroup>;
  32103. /**
  32104. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32105. */
  32106. get visibility(): number;
  32107. /**
  32108. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32109. */
  32110. set visibility(value: number);
  32111. /** Gets or sets the alpha index used to sort transparent meshes
  32112. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32113. */
  32114. alphaIndex: number;
  32115. /**
  32116. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32117. */
  32118. isVisible: boolean;
  32119. /**
  32120. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32121. */
  32122. isPickable: boolean;
  32123. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32124. showSubMeshesBoundingBox: boolean;
  32125. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32126. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32127. */
  32128. isBlocker: boolean;
  32129. /**
  32130. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32131. */
  32132. enablePointerMoveEvents: boolean;
  32133. private _renderingGroupId;
  32134. /**
  32135. * Specifies the rendering group id for this mesh (0 by default)
  32136. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32137. */
  32138. get renderingGroupId(): number;
  32139. set renderingGroupId(value: number);
  32140. private _material;
  32141. /** Gets or sets current material */
  32142. get material(): Nullable<Material>;
  32143. set material(value: Nullable<Material>);
  32144. /**
  32145. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32146. * @see https://doc.babylonjs.com/babylon101/shadows
  32147. */
  32148. get receiveShadows(): boolean;
  32149. set receiveShadows(value: boolean);
  32150. /** Defines color to use when rendering outline */
  32151. outlineColor: Color3;
  32152. /** Define width to use when rendering outline */
  32153. outlineWidth: number;
  32154. /** Defines color to use when rendering overlay */
  32155. overlayColor: Color3;
  32156. /** Defines alpha to use when rendering overlay */
  32157. overlayAlpha: number;
  32158. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32159. get hasVertexAlpha(): boolean;
  32160. set hasVertexAlpha(value: boolean);
  32161. /** 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) */
  32162. get useVertexColors(): boolean;
  32163. set useVertexColors(value: boolean);
  32164. /**
  32165. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32166. */
  32167. get computeBonesUsingShaders(): boolean;
  32168. set computeBonesUsingShaders(value: boolean);
  32169. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32170. get numBoneInfluencers(): number;
  32171. set numBoneInfluencers(value: number);
  32172. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32173. get applyFog(): boolean;
  32174. set applyFog(value: boolean);
  32175. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32176. useOctreeForRenderingSelection: boolean;
  32177. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32178. useOctreeForPicking: boolean;
  32179. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32180. useOctreeForCollisions: boolean;
  32181. /**
  32182. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32183. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32184. */
  32185. get layerMask(): number;
  32186. set layerMask(value: number);
  32187. /**
  32188. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32189. */
  32190. alwaysSelectAsActiveMesh: boolean;
  32191. /**
  32192. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32193. */
  32194. doNotSyncBoundingInfo: boolean;
  32195. /**
  32196. * Gets or sets the current action manager
  32197. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32198. */
  32199. actionManager: Nullable<AbstractActionManager>;
  32200. private _meshCollisionData;
  32201. /**
  32202. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32203. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32204. */
  32205. ellipsoid: Vector3;
  32206. /**
  32207. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32208. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32209. */
  32210. ellipsoidOffset: Vector3;
  32211. /**
  32212. * Gets or sets a collision mask used to mask collisions (default is -1).
  32213. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32214. */
  32215. get collisionMask(): number;
  32216. set collisionMask(mask: number);
  32217. /**
  32218. * Gets or sets the current collision group mask (-1 by default).
  32219. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32220. */
  32221. get collisionGroup(): number;
  32222. set collisionGroup(mask: number);
  32223. /**
  32224. * Gets or sets current surrounding meshes (null by default).
  32225. *
  32226. * By default collision detection is tested against every mesh in the scene.
  32227. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32228. * meshes will be tested for the collision.
  32229. *
  32230. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32231. */
  32232. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32233. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32234. /**
  32235. * Defines edge width used when edgesRenderer is enabled
  32236. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32237. */
  32238. edgesWidth: number;
  32239. /**
  32240. * Defines edge color used when edgesRenderer is enabled
  32241. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32242. */
  32243. edgesColor: Color4;
  32244. /** @hidden */
  32245. _edgesRenderer: Nullable<IEdgesRenderer>;
  32246. /** @hidden */
  32247. _masterMesh: Nullable<AbstractMesh>;
  32248. /** @hidden */
  32249. _boundingInfo: Nullable<BoundingInfo>;
  32250. /** @hidden */
  32251. _renderId: number;
  32252. /**
  32253. * Gets or sets the list of subMeshes
  32254. * @see https://doc.babylonjs.com/how_to/multi_materials
  32255. */
  32256. subMeshes: SubMesh[];
  32257. /** @hidden */
  32258. _intersectionsInProgress: AbstractMesh[];
  32259. /** @hidden */
  32260. _unIndexed: boolean;
  32261. /** @hidden */
  32262. _lightSources: Light[];
  32263. /** Gets the list of lights affecting that mesh */
  32264. get lightSources(): Light[];
  32265. /** @hidden */
  32266. get _positions(): Nullable<Vector3[]>;
  32267. /** @hidden */
  32268. _waitingData: {
  32269. lods: Nullable<any>;
  32270. actions: Nullable<any>;
  32271. freezeWorldMatrix: Nullable<boolean>;
  32272. };
  32273. /** @hidden */
  32274. _bonesTransformMatrices: Nullable<Float32Array>;
  32275. /** @hidden */
  32276. _transformMatrixTexture: Nullable<RawTexture>;
  32277. /**
  32278. * Gets or sets a skeleton to apply skining transformations
  32279. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32280. */
  32281. set skeleton(value: Nullable<Skeleton>);
  32282. get skeleton(): Nullable<Skeleton>;
  32283. /**
  32284. * An event triggered when the mesh is rebuilt.
  32285. */
  32286. onRebuildObservable: Observable<AbstractMesh>;
  32287. /**
  32288. * Creates a new AbstractMesh
  32289. * @param name defines the name of the mesh
  32290. * @param scene defines the hosting scene
  32291. */
  32292. constructor(name: string, scene?: Nullable<Scene>);
  32293. /**
  32294. * Returns the string "AbstractMesh"
  32295. * @returns "AbstractMesh"
  32296. */
  32297. getClassName(): string;
  32298. /**
  32299. * Gets a string representation of the current mesh
  32300. * @param fullDetails defines a boolean indicating if full details must be included
  32301. * @returns a string representation of the current mesh
  32302. */
  32303. toString(fullDetails?: boolean): string;
  32304. /**
  32305. * @hidden
  32306. */
  32307. protected _getEffectiveParent(): Nullable<Node>;
  32308. /** @hidden */
  32309. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32310. /** @hidden */
  32311. _rebuild(): void;
  32312. /** @hidden */
  32313. _resyncLightSources(): void;
  32314. /** @hidden */
  32315. _resyncLightSource(light: Light): void;
  32316. /** @hidden */
  32317. _unBindEffect(): void;
  32318. /** @hidden */
  32319. _removeLightSource(light: Light, dispose: boolean): void;
  32320. private _markSubMeshesAsDirty;
  32321. /** @hidden */
  32322. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32323. /** @hidden */
  32324. _markSubMeshesAsAttributesDirty(): void;
  32325. /** @hidden */
  32326. _markSubMeshesAsMiscDirty(): void;
  32327. /**
  32328. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32329. */
  32330. get scaling(): Vector3;
  32331. set scaling(newScaling: Vector3);
  32332. /**
  32333. * Returns true if the mesh is blocked. Implemented by child classes
  32334. */
  32335. get isBlocked(): boolean;
  32336. /**
  32337. * Returns the mesh itself by default. Implemented by child classes
  32338. * @param camera defines the camera to use to pick the right LOD level
  32339. * @returns the currentAbstractMesh
  32340. */
  32341. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32342. /**
  32343. * Returns 0 by default. Implemented by child classes
  32344. * @returns an integer
  32345. */
  32346. getTotalVertices(): number;
  32347. /**
  32348. * Returns a positive integer : the total number of indices in this mesh geometry.
  32349. * @returns the numner of indices or zero if the mesh has no geometry.
  32350. */
  32351. getTotalIndices(): number;
  32352. /**
  32353. * Returns null by default. Implemented by child classes
  32354. * @returns null
  32355. */
  32356. getIndices(): Nullable<IndicesArray>;
  32357. /**
  32358. * Returns the array of the requested vertex data kind. Implemented by child classes
  32359. * @param kind defines the vertex data kind to use
  32360. * @returns null
  32361. */
  32362. getVerticesData(kind: string): Nullable<FloatArray>;
  32363. /**
  32364. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32365. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32366. * Note that a new underlying VertexBuffer object is created each call.
  32367. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32368. * @param kind defines vertex data kind:
  32369. * * VertexBuffer.PositionKind
  32370. * * VertexBuffer.UVKind
  32371. * * VertexBuffer.UV2Kind
  32372. * * VertexBuffer.UV3Kind
  32373. * * VertexBuffer.UV4Kind
  32374. * * VertexBuffer.UV5Kind
  32375. * * VertexBuffer.UV6Kind
  32376. * * VertexBuffer.ColorKind
  32377. * * VertexBuffer.MatricesIndicesKind
  32378. * * VertexBuffer.MatricesIndicesExtraKind
  32379. * * VertexBuffer.MatricesWeightsKind
  32380. * * VertexBuffer.MatricesWeightsExtraKind
  32381. * @param data defines the data source
  32382. * @param updatable defines if the data must be flagged as updatable (or static)
  32383. * @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
  32384. * @returns the current mesh
  32385. */
  32386. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32387. /**
  32388. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32389. * If the mesh has no geometry, it is simply returned as it is.
  32390. * @param kind defines vertex data kind:
  32391. * * VertexBuffer.PositionKind
  32392. * * VertexBuffer.UVKind
  32393. * * VertexBuffer.UV2Kind
  32394. * * VertexBuffer.UV3Kind
  32395. * * VertexBuffer.UV4Kind
  32396. * * VertexBuffer.UV5Kind
  32397. * * VertexBuffer.UV6Kind
  32398. * * VertexBuffer.ColorKind
  32399. * * VertexBuffer.MatricesIndicesKind
  32400. * * VertexBuffer.MatricesIndicesExtraKind
  32401. * * VertexBuffer.MatricesWeightsKind
  32402. * * VertexBuffer.MatricesWeightsExtraKind
  32403. * @param data defines the data source
  32404. * @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
  32405. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32406. * @returns the current mesh
  32407. */
  32408. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32409. /**
  32410. * Sets the mesh indices,
  32411. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32412. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32413. * @param totalVertices Defines the total number of vertices
  32414. * @returns the current mesh
  32415. */
  32416. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32417. /**
  32418. * Gets a boolean indicating if specific vertex data is present
  32419. * @param kind defines the vertex data kind to use
  32420. * @returns true is data kind is present
  32421. */
  32422. isVerticesDataPresent(kind: string): boolean;
  32423. /**
  32424. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32425. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32426. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32427. * @returns a BoundingInfo
  32428. */
  32429. getBoundingInfo(): BoundingInfo;
  32430. /**
  32431. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32432. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32433. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32434. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32435. * @returns the current mesh
  32436. */
  32437. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32438. /**
  32439. * Overwrite the current bounding info
  32440. * @param boundingInfo defines the new bounding info
  32441. * @returns the current mesh
  32442. */
  32443. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32444. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32445. get useBones(): boolean;
  32446. /** @hidden */
  32447. _preActivate(): void;
  32448. /** @hidden */
  32449. _preActivateForIntermediateRendering(renderId: number): void;
  32450. /** @hidden */
  32451. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32452. /** @hidden */
  32453. _postActivate(): void;
  32454. /** @hidden */
  32455. _freeze(): void;
  32456. /** @hidden */
  32457. _unFreeze(): void;
  32458. /**
  32459. * Gets the current world matrix
  32460. * @returns a Matrix
  32461. */
  32462. getWorldMatrix(): Matrix;
  32463. /** @hidden */
  32464. _getWorldMatrixDeterminant(): number;
  32465. /**
  32466. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32467. */
  32468. get isAnInstance(): boolean;
  32469. /**
  32470. * Gets a boolean indicating if this mesh has instances
  32471. */
  32472. get hasInstances(): boolean;
  32473. /**
  32474. * Gets a boolean indicating if this mesh has thin instances
  32475. */
  32476. get hasThinInstances(): boolean;
  32477. /**
  32478. * Perform relative position change from the point of view of behind the front of the mesh.
  32479. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32480. * Supports definition of mesh facing forward or backward
  32481. * @param amountRight defines the distance on the right axis
  32482. * @param amountUp defines the distance on the up axis
  32483. * @param amountForward defines the distance on the forward axis
  32484. * @returns the current mesh
  32485. */
  32486. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32487. /**
  32488. * Calculate relative position change from the point of view of behind the front of the mesh.
  32489. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32490. * Supports definition of mesh facing forward or backward
  32491. * @param amountRight defines the distance on the right axis
  32492. * @param amountUp defines the distance on the up axis
  32493. * @param amountForward defines the distance on the forward axis
  32494. * @returns the new displacement vector
  32495. */
  32496. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32497. /**
  32498. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32499. * Supports definition of mesh facing forward or backward
  32500. * @param flipBack defines the flip
  32501. * @param twirlClockwise defines the twirl
  32502. * @param tiltRight defines the tilt
  32503. * @returns the current mesh
  32504. */
  32505. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32506. /**
  32507. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32508. * Supports definition of mesh facing forward or backward.
  32509. * @param flipBack defines the flip
  32510. * @param twirlClockwise defines the twirl
  32511. * @param tiltRight defines the tilt
  32512. * @returns the new rotation vector
  32513. */
  32514. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32515. /**
  32516. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32517. * This means the mesh underlying bounding box and sphere are recomputed.
  32518. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32519. * @returns the current mesh
  32520. */
  32521. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32522. /** @hidden */
  32523. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32524. /** @hidden */
  32525. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32526. /** @hidden */
  32527. _updateBoundingInfo(): AbstractMesh;
  32528. /** @hidden */
  32529. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32530. /** @hidden */
  32531. protected _afterComputeWorldMatrix(): void;
  32532. /** @hidden */
  32533. get _effectiveMesh(): AbstractMesh;
  32534. /**
  32535. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32536. * A mesh is in the frustum if its bounding box intersects the frustum
  32537. * @param frustumPlanes defines the frustum to test
  32538. * @returns true if the mesh is in the frustum planes
  32539. */
  32540. isInFrustum(frustumPlanes: Plane[]): boolean;
  32541. /**
  32542. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32543. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32544. * @param frustumPlanes defines the frustum to test
  32545. * @returns true if the mesh is completely in the frustum planes
  32546. */
  32547. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32548. /**
  32549. * True if the mesh intersects another mesh or a SolidParticle object
  32550. * @param mesh defines a target mesh or SolidParticle to test
  32551. * @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)
  32552. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32553. * @returns true if there is an intersection
  32554. */
  32555. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32556. /**
  32557. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32558. * @param point defines the point to test
  32559. * @returns true if there is an intersection
  32560. */
  32561. intersectsPoint(point: Vector3): boolean;
  32562. /**
  32563. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32564. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32565. */
  32566. get checkCollisions(): boolean;
  32567. set checkCollisions(collisionEnabled: boolean);
  32568. /**
  32569. * Gets Collider object used to compute collisions (not physics)
  32570. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32571. */
  32572. get collider(): Nullable<Collider>;
  32573. /**
  32574. * Move the mesh using collision engine
  32575. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32576. * @param displacement defines the requested displacement vector
  32577. * @returns the current mesh
  32578. */
  32579. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32580. private _onCollisionPositionChange;
  32581. /** @hidden */
  32582. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32583. /** @hidden */
  32584. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32585. /** @hidden */
  32586. _checkCollision(collider: Collider): AbstractMesh;
  32587. /** @hidden */
  32588. _generatePointsArray(): boolean;
  32589. /**
  32590. * Checks if the passed Ray intersects with the mesh
  32591. * @param ray defines the ray to use
  32592. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32593. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32594. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32595. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32596. * @returns the picking info
  32597. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32598. */
  32599. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32600. /**
  32601. * Clones the current mesh
  32602. * @param name defines the mesh name
  32603. * @param newParent defines the new mesh parent
  32604. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32605. * @returns the new mesh
  32606. */
  32607. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32608. /**
  32609. * Disposes all the submeshes of the current meshnp
  32610. * @returns the current mesh
  32611. */
  32612. releaseSubMeshes(): AbstractMesh;
  32613. /**
  32614. * Releases resources associated with this abstract mesh.
  32615. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32616. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32617. */
  32618. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32619. /**
  32620. * Adds the passed mesh as a child to the current mesh
  32621. * @param mesh defines the child mesh
  32622. * @returns the current mesh
  32623. */
  32624. addChild(mesh: AbstractMesh): AbstractMesh;
  32625. /**
  32626. * Removes the passed mesh from the current mesh children list
  32627. * @param mesh defines the child mesh
  32628. * @returns the current mesh
  32629. */
  32630. removeChild(mesh: AbstractMesh): AbstractMesh;
  32631. /** @hidden */
  32632. private _initFacetData;
  32633. /**
  32634. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32635. * This method can be called within the render loop.
  32636. * 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
  32637. * @returns the current mesh
  32638. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32639. */
  32640. updateFacetData(): AbstractMesh;
  32641. /**
  32642. * Returns the facetLocalNormals array.
  32643. * The normals are expressed in the mesh local spac
  32644. * @returns an array of Vector3
  32645. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32646. */
  32647. getFacetLocalNormals(): Vector3[];
  32648. /**
  32649. * Returns the facetLocalPositions array.
  32650. * The facet positions are expressed in the mesh local space
  32651. * @returns an array of Vector3
  32652. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32653. */
  32654. getFacetLocalPositions(): Vector3[];
  32655. /**
  32656. * Returns the facetLocalPartioning array
  32657. * @returns an array of array of numbers
  32658. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32659. */
  32660. getFacetLocalPartitioning(): number[][];
  32661. /**
  32662. * Returns the i-th facet position in the world system.
  32663. * This method allocates a new Vector3 per call
  32664. * @param i defines the facet index
  32665. * @returns a new Vector3
  32666. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32667. */
  32668. getFacetPosition(i: number): Vector3;
  32669. /**
  32670. * Sets the reference Vector3 with the i-th facet position in the world system
  32671. * @param i defines the facet index
  32672. * @param ref defines the target vector
  32673. * @returns the current mesh
  32674. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32675. */
  32676. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32677. /**
  32678. * Returns the i-th facet normal in the world system.
  32679. * This method allocates a new Vector3 per call
  32680. * @param i defines the facet index
  32681. * @returns a new Vector3
  32682. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32683. */
  32684. getFacetNormal(i: number): Vector3;
  32685. /**
  32686. * Sets the reference Vector3 with the i-th facet normal in the world system
  32687. * @param i defines the facet index
  32688. * @param ref defines the target vector
  32689. * @returns the current mesh
  32690. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32691. */
  32692. getFacetNormalToRef(i: number, ref: Vector3): this;
  32693. /**
  32694. * 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)
  32695. * @param x defines x coordinate
  32696. * @param y defines y coordinate
  32697. * @param z defines z coordinate
  32698. * @returns the array of facet indexes
  32699. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32700. */
  32701. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32702. /**
  32703. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32704. * @param projected sets as the (x,y,z) world projection on the facet
  32705. * @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
  32706. * @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
  32707. * @param x defines x coordinate
  32708. * @param y defines y coordinate
  32709. * @param z defines z coordinate
  32710. * @returns the face index if found (or null instead)
  32711. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32712. */
  32713. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32714. /**
  32715. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32716. * @param projected sets as the (x,y,z) local projection on the facet
  32717. * @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
  32718. * @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
  32719. * @param x defines x coordinate
  32720. * @param y defines y coordinate
  32721. * @param z defines z coordinate
  32722. * @returns the face index if found (or null instead)
  32723. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32724. */
  32725. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32726. /**
  32727. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32728. * @returns the parameters
  32729. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32730. */
  32731. getFacetDataParameters(): any;
  32732. /**
  32733. * Disables the feature FacetData and frees the related memory
  32734. * @returns the current mesh
  32735. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32736. */
  32737. disableFacetData(): AbstractMesh;
  32738. /**
  32739. * Updates the AbstractMesh indices array
  32740. * @param indices defines the data source
  32741. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32742. * @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)
  32743. * @returns the current mesh
  32744. */
  32745. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32746. /**
  32747. * Creates new normals data for the mesh
  32748. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32749. * @returns the current mesh
  32750. */
  32751. createNormals(updatable: boolean): AbstractMesh;
  32752. /**
  32753. * Align the mesh with a normal
  32754. * @param normal defines the normal to use
  32755. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32756. * @returns the current mesh
  32757. */
  32758. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32759. /** @hidden */
  32760. _checkOcclusionQuery(): boolean;
  32761. /**
  32762. * Disables the mesh edge rendering mode
  32763. * @returns the currentAbstractMesh
  32764. */
  32765. disableEdgesRendering(): AbstractMesh;
  32766. /**
  32767. * Enables the edge rendering mode on the mesh.
  32768. * This mode makes the mesh edges visible
  32769. * @param epsilon defines the maximal distance between two angles to detect a face
  32770. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32771. * @returns the currentAbstractMesh
  32772. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32773. */
  32774. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32775. /**
  32776. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32777. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32778. */
  32779. getConnectedParticleSystems(): IParticleSystem[];
  32780. }
  32781. }
  32782. declare module BABYLON {
  32783. /**
  32784. * Interface used to define ActionEvent
  32785. */
  32786. export interface IActionEvent {
  32787. /** The mesh or sprite that triggered the action */
  32788. source: any;
  32789. /** The X mouse cursor position at the time of the event */
  32790. pointerX: number;
  32791. /** The Y mouse cursor position at the time of the event */
  32792. pointerY: number;
  32793. /** The mesh that is currently pointed at (can be null) */
  32794. meshUnderPointer: Nullable<AbstractMesh>;
  32795. /** the original (browser) event that triggered the ActionEvent */
  32796. sourceEvent?: any;
  32797. /** additional data for the event */
  32798. additionalData?: any;
  32799. }
  32800. /**
  32801. * ActionEvent is the event being sent when an action is triggered.
  32802. */
  32803. export class ActionEvent implements IActionEvent {
  32804. /** The mesh or sprite that triggered the action */
  32805. source: any;
  32806. /** The X mouse cursor position at the time of the event */
  32807. pointerX: number;
  32808. /** The Y mouse cursor position at the time of the event */
  32809. pointerY: number;
  32810. /** The mesh that is currently pointed at (can be null) */
  32811. meshUnderPointer: Nullable<AbstractMesh>;
  32812. /** the original (browser) event that triggered the ActionEvent */
  32813. sourceEvent?: any;
  32814. /** additional data for the event */
  32815. additionalData?: any;
  32816. /**
  32817. * Creates a new ActionEvent
  32818. * @param source The mesh or sprite that triggered the action
  32819. * @param pointerX The X mouse cursor position at the time of the event
  32820. * @param pointerY The Y mouse cursor position at the time of the event
  32821. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32822. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32823. * @param additionalData additional data for the event
  32824. */
  32825. constructor(
  32826. /** The mesh or sprite that triggered the action */
  32827. source: any,
  32828. /** The X mouse cursor position at the time of the event */
  32829. pointerX: number,
  32830. /** The Y mouse cursor position at the time of the event */
  32831. pointerY: number,
  32832. /** The mesh that is currently pointed at (can be null) */
  32833. meshUnderPointer: Nullable<AbstractMesh>,
  32834. /** the original (browser) event that triggered the ActionEvent */
  32835. sourceEvent?: any,
  32836. /** additional data for the event */
  32837. additionalData?: any);
  32838. /**
  32839. * Helper function to auto-create an ActionEvent from a source mesh.
  32840. * @param source The source mesh that triggered the event
  32841. * @param evt The original (browser) event
  32842. * @param additionalData additional data for the event
  32843. * @returns the new ActionEvent
  32844. */
  32845. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32846. /**
  32847. * Helper function to auto-create an ActionEvent from a source sprite
  32848. * @param source The source sprite that triggered the event
  32849. * @param scene Scene associated with the sprite
  32850. * @param evt The original (browser) event
  32851. * @param additionalData additional data for the event
  32852. * @returns the new ActionEvent
  32853. */
  32854. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32855. /**
  32856. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32857. * @param scene the scene where the event occurred
  32858. * @param evt The original (browser) event
  32859. * @returns the new ActionEvent
  32860. */
  32861. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32862. /**
  32863. * Helper function to auto-create an ActionEvent from a primitive
  32864. * @param prim defines the target primitive
  32865. * @param pointerPos defines the pointer position
  32866. * @param evt The original (browser) event
  32867. * @param additionalData additional data for the event
  32868. * @returns the new ActionEvent
  32869. */
  32870. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32871. }
  32872. }
  32873. declare module BABYLON {
  32874. /**
  32875. * Abstract class used to decouple action Manager from scene and meshes.
  32876. * Do not instantiate.
  32877. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32878. */
  32879. export abstract class AbstractActionManager implements IDisposable {
  32880. /** Gets the list of active triggers */
  32881. static Triggers: {
  32882. [key: string]: number;
  32883. };
  32884. /** Gets the cursor to use when hovering items */
  32885. hoverCursor: string;
  32886. /** Gets the list of actions */
  32887. actions: IAction[];
  32888. /**
  32889. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32890. */
  32891. isRecursive: boolean;
  32892. /**
  32893. * Releases all associated resources
  32894. */
  32895. abstract dispose(): void;
  32896. /**
  32897. * Does this action manager has pointer triggers
  32898. */
  32899. abstract get hasPointerTriggers(): boolean;
  32900. /**
  32901. * Does this action manager has pick triggers
  32902. */
  32903. abstract get hasPickTriggers(): boolean;
  32904. /**
  32905. * Process a specific trigger
  32906. * @param trigger defines the trigger to process
  32907. * @param evt defines the event details to be processed
  32908. */
  32909. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32910. /**
  32911. * Does this action manager handles actions of any of the given triggers
  32912. * @param triggers defines the triggers to be tested
  32913. * @return a boolean indicating whether one (or more) of the triggers is handled
  32914. */
  32915. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32916. /**
  32917. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32918. * speed.
  32919. * @param triggerA defines the trigger to be tested
  32920. * @param triggerB defines the trigger to be tested
  32921. * @return a boolean indicating whether one (or more) of the triggers is handled
  32922. */
  32923. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32924. /**
  32925. * Does this action manager handles actions of a given trigger
  32926. * @param trigger defines the trigger to be tested
  32927. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32928. * @return whether the trigger is handled
  32929. */
  32930. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32931. /**
  32932. * Serialize this manager to a JSON object
  32933. * @param name defines the property name to store this manager
  32934. * @returns a JSON representation of this manager
  32935. */
  32936. abstract serialize(name: string): any;
  32937. /**
  32938. * Registers an action to this action manager
  32939. * @param action defines the action to be registered
  32940. * @return the action amended (prepared) after registration
  32941. */
  32942. abstract registerAction(action: IAction): Nullable<IAction>;
  32943. /**
  32944. * Unregisters an action to this action manager
  32945. * @param action defines the action to be unregistered
  32946. * @return a boolean indicating whether the action has been unregistered
  32947. */
  32948. abstract unregisterAction(action: IAction): Boolean;
  32949. /**
  32950. * Does exist one action manager with at least one trigger
  32951. **/
  32952. static get HasTriggers(): boolean;
  32953. /**
  32954. * Does exist one action manager with at least one pick trigger
  32955. **/
  32956. static get HasPickTriggers(): boolean;
  32957. /**
  32958. * Does exist one action manager that handles actions of a given trigger
  32959. * @param trigger defines the trigger to be tested
  32960. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32961. **/
  32962. static HasSpecificTrigger(trigger: number): boolean;
  32963. }
  32964. }
  32965. declare module BABYLON {
  32966. /**
  32967. * Defines how a node can be built from a string name.
  32968. */
  32969. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32970. /**
  32971. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32972. */
  32973. export class Node implements IBehaviorAware<Node> {
  32974. /** @hidden */
  32975. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32976. private static _NodeConstructors;
  32977. /**
  32978. * Add a new node constructor
  32979. * @param type defines the type name of the node to construct
  32980. * @param constructorFunc defines the constructor function
  32981. */
  32982. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32983. /**
  32984. * Returns a node constructor based on type name
  32985. * @param type defines the type name
  32986. * @param name defines the new node name
  32987. * @param scene defines the hosting scene
  32988. * @param options defines optional options to transmit to constructors
  32989. * @returns the new constructor or null
  32990. */
  32991. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32992. /**
  32993. * Gets or sets the name of the node
  32994. */
  32995. name: string;
  32996. /**
  32997. * Gets or sets the id of the node
  32998. */
  32999. id: string;
  33000. /**
  33001. * Gets or sets the unique id of the node
  33002. */
  33003. uniqueId: number;
  33004. /**
  33005. * Gets or sets a string used to store user defined state for the node
  33006. */
  33007. state: string;
  33008. /**
  33009. * Gets or sets an object used to store user defined information for the node
  33010. */
  33011. metadata: any;
  33012. /**
  33013. * For internal use only. Please do not use.
  33014. */
  33015. reservedDataStore: any;
  33016. /**
  33017. * List of inspectable custom properties (used by the Inspector)
  33018. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33019. */
  33020. inspectableCustomProperties: IInspectable[];
  33021. private _doNotSerialize;
  33022. /**
  33023. * Gets or sets a boolean used to define if the node must be serialized
  33024. */
  33025. get doNotSerialize(): boolean;
  33026. set doNotSerialize(value: boolean);
  33027. /** @hidden */
  33028. _isDisposed: boolean;
  33029. /**
  33030. * Gets a list of Animations associated with the node
  33031. */
  33032. animations: Animation[];
  33033. protected _ranges: {
  33034. [name: string]: Nullable<AnimationRange>;
  33035. };
  33036. /**
  33037. * Callback raised when the node is ready to be used
  33038. */
  33039. onReady: Nullable<(node: Node) => void>;
  33040. private _isEnabled;
  33041. private _isParentEnabled;
  33042. private _isReady;
  33043. /** @hidden */
  33044. _currentRenderId: number;
  33045. private _parentUpdateId;
  33046. /** @hidden */
  33047. _childUpdateId: number;
  33048. /** @hidden */
  33049. _waitingParentId: Nullable<string>;
  33050. /** @hidden */
  33051. _scene: Scene;
  33052. /** @hidden */
  33053. _cache: any;
  33054. private _parentNode;
  33055. private _children;
  33056. /** @hidden */
  33057. _worldMatrix: Matrix;
  33058. /** @hidden */
  33059. _worldMatrixDeterminant: number;
  33060. /** @hidden */
  33061. _worldMatrixDeterminantIsDirty: boolean;
  33062. /** @hidden */
  33063. private _sceneRootNodesIndex;
  33064. /**
  33065. * Gets a boolean indicating if the node has been disposed
  33066. * @returns true if the node was disposed
  33067. */
  33068. isDisposed(): boolean;
  33069. /**
  33070. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33071. * @see https://doc.babylonjs.com/how_to/parenting
  33072. */
  33073. set parent(parent: Nullable<Node>);
  33074. get parent(): Nullable<Node>;
  33075. /** @hidden */
  33076. _addToSceneRootNodes(): void;
  33077. /** @hidden */
  33078. _removeFromSceneRootNodes(): void;
  33079. private _animationPropertiesOverride;
  33080. /**
  33081. * Gets or sets the animation properties override
  33082. */
  33083. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33084. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33085. /**
  33086. * Gets a string identifying the name of the class
  33087. * @returns "Node" string
  33088. */
  33089. getClassName(): string;
  33090. /** @hidden */
  33091. readonly _isNode: boolean;
  33092. /**
  33093. * An event triggered when the mesh is disposed
  33094. */
  33095. onDisposeObservable: Observable<Node>;
  33096. private _onDisposeObserver;
  33097. /**
  33098. * Sets a callback that will be raised when the node will be disposed
  33099. */
  33100. set onDispose(callback: () => void);
  33101. /**
  33102. * Creates a new Node
  33103. * @param name the name and id to be given to this node
  33104. * @param scene the scene this node will be added to
  33105. */
  33106. constructor(name: string, scene?: Nullable<Scene>);
  33107. /**
  33108. * Gets the scene of the node
  33109. * @returns a scene
  33110. */
  33111. getScene(): Scene;
  33112. /**
  33113. * Gets the engine of the node
  33114. * @returns a Engine
  33115. */
  33116. getEngine(): Engine;
  33117. private _behaviors;
  33118. /**
  33119. * Attach a behavior to the node
  33120. * @see https://doc.babylonjs.com/features/behaviour
  33121. * @param behavior defines the behavior to attach
  33122. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33123. * @returns the current Node
  33124. */
  33125. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33126. /**
  33127. * Remove an attached behavior
  33128. * @see https://doc.babylonjs.com/features/behaviour
  33129. * @param behavior defines the behavior to attach
  33130. * @returns the current Node
  33131. */
  33132. removeBehavior(behavior: Behavior<Node>): Node;
  33133. /**
  33134. * Gets the list of attached behaviors
  33135. * @see https://doc.babylonjs.com/features/behaviour
  33136. */
  33137. get behaviors(): Behavior<Node>[];
  33138. /**
  33139. * Gets an attached behavior by name
  33140. * @param name defines the name of the behavior to look for
  33141. * @see https://doc.babylonjs.com/features/behaviour
  33142. * @returns null if behavior was not found else the requested behavior
  33143. */
  33144. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33145. /**
  33146. * Returns the latest update of the World matrix
  33147. * @returns a Matrix
  33148. */
  33149. getWorldMatrix(): Matrix;
  33150. /** @hidden */
  33151. _getWorldMatrixDeterminant(): number;
  33152. /**
  33153. * Returns directly the latest state of the mesh World matrix.
  33154. * A Matrix is returned.
  33155. */
  33156. get worldMatrixFromCache(): Matrix;
  33157. /** @hidden */
  33158. _initCache(): void;
  33159. /** @hidden */
  33160. updateCache(force?: boolean): void;
  33161. /** @hidden */
  33162. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33163. /** @hidden */
  33164. _updateCache(ignoreParentClass?: boolean): void;
  33165. /** @hidden */
  33166. _isSynchronized(): boolean;
  33167. /** @hidden */
  33168. _markSyncedWithParent(): void;
  33169. /** @hidden */
  33170. isSynchronizedWithParent(): boolean;
  33171. /** @hidden */
  33172. isSynchronized(): boolean;
  33173. /**
  33174. * Is this node ready to be used/rendered
  33175. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33176. * @return true if the node is ready
  33177. */
  33178. isReady(completeCheck?: boolean): boolean;
  33179. /**
  33180. * Is this node enabled?
  33181. * 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
  33182. * @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
  33183. * @return whether this node (and its parent) is enabled
  33184. */
  33185. isEnabled(checkAncestors?: boolean): boolean;
  33186. /** @hidden */
  33187. protected _syncParentEnabledState(): void;
  33188. /**
  33189. * Set the enabled state of this node
  33190. * @param value defines the new enabled state
  33191. */
  33192. setEnabled(value: boolean): void;
  33193. /**
  33194. * Is this node a descendant of the given node?
  33195. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33196. * @param ancestor defines the parent node to inspect
  33197. * @returns a boolean indicating if this node is a descendant of the given node
  33198. */
  33199. isDescendantOf(ancestor: Node): boolean;
  33200. /** @hidden */
  33201. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33202. /**
  33203. * Will return all nodes that have this node as ascendant
  33204. * @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
  33205. * @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
  33206. * @return all children nodes of all types
  33207. */
  33208. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33209. /**
  33210. * Get all child-meshes of this node
  33211. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  33212. * @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
  33213. * @returns an array of AbstractMesh
  33214. */
  33215. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33216. /**
  33217. * Get all direct children of this node
  33218. * @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
  33219. * @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)
  33220. * @returns an array of Node
  33221. */
  33222. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33223. /** @hidden */
  33224. _setReady(state: boolean): void;
  33225. /**
  33226. * Get an animation by name
  33227. * @param name defines the name of the animation to look for
  33228. * @returns null if not found else the requested animation
  33229. */
  33230. getAnimationByName(name: string): Nullable<Animation>;
  33231. /**
  33232. * Creates an animation range for this node
  33233. * @param name defines the name of the range
  33234. * @param from defines the starting key
  33235. * @param to defines the end key
  33236. */
  33237. createAnimationRange(name: string, from: number, to: number): void;
  33238. /**
  33239. * Delete a specific animation range
  33240. * @param name defines the name of the range to delete
  33241. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33242. */
  33243. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33244. /**
  33245. * Get an animation range by name
  33246. * @param name defines the name of the animation range to look for
  33247. * @returns null if not found else the requested animation range
  33248. */
  33249. getAnimationRange(name: string): Nullable<AnimationRange>;
  33250. /**
  33251. * Gets the list of all animation ranges defined on this node
  33252. * @returns an array
  33253. */
  33254. getAnimationRanges(): Nullable<AnimationRange>[];
  33255. /**
  33256. * Will start the animation sequence
  33257. * @param name defines the range frames for animation sequence
  33258. * @param loop defines if the animation should loop (false by default)
  33259. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33260. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33261. * @returns the object created for this animation. If range does not exist, it will return null
  33262. */
  33263. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33264. /**
  33265. * Serialize animation ranges into a JSON compatible object
  33266. * @returns serialization object
  33267. */
  33268. serializeAnimationRanges(): any;
  33269. /**
  33270. * Computes the world matrix of the node
  33271. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33272. * @returns the world matrix
  33273. */
  33274. computeWorldMatrix(force?: boolean): Matrix;
  33275. /**
  33276. * Releases resources associated with this node.
  33277. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33278. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33279. */
  33280. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33281. /**
  33282. * Parse animation range data from a serialization object and store them into a given node
  33283. * @param node defines where to store the animation ranges
  33284. * @param parsedNode defines the serialization object to read data from
  33285. * @param scene defines the hosting scene
  33286. */
  33287. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33288. /**
  33289. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33290. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33291. * @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
  33292. * @returns the new bounding vectors
  33293. */
  33294. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33295. min: Vector3;
  33296. max: Vector3;
  33297. };
  33298. }
  33299. }
  33300. declare module BABYLON {
  33301. /**
  33302. * @hidden
  33303. */
  33304. export class _IAnimationState {
  33305. key: number;
  33306. repeatCount: number;
  33307. workValue?: any;
  33308. loopMode?: number;
  33309. offsetValue?: any;
  33310. highLimitValue?: any;
  33311. }
  33312. /**
  33313. * Class used to store any kind of animation
  33314. */
  33315. export class Animation {
  33316. /**Name of the animation */
  33317. name: string;
  33318. /**Property to animate */
  33319. targetProperty: string;
  33320. /**The frames per second of the animation */
  33321. framePerSecond: number;
  33322. /**The data type of the animation */
  33323. dataType: number;
  33324. /**The loop mode of the animation */
  33325. loopMode?: number | undefined;
  33326. /**Specifies if blending should be enabled */
  33327. enableBlending?: boolean | undefined;
  33328. /**
  33329. * Use matrix interpolation instead of using direct key value when animating matrices
  33330. */
  33331. static AllowMatricesInterpolation: boolean;
  33332. /**
  33333. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33334. */
  33335. static AllowMatrixDecomposeForInterpolation: boolean;
  33336. /** Define the Url to load snippets */
  33337. static SnippetUrl: string;
  33338. /** Snippet ID if the animation was created from the snippet server */
  33339. snippetId: string;
  33340. /**
  33341. * Stores the key frames of the animation
  33342. */
  33343. private _keys;
  33344. /**
  33345. * Stores the easing function of the animation
  33346. */
  33347. private _easingFunction;
  33348. /**
  33349. * @hidden Internal use only
  33350. */
  33351. _runtimeAnimations: RuntimeAnimation[];
  33352. /**
  33353. * The set of event that will be linked to this animation
  33354. */
  33355. private _events;
  33356. /**
  33357. * Stores an array of target property paths
  33358. */
  33359. targetPropertyPath: string[];
  33360. /**
  33361. * Stores the blending speed of the animation
  33362. */
  33363. blendingSpeed: number;
  33364. /**
  33365. * Stores the animation ranges for the animation
  33366. */
  33367. private _ranges;
  33368. /**
  33369. * @hidden Internal use
  33370. */
  33371. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33372. /**
  33373. * Sets up an animation
  33374. * @param property The property to animate
  33375. * @param animationType The animation type to apply
  33376. * @param framePerSecond The frames per second of the animation
  33377. * @param easingFunction The easing function used in the animation
  33378. * @returns The created animation
  33379. */
  33380. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33381. /**
  33382. * Create and start an animation on a node
  33383. * @param name defines the name of the global animation that will be run on all nodes
  33384. * @param node defines the root node where the animation will take place
  33385. * @param targetProperty defines property to animate
  33386. * @param framePerSecond defines the number of frame per second yo use
  33387. * @param totalFrame defines the number of frames in total
  33388. * @param from defines the initial value
  33389. * @param to defines the final value
  33390. * @param loopMode defines which loop mode you want to use (off by default)
  33391. * @param easingFunction defines the easing function to use (linear by default)
  33392. * @param onAnimationEnd defines the callback to call when animation end
  33393. * @returns the animatable created for this animation
  33394. */
  33395. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33396. /**
  33397. * Create and start an animation on a node and its descendants
  33398. * @param name defines the name of the global animation that will be run on all nodes
  33399. * @param node defines the root node where the animation will take place
  33400. * @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
  33401. * @param targetProperty defines property to animate
  33402. * @param framePerSecond defines the number of frame per second to use
  33403. * @param totalFrame defines the number of frames in total
  33404. * @param from defines the initial value
  33405. * @param to defines the final value
  33406. * @param loopMode defines which loop mode you want to use (off by default)
  33407. * @param easingFunction defines the easing function to use (linear by default)
  33408. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33409. * @returns the list of animatables created for all nodes
  33410. * @example https://www.babylonjs-playground.com/#MH0VLI
  33411. */
  33412. 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[]>;
  33413. /**
  33414. * Creates a new animation, merges it with the existing animations and starts it
  33415. * @param name Name of the animation
  33416. * @param node Node which contains the scene that begins the animations
  33417. * @param targetProperty Specifies which property to animate
  33418. * @param framePerSecond The frames per second of the animation
  33419. * @param totalFrame The total number of frames
  33420. * @param from The frame at the beginning of the animation
  33421. * @param to The frame at the end of the animation
  33422. * @param loopMode Specifies the loop mode of the animation
  33423. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33424. * @param onAnimationEnd Callback to run once the animation is complete
  33425. * @returns Nullable animation
  33426. */
  33427. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33428. /**
  33429. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33430. * @param sourceAnimation defines the Animation containing keyframes to convert
  33431. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33432. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33433. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33434. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33435. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33436. */
  33437. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33438. /**
  33439. * Transition property of an host to the target Value
  33440. * @param property The property to transition
  33441. * @param targetValue The target Value of the property
  33442. * @param host The object where the property to animate belongs
  33443. * @param scene Scene used to run the animation
  33444. * @param frameRate Framerate (in frame/s) to use
  33445. * @param transition The transition type we want to use
  33446. * @param duration The duration of the animation, in milliseconds
  33447. * @param onAnimationEnd Callback trigger at the end of the animation
  33448. * @returns Nullable animation
  33449. */
  33450. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33451. /**
  33452. * Return the array of runtime animations currently using this animation
  33453. */
  33454. get runtimeAnimations(): RuntimeAnimation[];
  33455. /**
  33456. * Specifies if any of the runtime animations are currently running
  33457. */
  33458. get hasRunningRuntimeAnimations(): boolean;
  33459. /**
  33460. * Initializes the animation
  33461. * @param name Name of the animation
  33462. * @param targetProperty Property to animate
  33463. * @param framePerSecond The frames per second of the animation
  33464. * @param dataType The data type of the animation
  33465. * @param loopMode The loop mode of the animation
  33466. * @param enableBlending Specifies if blending should be enabled
  33467. */
  33468. constructor(
  33469. /**Name of the animation */
  33470. name: string,
  33471. /**Property to animate */
  33472. targetProperty: string,
  33473. /**The frames per second of the animation */
  33474. framePerSecond: number,
  33475. /**The data type of the animation */
  33476. dataType: number,
  33477. /**The loop mode of the animation */
  33478. loopMode?: number | undefined,
  33479. /**Specifies if blending should be enabled */
  33480. enableBlending?: boolean | undefined);
  33481. /**
  33482. * Converts the animation to a string
  33483. * @param fullDetails support for multiple levels of logging within scene loading
  33484. * @returns String form of the animation
  33485. */
  33486. toString(fullDetails?: boolean): string;
  33487. /**
  33488. * Add an event to this animation
  33489. * @param event Event to add
  33490. */
  33491. addEvent(event: AnimationEvent): void;
  33492. /**
  33493. * Remove all events found at the given frame
  33494. * @param frame The frame to remove events from
  33495. */
  33496. removeEvents(frame: number): void;
  33497. /**
  33498. * Retrieves all the events from the animation
  33499. * @returns Events from the animation
  33500. */
  33501. getEvents(): AnimationEvent[];
  33502. /**
  33503. * Creates an animation range
  33504. * @param name Name of the animation range
  33505. * @param from Starting frame of the animation range
  33506. * @param to Ending frame of the animation
  33507. */
  33508. createRange(name: string, from: number, to: number): void;
  33509. /**
  33510. * Deletes an animation range by name
  33511. * @param name Name of the animation range to delete
  33512. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33513. */
  33514. deleteRange(name: string, deleteFrames?: boolean): void;
  33515. /**
  33516. * Gets the animation range by name, or null if not defined
  33517. * @param name Name of the animation range
  33518. * @returns Nullable animation range
  33519. */
  33520. getRange(name: string): Nullable<AnimationRange>;
  33521. /**
  33522. * Gets the key frames from the animation
  33523. * @returns The key frames of the animation
  33524. */
  33525. getKeys(): Array<IAnimationKey>;
  33526. /**
  33527. * Gets the highest frame rate of the animation
  33528. * @returns Highest frame rate of the animation
  33529. */
  33530. getHighestFrame(): number;
  33531. /**
  33532. * Gets the easing function of the animation
  33533. * @returns Easing function of the animation
  33534. */
  33535. getEasingFunction(): IEasingFunction;
  33536. /**
  33537. * Sets the easing function of the animation
  33538. * @param easingFunction A custom mathematical formula for animation
  33539. */
  33540. setEasingFunction(easingFunction: EasingFunction): void;
  33541. /**
  33542. * Interpolates a scalar linearly
  33543. * @param startValue Start value of the animation curve
  33544. * @param endValue End value of the animation curve
  33545. * @param gradient Scalar amount to interpolate
  33546. * @returns Interpolated scalar value
  33547. */
  33548. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33549. /**
  33550. * Interpolates a scalar cubically
  33551. * @param startValue Start value of the animation curve
  33552. * @param outTangent End tangent of the animation
  33553. * @param endValue End value of the animation curve
  33554. * @param inTangent Start tangent of the animation curve
  33555. * @param gradient Scalar amount to interpolate
  33556. * @returns Interpolated scalar value
  33557. */
  33558. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33559. /**
  33560. * Interpolates a quaternion using a spherical linear interpolation
  33561. * @param startValue Start value of the animation curve
  33562. * @param endValue End value of the animation curve
  33563. * @param gradient Scalar amount to interpolate
  33564. * @returns Interpolated quaternion value
  33565. */
  33566. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33567. /**
  33568. * Interpolates a quaternion cubically
  33569. * @param startValue Start value of the animation curve
  33570. * @param outTangent End tangent of the animation curve
  33571. * @param endValue End value of the animation curve
  33572. * @param inTangent Start tangent of the animation curve
  33573. * @param gradient Scalar amount to interpolate
  33574. * @returns Interpolated quaternion value
  33575. */
  33576. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33577. /**
  33578. * Interpolates a Vector3 linearl
  33579. * @param startValue Start value of the animation curve
  33580. * @param endValue End value of the animation curve
  33581. * @param gradient Scalar amount to interpolate
  33582. * @returns Interpolated scalar value
  33583. */
  33584. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33585. /**
  33586. * Interpolates a Vector3 cubically
  33587. * @param startValue Start value of the animation curve
  33588. * @param outTangent End tangent of the animation
  33589. * @param endValue End value of the animation curve
  33590. * @param inTangent Start tangent of the animation curve
  33591. * @param gradient Scalar amount to interpolate
  33592. * @returns InterpolatedVector3 value
  33593. */
  33594. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33595. /**
  33596. * Interpolates a Vector2 linearly
  33597. * @param startValue Start value of the animation curve
  33598. * @param endValue End value of the animation curve
  33599. * @param gradient Scalar amount to interpolate
  33600. * @returns Interpolated Vector2 value
  33601. */
  33602. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33603. /**
  33604. * Interpolates a Vector2 cubically
  33605. * @param startValue Start value of the animation curve
  33606. * @param outTangent End tangent of the animation
  33607. * @param endValue End value of the animation curve
  33608. * @param inTangent Start tangent of the animation curve
  33609. * @param gradient Scalar amount to interpolate
  33610. * @returns Interpolated Vector2 value
  33611. */
  33612. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33613. /**
  33614. * Interpolates a size linearly
  33615. * @param startValue Start value of the animation curve
  33616. * @param endValue End value of the animation curve
  33617. * @param gradient Scalar amount to interpolate
  33618. * @returns Interpolated Size value
  33619. */
  33620. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33621. /**
  33622. * Interpolates a Color3 linearly
  33623. * @param startValue Start value of the animation curve
  33624. * @param endValue End value of the animation curve
  33625. * @param gradient Scalar amount to interpolate
  33626. * @returns Interpolated Color3 value
  33627. */
  33628. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33629. /**
  33630. * Interpolates a Color4 linearly
  33631. * @param startValue Start value of the animation curve
  33632. * @param endValue End value of the animation curve
  33633. * @param gradient Scalar amount to interpolate
  33634. * @returns Interpolated Color3 value
  33635. */
  33636. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33637. /**
  33638. * @hidden Internal use only
  33639. */
  33640. _getKeyValue(value: any): any;
  33641. /**
  33642. * @hidden Internal use only
  33643. */
  33644. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33645. /**
  33646. * Defines the function to use to interpolate matrices
  33647. * @param startValue defines the start matrix
  33648. * @param endValue defines the end matrix
  33649. * @param gradient defines the gradient between both matrices
  33650. * @param result defines an optional target matrix where to store the interpolation
  33651. * @returns the interpolated matrix
  33652. */
  33653. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33654. /**
  33655. * Makes a copy of the animation
  33656. * @returns Cloned animation
  33657. */
  33658. clone(): Animation;
  33659. /**
  33660. * Sets the key frames of the animation
  33661. * @param values The animation key frames to set
  33662. */
  33663. setKeys(values: Array<IAnimationKey>): void;
  33664. /**
  33665. * Serializes the animation to an object
  33666. * @returns Serialized object
  33667. */
  33668. serialize(): any;
  33669. /**
  33670. * Float animation type
  33671. */
  33672. static readonly ANIMATIONTYPE_FLOAT: number;
  33673. /**
  33674. * Vector3 animation type
  33675. */
  33676. static readonly ANIMATIONTYPE_VECTOR3: number;
  33677. /**
  33678. * Quaternion animation type
  33679. */
  33680. static readonly ANIMATIONTYPE_QUATERNION: number;
  33681. /**
  33682. * Matrix animation type
  33683. */
  33684. static readonly ANIMATIONTYPE_MATRIX: number;
  33685. /**
  33686. * Color3 animation type
  33687. */
  33688. static readonly ANIMATIONTYPE_COLOR3: number;
  33689. /**
  33690. * Color3 animation type
  33691. */
  33692. static readonly ANIMATIONTYPE_COLOR4: number;
  33693. /**
  33694. * Vector2 animation type
  33695. */
  33696. static readonly ANIMATIONTYPE_VECTOR2: number;
  33697. /**
  33698. * Size animation type
  33699. */
  33700. static readonly ANIMATIONTYPE_SIZE: number;
  33701. /**
  33702. * Relative Loop Mode
  33703. */
  33704. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33705. /**
  33706. * Cycle Loop Mode
  33707. */
  33708. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33709. /**
  33710. * Constant Loop Mode
  33711. */
  33712. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33713. /** @hidden */
  33714. static _UniversalLerp(left: any, right: any, amount: number): any;
  33715. /**
  33716. * Parses an animation object and creates an animation
  33717. * @param parsedAnimation Parsed animation object
  33718. * @returns Animation object
  33719. */
  33720. static Parse(parsedAnimation: any): Animation;
  33721. /**
  33722. * Appends the serialized animations from the source animations
  33723. * @param source Source containing the animations
  33724. * @param destination Target to store the animations
  33725. */
  33726. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33727. /**
  33728. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33729. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33730. * @param url defines the url to load from
  33731. * @returns a promise that will resolve to the new animation or an array of animations
  33732. */
  33733. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33734. /**
  33735. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33736. * @param snippetId defines the snippet to load
  33737. * @returns a promise that will resolve to the new animation or a new array of animations
  33738. */
  33739. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33740. }
  33741. }
  33742. declare module BABYLON {
  33743. /**
  33744. * Interface containing an array of animations
  33745. */
  33746. export interface IAnimatable {
  33747. /**
  33748. * Array of animations
  33749. */
  33750. animations: Nullable<Array<Animation>>;
  33751. }
  33752. }
  33753. declare module BABYLON {
  33754. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33755. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33756. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33757. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33758. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33759. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33760. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33761. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33762. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33763. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33764. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33765. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33766. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33767. /**
  33768. * Decorator used to define property that can be serialized as reference to a camera
  33769. * @param sourceName defines the name of the property to decorate
  33770. */
  33771. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33772. /**
  33773. * Class used to help serialization objects
  33774. */
  33775. export class SerializationHelper {
  33776. /** @hidden */
  33777. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33778. /** @hidden */
  33779. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33780. /** @hidden */
  33781. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33782. /** @hidden */
  33783. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33784. /**
  33785. * Appends the serialized animations from the source animations
  33786. * @param source Source containing the animations
  33787. * @param destination Target to store the animations
  33788. */
  33789. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33790. /**
  33791. * Static function used to serialized a specific entity
  33792. * @param entity defines the entity to serialize
  33793. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33794. * @returns a JSON compatible object representing the serialization of the entity
  33795. */
  33796. static Serialize<T>(entity: T, serializationObject?: any): any;
  33797. /**
  33798. * Creates a new entity from a serialization data object
  33799. * @param creationFunction defines a function used to instanciated the new entity
  33800. * @param source defines the source serialization data
  33801. * @param scene defines the hosting scene
  33802. * @param rootUrl defines the root url for resources
  33803. * @returns a new entity
  33804. */
  33805. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33806. /**
  33807. * Clones an object
  33808. * @param creationFunction defines the function used to instanciate the new object
  33809. * @param source defines the source object
  33810. * @returns the cloned object
  33811. */
  33812. static Clone<T>(creationFunction: () => T, source: T): T;
  33813. /**
  33814. * Instanciates a new object based on a source one (some data will be shared between both object)
  33815. * @param creationFunction defines the function used to instanciate the new object
  33816. * @param source defines the source object
  33817. * @returns the new object
  33818. */
  33819. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33820. }
  33821. }
  33822. declare module BABYLON {
  33823. /**
  33824. * Base class of all the textures in babylon.
  33825. * It groups all the common properties the materials, post process, lights... might need
  33826. * in order to make a correct use of the texture.
  33827. */
  33828. export class BaseTexture implements IAnimatable {
  33829. /**
  33830. * Default anisotropic filtering level for the application.
  33831. * It is set to 4 as a good tradeoff between perf and quality.
  33832. */
  33833. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33834. /**
  33835. * Gets or sets the unique id of the texture
  33836. */
  33837. uniqueId: number;
  33838. /**
  33839. * Define the name of the texture.
  33840. */
  33841. name: string;
  33842. /**
  33843. * Gets or sets an object used to store user defined information.
  33844. */
  33845. metadata: any;
  33846. /**
  33847. * For internal use only. Please do not use.
  33848. */
  33849. reservedDataStore: any;
  33850. private _hasAlpha;
  33851. /**
  33852. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33853. */
  33854. set hasAlpha(value: boolean);
  33855. get hasAlpha(): boolean;
  33856. /**
  33857. * Defines if the alpha value should be determined via the rgb values.
  33858. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33859. */
  33860. getAlphaFromRGB: boolean;
  33861. /**
  33862. * Intensity or strength of the texture.
  33863. * It is commonly used by materials to fine tune the intensity of the texture
  33864. */
  33865. level: number;
  33866. /**
  33867. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33868. * This is part of the texture as textures usually maps to one uv set.
  33869. */
  33870. coordinatesIndex: number;
  33871. protected _coordinatesMode: number;
  33872. /**
  33873. * How a texture is mapped.
  33874. *
  33875. * | Value | Type | Description |
  33876. * | ----- | ----------------------------------- | ----------- |
  33877. * | 0 | EXPLICIT_MODE | |
  33878. * | 1 | SPHERICAL_MODE | |
  33879. * | 2 | PLANAR_MODE | |
  33880. * | 3 | CUBIC_MODE | |
  33881. * | 4 | PROJECTION_MODE | |
  33882. * | 5 | SKYBOX_MODE | |
  33883. * | 6 | INVCUBIC_MODE | |
  33884. * | 7 | EQUIRECTANGULAR_MODE | |
  33885. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33886. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33887. */
  33888. set coordinatesMode(value: number);
  33889. get coordinatesMode(): number;
  33890. private _wrapU;
  33891. /**
  33892. * | Value | Type | Description |
  33893. * | ----- | ------------------ | ----------- |
  33894. * | 0 | CLAMP_ADDRESSMODE | |
  33895. * | 1 | WRAP_ADDRESSMODE | |
  33896. * | 2 | MIRROR_ADDRESSMODE | |
  33897. */
  33898. get wrapU(): number;
  33899. set wrapU(value: number);
  33900. private _wrapV;
  33901. /**
  33902. * | Value | Type | Description |
  33903. * | ----- | ------------------ | ----------- |
  33904. * | 0 | CLAMP_ADDRESSMODE | |
  33905. * | 1 | WRAP_ADDRESSMODE | |
  33906. * | 2 | MIRROR_ADDRESSMODE | |
  33907. */
  33908. get wrapV(): number;
  33909. set wrapV(value: number);
  33910. /**
  33911. * | Value | Type | Description |
  33912. * | ----- | ------------------ | ----------- |
  33913. * | 0 | CLAMP_ADDRESSMODE | |
  33914. * | 1 | WRAP_ADDRESSMODE | |
  33915. * | 2 | MIRROR_ADDRESSMODE | |
  33916. */
  33917. wrapR: number;
  33918. /**
  33919. * With compliant hardware and browser (supporting anisotropic filtering)
  33920. * this defines the level of anisotropic filtering in the texture.
  33921. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33922. */
  33923. anisotropicFilteringLevel: number;
  33924. /**
  33925. * Define if the texture is a cube texture or if false a 2d texture.
  33926. */
  33927. get isCube(): boolean;
  33928. set isCube(value: boolean);
  33929. /**
  33930. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33931. */
  33932. get is3D(): boolean;
  33933. set is3D(value: boolean);
  33934. /**
  33935. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33936. */
  33937. get is2DArray(): boolean;
  33938. set is2DArray(value: boolean);
  33939. /**
  33940. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33941. * HDR texture are usually stored in linear space.
  33942. * This only impacts the PBR and Background materials
  33943. */
  33944. gammaSpace: boolean;
  33945. /**
  33946. * Gets or sets whether or not the texture contains RGBD data.
  33947. */
  33948. get isRGBD(): boolean;
  33949. set isRGBD(value: boolean);
  33950. /**
  33951. * Is Z inverted in the texture (useful in a cube texture).
  33952. */
  33953. invertZ: boolean;
  33954. /**
  33955. * Are mip maps generated for this texture or not.
  33956. */
  33957. get noMipmap(): boolean;
  33958. /**
  33959. * @hidden
  33960. */
  33961. lodLevelInAlpha: boolean;
  33962. /**
  33963. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33964. */
  33965. get lodGenerationOffset(): number;
  33966. set lodGenerationOffset(value: number);
  33967. /**
  33968. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33969. */
  33970. get lodGenerationScale(): number;
  33971. set lodGenerationScale(value: number);
  33972. /**
  33973. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33974. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33975. * average roughness values.
  33976. */
  33977. get linearSpecularLOD(): boolean;
  33978. set linearSpecularLOD(value: boolean);
  33979. /**
  33980. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33981. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33982. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33983. */
  33984. get irradianceTexture(): Nullable<BaseTexture>;
  33985. set irradianceTexture(value: Nullable<BaseTexture>);
  33986. /**
  33987. * Define if the texture is a render target.
  33988. */
  33989. isRenderTarget: boolean;
  33990. /**
  33991. * Define the unique id of the texture in the scene.
  33992. */
  33993. get uid(): string;
  33994. /** @hidden */
  33995. _prefiltered: boolean;
  33996. /**
  33997. * Return a string representation of the texture.
  33998. * @returns the texture as a string
  33999. */
  34000. toString(): string;
  34001. /**
  34002. * Get the class name of the texture.
  34003. * @returns "BaseTexture"
  34004. */
  34005. getClassName(): string;
  34006. /**
  34007. * Define the list of animation attached to the texture.
  34008. */
  34009. animations: Animation[];
  34010. /**
  34011. * An event triggered when the texture is disposed.
  34012. */
  34013. onDisposeObservable: Observable<BaseTexture>;
  34014. private _onDisposeObserver;
  34015. /**
  34016. * Callback triggered when the texture has been disposed.
  34017. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34018. */
  34019. set onDispose(callback: () => void);
  34020. /**
  34021. * Define the current state of the loading sequence when in delayed load mode.
  34022. */
  34023. delayLoadState: number;
  34024. protected _scene: Nullable<Scene>;
  34025. protected _engine: Nullable<ThinEngine>;
  34026. /** @hidden */
  34027. _texture: Nullable<InternalTexture>;
  34028. private _uid;
  34029. /**
  34030. * Define if the texture is preventinga material to render or not.
  34031. * If not and the texture is not ready, the engine will use a default black texture instead.
  34032. */
  34033. get isBlocking(): boolean;
  34034. /**
  34035. * Instantiates a new BaseTexture.
  34036. * Base class of all the textures in babylon.
  34037. * It groups all the common properties the materials, post process, lights... might need
  34038. * in order to make a correct use of the texture.
  34039. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34040. */
  34041. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34042. /**
  34043. * Get the scene the texture belongs to.
  34044. * @returns the scene or null if undefined
  34045. */
  34046. getScene(): Nullable<Scene>;
  34047. /** @hidden */
  34048. protected _getEngine(): Nullable<ThinEngine>;
  34049. /**
  34050. * Get the texture transform matrix used to offset tile the texture for istance.
  34051. * @returns the transformation matrix
  34052. */
  34053. getTextureMatrix(): Matrix;
  34054. /**
  34055. * Get the texture reflection matrix used to rotate/transform the reflection.
  34056. * @returns the reflection matrix
  34057. */
  34058. getReflectionTextureMatrix(): Matrix;
  34059. /**
  34060. * Get the underlying lower level texture from Babylon.
  34061. * @returns the insternal texture
  34062. */
  34063. getInternalTexture(): Nullable<InternalTexture>;
  34064. /**
  34065. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34066. * @returns true if ready or not blocking
  34067. */
  34068. isReadyOrNotBlocking(): boolean;
  34069. /**
  34070. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34071. * @returns true if fully ready
  34072. */
  34073. isReady(): boolean;
  34074. private _cachedSize;
  34075. /**
  34076. * Get the size of the texture.
  34077. * @returns the texture size.
  34078. */
  34079. getSize(): ISize;
  34080. /**
  34081. * Get the base size of the texture.
  34082. * It can be different from the size if the texture has been resized for POT for instance
  34083. * @returns the base size
  34084. */
  34085. getBaseSize(): ISize;
  34086. /**
  34087. * Update the sampling mode of the texture.
  34088. * Default is Trilinear mode.
  34089. *
  34090. * | Value | Type | Description |
  34091. * | ----- | ------------------ | ----------- |
  34092. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34093. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34094. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34095. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34096. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34097. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34098. * | 7 | NEAREST_LINEAR | |
  34099. * | 8 | NEAREST_NEAREST | |
  34100. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34101. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34102. * | 11 | LINEAR_LINEAR | |
  34103. * | 12 | LINEAR_NEAREST | |
  34104. *
  34105. * > _mag_: magnification filter (close to the viewer)
  34106. * > _min_: minification filter (far from the viewer)
  34107. * > _mip_: filter used between mip map levels
  34108. *@param samplingMode Define the new sampling mode of the texture
  34109. */
  34110. updateSamplingMode(samplingMode: number): void;
  34111. /**
  34112. * Scales the texture if is `canRescale()`
  34113. * @param ratio the resize factor we want to use to rescale
  34114. */
  34115. scale(ratio: number): void;
  34116. /**
  34117. * Get if the texture can rescale.
  34118. */
  34119. get canRescale(): boolean;
  34120. /** @hidden */
  34121. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34122. /** @hidden */
  34123. _rebuild(): void;
  34124. /**
  34125. * Triggers the load sequence in delayed load mode.
  34126. */
  34127. delayLoad(): void;
  34128. /**
  34129. * Clones the texture.
  34130. * @returns the cloned texture
  34131. */
  34132. clone(): Nullable<BaseTexture>;
  34133. /**
  34134. * Get the texture underlying type (INT, FLOAT...)
  34135. */
  34136. get textureType(): number;
  34137. /**
  34138. * Get the texture underlying format (RGB, RGBA...)
  34139. */
  34140. get textureFormat(): number;
  34141. /**
  34142. * Indicates that textures need to be re-calculated for all materials
  34143. */
  34144. protected _markAllSubMeshesAsTexturesDirty(): void;
  34145. /**
  34146. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34147. * This will returns an RGBA array buffer containing either in values (0-255) or
  34148. * float values (0-1) depending of the underlying buffer type.
  34149. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34150. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34151. * @param buffer defines a user defined buffer to fill with data (can be null)
  34152. * @returns The Array buffer containing the pixels data.
  34153. */
  34154. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34155. /**
  34156. * Release and destroy the underlying lower level texture aka internalTexture.
  34157. */
  34158. releaseInternalTexture(): void;
  34159. /** @hidden */
  34160. get _lodTextureHigh(): Nullable<BaseTexture>;
  34161. /** @hidden */
  34162. get _lodTextureMid(): Nullable<BaseTexture>;
  34163. /** @hidden */
  34164. get _lodTextureLow(): Nullable<BaseTexture>;
  34165. /**
  34166. * Dispose the texture and release its associated resources.
  34167. */
  34168. dispose(): void;
  34169. /**
  34170. * Serialize the texture into a JSON representation that can be parsed later on.
  34171. * @returns the JSON representation of the texture
  34172. */
  34173. serialize(): any;
  34174. /**
  34175. * Helper function to be called back once a list of texture contains only ready textures.
  34176. * @param textures Define the list of textures to wait for
  34177. * @param callback Define the callback triggered once the entire list will be ready
  34178. */
  34179. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34180. private static _isScene;
  34181. }
  34182. }
  34183. declare module BABYLON {
  34184. /**
  34185. * Options to be used when creating an effect.
  34186. */
  34187. export interface IEffectCreationOptions {
  34188. /**
  34189. * Atrributes that will be used in the shader.
  34190. */
  34191. attributes: string[];
  34192. /**
  34193. * Uniform varible names that will be set in the shader.
  34194. */
  34195. uniformsNames: string[];
  34196. /**
  34197. * Uniform buffer variable names that will be set in the shader.
  34198. */
  34199. uniformBuffersNames: string[];
  34200. /**
  34201. * Sampler texture variable names that will be set in the shader.
  34202. */
  34203. samplers: string[];
  34204. /**
  34205. * Define statements that will be set in the shader.
  34206. */
  34207. defines: any;
  34208. /**
  34209. * Possible fallbacks for this effect to improve performance when needed.
  34210. */
  34211. fallbacks: Nullable<IEffectFallbacks>;
  34212. /**
  34213. * Callback that will be called when the shader is compiled.
  34214. */
  34215. onCompiled: Nullable<(effect: Effect) => void>;
  34216. /**
  34217. * Callback that will be called if an error occurs during shader compilation.
  34218. */
  34219. onError: Nullable<(effect: Effect, errors: string) => void>;
  34220. /**
  34221. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34222. */
  34223. indexParameters?: any;
  34224. /**
  34225. * Max number of lights that can be used in the shader.
  34226. */
  34227. maxSimultaneousLights?: number;
  34228. /**
  34229. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34230. */
  34231. transformFeedbackVaryings?: Nullable<string[]>;
  34232. /**
  34233. * 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
  34234. */
  34235. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34236. /**
  34237. * Is this effect rendering to several color attachments ?
  34238. */
  34239. multiTarget?: boolean;
  34240. }
  34241. /**
  34242. * Effect containing vertex and fragment shader that can be executed on an object.
  34243. */
  34244. export class Effect implements IDisposable {
  34245. /**
  34246. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34247. */
  34248. static ShadersRepository: string;
  34249. /**
  34250. * Enable logging of the shader code when a compilation error occurs
  34251. */
  34252. static LogShaderCodeOnCompilationError: boolean;
  34253. /**
  34254. * Name of the effect.
  34255. */
  34256. name: any;
  34257. /**
  34258. * String container all the define statements that should be set on the shader.
  34259. */
  34260. defines: string;
  34261. /**
  34262. * Callback that will be called when the shader is compiled.
  34263. */
  34264. onCompiled: Nullable<(effect: Effect) => void>;
  34265. /**
  34266. * Callback that will be called if an error occurs during shader compilation.
  34267. */
  34268. onError: Nullable<(effect: Effect, errors: string) => void>;
  34269. /**
  34270. * Callback that will be called when effect is bound.
  34271. */
  34272. onBind: Nullable<(effect: Effect) => void>;
  34273. /**
  34274. * Unique ID of the effect.
  34275. */
  34276. uniqueId: number;
  34277. /**
  34278. * Observable that will be called when the shader is compiled.
  34279. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34280. */
  34281. onCompileObservable: Observable<Effect>;
  34282. /**
  34283. * Observable that will be called if an error occurs during shader compilation.
  34284. */
  34285. onErrorObservable: Observable<Effect>;
  34286. /** @hidden */
  34287. _onBindObservable: Nullable<Observable<Effect>>;
  34288. /**
  34289. * @hidden
  34290. * Specifies if the effect was previously ready
  34291. */
  34292. _wasPreviouslyReady: boolean;
  34293. /**
  34294. * Observable that will be called when effect is bound.
  34295. */
  34296. get onBindObservable(): Observable<Effect>;
  34297. /** @hidden */
  34298. _bonesComputationForcedToCPU: boolean;
  34299. /** @hidden */
  34300. _multiTarget: boolean;
  34301. private static _uniqueIdSeed;
  34302. private _engine;
  34303. private _uniformBuffersNames;
  34304. private _uniformBuffersNamesList;
  34305. private _uniformsNames;
  34306. private _samplerList;
  34307. private _samplers;
  34308. private _isReady;
  34309. private _compilationError;
  34310. private _allFallbacksProcessed;
  34311. private _attributesNames;
  34312. private _attributes;
  34313. private _attributeLocationByName;
  34314. private _uniforms;
  34315. /**
  34316. * Key for the effect.
  34317. * @hidden
  34318. */
  34319. _key: string;
  34320. private _indexParameters;
  34321. private _fallbacks;
  34322. private _vertexSourceCode;
  34323. private _fragmentSourceCode;
  34324. private _vertexSourceCodeOverride;
  34325. private _fragmentSourceCodeOverride;
  34326. private _transformFeedbackVaryings;
  34327. /**
  34328. * Compiled shader to webGL program.
  34329. * @hidden
  34330. */
  34331. _pipelineContext: Nullable<IPipelineContext>;
  34332. private _valueCache;
  34333. private static _baseCache;
  34334. /**
  34335. * Instantiates an effect.
  34336. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34337. * @param baseName Name of the effect.
  34338. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34339. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34340. * @param samplers List of sampler variables that will be passed to the shader.
  34341. * @param engine Engine to be used to render the effect
  34342. * @param defines Define statements to be added to the shader.
  34343. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34344. * @param onCompiled Callback that will be called when the shader is compiled.
  34345. * @param onError Callback that will be called if an error occurs during shader compilation.
  34346. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34347. */
  34348. 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);
  34349. private _useFinalCode;
  34350. /**
  34351. * Unique key for this effect
  34352. */
  34353. get key(): string;
  34354. /**
  34355. * If the effect has been compiled and prepared.
  34356. * @returns if the effect is compiled and prepared.
  34357. */
  34358. isReady(): boolean;
  34359. private _isReadyInternal;
  34360. /**
  34361. * The engine the effect was initialized with.
  34362. * @returns the engine.
  34363. */
  34364. getEngine(): Engine;
  34365. /**
  34366. * The pipeline context for this effect
  34367. * @returns the associated pipeline context
  34368. */
  34369. getPipelineContext(): Nullable<IPipelineContext>;
  34370. /**
  34371. * The set of names of attribute variables for the shader.
  34372. * @returns An array of attribute names.
  34373. */
  34374. getAttributesNames(): string[];
  34375. /**
  34376. * Returns the attribute at the given index.
  34377. * @param index The index of the attribute.
  34378. * @returns The location of the attribute.
  34379. */
  34380. getAttributeLocation(index: number): number;
  34381. /**
  34382. * Returns the attribute based on the name of the variable.
  34383. * @param name of the attribute to look up.
  34384. * @returns the attribute location.
  34385. */
  34386. getAttributeLocationByName(name: string): number;
  34387. /**
  34388. * The number of attributes.
  34389. * @returns the numnber of attributes.
  34390. */
  34391. getAttributesCount(): number;
  34392. /**
  34393. * Gets the index of a uniform variable.
  34394. * @param uniformName of the uniform to look up.
  34395. * @returns the index.
  34396. */
  34397. getUniformIndex(uniformName: string): number;
  34398. /**
  34399. * Returns the attribute based on the name of the variable.
  34400. * @param uniformName of the uniform to look up.
  34401. * @returns the location of the uniform.
  34402. */
  34403. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34404. /**
  34405. * Returns an array of sampler variable names
  34406. * @returns The array of sampler variable names.
  34407. */
  34408. getSamplers(): string[];
  34409. /**
  34410. * Returns an array of uniform variable names
  34411. * @returns The array of uniform variable names.
  34412. */
  34413. getUniformNames(): string[];
  34414. /**
  34415. * Returns an array of uniform buffer variable names
  34416. * @returns The array of uniform buffer variable names.
  34417. */
  34418. getUniformBuffersNames(): string[];
  34419. /**
  34420. * Returns the index parameters used to create the effect
  34421. * @returns The index parameters object
  34422. */
  34423. getIndexParameters(): any;
  34424. /**
  34425. * The error from the last compilation.
  34426. * @returns the error string.
  34427. */
  34428. getCompilationError(): string;
  34429. /**
  34430. * Gets a boolean indicating that all fallbacks were used during compilation
  34431. * @returns true if all fallbacks were used
  34432. */
  34433. allFallbacksProcessed(): boolean;
  34434. /**
  34435. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34436. * @param func The callback to be used.
  34437. */
  34438. executeWhenCompiled(func: (effect: Effect) => void): void;
  34439. private _checkIsReady;
  34440. private _loadShader;
  34441. /**
  34442. * Gets the vertex shader source code of this effect
  34443. */
  34444. get vertexSourceCode(): string;
  34445. /**
  34446. * Gets the fragment shader source code of this effect
  34447. */
  34448. get fragmentSourceCode(): string;
  34449. /**
  34450. * Recompiles the webGL program
  34451. * @param vertexSourceCode The source code for the vertex shader.
  34452. * @param fragmentSourceCode The source code for the fragment shader.
  34453. * @param onCompiled Callback called when completed.
  34454. * @param onError Callback called on error.
  34455. * @hidden
  34456. */
  34457. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34458. /**
  34459. * Prepares the effect
  34460. * @hidden
  34461. */
  34462. _prepareEffect(): void;
  34463. private _getShaderCodeAndErrorLine;
  34464. private _processCompilationErrors;
  34465. /**
  34466. * Checks if the effect is supported. (Must be called after compilation)
  34467. */
  34468. get isSupported(): boolean;
  34469. /**
  34470. * Binds a texture to the engine to be used as output of the shader.
  34471. * @param channel Name of the output variable.
  34472. * @param texture Texture to bind.
  34473. * @hidden
  34474. */
  34475. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34476. /**
  34477. * Sets a texture on the engine to be used in the shader.
  34478. * @param channel Name of the sampler variable.
  34479. * @param texture Texture to set.
  34480. */
  34481. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34482. /**
  34483. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34484. * @param channel Name of the sampler variable.
  34485. * @param texture Texture to set.
  34486. */
  34487. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34488. /**
  34489. * Sets an array of textures on the engine to be used in the shader.
  34490. * @param channel Name of the variable.
  34491. * @param textures Textures to set.
  34492. */
  34493. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34494. /**
  34495. * 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)
  34496. * @param channel Name of the sampler variable.
  34497. * @param postProcess Post process to get the input texture from.
  34498. */
  34499. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34500. /**
  34501. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34502. * 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)
  34503. * @param channel Name of the sampler variable.
  34504. * @param postProcess Post process to get the output texture from.
  34505. */
  34506. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34507. /** @hidden */
  34508. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34509. /** @hidden */
  34510. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34511. /** @hidden */
  34512. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34513. /** @hidden */
  34514. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34515. /**
  34516. * Binds a buffer to a uniform.
  34517. * @param buffer Buffer to bind.
  34518. * @param name Name of the uniform variable to bind to.
  34519. */
  34520. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34521. /**
  34522. * Binds block to a uniform.
  34523. * @param blockName Name of the block to bind.
  34524. * @param index Index to bind.
  34525. */
  34526. bindUniformBlock(blockName: string, index: number): void;
  34527. /**
  34528. * Sets an interger value on a uniform variable.
  34529. * @param uniformName Name of the variable.
  34530. * @param value Value to be set.
  34531. * @returns this effect.
  34532. */
  34533. setInt(uniformName: string, value: number): Effect;
  34534. /**
  34535. * Sets an int array on a uniform variable.
  34536. * @param uniformName Name of the variable.
  34537. * @param array array to be set.
  34538. * @returns this effect.
  34539. */
  34540. setIntArray(uniformName: string, array: Int32Array): Effect;
  34541. /**
  34542. * 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)
  34543. * @param uniformName Name of the variable.
  34544. * @param array array to be set.
  34545. * @returns this effect.
  34546. */
  34547. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34548. /**
  34549. * 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)
  34550. * @param uniformName Name of the variable.
  34551. * @param array array to be set.
  34552. * @returns this effect.
  34553. */
  34554. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34555. /**
  34556. * 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)
  34557. * @param uniformName Name of the variable.
  34558. * @param array array to be set.
  34559. * @returns this effect.
  34560. */
  34561. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34562. /**
  34563. * Sets an float array on a uniform variable.
  34564. * @param uniformName Name of the variable.
  34565. * @param array array to be set.
  34566. * @returns this effect.
  34567. */
  34568. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34569. /**
  34570. * 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)
  34571. * @param uniformName Name of the variable.
  34572. * @param array array to be set.
  34573. * @returns this effect.
  34574. */
  34575. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34576. /**
  34577. * 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)
  34578. * @param uniformName Name of the variable.
  34579. * @param array array to be set.
  34580. * @returns this effect.
  34581. */
  34582. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34583. /**
  34584. * 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)
  34585. * @param uniformName Name of the variable.
  34586. * @param array array to be set.
  34587. * @returns this effect.
  34588. */
  34589. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34590. /**
  34591. * Sets an array on a uniform variable.
  34592. * @param uniformName Name of the variable.
  34593. * @param array array to be set.
  34594. * @returns this effect.
  34595. */
  34596. setArray(uniformName: string, array: number[]): Effect;
  34597. /**
  34598. * 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)
  34599. * @param uniformName Name of the variable.
  34600. * @param array array to be set.
  34601. * @returns this effect.
  34602. */
  34603. setArray2(uniformName: string, array: number[]): Effect;
  34604. /**
  34605. * 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)
  34606. * @param uniformName Name of the variable.
  34607. * @param array array to be set.
  34608. * @returns this effect.
  34609. */
  34610. setArray3(uniformName: string, array: number[]): Effect;
  34611. /**
  34612. * 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)
  34613. * @param uniformName Name of the variable.
  34614. * @param array array to be set.
  34615. * @returns this effect.
  34616. */
  34617. setArray4(uniformName: string, array: number[]): Effect;
  34618. /**
  34619. * Sets matrices on a uniform variable.
  34620. * @param uniformName Name of the variable.
  34621. * @param matrices matrices to be set.
  34622. * @returns this effect.
  34623. */
  34624. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34625. /**
  34626. * Sets matrix on a uniform variable.
  34627. * @param uniformName Name of the variable.
  34628. * @param matrix matrix to be set.
  34629. * @returns this effect.
  34630. */
  34631. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34632. /**
  34633. * 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)
  34634. * @param uniformName Name of the variable.
  34635. * @param matrix matrix to be set.
  34636. * @returns this effect.
  34637. */
  34638. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34639. /**
  34640. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34641. * @param uniformName Name of the variable.
  34642. * @param matrix matrix to be set.
  34643. * @returns this effect.
  34644. */
  34645. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34646. /**
  34647. * Sets a float on a uniform variable.
  34648. * @param uniformName Name of the variable.
  34649. * @param value value to be set.
  34650. * @returns this effect.
  34651. */
  34652. setFloat(uniformName: string, value: number): Effect;
  34653. /**
  34654. * Sets a boolean on a uniform variable.
  34655. * @param uniformName Name of the variable.
  34656. * @param bool value to be set.
  34657. * @returns this effect.
  34658. */
  34659. setBool(uniformName: string, bool: boolean): Effect;
  34660. /**
  34661. * Sets a Vector2 on a uniform variable.
  34662. * @param uniformName Name of the variable.
  34663. * @param vector2 vector2 to be set.
  34664. * @returns this effect.
  34665. */
  34666. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34667. /**
  34668. * Sets a float2 on a uniform variable.
  34669. * @param uniformName Name of the variable.
  34670. * @param x First float in float2.
  34671. * @param y Second float in float2.
  34672. * @returns this effect.
  34673. */
  34674. setFloat2(uniformName: string, x: number, y: number): Effect;
  34675. /**
  34676. * Sets a Vector3 on a uniform variable.
  34677. * @param uniformName Name of the variable.
  34678. * @param vector3 Value to be set.
  34679. * @returns this effect.
  34680. */
  34681. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34682. /**
  34683. * Sets a float3 on a uniform variable.
  34684. * @param uniformName Name of the variable.
  34685. * @param x First float in float3.
  34686. * @param y Second float in float3.
  34687. * @param z Third float in float3.
  34688. * @returns this effect.
  34689. */
  34690. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34691. /**
  34692. * Sets a Vector4 on a uniform variable.
  34693. * @param uniformName Name of the variable.
  34694. * @param vector4 Value to be set.
  34695. * @returns this effect.
  34696. */
  34697. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34698. /**
  34699. * Sets a float4 on a uniform variable.
  34700. * @param uniformName Name of the variable.
  34701. * @param x First float in float4.
  34702. * @param y Second float in float4.
  34703. * @param z Third float in float4.
  34704. * @param w Fourth float in float4.
  34705. * @returns this effect.
  34706. */
  34707. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34708. /**
  34709. * Sets a Color3 on a uniform variable.
  34710. * @param uniformName Name of the variable.
  34711. * @param color3 Value to be set.
  34712. * @returns this effect.
  34713. */
  34714. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34715. /**
  34716. * Sets a Color4 on a uniform variable.
  34717. * @param uniformName Name of the variable.
  34718. * @param color3 Value to be set.
  34719. * @param alpha Alpha value to be set.
  34720. * @returns this effect.
  34721. */
  34722. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34723. /**
  34724. * Sets a Color4 on a uniform variable
  34725. * @param uniformName defines the name of the variable
  34726. * @param color4 defines the value to be set
  34727. * @returns this effect.
  34728. */
  34729. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34730. /** Release all associated resources */
  34731. dispose(): void;
  34732. /**
  34733. * This function will add a new shader to the shader store
  34734. * @param name the name of the shader
  34735. * @param pixelShader optional pixel shader content
  34736. * @param vertexShader optional vertex shader content
  34737. */
  34738. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34739. /**
  34740. * Store of each shader (The can be looked up using effect.key)
  34741. */
  34742. static ShadersStore: {
  34743. [key: string]: string;
  34744. };
  34745. /**
  34746. * Store of each included file for a shader (The can be looked up using effect.key)
  34747. */
  34748. static IncludesShadersStore: {
  34749. [key: string]: string;
  34750. };
  34751. /**
  34752. * Resets the cache of effects.
  34753. */
  34754. static ResetCache(): void;
  34755. }
  34756. }
  34757. declare module BABYLON {
  34758. /**
  34759. * Interface used to describe the capabilities of the engine relatively to the current browser
  34760. */
  34761. export interface EngineCapabilities {
  34762. /** Maximum textures units per fragment shader */
  34763. maxTexturesImageUnits: number;
  34764. /** Maximum texture units per vertex shader */
  34765. maxVertexTextureImageUnits: number;
  34766. /** Maximum textures units in the entire pipeline */
  34767. maxCombinedTexturesImageUnits: number;
  34768. /** Maximum texture size */
  34769. maxTextureSize: number;
  34770. /** Maximum texture samples */
  34771. maxSamples?: number;
  34772. /** Maximum cube texture size */
  34773. maxCubemapTextureSize: number;
  34774. /** Maximum render texture size */
  34775. maxRenderTextureSize: number;
  34776. /** Maximum number of vertex attributes */
  34777. maxVertexAttribs: number;
  34778. /** Maximum number of varyings */
  34779. maxVaryingVectors: number;
  34780. /** Maximum number of uniforms per vertex shader */
  34781. maxVertexUniformVectors: number;
  34782. /** Maximum number of uniforms per fragment shader */
  34783. maxFragmentUniformVectors: number;
  34784. /** Defines if standard derivates (dx/dy) are supported */
  34785. standardDerivatives: boolean;
  34786. /** Defines if s3tc texture compression is supported */
  34787. s3tc?: WEBGL_compressed_texture_s3tc;
  34788. /** Defines if pvrtc texture compression is supported */
  34789. pvrtc: any;
  34790. /** Defines if etc1 texture compression is supported */
  34791. etc1: any;
  34792. /** Defines if etc2 texture compression is supported */
  34793. etc2: any;
  34794. /** Defines if astc texture compression is supported */
  34795. astc: any;
  34796. /** Defines if float textures are supported */
  34797. textureFloat: boolean;
  34798. /** Defines if vertex array objects are supported */
  34799. vertexArrayObject: boolean;
  34800. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34801. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34802. /** Gets the maximum level of anisotropy supported */
  34803. maxAnisotropy: number;
  34804. /** Defines if instancing is supported */
  34805. instancedArrays: boolean;
  34806. /** Defines if 32 bits indices are supported */
  34807. uintIndices: boolean;
  34808. /** Defines if high precision shaders are supported */
  34809. highPrecisionShaderSupported: boolean;
  34810. /** Defines if depth reading in the fragment shader is supported */
  34811. fragmentDepthSupported: boolean;
  34812. /** Defines if float texture linear filtering is supported*/
  34813. textureFloatLinearFiltering: boolean;
  34814. /** Defines if rendering to float textures is supported */
  34815. textureFloatRender: boolean;
  34816. /** Defines if half float textures are supported*/
  34817. textureHalfFloat: boolean;
  34818. /** Defines if half float texture linear filtering is supported*/
  34819. textureHalfFloatLinearFiltering: boolean;
  34820. /** Defines if rendering to half float textures is supported */
  34821. textureHalfFloatRender: boolean;
  34822. /** Defines if textureLOD shader command is supported */
  34823. textureLOD: boolean;
  34824. /** Defines if draw buffers extension is supported */
  34825. drawBuffersExtension: boolean;
  34826. /** Defines if depth textures are supported */
  34827. depthTextureExtension: boolean;
  34828. /** Defines if float color buffer are supported */
  34829. colorBufferFloat: boolean;
  34830. /** Gets disjoint timer query extension (null if not supported) */
  34831. timerQuery?: EXT_disjoint_timer_query;
  34832. /** Defines if timestamp can be used with timer query */
  34833. canUseTimestampForTimerQuery: boolean;
  34834. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34835. multiview?: any;
  34836. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34837. oculusMultiview?: any;
  34838. /** Function used to let the system compiles shaders in background */
  34839. parallelShaderCompile?: {
  34840. COMPLETION_STATUS_KHR: number;
  34841. };
  34842. /** Max number of texture samples for MSAA */
  34843. maxMSAASamples: number;
  34844. /** Defines if the blend min max extension is supported */
  34845. blendMinMax: boolean;
  34846. }
  34847. }
  34848. declare module BABYLON {
  34849. /**
  34850. * @hidden
  34851. **/
  34852. export class DepthCullingState {
  34853. private _isDepthTestDirty;
  34854. private _isDepthMaskDirty;
  34855. private _isDepthFuncDirty;
  34856. private _isCullFaceDirty;
  34857. private _isCullDirty;
  34858. private _isZOffsetDirty;
  34859. private _isFrontFaceDirty;
  34860. private _depthTest;
  34861. private _depthMask;
  34862. private _depthFunc;
  34863. private _cull;
  34864. private _cullFace;
  34865. private _zOffset;
  34866. private _frontFace;
  34867. /**
  34868. * Initializes the state.
  34869. */
  34870. constructor();
  34871. get isDirty(): boolean;
  34872. get zOffset(): number;
  34873. set zOffset(value: number);
  34874. get cullFace(): Nullable<number>;
  34875. set cullFace(value: Nullable<number>);
  34876. get cull(): Nullable<boolean>;
  34877. set cull(value: Nullable<boolean>);
  34878. get depthFunc(): Nullable<number>;
  34879. set depthFunc(value: Nullable<number>);
  34880. get depthMask(): boolean;
  34881. set depthMask(value: boolean);
  34882. get depthTest(): boolean;
  34883. set depthTest(value: boolean);
  34884. get frontFace(): Nullable<number>;
  34885. set frontFace(value: Nullable<number>);
  34886. reset(): void;
  34887. apply(gl: WebGLRenderingContext): void;
  34888. }
  34889. }
  34890. declare module BABYLON {
  34891. /**
  34892. * @hidden
  34893. **/
  34894. export class StencilState {
  34895. /** 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 */
  34896. static readonly ALWAYS: number;
  34897. /** Passed to stencilOperation to specify that stencil value must be kept */
  34898. static readonly KEEP: number;
  34899. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34900. static readonly REPLACE: number;
  34901. private _isStencilTestDirty;
  34902. private _isStencilMaskDirty;
  34903. private _isStencilFuncDirty;
  34904. private _isStencilOpDirty;
  34905. private _stencilTest;
  34906. private _stencilMask;
  34907. private _stencilFunc;
  34908. private _stencilFuncRef;
  34909. private _stencilFuncMask;
  34910. private _stencilOpStencilFail;
  34911. private _stencilOpDepthFail;
  34912. private _stencilOpStencilDepthPass;
  34913. get isDirty(): boolean;
  34914. get stencilFunc(): number;
  34915. set stencilFunc(value: number);
  34916. get stencilFuncRef(): number;
  34917. set stencilFuncRef(value: number);
  34918. get stencilFuncMask(): number;
  34919. set stencilFuncMask(value: number);
  34920. get stencilOpStencilFail(): number;
  34921. set stencilOpStencilFail(value: number);
  34922. get stencilOpDepthFail(): number;
  34923. set stencilOpDepthFail(value: number);
  34924. get stencilOpStencilDepthPass(): number;
  34925. set stencilOpStencilDepthPass(value: number);
  34926. get stencilMask(): number;
  34927. set stencilMask(value: number);
  34928. get stencilTest(): boolean;
  34929. set stencilTest(value: boolean);
  34930. constructor();
  34931. reset(): void;
  34932. apply(gl: WebGLRenderingContext): void;
  34933. }
  34934. }
  34935. declare module BABYLON {
  34936. /**
  34937. * @hidden
  34938. **/
  34939. export class AlphaState {
  34940. private _isAlphaBlendDirty;
  34941. private _isBlendFunctionParametersDirty;
  34942. private _isBlendEquationParametersDirty;
  34943. private _isBlendConstantsDirty;
  34944. private _alphaBlend;
  34945. private _blendFunctionParameters;
  34946. private _blendEquationParameters;
  34947. private _blendConstants;
  34948. /**
  34949. * Initializes the state.
  34950. */
  34951. constructor();
  34952. get isDirty(): boolean;
  34953. get alphaBlend(): boolean;
  34954. set alphaBlend(value: boolean);
  34955. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34956. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34957. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34958. reset(): void;
  34959. apply(gl: WebGLRenderingContext): void;
  34960. }
  34961. }
  34962. declare module BABYLON {
  34963. /** @hidden */
  34964. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34965. attributeProcessor(attribute: string): string;
  34966. varyingProcessor(varying: string, isFragment: boolean): string;
  34967. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34968. }
  34969. }
  34970. declare module BABYLON {
  34971. /**
  34972. * Interface for attribute information associated with buffer instanciation
  34973. */
  34974. export interface InstancingAttributeInfo {
  34975. /**
  34976. * Name of the GLSL attribute
  34977. * if attribute index is not specified, this is used to retrieve the index from the effect
  34978. */
  34979. attributeName: string;
  34980. /**
  34981. * Index/offset of the attribute in the vertex shader
  34982. * if not specified, this will be computes from the name.
  34983. */
  34984. index?: number;
  34985. /**
  34986. * size of the attribute, 1, 2, 3 or 4
  34987. */
  34988. attributeSize: number;
  34989. /**
  34990. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34991. */
  34992. offset: number;
  34993. /**
  34994. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34995. * default to 1
  34996. */
  34997. divisor?: number;
  34998. /**
  34999. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35000. * default is FLOAT
  35001. */
  35002. attributeType?: number;
  35003. /**
  35004. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35005. */
  35006. normalized?: boolean;
  35007. }
  35008. }
  35009. declare module BABYLON {
  35010. interface ThinEngine {
  35011. /**
  35012. * Update a video texture
  35013. * @param texture defines the texture to update
  35014. * @param video defines the video element to use
  35015. * @param invertY defines if data must be stored with Y axis inverted
  35016. */
  35017. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35018. }
  35019. }
  35020. declare module BABYLON {
  35021. interface ThinEngine {
  35022. /**
  35023. * Creates a dynamic texture
  35024. * @param width defines the width of the texture
  35025. * @param height defines the height of the texture
  35026. * @param generateMipMaps defines if the engine should generate the mip levels
  35027. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35028. * @returns the dynamic texture inside an InternalTexture
  35029. */
  35030. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35031. /**
  35032. * Update the content of a dynamic texture
  35033. * @param texture defines the texture to update
  35034. * @param canvas defines the canvas containing the source
  35035. * @param invertY defines if data must be stored with Y axis inverted
  35036. * @param premulAlpha defines if alpha is stored as premultiplied
  35037. * @param format defines the format of the data
  35038. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35039. */
  35040. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35041. }
  35042. }
  35043. declare module BABYLON {
  35044. /**
  35045. * Settings for finer control over video usage
  35046. */
  35047. export interface VideoTextureSettings {
  35048. /**
  35049. * Applies `autoplay` to video, if specified
  35050. */
  35051. autoPlay?: boolean;
  35052. /**
  35053. * Applies `loop` to video, if specified
  35054. */
  35055. loop?: boolean;
  35056. /**
  35057. * Automatically updates internal texture from video at every frame in the render loop
  35058. */
  35059. autoUpdateTexture: boolean;
  35060. /**
  35061. * Image src displayed during the video loading or until the user interacts with the video.
  35062. */
  35063. poster?: string;
  35064. }
  35065. /**
  35066. * If you want to display a video in your scene, this is the special texture for that.
  35067. * This special texture works similar to other textures, with the exception of a few parameters.
  35068. * @see https://doc.babylonjs.com/how_to/video_texture
  35069. */
  35070. export class VideoTexture extends Texture {
  35071. /**
  35072. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35073. */
  35074. readonly autoUpdateTexture: boolean;
  35075. /**
  35076. * The video instance used by the texture internally
  35077. */
  35078. readonly video: HTMLVideoElement;
  35079. private _onUserActionRequestedObservable;
  35080. /**
  35081. * Event triggerd when a dom action is required by the user to play the video.
  35082. * This happens due to recent changes in browser policies preventing video to auto start.
  35083. */
  35084. get onUserActionRequestedObservable(): Observable<Texture>;
  35085. private _generateMipMaps;
  35086. private _stillImageCaptured;
  35087. private _displayingPosterTexture;
  35088. private _settings;
  35089. private _createInternalTextureOnEvent;
  35090. private _frameId;
  35091. private _currentSrc;
  35092. /**
  35093. * Creates a video texture.
  35094. * If you want to display a video in your scene, this is the special texture for that.
  35095. * This special texture works similar to other textures, with the exception of a few parameters.
  35096. * @see https://doc.babylonjs.com/how_to/video_texture
  35097. * @param name optional name, will detect from video source, if not defined
  35098. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35099. * @param scene is obviously the current scene.
  35100. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35101. * @param invertY is false by default but can be used to invert video on Y axis
  35102. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35103. * @param settings allows finer control over video usage
  35104. */
  35105. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35106. private _getName;
  35107. private _getVideo;
  35108. private _createInternalTexture;
  35109. private reset;
  35110. /**
  35111. * @hidden Internal method to initiate `update`.
  35112. */
  35113. _rebuild(): void;
  35114. /**
  35115. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35116. */
  35117. update(): void;
  35118. /**
  35119. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35120. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35121. */
  35122. updateTexture(isVisible: boolean): void;
  35123. protected _updateInternalTexture: () => void;
  35124. /**
  35125. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35126. * @param url New url.
  35127. */
  35128. updateURL(url: string): void;
  35129. /**
  35130. * Clones the texture.
  35131. * @returns the cloned texture
  35132. */
  35133. clone(): VideoTexture;
  35134. /**
  35135. * Dispose the texture and release its associated resources.
  35136. */
  35137. dispose(): void;
  35138. /**
  35139. * Creates a video texture straight from a stream.
  35140. * @param scene Define the scene the texture should be created in
  35141. * @param stream Define the stream the texture should be created from
  35142. * @returns The created video texture as a promise
  35143. */
  35144. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35145. /**
  35146. * Creates a video texture straight from your WebCam video feed.
  35147. * @param scene Define the scene the texture should be created in
  35148. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35149. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35150. * @returns The created video texture as a promise
  35151. */
  35152. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35153. minWidth: number;
  35154. maxWidth: number;
  35155. minHeight: number;
  35156. maxHeight: number;
  35157. deviceId: string;
  35158. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35159. /**
  35160. * Creates a video texture straight from your WebCam video feed.
  35161. * @param scene Define the scene the texture should be created in
  35162. * @param onReady Define a callback to triggered once the texture will be ready
  35163. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35164. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35165. */
  35166. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35167. minWidth: number;
  35168. maxWidth: number;
  35169. minHeight: number;
  35170. maxHeight: number;
  35171. deviceId: string;
  35172. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35173. }
  35174. }
  35175. declare module BABYLON {
  35176. /**
  35177. * Defines the interface used by objects working like Scene
  35178. * @hidden
  35179. */
  35180. export interface ISceneLike {
  35181. _addPendingData(data: any): void;
  35182. _removePendingData(data: any): void;
  35183. offlineProvider: IOfflineProvider;
  35184. }
  35185. /**
  35186. * Information about the current host
  35187. */
  35188. export interface HostInformation {
  35189. /**
  35190. * Defines if the current host is a mobile
  35191. */
  35192. isMobile: boolean;
  35193. }
  35194. /** Interface defining initialization parameters for Engine class */
  35195. export interface EngineOptions extends WebGLContextAttributes {
  35196. /**
  35197. * Defines if the engine should no exceed a specified device ratio
  35198. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35199. */
  35200. limitDeviceRatio?: number;
  35201. /**
  35202. * Defines if webvr should be enabled automatically
  35203. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35204. */
  35205. autoEnableWebVR?: boolean;
  35206. /**
  35207. * Defines if webgl2 should be turned off even if supported
  35208. * @see https://doc.babylonjs.com/features/webgl2
  35209. */
  35210. disableWebGL2Support?: boolean;
  35211. /**
  35212. * Defines if webaudio should be initialized as well
  35213. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35214. */
  35215. audioEngine?: boolean;
  35216. /**
  35217. * Defines if animations should run using a deterministic lock step
  35218. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35219. */
  35220. deterministicLockstep?: boolean;
  35221. /** Defines the maximum steps to use with deterministic lock step mode */
  35222. lockstepMaxSteps?: number;
  35223. /** Defines the seconds between each deterministic lock step */
  35224. timeStep?: number;
  35225. /**
  35226. * Defines that engine should ignore context lost events
  35227. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35228. */
  35229. doNotHandleContextLost?: boolean;
  35230. /**
  35231. * Defines that engine should ignore modifying touch action attribute and style
  35232. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35233. */
  35234. doNotHandleTouchAction?: boolean;
  35235. /**
  35236. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35237. */
  35238. useHighPrecisionFloats?: boolean;
  35239. /**
  35240. * Make the canvas XR Compatible for XR sessions
  35241. */
  35242. xrCompatible?: boolean;
  35243. /**
  35244. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35245. */
  35246. useHighPrecisionMatrix?: boolean;
  35247. }
  35248. /**
  35249. * The base engine class (root of all engines)
  35250. */
  35251. export class ThinEngine {
  35252. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35253. static ExceptionList: ({
  35254. key: string;
  35255. capture: string;
  35256. captureConstraint: number;
  35257. targets: string[];
  35258. } | {
  35259. key: string;
  35260. capture: null;
  35261. captureConstraint: null;
  35262. targets: string[];
  35263. })[];
  35264. /** @hidden */
  35265. static _TextureLoaders: IInternalTextureLoader[];
  35266. /**
  35267. * Returns the current npm package of the sdk
  35268. */
  35269. static get NpmPackage(): string;
  35270. /**
  35271. * Returns the current version of the framework
  35272. */
  35273. static get Version(): string;
  35274. /**
  35275. * Returns a string describing the current engine
  35276. */
  35277. get description(): string;
  35278. /**
  35279. * Gets or sets the epsilon value used by collision engine
  35280. */
  35281. static CollisionsEpsilon: number;
  35282. /**
  35283. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35284. */
  35285. static get ShadersRepository(): string;
  35286. static set ShadersRepository(value: string);
  35287. /** @hidden */
  35288. _shaderProcessor: IShaderProcessor;
  35289. /**
  35290. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35291. */
  35292. forcePOTTextures: boolean;
  35293. /**
  35294. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35295. */
  35296. isFullscreen: boolean;
  35297. /**
  35298. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35299. */
  35300. cullBackFaces: boolean;
  35301. /**
  35302. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35303. */
  35304. renderEvenInBackground: boolean;
  35305. /**
  35306. * Gets or sets a boolean indicating that cache can be kept between frames
  35307. */
  35308. preventCacheWipeBetweenFrames: boolean;
  35309. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35310. validateShaderPrograms: boolean;
  35311. /**
  35312. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35313. * This can provide greater z depth for distant objects.
  35314. */
  35315. useReverseDepthBuffer: boolean;
  35316. /**
  35317. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35318. */
  35319. disableUniformBuffers: boolean;
  35320. /** @hidden */
  35321. _uniformBuffers: UniformBuffer[];
  35322. /**
  35323. * Gets a boolean indicating that the engine supports uniform buffers
  35324. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35325. */
  35326. get supportsUniformBuffers(): boolean;
  35327. /** @hidden */
  35328. _gl: WebGLRenderingContext;
  35329. /** @hidden */
  35330. _webGLVersion: number;
  35331. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35332. protected _windowIsBackground: boolean;
  35333. protected _creationOptions: EngineOptions;
  35334. protected _highPrecisionShadersAllowed: boolean;
  35335. /** @hidden */
  35336. get _shouldUseHighPrecisionShader(): boolean;
  35337. /**
  35338. * Gets a boolean indicating that only power of 2 textures are supported
  35339. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35340. */
  35341. get needPOTTextures(): boolean;
  35342. /** @hidden */
  35343. _badOS: boolean;
  35344. /** @hidden */
  35345. _badDesktopOS: boolean;
  35346. private _hardwareScalingLevel;
  35347. /** @hidden */
  35348. _caps: EngineCapabilities;
  35349. private _isStencilEnable;
  35350. private _glVersion;
  35351. private _glRenderer;
  35352. private _glVendor;
  35353. /** @hidden */
  35354. _videoTextureSupported: boolean;
  35355. protected _renderingQueueLaunched: boolean;
  35356. protected _activeRenderLoops: (() => void)[];
  35357. /**
  35358. * Observable signaled when a context lost event is raised
  35359. */
  35360. onContextLostObservable: Observable<ThinEngine>;
  35361. /**
  35362. * Observable signaled when a context restored event is raised
  35363. */
  35364. onContextRestoredObservable: Observable<ThinEngine>;
  35365. private _onContextLost;
  35366. private _onContextRestored;
  35367. protected _contextWasLost: boolean;
  35368. /** @hidden */
  35369. _doNotHandleContextLost: boolean;
  35370. /**
  35371. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35372. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35373. */
  35374. get doNotHandleContextLost(): boolean;
  35375. set doNotHandleContextLost(value: boolean);
  35376. /**
  35377. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35378. */
  35379. disableVertexArrayObjects: boolean;
  35380. /** @hidden */
  35381. protected _colorWrite: boolean;
  35382. /** @hidden */
  35383. protected _colorWriteChanged: boolean;
  35384. /** @hidden */
  35385. protected _depthCullingState: DepthCullingState;
  35386. /** @hidden */
  35387. protected _stencilState: StencilState;
  35388. /** @hidden */
  35389. _alphaState: AlphaState;
  35390. /** @hidden */
  35391. _alphaMode: number;
  35392. /** @hidden */
  35393. _alphaEquation: number;
  35394. /** @hidden */
  35395. _internalTexturesCache: InternalTexture[];
  35396. /** @hidden */
  35397. protected _activeChannel: number;
  35398. private _currentTextureChannel;
  35399. /** @hidden */
  35400. protected _boundTexturesCache: {
  35401. [key: string]: Nullable<InternalTexture>;
  35402. };
  35403. /** @hidden */
  35404. protected _currentEffect: Nullable<Effect>;
  35405. /** @hidden */
  35406. protected _currentProgram: Nullable<WebGLProgram>;
  35407. private _compiledEffects;
  35408. private _vertexAttribArraysEnabled;
  35409. /** @hidden */
  35410. protected _cachedViewport: Nullable<IViewportLike>;
  35411. private _cachedVertexArrayObject;
  35412. /** @hidden */
  35413. protected _cachedVertexBuffers: any;
  35414. /** @hidden */
  35415. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35416. /** @hidden */
  35417. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35418. /** @hidden */
  35419. _currentRenderTarget: Nullable<InternalTexture>;
  35420. private _uintIndicesCurrentlySet;
  35421. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35422. /** @hidden */
  35423. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35424. /** @hidden */
  35425. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35426. private _currentBufferPointers;
  35427. private _currentInstanceLocations;
  35428. private _currentInstanceBuffers;
  35429. private _textureUnits;
  35430. /** @hidden */
  35431. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35432. /** @hidden */
  35433. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35434. /** @hidden */
  35435. _boundRenderFunction: any;
  35436. private _vaoRecordInProgress;
  35437. private _mustWipeVertexAttributes;
  35438. private _emptyTexture;
  35439. private _emptyCubeTexture;
  35440. private _emptyTexture3D;
  35441. private _emptyTexture2DArray;
  35442. /** @hidden */
  35443. _frameHandler: number;
  35444. private _nextFreeTextureSlots;
  35445. private _maxSimultaneousTextures;
  35446. private _activeRequests;
  35447. /** @hidden */
  35448. _transformTextureUrl: Nullable<(url: string) => string>;
  35449. /**
  35450. * Gets information about the current host
  35451. */
  35452. hostInformation: HostInformation;
  35453. protected get _supportsHardwareTextureRescaling(): boolean;
  35454. private _framebufferDimensionsObject;
  35455. /**
  35456. * sets the object from which width and height will be taken from when getting render width and height
  35457. * Will fallback to the gl object
  35458. * @param dimensions the framebuffer width and height that will be used.
  35459. */
  35460. set framebufferDimensionsObject(dimensions: Nullable<{
  35461. framebufferWidth: number;
  35462. framebufferHeight: number;
  35463. }>);
  35464. /**
  35465. * Gets the current viewport
  35466. */
  35467. get currentViewport(): Nullable<IViewportLike>;
  35468. /**
  35469. * Gets the default empty texture
  35470. */
  35471. get emptyTexture(): InternalTexture;
  35472. /**
  35473. * Gets the default empty 3D texture
  35474. */
  35475. get emptyTexture3D(): InternalTexture;
  35476. /**
  35477. * Gets the default empty 2D array texture
  35478. */
  35479. get emptyTexture2DArray(): InternalTexture;
  35480. /**
  35481. * Gets the default empty cube texture
  35482. */
  35483. get emptyCubeTexture(): InternalTexture;
  35484. /**
  35485. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35486. */
  35487. readonly premultipliedAlpha: boolean;
  35488. /**
  35489. * Observable event triggered before each texture is initialized
  35490. */
  35491. onBeforeTextureInitObservable: Observable<Texture>;
  35492. /**
  35493. * Creates a new engine
  35494. * @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
  35495. * @param antialias defines enable antialiasing (default: false)
  35496. * @param options defines further options to be sent to the getContext() function
  35497. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35498. */
  35499. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35500. private _rebuildInternalTextures;
  35501. private _rebuildEffects;
  35502. /**
  35503. * Gets a boolean indicating if all created effects are ready
  35504. * @returns true if all effects are ready
  35505. */
  35506. areAllEffectsReady(): boolean;
  35507. protected _rebuildBuffers(): void;
  35508. protected _initGLContext(): void;
  35509. /**
  35510. * Gets version of the current webGL context
  35511. */
  35512. get webGLVersion(): number;
  35513. /**
  35514. * Gets a string identifying the name of the class
  35515. * @returns "Engine" string
  35516. */
  35517. getClassName(): string;
  35518. /**
  35519. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35520. */
  35521. get isStencilEnable(): boolean;
  35522. /** @hidden */
  35523. _prepareWorkingCanvas(): void;
  35524. /**
  35525. * Reset the texture cache to empty state
  35526. */
  35527. resetTextureCache(): void;
  35528. /**
  35529. * Gets an object containing information about the current webGL context
  35530. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35531. */
  35532. getGlInfo(): {
  35533. vendor: string;
  35534. renderer: string;
  35535. version: string;
  35536. };
  35537. /**
  35538. * Defines the hardware scaling level.
  35539. * By default the hardware scaling level is computed from the window device ratio.
  35540. * 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.
  35541. * @param level defines the level to use
  35542. */
  35543. setHardwareScalingLevel(level: number): void;
  35544. /**
  35545. * Gets the current hardware scaling level.
  35546. * By default the hardware scaling level is computed from the window device ratio.
  35547. * 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.
  35548. * @returns a number indicating the current hardware scaling level
  35549. */
  35550. getHardwareScalingLevel(): number;
  35551. /**
  35552. * Gets the list of loaded textures
  35553. * @returns an array containing all loaded textures
  35554. */
  35555. getLoadedTexturesCache(): InternalTexture[];
  35556. /**
  35557. * Gets the object containing all engine capabilities
  35558. * @returns the EngineCapabilities object
  35559. */
  35560. getCaps(): EngineCapabilities;
  35561. /**
  35562. * stop executing a render loop function and remove it from the execution array
  35563. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35564. */
  35565. stopRenderLoop(renderFunction?: () => void): void;
  35566. /** @hidden */
  35567. _renderLoop(): void;
  35568. /**
  35569. * Gets the HTML canvas attached with the current webGL context
  35570. * @returns a HTML canvas
  35571. */
  35572. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35573. /**
  35574. * Gets host window
  35575. * @returns the host window object
  35576. */
  35577. getHostWindow(): Nullable<Window>;
  35578. /**
  35579. * Gets the current render width
  35580. * @param useScreen defines if screen size must be used (or the current render target if any)
  35581. * @returns a number defining the current render width
  35582. */
  35583. getRenderWidth(useScreen?: boolean): number;
  35584. /**
  35585. * Gets the current render height
  35586. * @param useScreen defines if screen size must be used (or the current render target if any)
  35587. * @returns a number defining the current render height
  35588. */
  35589. getRenderHeight(useScreen?: boolean): number;
  35590. /**
  35591. * Can be used to override the current requestAnimationFrame requester.
  35592. * @hidden
  35593. */
  35594. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35595. /**
  35596. * Register and execute a render loop. The engine can have more than one render function
  35597. * @param renderFunction defines the function to continuously execute
  35598. */
  35599. runRenderLoop(renderFunction: () => void): void;
  35600. /**
  35601. * Clear the current render buffer or the current render target (if any is set up)
  35602. * @param color defines the color to use
  35603. * @param backBuffer defines if the back buffer must be cleared
  35604. * @param depth defines if the depth buffer must be cleared
  35605. * @param stencil defines if the stencil buffer must be cleared
  35606. */
  35607. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35608. private _viewportCached;
  35609. /** @hidden */
  35610. _viewport(x: number, y: number, width: number, height: number): void;
  35611. /**
  35612. * Set the WebGL's viewport
  35613. * @param viewport defines the viewport element to be used
  35614. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35615. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35616. */
  35617. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35618. /**
  35619. * Begin a new frame
  35620. */
  35621. beginFrame(): void;
  35622. /**
  35623. * Enf the current frame
  35624. */
  35625. endFrame(): void;
  35626. /**
  35627. * Resize the view according to the canvas' size
  35628. */
  35629. resize(): void;
  35630. /**
  35631. * Force a specific size of the canvas
  35632. * @param width defines the new canvas' width
  35633. * @param height defines the new canvas' height
  35634. * @returns true if the size was changed
  35635. */
  35636. setSize(width: number, height: number): boolean;
  35637. /**
  35638. * Binds the frame buffer to the specified texture.
  35639. * @param texture The texture to render to or null for the default canvas
  35640. * @param faceIndex The face of the texture to render to in case of cube texture
  35641. * @param requiredWidth The width of the target to render to
  35642. * @param requiredHeight The height of the target to render to
  35643. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35644. * @param lodLevel defines the lod level to bind to the frame buffer
  35645. * @param layer defines the 2d array index to bind to frame buffer to
  35646. */
  35647. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35648. /** @hidden */
  35649. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35650. /**
  35651. * Unbind the current render target texture from the webGL context
  35652. * @param texture defines the render target texture to unbind
  35653. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35654. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35655. */
  35656. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35657. /**
  35658. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35659. */
  35660. flushFramebuffer(): void;
  35661. /**
  35662. * Unbind the current render target and bind the default framebuffer
  35663. */
  35664. restoreDefaultFramebuffer(): void;
  35665. /** @hidden */
  35666. protected _resetVertexBufferBinding(): void;
  35667. /**
  35668. * Creates a vertex buffer
  35669. * @param data the data for the vertex buffer
  35670. * @returns the new WebGL static buffer
  35671. */
  35672. createVertexBuffer(data: DataArray): DataBuffer;
  35673. private _createVertexBuffer;
  35674. /**
  35675. * Creates a dynamic vertex buffer
  35676. * @param data the data for the dynamic vertex buffer
  35677. * @returns the new WebGL dynamic buffer
  35678. */
  35679. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35680. protected _resetIndexBufferBinding(): void;
  35681. /**
  35682. * Creates a new index buffer
  35683. * @param indices defines the content of the index buffer
  35684. * @param updatable defines if the index buffer must be updatable
  35685. * @returns a new webGL buffer
  35686. */
  35687. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35688. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35689. /**
  35690. * Bind a webGL buffer to the webGL context
  35691. * @param buffer defines the buffer to bind
  35692. */
  35693. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35694. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35695. private bindBuffer;
  35696. /**
  35697. * update the bound buffer with the given data
  35698. * @param data defines the data to update
  35699. */
  35700. updateArrayBuffer(data: Float32Array): void;
  35701. private _vertexAttribPointer;
  35702. /** @hidden */
  35703. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35704. private _bindVertexBuffersAttributes;
  35705. /**
  35706. * Records a vertex array object
  35707. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35708. * @param vertexBuffers defines the list of vertex buffers to store
  35709. * @param indexBuffer defines the index buffer to store
  35710. * @param effect defines the effect to store
  35711. * @returns the new vertex array object
  35712. */
  35713. recordVertexArrayObject(vertexBuffers: {
  35714. [key: string]: VertexBuffer;
  35715. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35716. /**
  35717. * Bind a specific vertex array object
  35718. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35719. * @param vertexArrayObject defines the vertex array object to bind
  35720. * @param indexBuffer defines the index buffer to bind
  35721. */
  35722. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35723. /**
  35724. * Bind webGl buffers directly to the webGL context
  35725. * @param vertexBuffer defines the vertex buffer to bind
  35726. * @param indexBuffer defines the index buffer to bind
  35727. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35728. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35729. * @param effect defines the effect associated with the vertex buffer
  35730. */
  35731. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35732. private _unbindVertexArrayObject;
  35733. /**
  35734. * Bind a list of vertex buffers to the webGL context
  35735. * @param vertexBuffers defines the list of vertex buffers to bind
  35736. * @param indexBuffer defines the index buffer to bind
  35737. * @param effect defines the effect associated with the vertex buffers
  35738. */
  35739. bindBuffers(vertexBuffers: {
  35740. [key: string]: Nullable<VertexBuffer>;
  35741. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35742. /**
  35743. * Unbind all instance attributes
  35744. */
  35745. unbindInstanceAttributes(): void;
  35746. /**
  35747. * Release and free the memory of a vertex array object
  35748. * @param vao defines the vertex array object to delete
  35749. */
  35750. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35751. /** @hidden */
  35752. _releaseBuffer(buffer: DataBuffer): boolean;
  35753. protected _deleteBuffer(buffer: DataBuffer): void;
  35754. /**
  35755. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35756. * @param instancesBuffer defines the webGL buffer to update and bind
  35757. * @param data defines the data to store in the buffer
  35758. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35759. */
  35760. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35761. /**
  35762. * Bind the content of a webGL buffer used with instantiation
  35763. * @param instancesBuffer defines the webGL buffer to bind
  35764. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35765. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35766. */
  35767. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35768. /**
  35769. * Disable the instance attribute corresponding to the name in parameter
  35770. * @param name defines the name of the attribute to disable
  35771. */
  35772. disableInstanceAttributeByName(name: string): void;
  35773. /**
  35774. * Disable the instance attribute corresponding to the location in parameter
  35775. * @param attributeLocation defines the attribute location of the attribute to disable
  35776. */
  35777. disableInstanceAttribute(attributeLocation: number): void;
  35778. /**
  35779. * Disable the attribute corresponding to the location in parameter
  35780. * @param attributeLocation defines the attribute location of the attribute to disable
  35781. */
  35782. disableAttributeByIndex(attributeLocation: number): void;
  35783. /**
  35784. * Send a draw order
  35785. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35786. * @param indexStart defines the starting index
  35787. * @param indexCount defines the number of index to draw
  35788. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35789. */
  35790. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35791. /**
  35792. * Draw a list of points
  35793. * @param verticesStart defines the index of first vertex to draw
  35794. * @param verticesCount defines the count of vertices to draw
  35795. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35796. */
  35797. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35798. /**
  35799. * Draw a list of unindexed primitives
  35800. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35801. * @param verticesStart defines the index of first vertex to draw
  35802. * @param verticesCount defines the count of vertices to draw
  35803. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35804. */
  35805. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35806. /**
  35807. * Draw a list of indexed primitives
  35808. * @param fillMode defines the primitive to use
  35809. * @param indexStart defines the starting index
  35810. * @param indexCount defines the number of index to draw
  35811. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35812. */
  35813. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35814. /**
  35815. * Draw a list of unindexed primitives
  35816. * @param fillMode defines the primitive to use
  35817. * @param verticesStart defines the index of first vertex to draw
  35818. * @param verticesCount defines the count of vertices to draw
  35819. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35820. */
  35821. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35822. private _drawMode;
  35823. /** @hidden */
  35824. protected _reportDrawCall(): void;
  35825. /** @hidden */
  35826. _releaseEffect(effect: Effect): void;
  35827. /** @hidden */
  35828. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35829. /**
  35830. * Create a new effect (used to store vertex/fragment shaders)
  35831. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35832. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35833. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35834. * @param samplers defines an array of string used to represent textures
  35835. * @param defines defines the string containing the defines to use to compile the shaders
  35836. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35837. * @param onCompiled defines a function to call when the effect creation is successful
  35838. * @param onError defines a function to call when the effect creation has failed
  35839. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35840. * @returns the new Effect
  35841. */
  35842. 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;
  35843. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35844. private _compileShader;
  35845. private _compileRawShader;
  35846. /** @hidden */
  35847. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35848. /**
  35849. * Directly creates a webGL program
  35850. * @param pipelineContext defines the pipeline context to attach to
  35851. * @param vertexCode defines the vertex shader code to use
  35852. * @param fragmentCode defines the fragment shader code to use
  35853. * @param context defines the webGL context to use (if not set, the current one will be used)
  35854. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35855. * @returns the new webGL program
  35856. */
  35857. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35858. /**
  35859. * Creates a webGL program
  35860. * @param pipelineContext defines the pipeline context to attach to
  35861. * @param vertexCode defines the vertex shader code to use
  35862. * @param fragmentCode defines the fragment shader code to use
  35863. * @param defines defines the string containing the defines to use to compile the shaders
  35864. * @param context defines the webGL context to use (if not set, the current one will be used)
  35865. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35866. * @returns the new webGL program
  35867. */
  35868. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35869. /**
  35870. * Creates a new pipeline context
  35871. * @returns the new pipeline
  35872. */
  35873. createPipelineContext(): IPipelineContext;
  35874. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35875. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35876. /** @hidden */
  35877. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35878. /** @hidden */
  35879. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35880. /** @hidden */
  35881. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35882. /**
  35883. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35884. * @param pipelineContext defines the pipeline context to use
  35885. * @param uniformsNames defines the list of uniform names
  35886. * @returns an array of webGL uniform locations
  35887. */
  35888. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35889. /**
  35890. * Gets the lsit of active attributes for a given webGL program
  35891. * @param pipelineContext defines the pipeline context to use
  35892. * @param attributesNames defines the list of attribute names to get
  35893. * @returns an array of indices indicating the offset of each attribute
  35894. */
  35895. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35896. /**
  35897. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35898. * @param effect defines the effect to activate
  35899. */
  35900. enableEffect(effect: Nullable<Effect>): void;
  35901. /**
  35902. * Set the value of an uniform to a number (int)
  35903. * @param uniform defines the webGL uniform location where to store the value
  35904. * @param value defines the int number to store
  35905. */
  35906. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35907. /**
  35908. * Set the value of an uniform to an array of int32
  35909. * @param uniform defines the webGL uniform location where to store the value
  35910. * @param array defines the array of int32 to store
  35911. */
  35912. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35913. /**
  35914. * Set the value of an uniform to an array of int32 (stored as vec2)
  35915. * @param uniform defines the webGL uniform location where to store the value
  35916. * @param array defines the array of int32 to store
  35917. */
  35918. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35919. /**
  35920. * Set the value of an uniform to an array of int32 (stored as vec3)
  35921. * @param uniform defines the webGL uniform location where to store the value
  35922. * @param array defines the array of int32 to store
  35923. */
  35924. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35925. /**
  35926. * Set the value of an uniform to an array of int32 (stored as vec4)
  35927. * @param uniform defines the webGL uniform location where to store the value
  35928. * @param array defines the array of int32 to store
  35929. */
  35930. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35931. /**
  35932. * Set the value of an uniform to an array of number
  35933. * @param uniform defines the webGL uniform location where to store the value
  35934. * @param array defines the array of number to store
  35935. */
  35936. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35937. /**
  35938. * Set the value of an uniform to an array of number (stored as vec2)
  35939. * @param uniform defines the webGL uniform location where to store the value
  35940. * @param array defines the array of number to store
  35941. */
  35942. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35943. /**
  35944. * Set the value of an uniform to an array of number (stored as vec3)
  35945. * @param uniform defines the webGL uniform location where to store the value
  35946. * @param array defines the array of number to store
  35947. */
  35948. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35949. /**
  35950. * Set the value of an uniform to an array of number (stored as vec4)
  35951. * @param uniform defines the webGL uniform location where to store the value
  35952. * @param array defines the array of number to store
  35953. */
  35954. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35955. /**
  35956. * Set the value of an uniform to an array of float32 (stored as matrices)
  35957. * @param uniform defines the webGL uniform location where to store the value
  35958. * @param matrices defines the array of float32 to store
  35959. */
  35960. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35961. /**
  35962. * Set the value of an uniform to a matrix (3x3)
  35963. * @param uniform defines the webGL uniform location where to store the value
  35964. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35965. */
  35966. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35967. /**
  35968. * Set the value of an uniform to a matrix (2x2)
  35969. * @param uniform defines the webGL uniform location where to store the value
  35970. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35971. */
  35972. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35973. /**
  35974. * Set the value of an uniform to a number (float)
  35975. * @param uniform defines the webGL uniform location where to store the value
  35976. * @param value defines the float number to store
  35977. */
  35978. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35979. /**
  35980. * Set the value of an uniform to a vec2
  35981. * @param uniform defines the webGL uniform location where to store the value
  35982. * @param x defines the 1st component of the value
  35983. * @param y defines the 2nd component of the value
  35984. */
  35985. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35986. /**
  35987. * Set the value of an uniform to a vec3
  35988. * @param uniform defines the webGL uniform location where to store the value
  35989. * @param x defines the 1st component of the value
  35990. * @param y defines the 2nd component of the value
  35991. * @param z defines the 3rd component of the value
  35992. */
  35993. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35994. /**
  35995. * Set the value of an uniform to a vec4
  35996. * @param uniform defines the webGL uniform location where to store the value
  35997. * @param x defines the 1st component of the value
  35998. * @param y defines the 2nd component of the value
  35999. * @param z defines the 3rd component of the value
  36000. * @param w defines the 4th component of the value
  36001. */
  36002. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36003. /**
  36004. * Apply all cached states (depth, culling, stencil and alpha)
  36005. */
  36006. applyStates(): void;
  36007. /**
  36008. * Enable or disable color writing
  36009. * @param enable defines the state to set
  36010. */
  36011. setColorWrite(enable: boolean): void;
  36012. /**
  36013. * Gets a boolean indicating if color writing is enabled
  36014. * @returns the current color writing state
  36015. */
  36016. getColorWrite(): boolean;
  36017. /**
  36018. * Gets the depth culling state manager
  36019. */
  36020. get depthCullingState(): DepthCullingState;
  36021. /**
  36022. * Gets the alpha state manager
  36023. */
  36024. get alphaState(): AlphaState;
  36025. /**
  36026. * Gets the stencil state manager
  36027. */
  36028. get stencilState(): StencilState;
  36029. /**
  36030. * Clears the list of texture accessible through engine.
  36031. * This can help preventing texture load conflict due to name collision.
  36032. */
  36033. clearInternalTexturesCache(): void;
  36034. /**
  36035. * Force the entire cache to be cleared
  36036. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36037. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36038. */
  36039. wipeCaches(bruteForce?: boolean): void;
  36040. /** @hidden */
  36041. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36042. min: number;
  36043. mag: number;
  36044. };
  36045. /** @hidden */
  36046. _createTexture(): WebGLTexture;
  36047. /**
  36048. * Usually called from Texture.ts.
  36049. * Passed information to create a WebGLTexture
  36050. * @param url defines a value which contains one of the following:
  36051. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36052. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36053. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36054. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36055. * @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)
  36056. * @param scene needed for loading to the correct scene
  36057. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36058. * @param onLoad optional callback to be called upon successful completion
  36059. * @param onError optional callback to be called upon failure
  36060. * @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
  36061. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36062. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36063. * @param forcedExtension defines the extension to use to pick the right loader
  36064. * @param mimeType defines an optional mime type
  36065. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36066. */
  36067. 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;
  36068. /**
  36069. * Loads an image as an HTMLImageElement.
  36070. * @param input url string, ArrayBuffer, or Blob to load
  36071. * @param onLoad callback called when the image successfully loads
  36072. * @param onError callback called when the image fails to load
  36073. * @param offlineProvider offline provider for caching
  36074. * @param mimeType optional mime type
  36075. * @returns the HTMLImageElement of the loaded image
  36076. * @hidden
  36077. */
  36078. 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>;
  36079. /**
  36080. * @hidden
  36081. */
  36082. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36083. private _unpackFlipYCached;
  36084. /**
  36085. * In case you are sharing the context with other applications, it might
  36086. * be interested to not cache the unpack flip y state to ensure a consistent
  36087. * value would be set.
  36088. */
  36089. enableUnpackFlipYCached: boolean;
  36090. /** @hidden */
  36091. _unpackFlipY(value: boolean): void;
  36092. /** @hidden */
  36093. _getUnpackAlignement(): number;
  36094. private _getTextureTarget;
  36095. /**
  36096. * Update the sampling mode of a given texture
  36097. * @param samplingMode defines the required sampling mode
  36098. * @param texture defines the texture to update
  36099. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36100. */
  36101. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36102. /**
  36103. * Update the sampling mode of a given texture
  36104. * @param texture defines the texture to update
  36105. * @param wrapU defines the texture wrap mode of the u coordinates
  36106. * @param wrapV defines the texture wrap mode of the v coordinates
  36107. * @param wrapR defines the texture wrap mode of the r coordinates
  36108. */
  36109. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36110. /** @hidden */
  36111. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36112. width: number;
  36113. height: number;
  36114. layers?: number;
  36115. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36116. /** @hidden */
  36117. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36118. /** @hidden */
  36119. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36120. /**
  36121. * Update a portion of an internal texture
  36122. * @param texture defines the texture to update
  36123. * @param imageData defines the data to store into the texture
  36124. * @param xOffset defines the x coordinates of the update rectangle
  36125. * @param yOffset defines the y coordinates of the update rectangle
  36126. * @param width defines the width of the update rectangle
  36127. * @param height defines the height of the update rectangle
  36128. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36129. * @param lod defines the lod level to update (0 by default)
  36130. */
  36131. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36132. /** @hidden */
  36133. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36134. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36135. private _prepareWebGLTexture;
  36136. /** @hidden */
  36137. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36138. private _getDepthStencilBuffer;
  36139. /** @hidden */
  36140. _releaseFramebufferObjects(texture: InternalTexture): void;
  36141. /** @hidden */
  36142. _releaseTexture(texture: InternalTexture): void;
  36143. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36144. protected _setProgram(program: WebGLProgram): void;
  36145. protected _boundUniforms: {
  36146. [key: number]: WebGLUniformLocation;
  36147. };
  36148. /**
  36149. * Binds an effect to the webGL context
  36150. * @param effect defines the effect to bind
  36151. */
  36152. bindSamplers(effect: Effect): void;
  36153. private _activateCurrentTexture;
  36154. /** @hidden */
  36155. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36156. /** @hidden */
  36157. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36158. /**
  36159. * Unbind all textures from the webGL context
  36160. */
  36161. unbindAllTextures(): void;
  36162. /**
  36163. * Sets a texture to the according uniform.
  36164. * @param channel The texture channel
  36165. * @param uniform The uniform to set
  36166. * @param texture The texture to apply
  36167. */
  36168. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36169. private _bindSamplerUniformToChannel;
  36170. private _getTextureWrapMode;
  36171. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36172. /**
  36173. * Sets an array of texture to the webGL context
  36174. * @param channel defines the channel where the texture array must be set
  36175. * @param uniform defines the associated uniform location
  36176. * @param textures defines the array of textures to bind
  36177. */
  36178. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36179. /** @hidden */
  36180. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36181. private _setTextureParameterFloat;
  36182. private _setTextureParameterInteger;
  36183. /**
  36184. * Unbind all vertex attributes from the webGL context
  36185. */
  36186. unbindAllAttributes(): void;
  36187. /**
  36188. * 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
  36189. */
  36190. releaseEffects(): void;
  36191. /**
  36192. * Dispose and release all associated resources
  36193. */
  36194. dispose(): void;
  36195. /**
  36196. * Attach a new callback raised when context lost event is fired
  36197. * @param callback defines the callback to call
  36198. */
  36199. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36200. /**
  36201. * Attach a new callback raised when context restored event is fired
  36202. * @param callback defines the callback to call
  36203. */
  36204. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36205. /**
  36206. * Get the current error code of the webGL context
  36207. * @returns the error code
  36208. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36209. */
  36210. getError(): number;
  36211. private _canRenderToFloatFramebuffer;
  36212. private _canRenderToHalfFloatFramebuffer;
  36213. private _canRenderToFramebuffer;
  36214. /** @hidden */
  36215. _getWebGLTextureType(type: number): number;
  36216. /** @hidden */
  36217. _getInternalFormat(format: number): number;
  36218. /** @hidden */
  36219. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36220. /** @hidden */
  36221. _getRGBAMultiSampleBufferFormat(type: number): number;
  36222. /** @hidden */
  36223. _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;
  36224. /**
  36225. * Loads a file from a url
  36226. * @param url url to load
  36227. * @param onSuccess callback called when the file successfully loads
  36228. * @param onProgress callback called while file is loading (if the server supports this mode)
  36229. * @param offlineProvider defines the offline provider for caching
  36230. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36231. * @param onError callback called when the file fails to load
  36232. * @returns a file request object
  36233. * @hidden
  36234. */
  36235. 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;
  36236. /**
  36237. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36238. * @param x defines the x coordinate of the rectangle where pixels must be read
  36239. * @param y defines the y coordinate of the rectangle where pixels must be read
  36240. * @param width defines the width of the rectangle where pixels must be read
  36241. * @param height defines the height of the rectangle where pixels must be read
  36242. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36243. * @returns a Uint8Array containing RGBA colors
  36244. */
  36245. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36246. private static _isSupported;
  36247. /**
  36248. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36249. * @returns true if the engine can be created
  36250. * @ignorenaming
  36251. */
  36252. static isSupported(): boolean;
  36253. /**
  36254. * Find the next highest power of two.
  36255. * @param x Number to start search from.
  36256. * @return Next highest power of two.
  36257. */
  36258. static CeilingPOT(x: number): number;
  36259. /**
  36260. * Find the next lowest power of two.
  36261. * @param x Number to start search from.
  36262. * @return Next lowest power of two.
  36263. */
  36264. static FloorPOT(x: number): number;
  36265. /**
  36266. * Find the nearest power of two.
  36267. * @param x Number to start search from.
  36268. * @return Next nearest power of two.
  36269. */
  36270. static NearestPOT(x: number): number;
  36271. /**
  36272. * Get the closest exponent of two
  36273. * @param value defines the value to approximate
  36274. * @param max defines the maximum value to return
  36275. * @param mode defines how to define the closest value
  36276. * @returns closest exponent of two of the given value
  36277. */
  36278. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36279. /**
  36280. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36281. * @param func - the function to be called
  36282. * @param requester - the object that will request the next frame. Falls back to window.
  36283. * @returns frame number
  36284. */
  36285. static QueueNewFrame(func: () => void, requester?: any): number;
  36286. /**
  36287. * Gets host document
  36288. * @returns the host document object
  36289. */
  36290. getHostDocument(): Nullable<Document>;
  36291. }
  36292. }
  36293. declare module BABYLON {
  36294. /**
  36295. * Class representing spherical harmonics coefficients to the 3rd degree
  36296. */
  36297. export class SphericalHarmonics {
  36298. /**
  36299. * Defines whether or not the harmonics have been prescaled for rendering.
  36300. */
  36301. preScaled: boolean;
  36302. /**
  36303. * The l0,0 coefficients of the spherical harmonics
  36304. */
  36305. l00: Vector3;
  36306. /**
  36307. * The l1,-1 coefficients of the spherical harmonics
  36308. */
  36309. l1_1: Vector3;
  36310. /**
  36311. * The l1,0 coefficients of the spherical harmonics
  36312. */
  36313. l10: Vector3;
  36314. /**
  36315. * The l1,1 coefficients of the spherical harmonics
  36316. */
  36317. l11: Vector3;
  36318. /**
  36319. * The l2,-2 coefficients of the spherical harmonics
  36320. */
  36321. l2_2: Vector3;
  36322. /**
  36323. * The l2,-1 coefficients of the spherical harmonics
  36324. */
  36325. l2_1: Vector3;
  36326. /**
  36327. * The l2,0 coefficients of the spherical harmonics
  36328. */
  36329. l20: Vector3;
  36330. /**
  36331. * The l2,1 coefficients of the spherical harmonics
  36332. */
  36333. l21: Vector3;
  36334. /**
  36335. * The l2,2 coefficients of the spherical harmonics
  36336. */
  36337. l22: Vector3;
  36338. /**
  36339. * Adds a light to the spherical harmonics
  36340. * @param direction the direction of the light
  36341. * @param color the color of the light
  36342. * @param deltaSolidAngle the delta solid angle of the light
  36343. */
  36344. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36345. /**
  36346. * Scales the spherical harmonics by the given amount
  36347. * @param scale the amount to scale
  36348. */
  36349. scaleInPlace(scale: number): void;
  36350. /**
  36351. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36352. *
  36353. * ```
  36354. * E_lm = A_l * L_lm
  36355. * ```
  36356. *
  36357. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36358. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36359. * the scaling factors are given in equation 9.
  36360. */
  36361. convertIncidentRadianceToIrradiance(): void;
  36362. /**
  36363. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36364. *
  36365. * ```
  36366. * L = (1/pi) * E * rho
  36367. * ```
  36368. *
  36369. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36370. */
  36371. convertIrradianceToLambertianRadiance(): void;
  36372. /**
  36373. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36374. * required operations at run time.
  36375. *
  36376. * This is simply done by scaling back the SH with Ylm constants parameter.
  36377. * The trigonometric part being applied by the shader at run time.
  36378. */
  36379. preScaleForRendering(): void;
  36380. /**
  36381. * Constructs a spherical harmonics from an array.
  36382. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36383. * @returns the spherical harmonics
  36384. */
  36385. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36386. /**
  36387. * Gets the spherical harmonics from polynomial
  36388. * @param polynomial the spherical polynomial
  36389. * @returns the spherical harmonics
  36390. */
  36391. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36392. }
  36393. /**
  36394. * Class representing spherical polynomial coefficients to the 3rd degree
  36395. */
  36396. export class SphericalPolynomial {
  36397. private _harmonics;
  36398. /**
  36399. * The spherical harmonics used to create the polynomials.
  36400. */
  36401. get preScaledHarmonics(): SphericalHarmonics;
  36402. /**
  36403. * The x coefficients of the spherical polynomial
  36404. */
  36405. x: Vector3;
  36406. /**
  36407. * The y coefficients of the spherical polynomial
  36408. */
  36409. y: Vector3;
  36410. /**
  36411. * The z coefficients of the spherical polynomial
  36412. */
  36413. z: Vector3;
  36414. /**
  36415. * The xx coefficients of the spherical polynomial
  36416. */
  36417. xx: Vector3;
  36418. /**
  36419. * The yy coefficients of the spherical polynomial
  36420. */
  36421. yy: Vector3;
  36422. /**
  36423. * The zz coefficients of the spherical polynomial
  36424. */
  36425. zz: Vector3;
  36426. /**
  36427. * The xy coefficients of the spherical polynomial
  36428. */
  36429. xy: Vector3;
  36430. /**
  36431. * The yz coefficients of the spherical polynomial
  36432. */
  36433. yz: Vector3;
  36434. /**
  36435. * The zx coefficients of the spherical polynomial
  36436. */
  36437. zx: Vector3;
  36438. /**
  36439. * Adds an ambient color to the spherical polynomial
  36440. * @param color the color to add
  36441. */
  36442. addAmbient(color: Color3): void;
  36443. /**
  36444. * Scales the spherical polynomial by the given amount
  36445. * @param scale the amount to scale
  36446. */
  36447. scaleInPlace(scale: number): void;
  36448. /**
  36449. * Gets the spherical polynomial from harmonics
  36450. * @param harmonics the spherical harmonics
  36451. * @returns the spherical polynomial
  36452. */
  36453. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36454. /**
  36455. * Constructs a spherical polynomial from an array.
  36456. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36457. * @returns the spherical polynomial
  36458. */
  36459. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36460. }
  36461. }
  36462. declare module BABYLON {
  36463. /**
  36464. * Defines the source of the internal texture
  36465. */
  36466. export enum InternalTextureSource {
  36467. /**
  36468. * The source of the texture data is unknown
  36469. */
  36470. Unknown = 0,
  36471. /**
  36472. * Texture data comes from an URL
  36473. */
  36474. Url = 1,
  36475. /**
  36476. * Texture data is only used for temporary storage
  36477. */
  36478. Temp = 2,
  36479. /**
  36480. * Texture data comes from raw data (ArrayBuffer)
  36481. */
  36482. Raw = 3,
  36483. /**
  36484. * Texture content is dynamic (video or dynamic texture)
  36485. */
  36486. Dynamic = 4,
  36487. /**
  36488. * Texture content is generated by rendering to it
  36489. */
  36490. RenderTarget = 5,
  36491. /**
  36492. * Texture content is part of a multi render target process
  36493. */
  36494. MultiRenderTarget = 6,
  36495. /**
  36496. * Texture data comes from a cube data file
  36497. */
  36498. Cube = 7,
  36499. /**
  36500. * Texture data comes from a raw cube data
  36501. */
  36502. CubeRaw = 8,
  36503. /**
  36504. * Texture data come from a prefiltered cube data file
  36505. */
  36506. CubePrefiltered = 9,
  36507. /**
  36508. * Texture content is raw 3D data
  36509. */
  36510. Raw3D = 10,
  36511. /**
  36512. * Texture content is raw 2D array data
  36513. */
  36514. Raw2DArray = 11,
  36515. /**
  36516. * Texture content is a depth texture
  36517. */
  36518. Depth = 12,
  36519. /**
  36520. * Texture data comes from a raw cube data encoded with RGBD
  36521. */
  36522. CubeRawRGBD = 13
  36523. }
  36524. /**
  36525. * Class used to store data associated with WebGL texture data for the engine
  36526. * This class should not be used directly
  36527. */
  36528. export class InternalTexture {
  36529. /** @hidden */
  36530. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36531. /**
  36532. * Defines if the texture is ready
  36533. */
  36534. isReady: boolean;
  36535. /**
  36536. * Defines if the texture is a cube texture
  36537. */
  36538. isCube: boolean;
  36539. /**
  36540. * Defines if the texture contains 3D data
  36541. */
  36542. is3D: boolean;
  36543. /**
  36544. * Defines if the texture contains 2D array data
  36545. */
  36546. is2DArray: boolean;
  36547. /**
  36548. * Defines if the texture contains multiview data
  36549. */
  36550. isMultiview: boolean;
  36551. /**
  36552. * Gets the URL used to load this texture
  36553. */
  36554. url: string;
  36555. /**
  36556. * Gets the sampling mode of the texture
  36557. */
  36558. samplingMode: number;
  36559. /**
  36560. * Gets a boolean indicating if the texture needs mipmaps generation
  36561. */
  36562. generateMipMaps: boolean;
  36563. /**
  36564. * Gets the number of samples used by the texture (WebGL2+ only)
  36565. */
  36566. samples: number;
  36567. /**
  36568. * Gets the type of the texture (int, float...)
  36569. */
  36570. type: number;
  36571. /**
  36572. * Gets the format of the texture (RGB, RGBA...)
  36573. */
  36574. format: number;
  36575. /**
  36576. * Observable called when the texture is loaded
  36577. */
  36578. onLoadedObservable: Observable<InternalTexture>;
  36579. /**
  36580. * Gets the width of the texture
  36581. */
  36582. width: number;
  36583. /**
  36584. * Gets the height of the texture
  36585. */
  36586. height: number;
  36587. /**
  36588. * Gets the depth of the texture
  36589. */
  36590. depth: number;
  36591. /**
  36592. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36593. */
  36594. baseWidth: number;
  36595. /**
  36596. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36597. */
  36598. baseHeight: number;
  36599. /**
  36600. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36601. */
  36602. baseDepth: number;
  36603. /**
  36604. * Gets a boolean indicating if the texture is inverted on Y axis
  36605. */
  36606. invertY: boolean;
  36607. /** @hidden */
  36608. _invertVScale: boolean;
  36609. /** @hidden */
  36610. _associatedChannel: number;
  36611. /** @hidden */
  36612. _source: InternalTextureSource;
  36613. /** @hidden */
  36614. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36615. /** @hidden */
  36616. _bufferView: Nullable<ArrayBufferView>;
  36617. /** @hidden */
  36618. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36619. /** @hidden */
  36620. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36621. /** @hidden */
  36622. _size: number;
  36623. /** @hidden */
  36624. _extension: string;
  36625. /** @hidden */
  36626. _files: Nullable<string[]>;
  36627. /** @hidden */
  36628. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36629. /** @hidden */
  36630. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36631. /** @hidden */
  36632. _framebuffer: Nullable<WebGLFramebuffer>;
  36633. /** @hidden */
  36634. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36635. /** @hidden */
  36636. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36637. /** @hidden */
  36638. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36639. /** @hidden */
  36640. _attachments: Nullable<number[]>;
  36641. /** @hidden */
  36642. _textureArray: Nullable<InternalTexture[]>;
  36643. /** @hidden */
  36644. _cachedCoordinatesMode: Nullable<number>;
  36645. /** @hidden */
  36646. _cachedWrapU: Nullable<number>;
  36647. /** @hidden */
  36648. _cachedWrapV: Nullable<number>;
  36649. /** @hidden */
  36650. _cachedWrapR: Nullable<number>;
  36651. /** @hidden */
  36652. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36653. /** @hidden */
  36654. _isDisabled: boolean;
  36655. /** @hidden */
  36656. _compression: Nullable<string>;
  36657. /** @hidden */
  36658. _generateStencilBuffer: boolean;
  36659. /** @hidden */
  36660. _generateDepthBuffer: boolean;
  36661. /** @hidden */
  36662. _comparisonFunction: number;
  36663. /** @hidden */
  36664. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36665. /** @hidden */
  36666. _lodGenerationScale: number;
  36667. /** @hidden */
  36668. _lodGenerationOffset: number;
  36669. /** @hidden */
  36670. _depthStencilTexture: Nullable<InternalTexture>;
  36671. /** @hidden */
  36672. _colorTextureArray: Nullable<WebGLTexture>;
  36673. /** @hidden */
  36674. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36675. /** @hidden */
  36676. _lodTextureHigh: Nullable<BaseTexture>;
  36677. /** @hidden */
  36678. _lodTextureMid: Nullable<BaseTexture>;
  36679. /** @hidden */
  36680. _lodTextureLow: Nullable<BaseTexture>;
  36681. /** @hidden */
  36682. _isRGBD: boolean;
  36683. /** @hidden */
  36684. _linearSpecularLOD: boolean;
  36685. /** @hidden */
  36686. _irradianceTexture: Nullable<BaseTexture>;
  36687. /** @hidden */
  36688. _webGLTexture: Nullable<WebGLTexture>;
  36689. /** @hidden */
  36690. _references: number;
  36691. private _engine;
  36692. /**
  36693. * Gets the Engine the texture belongs to.
  36694. * @returns The babylon engine
  36695. */
  36696. getEngine(): ThinEngine;
  36697. /**
  36698. * Gets the data source type of the texture
  36699. */
  36700. get source(): InternalTextureSource;
  36701. /**
  36702. * Creates a new InternalTexture
  36703. * @param engine defines the engine to use
  36704. * @param source defines the type of data that will be used
  36705. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36706. */
  36707. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36708. /**
  36709. * Increments the number of references (ie. the number of Texture that point to it)
  36710. */
  36711. incrementReferences(): void;
  36712. /**
  36713. * Change the size of the texture (not the size of the content)
  36714. * @param width defines the new width
  36715. * @param height defines the new height
  36716. * @param depth defines the new depth (1 by default)
  36717. */
  36718. updateSize(width: int, height: int, depth?: int): void;
  36719. /** @hidden */
  36720. _rebuild(): void;
  36721. /** @hidden */
  36722. _swapAndDie(target: InternalTexture): void;
  36723. /**
  36724. * Dispose the current allocated resources
  36725. */
  36726. dispose(): void;
  36727. }
  36728. }
  36729. declare module BABYLON {
  36730. /**
  36731. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36732. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36733. */
  36734. export class Analyser {
  36735. /**
  36736. * Gets or sets the smoothing
  36737. * @ignorenaming
  36738. */
  36739. SMOOTHING: number;
  36740. /**
  36741. * Gets or sets the FFT table size
  36742. * @ignorenaming
  36743. */
  36744. FFT_SIZE: number;
  36745. /**
  36746. * Gets or sets the bar graph amplitude
  36747. * @ignorenaming
  36748. */
  36749. BARGRAPHAMPLITUDE: number;
  36750. /**
  36751. * Gets or sets the position of the debug canvas
  36752. * @ignorenaming
  36753. */
  36754. DEBUGCANVASPOS: {
  36755. x: number;
  36756. y: number;
  36757. };
  36758. /**
  36759. * Gets or sets the debug canvas size
  36760. * @ignorenaming
  36761. */
  36762. DEBUGCANVASSIZE: {
  36763. width: number;
  36764. height: number;
  36765. };
  36766. private _byteFreqs;
  36767. private _byteTime;
  36768. private _floatFreqs;
  36769. private _webAudioAnalyser;
  36770. private _debugCanvas;
  36771. private _debugCanvasContext;
  36772. private _scene;
  36773. private _registerFunc;
  36774. private _audioEngine;
  36775. /**
  36776. * Creates a new analyser
  36777. * @param scene defines hosting scene
  36778. */
  36779. constructor(scene: Scene);
  36780. /**
  36781. * Get the number of data values you will have to play with for the visualization
  36782. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36783. * @returns a number
  36784. */
  36785. getFrequencyBinCount(): number;
  36786. /**
  36787. * Gets the current frequency data as a byte array
  36788. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36789. * @returns a Uint8Array
  36790. */
  36791. getByteFrequencyData(): Uint8Array;
  36792. /**
  36793. * Gets the current waveform as a byte array
  36794. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36795. * @returns a Uint8Array
  36796. */
  36797. getByteTimeDomainData(): Uint8Array;
  36798. /**
  36799. * Gets the current frequency data as a float array
  36800. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36801. * @returns a Float32Array
  36802. */
  36803. getFloatFrequencyData(): Float32Array;
  36804. /**
  36805. * Renders the debug canvas
  36806. */
  36807. drawDebugCanvas(): void;
  36808. /**
  36809. * Stops rendering the debug canvas and removes it
  36810. */
  36811. stopDebugCanvas(): void;
  36812. /**
  36813. * Connects two audio nodes
  36814. * @param inputAudioNode defines first node to connect
  36815. * @param outputAudioNode defines second node to connect
  36816. */
  36817. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36818. /**
  36819. * Releases all associated resources
  36820. */
  36821. dispose(): void;
  36822. }
  36823. }
  36824. declare module BABYLON {
  36825. /**
  36826. * This represents an audio engine and it is responsible
  36827. * to play, synchronize and analyse sounds throughout the application.
  36828. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36829. */
  36830. export interface IAudioEngine extends IDisposable {
  36831. /**
  36832. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36833. */
  36834. readonly canUseWebAudio: boolean;
  36835. /**
  36836. * Gets the current AudioContext if available.
  36837. */
  36838. readonly audioContext: Nullable<AudioContext>;
  36839. /**
  36840. * The master gain node defines the global audio volume of your audio engine.
  36841. */
  36842. readonly masterGain: GainNode;
  36843. /**
  36844. * Gets whether or not mp3 are supported by your browser.
  36845. */
  36846. readonly isMP3supported: boolean;
  36847. /**
  36848. * Gets whether or not ogg are supported by your browser.
  36849. */
  36850. readonly isOGGsupported: boolean;
  36851. /**
  36852. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36853. * @ignoreNaming
  36854. */
  36855. WarnedWebAudioUnsupported: boolean;
  36856. /**
  36857. * Defines if the audio engine relies on a custom unlocked button.
  36858. * In this case, the embedded button will not be displayed.
  36859. */
  36860. useCustomUnlockedButton: boolean;
  36861. /**
  36862. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36863. */
  36864. readonly unlocked: boolean;
  36865. /**
  36866. * Event raised when audio has been unlocked on the browser.
  36867. */
  36868. onAudioUnlockedObservable: Observable<AudioEngine>;
  36869. /**
  36870. * Event raised when audio has been locked on the browser.
  36871. */
  36872. onAudioLockedObservable: Observable<AudioEngine>;
  36873. /**
  36874. * Flags the audio engine in Locked state.
  36875. * This happens due to new browser policies preventing audio to autoplay.
  36876. */
  36877. lock(): void;
  36878. /**
  36879. * Unlocks the audio engine once a user action has been done on the dom.
  36880. * This is helpful to resume play once browser policies have been satisfied.
  36881. */
  36882. unlock(): void;
  36883. /**
  36884. * Gets the global volume sets on the master gain.
  36885. * @returns the global volume if set or -1 otherwise
  36886. */
  36887. getGlobalVolume(): number;
  36888. /**
  36889. * Sets the global volume of your experience (sets on the master gain).
  36890. * @param newVolume Defines the new global volume of the application
  36891. */
  36892. setGlobalVolume(newVolume: number): void;
  36893. /**
  36894. * Connect the audio engine to an audio analyser allowing some amazing
  36895. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36896. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36897. * @param analyser The analyser to connect to the engine
  36898. */
  36899. connectToAnalyser(analyser: Analyser): void;
  36900. }
  36901. /**
  36902. * This represents the default audio engine used in babylon.
  36903. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36904. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36905. */
  36906. export class AudioEngine implements IAudioEngine {
  36907. private _audioContext;
  36908. private _audioContextInitialized;
  36909. private _muteButton;
  36910. private _hostElement;
  36911. /**
  36912. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36913. */
  36914. canUseWebAudio: boolean;
  36915. /**
  36916. * The master gain node defines the global audio volume of your audio engine.
  36917. */
  36918. masterGain: GainNode;
  36919. /**
  36920. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36921. * @ignoreNaming
  36922. */
  36923. WarnedWebAudioUnsupported: boolean;
  36924. /**
  36925. * Gets whether or not mp3 are supported by your browser.
  36926. */
  36927. isMP3supported: boolean;
  36928. /**
  36929. * Gets whether or not ogg are supported by your browser.
  36930. */
  36931. isOGGsupported: boolean;
  36932. /**
  36933. * Gets whether audio has been unlocked on the device.
  36934. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36935. * a user interaction has happened.
  36936. */
  36937. unlocked: boolean;
  36938. /**
  36939. * Defines if the audio engine relies on a custom unlocked button.
  36940. * In this case, the embedded button will not be displayed.
  36941. */
  36942. useCustomUnlockedButton: boolean;
  36943. /**
  36944. * Event raised when audio has been unlocked on the browser.
  36945. */
  36946. onAudioUnlockedObservable: Observable<AudioEngine>;
  36947. /**
  36948. * Event raised when audio has been locked on the browser.
  36949. */
  36950. onAudioLockedObservable: Observable<AudioEngine>;
  36951. /**
  36952. * Gets the current AudioContext if available.
  36953. */
  36954. get audioContext(): Nullable<AudioContext>;
  36955. private _connectedAnalyser;
  36956. /**
  36957. * Instantiates a new audio engine.
  36958. *
  36959. * There should be only one per page as some browsers restrict the number
  36960. * of audio contexts you can create.
  36961. * @param hostElement defines the host element where to display the mute icon if necessary
  36962. */
  36963. constructor(hostElement?: Nullable<HTMLElement>);
  36964. /**
  36965. * Flags the audio engine in Locked state.
  36966. * This happens due to new browser policies preventing audio to autoplay.
  36967. */
  36968. lock(): void;
  36969. /**
  36970. * Unlocks the audio engine once a user action has been done on the dom.
  36971. * This is helpful to resume play once browser policies have been satisfied.
  36972. */
  36973. unlock(): void;
  36974. private _resumeAudioContext;
  36975. private _initializeAudioContext;
  36976. private _tryToRun;
  36977. private _triggerRunningState;
  36978. private _triggerSuspendedState;
  36979. private _displayMuteButton;
  36980. private _moveButtonToTopLeft;
  36981. private _onResize;
  36982. private _hideMuteButton;
  36983. /**
  36984. * Destroy and release the resources associated with the audio ccontext.
  36985. */
  36986. dispose(): void;
  36987. /**
  36988. * Gets the global volume sets on the master gain.
  36989. * @returns the global volume if set or -1 otherwise
  36990. */
  36991. getGlobalVolume(): number;
  36992. /**
  36993. * Sets the global volume of your experience (sets on the master gain).
  36994. * @param newVolume Defines the new global volume of the application
  36995. */
  36996. setGlobalVolume(newVolume: number): void;
  36997. /**
  36998. * Connect the audio engine to an audio analyser allowing some amazing
  36999. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37000. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37001. * @param analyser The analyser to connect to the engine
  37002. */
  37003. connectToAnalyser(analyser: Analyser): void;
  37004. }
  37005. }
  37006. declare module BABYLON {
  37007. /**
  37008. * Interface used to present a loading screen while loading a scene
  37009. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37010. */
  37011. export interface ILoadingScreen {
  37012. /**
  37013. * Function called to display the loading screen
  37014. */
  37015. displayLoadingUI: () => void;
  37016. /**
  37017. * Function called to hide the loading screen
  37018. */
  37019. hideLoadingUI: () => void;
  37020. /**
  37021. * Gets or sets the color to use for the background
  37022. */
  37023. loadingUIBackgroundColor: string;
  37024. /**
  37025. * Gets or sets the text to display while loading
  37026. */
  37027. loadingUIText: string;
  37028. }
  37029. /**
  37030. * Class used for the default loading screen
  37031. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37032. */
  37033. export class DefaultLoadingScreen implements ILoadingScreen {
  37034. private _renderingCanvas;
  37035. private _loadingText;
  37036. private _loadingDivBackgroundColor;
  37037. private _loadingDiv;
  37038. private _loadingTextDiv;
  37039. /** Gets or sets the logo url to use for the default loading screen */
  37040. static DefaultLogoUrl: string;
  37041. /** Gets or sets the spinner url to use for the default loading screen */
  37042. static DefaultSpinnerUrl: string;
  37043. /**
  37044. * Creates a new default loading screen
  37045. * @param _renderingCanvas defines the canvas used to render the scene
  37046. * @param _loadingText defines the default text to display
  37047. * @param _loadingDivBackgroundColor defines the default background color
  37048. */
  37049. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37050. /**
  37051. * Function called to display the loading screen
  37052. */
  37053. displayLoadingUI(): void;
  37054. /**
  37055. * Function called to hide the loading screen
  37056. */
  37057. hideLoadingUI(): void;
  37058. /**
  37059. * Gets or sets the text to display while loading
  37060. */
  37061. set loadingUIText(text: string);
  37062. get loadingUIText(): string;
  37063. /**
  37064. * Gets or sets the color to use for the background
  37065. */
  37066. get loadingUIBackgroundColor(): string;
  37067. set loadingUIBackgroundColor(color: string);
  37068. private _resizeLoadingUI;
  37069. }
  37070. }
  37071. declare module BABYLON {
  37072. /**
  37073. * Interface for any object that can request an animation frame
  37074. */
  37075. export interface ICustomAnimationFrameRequester {
  37076. /**
  37077. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37078. */
  37079. renderFunction?: Function;
  37080. /**
  37081. * Called to request the next frame to render to
  37082. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37083. */
  37084. requestAnimationFrame: Function;
  37085. /**
  37086. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37087. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37088. */
  37089. requestID?: number;
  37090. }
  37091. }
  37092. declare module BABYLON {
  37093. /**
  37094. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37095. */
  37096. export class PerformanceMonitor {
  37097. private _enabled;
  37098. private _rollingFrameTime;
  37099. private _lastFrameTimeMs;
  37100. /**
  37101. * constructor
  37102. * @param frameSampleSize The number of samples required to saturate the sliding window
  37103. */
  37104. constructor(frameSampleSize?: number);
  37105. /**
  37106. * Samples current frame
  37107. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37108. */
  37109. sampleFrame(timeMs?: number): void;
  37110. /**
  37111. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37112. */
  37113. get averageFrameTime(): number;
  37114. /**
  37115. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37116. */
  37117. get averageFrameTimeVariance(): number;
  37118. /**
  37119. * Returns the frame time of the most recent frame
  37120. */
  37121. get instantaneousFrameTime(): number;
  37122. /**
  37123. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37124. */
  37125. get averageFPS(): number;
  37126. /**
  37127. * Returns the average framerate in frames per second using the most recent frame time
  37128. */
  37129. get instantaneousFPS(): number;
  37130. /**
  37131. * Returns true if enough samples have been taken to completely fill the sliding window
  37132. */
  37133. get isSaturated(): boolean;
  37134. /**
  37135. * Enables contributions to the sliding window sample set
  37136. */
  37137. enable(): void;
  37138. /**
  37139. * Disables contributions to the sliding window sample set
  37140. * Samples will not be interpolated over the disabled period
  37141. */
  37142. disable(): void;
  37143. /**
  37144. * Returns true if sampling is enabled
  37145. */
  37146. get isEnabled(): boolean;
  37147. /**
  37148. * Resets performance monitor
  37149. */
  37150. reset(): void;
  37151. }
  37152. /**
  37153. * RollingAverage
  37154. *
  37155. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37156. */
  37157. export class RollingAverage {
  37158. /**
  37159. * Current average
  37160. */
  37161. average: number;
  37162. /**
  37163. * Current variance
  37164. */
  37165. variance: number;
  37166. protected _samples: Array<number>;
  37167. protected _sampleCount: number;
  37168. protected _pos: number;
  37169. protected _m2: number;
  37170. /**
  37171. * constructor
  37172. * @param length The number of samples required to saturate the sliding window
  37173. */
  37174. constructor(length: number);
  37175. /**
  37176. * Adds a sample to the sample set
  37177. * @param v The sample value
  37178. */
  37179. add(v: number): void;
  37180. /**
  37181. * Returns previously added values or null if outside of history or outside the sliding window domain
  37182. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37183. * @return Value previously recorded with add() or null if outside of range
  37184. */
  37185. history(i: number): number;
  37186. /**
  37187. * Returns true if enough samples have been taken to completely fill the sliding window
  37188. * @return true if sample-set saturated
  37189. */
  37190. isSaturated(): boolean;
  37191. /**
  37192. * Resets the rolling average (equivalent to 0 samples taken so far)
  37193. */
  37194. reset(): void;
  37195. /**
  37196. * Wraps a value around the sample range boundaries
  37197. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37198. * @return Wrapped position in sample range
  37199. */
  37200. protected _wrapPosition(i: number): number;
  37201. }
  37202. }
  37203. declare module BABYLON {
  37204. /**
  37205. * This class is used to track a performance counter which is number based.
  37206. * The user has access to many properties which give statistics of different nature.
  37207. *
  37208. * The implementer can track two kinds of Performance Counter: time and count.
  37209. * 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.
  37210. * 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.
  37211. */
  37212. export class PerfCounter {
  37213. /**
  37214. * Gets or sets a global boolean to turn on and off all the counters
  37215. */
  37216. static Enabled: boolean;
  37217. /**
  37218. * Returns the smallest value ever
  37219. */
  37220. get min(): number;
  37221. /**
  37222. * Returns the biggest value ever
  37223. */
  37224. get max(): number;
  37225. /**
  37226. * Returns the average value since the performance counter is running
  37227. */
  37228. get average(): number;
  37229. /**
  37230. * Returns the average value of the last second the counter was monitored
  37231. */
  37232. get lastSecAverage(): number;
  37233. /**
  37234. * Returns the current value
  37235. */
  37236. get current(): number;
  37237. /**
  37238. * Gets the accumulated total
  37239. */
  37240. get total(): number;
  37241. /**
  37242. * Gets the total value count
  37243. */
  37244. get count(): number;
  37245. /**
  37246. * Creates a new counter
  37247. */
  37248. constructor();
  37249. /**
  37250. * Call this method to start monitoring a new frame.
  37251. * 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.
  37252. */
  37253. fetchNewFrame(): void;
  37254. /**
  37255. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37256. * @param newCount the count value to add to the monitored count
  37257. * @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.
  37258. */
  37259. addCount(newCount: number, fetchResult: boolean): void;
  37260. /**
  37261. * Start monitoring this performance counter
  37262. */
  37263. beginMonitoring(): void;
  37264. /**
  37265. * Compute the time lapsed since the previous beginMonitoring() call.
  37266. * @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
  37267. */
  37268. endMonitoring(newFrame?: boolean): void;
  37269. private _fetchResult;
  37270. private _startMonitoringTime;
  37271. private _min;
  37272. private _max;
  37273. private _average;
  37274. private _current;
  37275. private _totalValueCount;
  37276. private _totalAccumulated;
  37277. private _lastSecAverage;
  37278. private _lastSecAccumulated;
  37279. private _lastSecTime;
  37280. private _lastSecValueCount;
  37281. }
  37282. }
  37283. declare module BABYLON {
  37284. interface ThinEngine {
  37285. /** @hidden */
  37286. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37287. }
  37288. }
  37289. declare module BABYLON {
  37290. /**
  37291. * Defines the interface used by display changed events
  37292. */
  37293. export interface IDisplayChangedEventArgs {
  37294. /** Gets the vrDisplay object (if any) */
  37295. vrDisplay: Nullable<any>;
  37296. /** Gets a boolean indicating if webVR is supported */
  37297. vrSupported: boolean;
  37298. }
  37299. /**
  37300. * Defines the interface used by objects containing a viewport (like a camera)
  37301. */
  37302. interface IViewportOwnerLike {
  37303. /**
  37304. * Gets or sets the viewport
  37305. */
  37306. viewport: IViewportLike;
  37307. }
  37308. /**
  37309. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37310. */
  37311. export class Engine extends ThinEngine {
  37312. /** Defines that alpha blending is disabled */
  37313. static readonly ALPHA_DISABLE: number;
  37314. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37315. static readonly ALPHA_ADD: number;
  37316. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37317. static readonly ALPHA_COMBINE: number;
  37318. /** Defines that alpha blending to DEST - SRC * DEST */
  37319. static readonly ALPHA_SUBTRACT: number;
  37320. /** Defines that alpha blending to SRC * DEST */
  37321. static readonly ALPHA_MULTIPLY: number;
  37322. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37323. static readonly ALPHA_MAXIMIZED: number;
  37324. /** Defines that alpha blending to SRC + DEST */
  37325. static readonly ALPHA_ONEONE: number;
  37326. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37327. static readonly ALPHA_PREMULTIPLIED: number;
  37328. /**
  37329. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37330. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37331. */
  37332. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37333. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37334. static readonly ALPHA_INTERPOLATE: number;
  37335. /**
  37336. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37337. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37338. */
  37339. static readonly ALPHA_SCREENMODE: number;
  37340. /** Defines that the ressource is not delayed*/
  37341. static readonly DELAYLOADSTATE_NONE: number;
  37342. /** Defines that the ressource was successfully delay loaded */
  37343. static readonly DELAYLOADSTATE_LOADED: number;
  37344. /** Defines that the ressource is currently delay loading */
  37345. static readonly DELAYLOADSTATE_LOADING: number;
  37346. /** Defines that the ressource is delayed and has not started loading */
  37347. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37348. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37349. static readonly NEVER: number;
  37350. /** 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 */
  37351. static readonly ALWAYS: number;
  37352. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37353. static readonly LESS: number;
  37354. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37355. static readonly EQUAL: number;
  37356. /** 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 */
  37357. static readonly LEQUAL: number;
  37358. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37359. static readonly GREATER: number;
  37360. /** 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 */
  37361. static readonly GEQUAL: number;
  37362. /** 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 */
  37363. static readonly NOTEQUAL: number;
  37364. /** Passed to stencilOperation to specify that stencil value must be kept */
  37365. static readonly KEEP: number;
  37366. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37367. static readonly REPLACE: number;
  37368. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37369. static readonly INCR: number;
  37370. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37371. static readonly DECR: number;
  37372. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37373. static readonly INVERT: number;
  37374. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37375. static readonly INCR_WRAP: number;
  37376. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37377. static readonly DECR_WRAP: number;
  37378. /** Texture is not repeating outside of 0..1 UVs */
  37379. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37380. /** Texture is repeating outside of 0..1 UVs */
  37381. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37382. /** Texture is repeating and mirrored */
  37383. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37384. /** ALPHA */
  37385. static readonly TEXTUREFORMAT_ALPHA: number;
  37386. /** LUMINANCE */
  37387. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37388. /** LUMINANCE_ALPHA */
  37389. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37390. /** RGB */
  37391. static readonly TEXTUREFORMAT_RGB: number;
  37392. /** RGBA */
  37393. static readonly TEXTUREFORMAT_RGBA: number;
  37394. /** RED */
  37395. static readonly TEXTUREFORMAT_RED: number;
  37396. /** RED (2nd reference) */
  37397. static readonly TEXTUREFORMAT_R: number;
  37398. /** RG */
  37399. static readonly TEXTUREFORMAT_RG: number;
  37400. /** RED_INTEGER */
  37401. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37402. /** RED_INTEGER (2nd reference) */
  37403. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37404. /** RG_INTEGER */
  37405. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37406. /** RGB_INTEGER */
  37407. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37408. /** RGBA_INTEGER */
  37409. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37410. /** UNSIGNED_BYTE */
  37411. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37412. /** UNSIGNED_BYTE (2nd reference) */
  37413. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37414. /** FLOAT */
  37415. static readonly TEXTURETYPE_FLOAT: number;
  37416. /** HALF_FLOAT */
  37417. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37418. /** BYTE */
  37419. static readonly TEXTURETYPE_BYTE: number;
  37420. /** SHORT */
  37421. static readonly TEXTURETYPE_SHORT: number;
  37422. /** UNSIGNED_SHORT */
  37423. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37424. /** INT */
  37425. static readonly TEXTURETYPE_INT: number;
  37426. /** UNSIGNED_INT */
  37427. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37428. /** UNSIGNED_SHORT_4_4_4_4 */
  37429. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37430. /** UNSIGNED_SHORT_5_5_5_1 */
  37431. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37432. /** UNSIGNED_SHORT_5_6_5 */
  37433. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37434. /** UNSIGNED_INT_2_10_10_10_REV */
  37435. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37436. /** UNSIGNED_INT_24_8 */
  37437. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37438. /** UNSIGNED_INT_10F_11F_11F_REV */
  37439. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37440. /** UNSIGNED_INT_5_9_9_9_REV */
  37441. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37442. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37443. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37444. /** nearest is mag = nearest and min = nearest and mip = linear */
  37445. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37446. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37447. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37448. /** Trilinear is mag = linear and min = linear and mip = linear */
  37449. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37450. /** nearest is mag = nearest and min = nearest and mip = linear */
  37451. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37452. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37453. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37454. /** Trilinear is mag = linear and min = linear and mip = linear */
  37455. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37456. /** mag = nearest and min = nearest and mip = nearest */
  37457. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37458. /** mag = nearest and min = linear and mip = nearest */
  37459. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37460. /** mag = nearest and min = linear and mip = linear */
  37461. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37462. /** mag = nearest and min = linear and mip = none */
  37463. static readonly TEXTURE_NEAREST_LINEAR: number;
  37464. /** mag = nearest and min = nearest and mip = none */
  37465. static readonly TEXTURE_NEAREST_NEAREST: number;
  37466. /** mag = linear and min = nearest and mip = nearest */
  37467. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37468. /** mag = linear and min = nearest and mip = linear */
  37469. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37470. /** mag = linear and min = linear and mip = none */
  37471. static readonly TEXTURE_LINEAR_LINEAR: number;
  37472. /** mag = linear and min = nearest and mip = none */
  37473. static readonly TEXTURE_LINEAR_NEAREST: number;
  37474. /** Explicit coordinates mode */
  37475. static readonly TEXTURE_EXPLICIT_MODE: number;
  37476. /** Spherical coordinates mode */
  37477. static readonly TEXTURE_SPHERICAL_MODE: number;
  37478. /** Planar coordinates mode */
  37479. static readonly TEXTURE_PLANAR_MODE: number;
  37480. /** Cubic coordinates mode */
  37481. static readonly TEXTURE_CUBIC_MODE: number;
  37482. /** Projection coordinates mode */
  37483. static readonly TEXTURE_PROJECTION_MODE: number;
  37484. /** Skybox coordinates mode */
  37485. static readonly TEXTURE_SKYBOX_MODE: number;
  37486. /** Inverse Cubic coordinates mode */
  37487. static readonly TEXTURE_INVCUBIC_MODE: number;
  37488. /** Equirectangular coordinates mode */
  37489. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37490. /** Equirectangular Fixed coordinates mode */
  37491. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37492. /** Equirectangular Fixed Mirrored coordinates mode */
  37493. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37494. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37495. static readonly SCALEMODE_FLOOR: number;
  37496. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37497. static readonly SCALEMODE_NEAREST: number;
  37498. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37499. static readonly SCALEMODE_CEILING: number;
  37500. /**
  37501. * Returns the current npm package of the sdk
  37502. */
  37503. static get NpmPackage(): string;
  37504. /**
  37505. * Returns the current version of the framework
  37506. */
  37507. static get Version(): string;
  37508. /** Gets the list of created engines */
  37509. static get Instances(): Engine[];
  37510. /**
  37511. * Gets the latest created engine
  37512. */
  37513. static get LastCreatedEngine(): Nullable<Engine>;
  37514. /**
  37515. * Gets the latest created scene
  37516. */
  37517. static get LastCreatedScene(): Nullable<Scene>;
  37518. /**
  37519. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37520. * @param flag defines which part of the materials must be marked as dirty
  37521. * @param predicate defines a predicate used to filter which materials should be affected
  37522. */
  37523. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37524. /**
  37525. * Method called to create the default loading screen.
  37526. * This can be overriden in your own app.
  37527. * @param canvas The rendering canvas element
  37528. * @returns The loading screen
  37529. */
  37530. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37531. /**
  37532. * Method called to create the default rescale post process on each engine.
  37533. */
  37534. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37535. /**
  37536. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37537. **/
  37538. enableOfflineSupport: boolean;
  37539. /**
  37540. * 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)
  37541. **/
  37542. disableManifestCheck: boolean;
  37543. /**
  37544. * Gets the list of created scenes
  37545. */
  37546. scenes: Scene[];
  37547. /**
  37548. * Event raised when a new scene is created
  37549. */
  37550. onNewSceneAddedObservable: Observable<Scene>;
  37551. /**
  37552. * Gets the list of created postprocesses
  37553. */
  37554. postProcesses: PostProcess[];
  37555. /**
  37556. * Gets a boolean indicating if the pointer is currently locked
  37557. */
  37558. isPointerLock: boolean;
  37559. /**
  37560. * Observable event triggered each time the rendering canvas is resized
  37561. */
  37562. onResizeObservable: Observable<Engine>;
  37563. /**
  37564. * Observable event triggered each time the canvas loses focus
  37565. */
  37566. onCanvasBlurObservable: Observable<Engine>;
  37567. /**
  37568. * Observable event triggered each time the canvas gains focus
  37569. */
  37570. onCanvasFocusObservable: Observable<Engine>;
  37571. /**
  37572. * Observable event triggered each time the canvas receives pointerout event
  37573. */
  37574. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37575. /**
  37576. * Observable raised when the engine begins a new frame
  37577. */
  37578. onBeginFrameObservable: Observable<Engine>;
  37579. /**
  37580. * If set, will be used to request the next animation frame for the render loop
  37581. */
  37582. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37583. /**
  37584. * Observable raised when the engine ends the current frame
  37585. */
  37586. onEndFrameObservable: Observable<Engine>;
  37587. /**
  37588. * Observable raised when the engine is about to compile a shader
  37589. */
  37590. onBeforeShaderCompilationObservable: Observable<Engine>;
  37591. /**
  37592. * Observable raised when the engine has jsut compiled a shader
  37593. */
  37594. onAfterShaderCompilationObservable: Observable<Engine>;
  37595. /**
  37596. * Gets the audio engine
  37597. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37598. * @ignorenaming
  37599. */
  37600. static audioEngine: IAudioEngine;
  37601. /**
  37602. * Default AudioEngine factory responsible of creating the Audio Engine.
  37603. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37604. */
  37605. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37606. /**
  37607. * Default offline support factory responsible of creating a tool used to store data locally.
  37608. * By default, this will create a Database object if the workload has been embedded.
  37609. */
  37610. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37611. private _loadingScreen;
  37612. private _pointerLockRequested;
  37613. private _rescalePostProcess;
  37614. private _deterministicLockstep;
  37615. private _lockstepMaxSteps;
  37616. private _timeStep;
  37617. protected get _supportsHardwareTextureRescaling(): boolean;
  37618. private _fps;
  37619. private _deltaTime;
  37620. /** @hidden */
  37621. _drawCalls: PerfCounter;
  37622. /** 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 */
  37623. canvasTabIndex: number;
  37624. /**
  37625. * Turn this value on if you want to pause FPS computation when in background
  37626. */
  37627. disablePerformanceMonitorInBackground: boolean;
  37628. private _performanceMonitor;
  37629. /**
  37630. * Gets the performance monitor attached to this engine
  37631. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37632. */
  37633. get performanceMonitor(): PerformanceMonitor;
  37634. private _onFocus;
  37635. private _onBlur;
  37636. private _onCanvasPointerOut;
  37637. private _onCanvasBlur;
  37638. private _onCanvasFocus;
  37639. private _onFullscreenChange;
  37640. private _onPointerLockChange;
  37641. /**
  37642. * Gets the HTML element used to attach event listeners
  37643. * @returns a HTML element
  37644. */
  37645. getInputElement(): Nullable<HTMLElement>;
  37646. /**
  37647. * Creates a new engine
  37648. * @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
  37649. * @param antialias defines enable antialiasing (default: false)
  37650. * @param options defines further options to be sent to the getContext() function
  37651. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37652. */
  37653. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37654. /**
  37655. * Gets current aspect ratio
  37656. * @param viewportOwner defines the camera to use to get the aspect ratio
  37657. * @param useScreen defines if screen size must be used (or the current render target if any)
  37658. * @returns a number defining the aspect ratio
  37659. */
  37660. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37661. /**
  37662. * Gets current screen aspect ratio
  37663. * @returns a number defining the aspect ratio
  37664. */
  37665. getScreenAspectRatio(): number;
  37666. /**
  37667. * Gets the client rect of the HTML canvas attached with the current webGL context
  37668. * @returns a client rectanglee
  37669. */
  37670. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37671. /**
  37672. * Gets the client rect of the HTML element used for events
  37673. * @returns a client rectanglee
  37674. */
  37675. getInputElementClientRect(): Nullable<ClientRect>;
  37676. /**
  37677. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37678. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37679. * @returns true if engine is in deterministic lock step mode
  37680. */
  37681. isDeterministicLockStep(): boolean;
  37682. /**
  37683. * Gets the max steps when engine is running in deterministic lock step
  37684. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37685. * @returns the max steps
  37686. */
  37687. getLockstepMaxSteps(): number;
  37688. /**
  37689. * Returns the time in ms between steps when using deterministic lock step.
  37690. * @returns time step in (ms)
  37691. */
  37692. getTimeStep(): number;
  37693. /**
  37694. * Force the mipmap generation for the given render target texture
  37695. * @param texture defines the render target texture to use
  37696. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37697. */
  37698. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37699. /** States */
  37700. /**
  37701. * Set various states to the webGL context
  37702. * @param culling defines backface culling state
  37703. * @param zOffset defines the value to apply to zOffset (0 by default)
  37704. * @param force defines if states must be applied even if cache is up to date
  37705. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37706. */
  37707. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37708. /**
  37709. * Set the z offset to apply to current rendering
  37710. * @param value defines the offset to apply
  37711. */
  37712. setZOffset(value: number): void;
  37713. /**
  37714. * Gets the current value of the zOffset
  37715. * @returns the current zOffset state
  37716. */
  37717. getZOffset(): number;
  37718. /**
  37719. * Enable or disable depth buffering
  37720. * @param enable defines the state to set
  37721. */
  37722. setDepthBuffer(enable: boolean): void;
  37723. /**
  37724. * Gets a boolean indicating if depth writing is enabled
  37725. * @returns the current depth writing state
  37726. */
  37727. getDepthWrite(): boolean;
  37728. /**
  37729. * Enable or disable depth writing
  37730. * @param enable defines the state to set
  37731. */
  37732. setDepthWrite(enable: boolean): void;
  37733. /**
  37734. * Gets a boolean indicating if stencil buffer is enabled
  37735. * @returns the current stencil buffer state
  37736. */
  37737. getStencilBuffer(): boolean;
  37738. /**
  37739. * Enable or disable the stencil buffer
  37740. * @param enable defines if the stencil buffer must be enabled or disabled
  37741. */
  37742. setStencilBuffer(enable: boolean): void;
  37743. /**
  37744. * Gets the current stencil mask
  37745. * @returns a number defining the new stencil mask to use
  37746. */
  37747. getStencilMask(): number;
  37748. /**
  37749. * Sets the current stencil mask
  37750. * @param mask defines the new stencil mask to use
  37751. */
  37752. setStencilMask(mask: number): void;
  37753. /**
  37754. * Gets the current stencil function
  37755. * @returns a number defining the stencil function to use
  37756. */
  37757. getStencilFunction(): number;
  37758. /**
  37759. * Gets the current stencil reference value
  37760. * @returns a number defining the stencil reference value to use
  37761. */
  37762. getStencilFunctionReference(): number;
  37763. /**
  37764. * Gets the current stencil mask
  37765. * @returns a number defining the stencil mask to use
  37766. */
  37767. getStencilFunctionMask(): number;
  37768. /**
  37769. * Sets the current stencil function
  37770. * @param stencilFunc defines the new stencil function to use
  37771. */
  37772. setStencilFunction(stencilFunc: number): void;
  37773. /**
  37774. * Sets the current stencil reference
  37775. * @param reference defines the new stencil reference to use
  37776. */
  37777. setStencilFunctionReference(reference: number): void;
  37778. /**
  37779. * Sets the current stencil mask
  37780. * @param mask defines the new stencil mask to use
  37781. */
  37782. setStencilFunctionMask(mask: number): void;
  37783. /**
  37784. * Gets the current stencil operation when stencil fails
  37785. * @returns a number defining stencil operation to use when stencil fails
  37786. */
  37787. getStencilOperationFail(): number;
  37788. /**
  37789. * Gets the current stencil operation when depth fails
  37790. * @returns a number defining stencil operation to use when depth fails
  37791. */
  37792. getStencilOperationDepthFail(): number;
  37793. /**
  37794. * Gets the current stencil operation when stencil passes
  37795. * @returns a number defining stencil operation to use when stencil passes
  37796. */
  37797. getStencilOperationPass(): number;
  37798. /**
  37799. * Sets the stencil operation to use when stencil fails
  37800. * @param operation defines the stencil operation to use when stencil fails
  37801. */
  37802. setStencilOperationFail(operation: number): void;
  37803. /**
  37804. * Sets the stencil operation to use when depth fails
  37805. * @param operation defines the stencil operation to use when depth fails
  37806. */
  37807. setStencilOperationDepthFail(operation: number): void;
  37808. /**
  37809. * Sets the stencil operation to use when stencil passes
  37810. * @param operation defines the stencil operation to use when stencil passes
  37811. */
  37812. setStencilOperationPass(operation: number): void;
  37813. /**
  37814. * Sets a boolean indicating if the dithering state is enabled or disabled
  37815. * @param value defines the dithering state
  37816. */
  37817. setDitheringState(value: boolean): void;
  37818. /**
  37819. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37820. * @param value defines the rasterizer state
  37821. */
  37822. setRasterizerState(value: boolean): void;
  37823. /**
  37824. * Gets the current depth function
  37825. * @returns a number defining the depth function
  37826. */
  37827. getDepthFunction(): Nullable<number>;
  37828. /**
  37829. * Sets the current depth function
  37830. * @param depthFunc defines the function to use
  37831. */
  37832. setDepthFunction(depthFunc: number): void;
  37833. /**
  37834. * Sets the current depth function to GREATER
  37835. */
  37836. setDepthFunctionToGreater(): void;
  37837. /**
  37838. * Sets the current depth function to GEQUAL
  37839. */
  37840. setDepthFunctionToGreaterOrEqual(): void;
  37841. /**
  37842. * Sets the current depth function to LESS
  37843. */
  37844. setDepthFunctionToLess(): void;
  37845. /**
  37846. * Sets the current depth function to LEQUAL
  37847. */
  37848. setDepthFunctionToLessOrEqual(): void;
  37849. private _cachedStencilBuffer;
  37850. private _cachedStencilFunction;
  37851. private _cachedStencilMask;
  37852. private _cachedStencilOperationPass;
  37853. private _cachedStencilOperationFail;
  37854. private _cachedStencilOperationDepthFail;
  37855. private _cachedStencilReference;
  37856. /**
  37857. * Caches the the state of the stencil buffer
  37858. */
  37859. cacheStencilState(): void;
  37860. /**
  37861. * Restores the state of the stencil buffer
  37862. */
  37863. restoreStencilState(): void;
  37864. /**
  37865. * Directly set the WebGL Viewport
  37866. * @param x defines the x coordinate of the viewport (in screen space)
  37867. * @param y defines the y coordinate of the viewport (in screen space)
  37868. * @param width defines the width of the viewport (in screen space)
  37869. * @param height defines the height of the viewport (in screen space)
  37870. * @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
  37871. */
  37872. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37873. /**
  37874. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37875. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37876. * @param y defines the y-coordinate of the corner of the clear rectangle
  37877. * @param width defines the width of the clear rectangle
  37878. * @param height defines the height of the clear rectangle
  37879. * @param clearColor defines the clear color
  37880. */
  37881. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37882. /**
  37883. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37884. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37885. * @param y defines the y-coordinate of the corner of the clear rectangle
  37886. * @param width defines the width of the clear rectangle
  37887. * @param height defines the height of the clear rectangle
  37888. */
  37889. enableScissor(x: number, y: number, width: number, height: number): void;
  37890. /**
  37891. * Disable previously set scissor test rectangle
  37892. */
  37893. disableScissor(): void;
  37894. protected _reportDrawCall(): void;
  37895. /**
  37896. * Initializes a webVR display and starts listening to display change events
  37897. * The onVRDisplayChangedObservable will be notified upon these changes
  37898. * @returns The onVRDisplayChangedObservable
  37899. */
  37900. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37901. /** @hidden */
  37902. _prepareVRComponent(): void;
  37903. /** @hidden */
  37904. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37905. /** @hidden */
  37906. _submitVRFrame(): void;
  37907. /**
  37908. * Call this function to leave webVR mode
  37909. * Will do nothing if webVR is not supported or if there is no webVR device
  37910. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37911. */
  37912. disableVR(): void;
  37913. /**
  37914. * Gets a boolean indicating that the system is in VR mode and is presenting
  37915. * @returns true if VR mode is engaged
  37916. */
  37917. isVRPresenting(): boolean;
  37918. /** @hidden */
  37919. _requestVRFrame(): void;
  37920. /** @hidden */
  37921. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37922. /**
  37923. * Gets the source code of the vertex shader associated with a specific webGL program
  37924. * @param program defines the program to use
  37925. * @returns a string containing the source code of the vertex shader associated with the program
  37926. */
  37927. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37928. /**
  37929. * Gets the source code of the fragment shader associated with a specific webGL program
  37930. * @param program defines the program to use
  37931. * @returns a string containing the source code of the fragment shader associated with the program
  37932. */
  37933. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37934. /**
  37935. * Sets a depth stencil texture from a render target to the according uniform.
  37936. * @param channel The texture channel
  37937. * @param uniform The uniform to set
  37938. * @param texture The render target texture containing the depth stencil texture to apply
  37939. */
  37940. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37941. /**
  37942. * Sets a texture to the webGL context from a postprocess
  37943. * @param channel defines the channel to use
  37944. * @param postProcess defines the source postprocess
  37945. */
  37946. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37947. /**
  37948. * Binds the output of the passed in post process to the texture channel specified
  37949. * @param channel The channel the texture should be bound to
  37950. * @param postProcess The post process which's output should be bound
  37951. */
  37952. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37953. protected _rebuildBuffers(): void;
  37954. /** @hidden */
  37955. _renderFrame(): void;
  37956. _renderLoop(): void;
  37957. /** @hidden */
  37958. _renderViews(): boolean;
  37959. /**
  37960. * Toggle full screen mode
  37961. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37962. */
  37963. switchFullscreen(requestPointerLock: boolean): void;
  37964. /**
  37965. * Enters full screen mode
  37966. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37967. */
  37968. enterFullscreen(requestPointerLock: boolean): void;
  37969. /**
  37970. * Exits full screen mode
  37971. */
  37972. exitFullscreen(): void;
  37973. /**
  37974. * Enters Pointerlock mode
  37975. */
  37976. enterPointerlock(): void;
  37977. /**
  37978. * Exits Pointerlock mode
  37979. */
  37980. exitPointerlock(): void;
  37981. /**
  37982. * Begin a new frame
  37983. */
  37984. beginFrame(): void;
  37985. /**
  37986. * Enf the current frame
  37987. */
  37988. endFrame(): void;
  37989. resize(): void;
  37990. /**
  37991. * Force a specific size of the canvas
  37992. * @param width defines the new canvas' width
  37993. * @param height defines the new canvas' height
  37994. * @returns true if the size was changed
  37995. */
  37996. setSize(width: number, height: number): boolean;
  37997. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37998. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37999. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38000. _releaseTexture(texture: InternalTexture): void;
  38001. /**
  38002. * @hidden
  38003. * Rescales a texture
  38004. * @param source input texutre
  38005. * @param destination destination texture
  38006. * @param scene scene to use to render the resize
  38007. * @param internalFormat format to use when resizing
  38008. * @param onComplete callback to be called when resize has completed
  38009. */
  38010. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38011. /**
  38012. * Gets the current framerate
  38013. * @returns a number representing the framerate
  38014. */
  38015. getFps(): number;
  38016. /**
  38017. * Gets the time spent between current and previous frame
  38018. * @returns a number representing the delta time in ms
  38019. */
  38020. getDeltaTime(): number;
  38021. private _measureFps;
  38022. /** @hidden */
  38023. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38024. /**
  38025. * Updates the sample count of a render target texture
  38026. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38027. * @param texture defines the texture to update
  38028. * @param samples defines the sample count to set
  38029. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38030. */
  38031. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38032. /**
  38033. * Updates a depth texture Comparison Mode and Function.
  38034. * If the comparison Function is equal to 0, the mode will be set to none.
  38035. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38036. * @param texture The texture to set the comparison function for
  38037. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38038. */
  38039. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38040. /**
  38041. * Creates a webGL buffer to use with instanciation
  38042. * @param capacity defines the size of the buffer
  38043. * @returns the webGL buffer
  38044. */
  38045. createInstancesBuffer(capacity: number): DataBuffer;
  38046. /**
  38047. * Delete a webGL buffer used with instanciation
  38048. * @param buffer defines the webGL buffer to delete
  38049. */
  38050. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38051. private _clientWaitAsync;
  38052. /** @hidden */
  38053. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38054. dispose(): void;
  38055. private _disableTouchAction;
  38056. /**
  38057. * Display the loading screen
  38058. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38059. */
  38060. displayLoadingUI(): void;
  38061. /**
  38062. * Hide the loading screen
  38063. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38064. */
  38065. hideLoadingUI(): void;
  38066. /**
  38067. * Gets the current loading screen object
  38068. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38069. */
  38070. get loadingScreen(): ILoadingScreen;
  38071. /**
  38072. * Sets the current loading screen object
  38073. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38074. */
  38075. set loadingScreen(loadingScreen: ILoadingScreen);
  38076. /**
  38077. * Sets the current loading screen text
  38078. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38079. */
  38080. set loadingUIText(text: string);
  38081. /**
  38082. * Sets the current loading screen background color
  38083. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38084. */
  38085. set loadingUIBackgroundColor(color: string);
  38086. /** Pointerlock and fullscreen */
  38087. /**
  38088. * Ask the browser to promote the current element to pointerlock mode
  38089. * @param element defines the DOM element to promote
  38090. */
  38091. static _RequestPointerlock(element: HTMLElement): void;
  38092. /**
  38093. * Asks the browser to exit pointerlock mode
  38094. */
  38095. static _ExitPointerlock(): void;
  38096. /**
  38097. * Ask the browser to promote the current element to fullscreen rendering mode
  38098. * @param element defines the DOM element to promote
  38099. */
  38100. static _RequestFullscreen(element: HTMLElement): void;
  38101. /**
  38102. * Asks the browser to exit fullscreen mode
  38103. */
  38104. static _ExitFullscreen(): void;
  38105. }
  38106. }
  38107. declare module BABYLON {
  38108. /**
  38109. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38110. * during the life time of the application.
  38111. */
  38112. export class EngineStore {
  38113. /** Gets the list of created engines */
  38114. static Instances: Engine[];
  38115. /** @hidden */
  38116. static _LastCreatedScene: Nullable<Scene>;
  38117. /**
  38118. * Gets the latest created engine
  38119. */
  38120. static get LastCreatedEngine(): Nullable<Engine>;
  38121. /**
  38122. * Gets the latest created scene
  38123. */
  38124. static get LastCreatedScene(): Nullable<Scene>;
  38125. /**
  38126. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38127. * @ignorenaming
  38128. */
  38129. static UseFallbackTexture: boolean;
  38130. /**
  38131. * Texture content used if a texture cannot loaded
  38132. * @ignorenaming
  38133. */
  38134. static FallbackTexture: string;
  38135. }
  38136. }
  38137. declare module BABYLON {
  38138. /**
  38139. * Helper class that provides a small promise polyfill
  38140. */
  38141. export class PromisePolyfill {
  38142. /**
  38143. * Static function used to check if the polyfill is required
  38144. * If this is the case then the function will inject the polyfill to window.Promise
  38145. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38146. */
  38147. static Apply(force?: boolean): void;
  38148. }
  38149. }
  38150. declare module BABYLON {
  38151. /**
  38152. * Interface for screenshot methods with describe argument called `size` as object with options
  38153. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38154. */
  38155. export interface IScreenshotSize {
  38156. /**
  38157. * number in pixels for canvas height
  38158. */
  38159. height?: number;
  38160. /**
  38161. * multiplier allowing render at a higher or lower resolution
  38162. * If value is defined then height and width will be ignored and taken from camera
  38163. */
  38164. precision?: number;
  38165. /**
  38166. * number in pixels for canvas width
  38167. */
  38168. width?: number;
  38169. }
  38170. }
  38171. declare module BABYLON {
  38172. interface IColor4Like {
  38173. r: float;
  38174. g: float;
  38175. b: float;
  38176. a: float;
  38177. }
  38178. /**
  38179. * Class containing a set of static utilities functions
  38180. */
  38181. export class Tools {
  38182. /**
  38183. * Gets or sets the base URL to use to load assets
  38184. */
  38185. static get BaseUrl(): string;
  38186. static set BaseUrl(value: string);
  38187. /**
  38188. * Enable/Disable Custom HTTP Request Headers globally.
  38189. * default = false
  38190. * @see CustomRequestHeaders
  38191. */
  38192. static UseCustomRequestHeaders: boolean;
  38193. /**
  38194. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38195. * i.e. when loading files, where the server/service expects an Authorization header
  38196. */
  38197. static CustomRequestHeaders: {
  38198. [key: string]: string;
  38199. };
  38200. /**
  38201. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38202. */
  38203. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38204. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38205. /**
  38206. * Default behaviour for cors in the application.
  38207. * It can be a string if the expected behavior is identical in the entire app.
  38208. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38209. */
  38210. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38211. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38212. /**
  38213. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38214. * @ignorenaming
  38215. */
  38216. static get UseFallbackTexture(): boolean;
  38217. static set UseFallbackTexture(value: boolean);
  38218. /**
  38219. * Use this object to register external classes like custom textures or material
  38220. * to allow the laoders to instantiate them
  38221. */
  38222. static get RegisteredExternalClasses(): {
  38223. [key: string]: Object;
  38224. };
  38225. static set RegisteredExternalClasses(classes: {
  38226. [key: string]: Object;
  38227. });
  38228. /**
  38229. * Texture content used if a texture cannot loaded
  38230. * @ignorenaming
  38231. */
  38232. static get fallbackTexture(): string;
  38233. static set fallbackTexture(value: string);
  38234. /**
  38235. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38236. * @param u defines the coordinate on X axis
  38237. * @param v defines the coordinate on Y axis
  38238. * @param width defines the width of the source data
  38239. * @param height defines the height of the source data
  38240. * @param pixels defines the source byte array
  38241. * @param color defines the output color
  38242. */
  38243. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38244. /**
  38245. * Interpolates between a and b via alpha
  38246. * @param a The lower value (returned when alpha = 0)
  38247. * @param b The upper value (returned when alpha = 1)
  38248. * @param alpha The interpolation-factor
  38249. * @return The mixed value
  38250. */
  38251. static Mix(a: number, b: number, alpha: number): number;
  38252. /**
  38253. * Tries to instantiate a new object from a given class name
  38254. * @param className defines the class name to instantiate
  38255. * @returns the new object or null if the system was not able to do the instantiation
  38256. */
  38257. static Instantiate(className: string): any;
  38258. /**
  38259. * Provides a slice function that will work even on IE
  38260. * @param data defines the array to slice
  38261. * @param start defines the start of the data (optional)
  38262. * @param end defines the end of the data (optional)
  38263. * @returns the new sliced array
  38264. */
  38265. static Slice<T>(data: T, start?: number, end?: number): T;
  38266. /**
  38267. * Polyfill for setImmediate
  38268. * @param action defines the action to execute after the current execution block
  38269. */
  38270. static SetImmediate(action: () => void): void;
  38271. /**
  38272. * Function indicating if a number is an exponent of 2
  38273. * @param value defines the value to test
  38274. * @returns true if the value is an exponent of 2
  38275. */
  38276. static IsExponentOfTwo(value: number): boolean;
  38277. private static _tmpFloatArray;
  38278. /**
  38279. * Returns the nearest 32-bit single precision float representation of a Number
  38280. * @param value A Number. If the parameter is of a different type, it will get converted
  38281. * to a number or to NaN if it cannot be converted
  38282. * @returns number
  38283. */
  38284. static FloatRound(value: number): number;
  38285. /**
  38286. * Extracts the filename from a path
  38287. * @param path defines the path to use
  38288. * @returns the filename
  38289. */
  38290. static GetFilename(path: string): string;
  38291. /**
  38292. * Extracts the "folder" part of a path (everything before the filename).
  38293. * @param uri The URI to extract the info from
  38294. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38295. * @returns The "folder" part of the path
  38296. */
  38297. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38298. /**
  38299. * Extracts text content from a DOM element hierarchy
  38300. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38301. */
  38302. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38303. /**
  38304. * Convert an angle in radians to degrees
  38305. * @param angle defines the angle to convert
  38306. * @returns the angle in degrees
  38307. */
  38308. static ToDegrees(angle: number): number;
  38309. /**
  38310. * Convert an angle in degrees to radians
  38311. * @param angle defines the angle to convert
  38312. * @returns the angle in radians
  38313. */
  38314. static ToRadians(angle: number): number;
  38315. /**
  38316. * Returns an array if obj is not an array
  38317. * @param obj defines the object to evaluate as an array
  38318. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38319. * @returns either obj directly if obj is an array or a new array containing obj
  38320. */
  38321. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38322. /**
  38323. * Gets the pointer prefix to use
  38324. * @param engine defines the engine we are finding the prefix for
  38325. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38326. */
  38327. static GetPointerPrefix(engine: Engine): string;
  38328. /**
  38329. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38330. * @param url define the url we are trying
  38331. * @param element define the dom element where to configure the cors policy
  38332. */
  38333. static SetCorsBehavior(url: string | string[], element: {
  38334. crossOrigin: string | null;
  38335. }): void;
  38336. /**
  38337. * Removes unwanted characters from an url
  38338. * @param url defines the url to clean
  38339. * @returns the cleaned url
  38340. */
  38341. static CleanUrl(url: string): string;
  38342. /**
  38343. * Gets or sets a function used to pre-process url before using them to load assets
  38344. */
  38345. static get PreprocessUrl(): (url: string) => string;
  38346. static set PreprocessUrl(processor: (url: string) => string);
  38347. /**
  38348. * Loads an image as an HTMLImageElement.
  38349. * @param input url string, ArrayBuffer, or Blob to load
  38350. * @param onLoad callback called when the image successfully loads
  38351. * @param onError callback called when the image fails to load
  38352. * @param offlineProvider offline provider for caching
  38353. * @param mimeType optional mime type
  38354. * @returns the HTMLImageElement of the loaded image
  38355. */
  38356. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38357. /**
  38358. * Loads a file from a url
  38359. * @param url url string, ArrayBuffer, or Blob to load
  38360. * @param onSuccess callback called when the file successfully loads
  38361. * @param onProgress callback called while file is loading (if the server supports this mode)
  38362. * @param offlineProvider defines the offline provider for caching
  38363. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38364. * @param onError callback called when the file fails to load
  38365. * @returns a file request object
  38366. */
  38367. 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;
  38368. /**
  38369. * Loads a file from a url
  38370. * @param url the file url to load
  38371. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38372. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38373. */
  38374. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38375. /**
  38376. * Load a script (identified by an url). When the url returns, the
  38377. * content of this file is added into a new script element, attached to the DOM (body element)
  38378. * @param scriptUrl defines the url of the script to laod
  38379. * @param onSuccess defines the callback called when the script is loaded
  38380. * @param onError defines the callback to call if an error occurs
  38381. * @param scriptId defines the id of the script element
  38382. */
  38383. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38384. /**
  38385. * Load an asynchronous script (identified by an url). When the url returns, the
  38386. * content of this file is added into a new script element, attached to the DOM (body element)
  38387. * @param scriptUrl defines the url of the script to laod
  38388. * @param scriptId defines the id of the script element
  38389. * @returns a promise request object
  38390. */
  38391. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38392. /**
  38393. * Loads a file from a blob
  38394. * @param fileToLoad defines the blob to use
  38395. * @param callback defines the callback to call when data is loaded
  38396. * @param progressCallback defines the callback to call during loading process
  38397. * @returns a file request object
  38398. */
  38399. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38400. /**
  38401. * Reads a file from a File object
  38402. * @param file defines the file to load
  38403. * @param onSuccess defines the callback to call when data is loaded
  38404. * @param onProgress defines the callback to call during loading process
  38405. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38406. * @param onError defines the callback to call when an error occurs
  38407. * @returns a file request object
  38408. */
  38409. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38410. /**
  38411. * Creates a data url from a given string content
  38412. * @param content defines the content to convert
  38413. * @returns the new data url link
  38414. */
  38415. static FileAsURL(content: string): string;
  38416. /**
  38417. * Format the given number to a specific decimal format
  38418. * @param value defines the number to format
  38419. * @param decimals defines the number of decimals to use
  38420. * @returns the formatted string
  38421. */
  38422. static Format(value: number, decimals?: number): string;
  38423. /**
  38424. * Tries to copy an object by duplicating every property
  38425. * @param source defines the source object
  38426. * @param destination defines the target object
  38427. * @param doNotCopyList defines a list of properties to avoid
  38428. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38429. */
  38430. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38431. /**
  38432. * Gets a boolean indicating if the given object has no own property
  38433. * @param obj defines the object to test
  38434. * @returns true if object has no own property
  38435. */
  38436. static IsEmpty(obj: any): boolean;
  38437. /**
  38438. * Function used to register events at window level
  38439. * @param windowElement defines the Window object to use
  38440. * @param events defines the events to register
  38441. */
  38442. static RegisterTopRootEvents(windowElement: Window, events: {
  38443. name: string;
  38444. handler: Nullable<(e: FocusEvent) => any>;
  38445. }[]): void;
  38446. /**
  38447. * Function used to unregister events from window level
  38448. * @param windowElement defines the Window object to use
  38449. * @param events defines the events to unregister
  38450. */
  38451. static UnregisterTopRootEvents(windowElement: Window, events: {
  38452. name: string;
  38453. handler: Nullable<(e: FocusEvent) => any>;
  38454. }[]): void;
  38455. /**
  38456. * @ignore
  38457. */
  38458. static _ScreenshotCanvas: HTMLCanvasElement;
  38459. /**
  38460. * Dumps the current bound framebuffer
  38461. * @param width defines the rendering width
  38462. * @param height defines the rendering height
  38463. * @param engine defines the hosting engine
  38464. * @param successCallback defines the callback triggered once the data are available
  38465. * @param mimeType defines the mime type of the result
  38466. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38467. */
  38468. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38469. /**
  38470. * Converts the canvas data to blob.
  38471. * This acts as a polyfill for browsers not supporting the to blob function.
  38472. * @param canvas Defines the canvas to extract the data from
  38473. * @param successCallback Defines the callback triggered once the data are available
  38474. * @param mimeType Defines the mime type of the result
  38475. */
  38476. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38477. /**
  38478. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38479. * @param successCallback defines the callback triggered once the data are available
  38480. * @param mimeType defines the mime type of the result
  38481. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38482. */
  38483. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38484. /**
  38485. * Downloads a blob in the browser
  38486. * @param blob defines the blob to download
  38487. * @param fileName defines the name of the downloaded file
  38488. */
  38489. static Download(blob: Blob, fileName: string): void;
  38490. /**
  38491. * Captures a screenshot of the current rendering
  38492. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38493. * @param engine defines the rendering engine
  38494. * @param camera defines the source camera
  38495. * @param size This parameter can be set to a single number or to an object with the
  38496. * following (optional) properties: precision, width, height. If a single number is passed,
  38497. * it will be used for both width and height. If an object is passed, the screenshot size
  38498. * will be derived from the parameters. The precision property is a multiplier allowing
  38499. * rendering at a higher or lower resolution
  38500. * @param successCallback defines the callback receives a single parameter which contains the
  38501. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38502. * src parameter of an <img> to display it
  38503. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38504. * Check your browser for supported MIME types
  38505. */
  38506. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38507. /**
  38508. * Captures a screenshot of the current rendering
  38509. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38510. * @param engine defines the rendering engine
  38511. * @param camera defines the source camera
  38512. * @param size This parameter can be set to a single number or to an object with the
  38513. * following (optional) properties: precision, width, height. If a single number is passed,
  38514. * it will be used for both width and height. If an object is passed, the screenshot size
  38515. * will be derived from the parameters. The precision property is a multiplier allowing
  38516. * rendering at a higher or lower resolution
  38517. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38518. * Check your browser for supported MIME types
  38519. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38520. * to the src parameter of an <img> to display it
  38521. */
  38522. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38523. /**
  38524. * Generates an image screenshot from the specified camera.
  38525. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38526. * @param engine The engine to use for rendering
  38527. * @param camera The camera to use for rendering
  38528. * @param size This parameter can be set to a single number or to an object with the
  38529. * following (optional) properties: precision, width, height. If a single number is passed,
  38530. * it will be used for both width and height. If an object is passed, the screenshot size
  38531. * will be derived from the parameters. The precision property is a multiplier allowing
  38532. * rendering at a higher or lower resolution
  38533. * @param successCallback The callback receives a single parameter which contains the
  38534. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38535. * src parameter of an <img> to display it
  38536. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38537. * Check your browser for supported MIME types
  38538. * @param samples Texture samples (default: 1)
  38539. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38540. * @param fileName A name for for the downloaded file.
  38541. */
  38542. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38543. /**
  38544. * Generates an image screenshot from the specified camera.
  38545. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38546. * @param engine The engine to use for rendering
  38547. * @param camera The camera to use for rendering
  38548. * @param size This parameter can be set to a single number or to an object with the
  38549. * following (optional) properties: precision, width, height. If a single number is passed,
  38550. * it will be used for both width and height. If an object is passed, the screenshot size
  38551. * will be derived from the parameters. The precision property is a multiplier allowing
  38552. * rendering at a higher or lower resolution
  38553. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38554. * Check your browser for supported MIME types
  38555. * @param samples Texture samples (default: 1)
  38556. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38557. * @param fileName A name for for the downloaded file.
  38558. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38559. * to the src parameter of an <img> to display it
  38560. */
  38561. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38562. /**
  38563. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38564. * Be aware Math.random() could cause collisions, but:
  38565. * "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"
  38566. * @returns a pseudo random id
  38567. */
  38568. static RandomId(): string;
  38569. /**
  38570. * Test if the given uri is a base64 string
  38571. * @param uri The uri to test
  38572. * @return True if the uri is a base64 string or false otherwise
  38573. */
  38574. static IsBase64(uri: string): boolean;
  38575. /**
  38576. * Decode the given base64 uri.
  38577. * @param uri The uri to decode
  38578. * @return The decoded base64 data.
  38579. */
  38580. static DecodeBase64(uri: string): ArrayBuffer;
  38581. /**
  38582. * Gets the absolute url.
  38583. * @param url the input url
  38584. * @return the absolute url
  38585. */
  38586. static GetAbsoluteUrl(url: string): string;
  38587. /**
  38588. * No log
  38589. */
  38590. static readonly NoneLogLevel: number;
  38591. /**
  38592. * Only message logs
  38593. */
  38594. static readonly MessageLogLevel: number;
  38595. /**
  38596. * Only warning logs
  38597. */
  38598. static readonly WarningLogLevel: number;
  38599. /**
  38600. * Only error logs
  38601. */
  38602. static readonly ErrorLogLevel: number;
  38603. /**
  38604. * All logs
  38605. */
  38606. static readonly AllLogLevel: number;
  38607. /**
  38608. * Gets a value indicating the number of loading errors
  38609. * @ignorenaming
  38610. */
  38611. static get errorsCount(): number;
  38612. /**
  38613. * Callback called when a new log is added
  38614. */
  38615. static OnNewCacheEntry: (entry: string) => void;
  38616. /**
  38617. * Log a message to the console
  38618. * @param message defines the message to log
  38619. */
  38620. static Log(message: string): void;
  38621. /**
  38622. * Write a warning message to the console
  38623. * @param message defines the message to log
  38624. */
  38625. static Warn(message: string): void;
  38626. /**
  38627. * Write an error message to the console
  38628. * @param message defines the message to log
  38629. */
  38630. static Error(message: string): void;
  38631. /**
  38632. * Gets current log cache (list of logs)
  38633. */
  38634. static get LogCache(): string;
  38635. /**
  38636. * Clears the log cache
  38637. */
  38638. static ClearLogCache(): void;
  38639. /**
  38640. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38641. */
  38642. static set LogLevels(level: number);
  38643. /**
  38644. * Checks if the window object exists
  38645. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38646. */
  38647. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38648. /**
  38649. * No performance log
  38650. */
  38651. static readonly PerformanceNoneLogLevel: number;
  38652. /**
  38653. * Use user marks to log performance
  38654. */
  38655. static readonly PerformanceUserMarkLogLevel: number;
  38656. /**
  38657. * Log performance to the console
  38658. */
  38659. static readonly PerformanceConsoleLogLevel: number;
  38660. private static _performance;
  38661. /**
  38662. * Sets the current performance log level
  38663. */
  38664. static set PerformanceLogLevel(level: number);
  38665. private static _StartPerformanceCounterDisabled;
  38666. private static _EndPerformanceCounterDisabled;
  38667. private static _StartUserMark;
  38668. private static _EndUserMark;
  38669. private static _StartPerformanceConsole;
  38670. private static _EndPerformanceConsole;
  38671. /**
  38672. * Starts a performance counter
  38673. */
  38674. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38675. /**
  38676. * Ends a specific performance coutner
  38677. */
  38678. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38679. /**
  38680. * Gets either window.performance.now() if supported or Date.now() else
  38681. */
  38682. static get Now(): number;
  38683. /**
  38684. * This method will return the name of the class used to create the instance of the given object.
  38685. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38686. * @param object the object to get the class name from
  38687. * @param isType defines if the object is actually a type
  38688. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38689. */
  38690. static GetClassName(object: any, isType?: boolean): string;
  38691. /**
  38692. * Gets the first element of an array satisfying a given predicate
  38693. * @param array defines the array to browse
  38694. * @param predicate defines the predicate to use
  38695. * @returns null if not found or the element
  38696. */
  38697. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38698. /**
  38699. * This method will return the name of the full name of the class, including its owning module (if any).
  38700. * 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).
  38701. * @param object the object to get the class name from
  38702. * @param isType defines if the object is actually a type
  38703. * @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.
  38704. * @ignorenaming
  38705. */
  38706. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38707. /**
  38708. * Returns a promise that resolves after the given amount of time.
  38709. * @param delay Number of milliseconds to delay
  38710. * @returns Promise that resolves after the given amount of time
  38711. */
  38712. static DelayAsync(delay: number): Promise<void>;
  38713. /**
  38714. * Utility function to detect if the current user agent is Safari
  38715. * @returns whether or not the current user agent is safari
  38716. */
  38717. static IsSafari(): boolean;
  38718. }
  38719. /**
  38720. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38721. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38722. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38723. * @param name The name of the class, case should be preserved
  38724. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38725. */
  38726. export function className(name: string, module?: string): (target: Object) => void;
  38727. /**
  38728. * An implementation of a loop for asynchronous functions.
  38729. */
  38730. export class AsyncLoop {
  38731. /**
  38732. * Defines the number of iterations for the loop
  38733. */
  38734. iterations: number;
  38735. /**
  38736. * Defines the current index of the loop.
  38737. */
  38738. index: number;
  38739. private _done;
  38740. private _fn;
  38741. private _successCallback;
  38742. /**
  38743. * Constructor.
  38744. * @param iterations the number of iterations.
  38745. * @param func the function to run each iteration
  38746. * @param successCallback the callback that will be called upon succesful execution
  38747. * @param offset starting offset.
  38748. */
  38749. constructor(
  38750. /**
  38751. * Defines the number of iterations for the loop
  38752. */
  38753. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38754. /**
  38755. * Execute the next iteration. Must be called after the last iteration was finished.
  38756. */
  38757. executeNext(): void;
  38758. /**
  38759. * Break the loop and run the success callback.
  38760. */
  38761. breakLoop(): void;
  38762. /**
  38763. * Create and run an async loop.
  38764. * @param iterations the number of iterations.
  38765. * @param fn the function to run each iteration
  38766. * @param successCallback the callback that will be called upon succesful execution
  38767. * @param offset starting offset.
  38768. * @returns the created async loop object
  38769. */
  38770. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38771. /**
  38772. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38773. * @param iterations total number of iterations
  38774. * @param syncedIterations number of synchronous iterations in each async iteration.
  38775. * @param fn the function to call each iteration.
  38776. * @param callback a success call back that will be called when iterating stops.
  38777. * @param breakFunction a break condition (optional)
  38778. * @param timeout timeout settings for the setTimeout function. default - 0.
  38779. * @returns the created async loop object
  38780. */
  38781. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38782. }
  38783. }
  38784. declare module BABYLON {
  38785. /**
  38786. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38787. * The underlying implementation relies on an associative array to ensure the best performances.
  38788. * The value can be anything including 'null' but except 'undefined'
  38789. */
  38790. export class StringDictionary<T> {
  38791. /**
  38792. * This will clear this dictionary and copy the content from the 'source' one.
  38793. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38794. * @param source the dictionary to take the content from and copy to this dictionary
  38795. */
  38796. copyFrom(source: StringDictionary<T>): void;
  38797. /**
  38798. * Get a value based from its key
  38799. * @param key the given key to get the matching value from
  38800. * @return the value if found, otherwise undefined is returned
  38801. */
  38802. get(key: string): T | undefined;
  38803. /**
  38804. * Get a value from its key or add it if it doesn't exist.
  38805. * This method will ensure you that a given key/data will be present in the dictionary.
  38806. * @param key the given key to get the matching value from
  38807. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38808. * The factory will only be invoked if there's no data for the given key.
  38809. * @return the value corresponding to the key.
  38810. */
  38811. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38812. /**
  38813. * Get a value from its key if present in the dictionary otherwise add it
  38814. * @param key the key to get the value from
  38815. * @param val if there's no such key/value pair in the dictionary add it with this value
  38816. * @return the value corresponding to the key
  38817. */
  38818. getOrAdd(key: string, val: T): T;
  38819. /**
  38820. * Check if there's a given key in the dictionary
  38821. * @param key the key to check for
  38822. * @return true if the key is present, false otherwise
  38823. */
  38824. contains(key: string): boolean;
  38825. /**
  38826. * Add a new key and its corresponding value
  38827. * @param key the key to add
  38828. * @param value the value corresponding to the key
  38829. * @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
  38830. */
  38831. add(key: string, value: T): boolean;
  38832. /**
  38833. * Update a specific value associated to a key
  38834. * @param key defines the key to use
  38835. * @param value defines the value to store
  38836. * @returns true if the value was updated (or false if the key was not found)
  38837. */
  38838. set(key: string, value: T): boolean;
  38839. /**
  38840. * Get the element of the given key and remove it from the dictionary
  38841. * @param key defines the key to search
  38842. * @returns the value associated with the key or null if not found
  38843. */
  38844. getAndRemove(key: string): Nullable<T>;
  38845. /**
  38846. * Remove a key/value from the dictionary.
  38847. * @param key the key to remove
  38848. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38849. */
  38850. remove(key: string): boolean;
  38851. /**
  38852. * Clear the whole content of the dictionary
  38853. */
  38854. clear(): void;
  38855. /**
  38856. * Gets the current count
  38857. */
  38858. get count(): number;
  38859. /**
  38860. * Execute a callback on each key/val of the dictionary.
  38861. * Note that you can remove any element in this dictionary in the callback implementation
  38862. * @param callback the callback to execute on a given key/value pair
  38863. */
  38864. forEach(callback: (key: string, val: T) => void): void;
  38865. /**
  38866. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38867. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38868. * Note that you can remove any element in this dictionary in the callback implementation
  38869. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38870. * @returns the first item
  38871. */
  38872. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38873. private _count;
  38874. private _data;
  38875. }
  38876. }
  38877. declare module BABYLON {
  38878. /** @hidden */
  38879. export interface ICollisionCoordinator {
  38880. createCollider(): Collider;
  38881. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38882. init(scene: Scene): void;
  38883. }
  38884. /** @hidden */
  38885. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38886. private _scene;
  38887. private _scaledPosition;
  38888. private _scaledVelocity;
  38889. private _finalPosition;
  38890. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38891. createCollider(): Collider;
  38892. init(scene: Scene): void;
  38893. private _collideWithWorld;
  38894. }
  38895. }
  38896. declare module BABYLON {
  38897. /**
  38898. * Class used to manage all inputs for the scene.
  38899. */
  38900. export class InputManager {
  38901. /** The distance in pixel that you have to move to prevent some events */
  38902. static DragMovementThreshold: number;
  38903. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38904. static LongPressDelay: number;
  38905. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38906. static DoubleClickDelay: number;
  38907. /** If you need to check double click without raising a single click at first click, enable this flag */
  38908. static ExclusiveDoubleClickMode: boolean;
  38909. /** 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. */
  38910. private _alreadyAttached;
  38911. private _wheelEventName;
  38912. private _onPointerMove;
  38913. private _onPointerDown;
  38914. private _onPointerUp;
  38915. private _initClickEvent;
  38916. private _initActionManager;
  38917. private _delayedSimpleClick;
  38918. private _delayedSimpleClickTimeout;
  38919. private _previousDelayedSimpleClickTimeout;
  38920. private _meshPickProceed;
  38921. private _previousButtonPressed;
  38922. private _currentPickResult;
  38923. private _previousPickResult;
  38924. private _totalPointersPressed;
  38925. private _doubleClickOccured;
  38926. private _pointerOverMesh;
  38927. private _pickedDownMesh;
  38928. private _pickedUpMesh;
  38929. private _pointerX;
  38930. private _pointerY;
  38931. private _unTranslatedPointerX;
  38932. private _unTranslatedPointerY;
  38933. private _startingPointerPosition;
  38934. private _previousStartingPointerPosition;
  38935. private _startingPointerTime;
  38936. private _previousStartingPointerTime;
  38937. private _pointerCaptures;
  38938. private _meshUnderPointerId;
  38939. private _onKeyDown;
  38940. private _onKeyUp;
  38941. private _onCanvasFocusObserver;
  38942. private _onCanvasBlurObserver;
  38943. private _scene;
  38944. /**
  38945. * Creates a new InputManager
  38946. * @param scene defines the hosting scene
  38947. */
  38948. constructor(scene: Scene);
  38949. /**
  38950. * Gets the mesh that is currently under the pointer
  38951. */
  38952. get meshUnderPointer(): Nullable<AbstractMesh>;
  38953. /**
  38954. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  38955. * @param pointerId the pointer id to use
  38956. * @returns The mesh under this pointer id or null if not found
  38957. */
  38958. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  38959. /**
  38960. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38961. */
  38962. get unTranslatedPointer(): Vector2;
  38963. /**
  38964. * Gets or sets the current on-screen X position of the pointer
  38965. */
  38966. get pointerX(): number;
  38967. set pointerX(value: number);
  38968. /**
  38969. * Gets or sets the current on-screen Y position of the pointer
  38970. */
  38971. get pointerY(): number;
  38972. set pointerY(value: number);
  38973. private _updatePointerPosition;
  38974. private _processPointerMove;
  38975. private _setRayOnPointerInfo;
  38976. private _checkPrePointerObservable;
  38977. /**
  38978. * Use this method to simulate a pointer move on a mesh
  38979. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38980. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38981. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38982. */
  38983. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38984. /**
  38985. * Use this method to simulate a pointer down on a mesh
  38986. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38987. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38988. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38989. */
  38990. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38991. private _processPointerDown;
  38992. /** @hidden */
  38993. _isPointerSwiping(): boolean;
  38994. /**
  38995. * Use this method to simulate a pointer up on a mesh
  38996. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38997. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38998. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38999. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39000. */
  39001. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39002. private _processPointerUp;
  39003. /**
  39004. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39005. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39006. * @returns true if the pointer was captured
  39007. */
  39008. isPointerCaptured(pointerId?: number): boolean;
  39009. /**
  39010. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39011. * @param attachUp defines if you want to attach events to pointerup
  39012. * @param attachDown defines if you want to attach events to pointerdown
  39013. * @param attachMove defines if you want to attach events to pointermove
  39014. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39015. */
  39016. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39017. /**
  39018. * Detaches all event handlers
  39019. */
  39020. detachControl(): void;
  39021. /**
  39022. * Force the value of meshUnderPointer
  39023. * @param mesh defines the mesh to use
  39024. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  39025. */
  39026. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  39027. /**
  39028. * Gets the mesh under the pointer
  39029. * @returns a Mesh or null if no mesh is under the pointer
  39030. */
  39031. getPointerOverMesh(): Nullable<AbstractMesh>;
  39032. }
  39033. }
  39034. declare module BABYLON {
  39035. /**
  39036. * This class defines the direct association between an animation and a target
  39037. */
  39038. export class TargetedAnimation {
  39039. /**
  39040. * Animation to perform
  39041. */
  39042. animation: Animation;
  39043. /**
  39044. * Target to animate
  39045. */
  39046. target: any;
  39047. /**
  39048. * Returns the string "TargetedAnimation"
  39049. * @returns "TargetedAnimation"
  39050. */
  39051. getClassName(): string;
  39052. /**
  39053. * Serialize the object
  39054. * @returns the JSON object representing the current entity
  39055. */
  39056. serialize(): any;
  39057. }
  39058. /**
  39059. * Use this class to create coordinated animations on multiple targets
  39060. */
  39061. export class AnimationGroup implements IDisposable {
  39062. /** The name of the animation group */
  39063. name: string;
  39064. private _scene;
  39065. private _targetedAnimations;
  39066. private _animatables;
  39067. private _from;
  39068. private _to;
  39069. private _isStarted;
  39070. private _isPaused;
  39071. private _speedRatio;
  39072. private _loopAnimation;
  39073. private _isAdditive;
  39074. /**
  39075. * Gets or sets the unique id of the node
  39076. */
  39077. uniqueId: number;
  39078. /**
  39079. * This observable will notify when one animation have ended
  39080. */
  39081. onAnimationEndObservable: Observable<TargetedAnimation>;
  39082. /**
  39083. * Observer raised when one animation loops
  39084. */
  39085. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39086. /**
  39087. * Observer raised when all animations have looped
  39088. */
  39089. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39090. /**
  39091. * This observable will notify when all animations have ended.
  39092. */
  39093. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39094. /**
  39095. * This observable will notify when all animations have paused.
  39096. */
  39097. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39098. /**
  39099. * This observable will notify when all animations are playing.
  39100. */
  39101. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39102. /**
  39103. * Gets the first frame
  39104. */
  39105. get from(): number;
  39106. /**
  39107. * Gets the last frame
  39108. */
  39109. get to(): number;
  39110. /**
  39111. * Define if the animations are started
  39112. */
  39113. get isStarted(): boolean;
  39114. /**
  39115. * Gets a value indicating that the current group is playing
  39116. */
  39117. get isPlaying(): boolean;
  39118. /**
  39119. * Gets or sets the speed ratio to use for all animations
  39120. */
  39121. get speedRatio(): number;
  39122. /**
  39123. * Gets or sets the speed ratio to use for all animations
  39124. */
  39125. set speedRatio(value: number);
  39126. /**
  39127. * Gets or sets if all animations should loop or not
  39128. */
  39129. get loopAnimation(): boolean;
  39130. set loopAnimation(value: boolean);
  39131. /**
  39132. * Gets or sets if all animations should be evaluated additively
  39133. */
  39134. get isAdditive(): boolean;
  39135. set isAdditive(value: boolean);
  39136. /**
  39137. * Gets the targeted animations for this animation group
  39138. */
  39139. get targetedAnimations(): Array<TargetedAnimation>;
  39140. /**
  39141. * returning the list of animatables controlled by this animation group.
  39142. */
  39143. get animatables(): Array<Animatable>;
  39144. /**
  39145. * Gets the list of target animations
  39146. */
  39147. get children(): TargetedAnimation[];
  39148. /**
  39149. * Instantiates a new Animation Group.
  39150. * This helps managing several animations at once.
  39151. * @see https://doc.babylonjs.com/how_to/group
  39152. * @param name Defines the name of the group
  39153. * @param scene Defines the scene the group belongs to
  39154. */
  39155. constructor(
  39156. /** The name of the animation group */
  39157. name: string, scene?: Nullable<Scene>);
  39158. /**
  39159. * Add an animation (with its target) in the group
  39160. * @param animation defines the animation we want to add
  39161. * @param target defines the target of the animation
  39162. * @returns the TargetedAnimation object
  39163. */
  39164. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39165. /**
  39166. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39167. * It can add constant keys at begin or end
  39168. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39169. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39170. * @returns the animation group
  39171. */
  39172. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39173. private _animationLoopCount;
  39174. private _animationLoopFlags;
  39175. private _processLoop;
  39176. /**
  39177. * Start all animations on given targets
  39178. * @param loop defines if animations must loop
  39179. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39180. * @param from defines the from key (optional)
  39181. * @param to defines the to key (optional)
  39182. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39183. * @returns the current animation group
  39184. */
  39185. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39186. /**
  39187. * Pause all animations
  39188. * @returns the animation group
  39189. */
  39190. pause(): AnimationGroup;
  39191. /**
  39192. * Play all animations to initial state
  39193. * This function will start() the animations if they were not started or will restart() them if they were paused
  39194. * @param loop defines if animations must loop
  39195. * @returns the animation group
  39196. */
  39197. play(loop?: boolean): AnimationGroup;
  39198. /**
  39199. * Reset all animations to initial state
  39200. * @returns the animation group
  39201. */
  39202. reset(): AnimationGroup;
  39203. /**
  39204. * Restart animations from key 0
  39205. * @returns the animation group
  39206. */
  39207. restart(): AnimationGroup;
  39208. /**
  39209. * Stop all animations
  39210. * @returns the animation group
  39211. */
  39212. stop(): AnimationGroup;
  39213. /**
  39214. * Set animation weight for all animatables
  39215. * @param weight defines the weight to use
  39216. * @return the animationGroup
  39217. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39218. */
  39219. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39220. /**
  39221. * Synchronize and normalize all animatables with a source animatable
  39222. * @param root defines the root animatable to synchronize with
  39223. * @return the animationGroup
  39224. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39225. */
  39226. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39227. /**
  39228. * Goes to a specific frame in this animation group
  39229. * @param frame the frame number to go to
  39230. * @return the animationGroup
  39231. */
  39232. goToFrame(frame: number): AnimationGroup;
  39233. /**
  39234. * Dispose all associated resources
  39235. */
  39236. dispose(): void;
  39237. private _checkAnimationGroupEnded;
  39238. /**
  39239. * Clone the current animation group and returns a copy
  39240. * @param newName defines the name of the new group
  39241. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39242. * @returns the new aniamtion group
  39243. */
  39244. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39245. /**
  39246. * Serializes the animationGroup to an object
  39247. * @returns Serialized object
  39248. */
  39249. serialize(): any;
  39250. /**
  39251. * Returns a new AnimationGroup object parsed from the source provided.
  39252. * @param parsedAnimationGroup defines the source
  39253. * @param scene defines the scene that will receive the animationGroup
  39254. * @returns a new AnimationGroup
  39255. */
  39256. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39257. /**
  39258. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39259. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39260. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39261. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39262. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39263. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39264. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39265. */
  39266. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39267. /**
  39268. * Returns the string "AnimationGroup"
  39269. * @returns "AnimationGroup"
  39270. */
  39271. getClassName(): string;
  39272. /**
  39273. * Creates a detailled string about the object
  39274. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39275. * @returns a string representing the object
  39276. */
  39277. toString(fullDetails?: boolean): string;
  39278. }
  39279. }
  39280. declare module BABYLON {
  39281. /**
  39282. * Define an interface for all classes that will hold resources
  39283. */
  39284. export interface IDisposable {
  39285. /**
  39286. * Releases all held resources
  39287. */
  39288. dispose(): void;
  39289. }
  39290. /** Interface defining initialization parameters for Scene class */
  39291. export interface SceneOptions {
  39292. /**
  39293. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39294. * It will improve performance when the number of geometries becomes important.
  39295. */
  39296. useGeometryUniqueIdsMap?: boolean;
  39297. /**
  39298. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39299. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39300. */
  39301. useMaterialMeshMap?: boolean;
  39302. /**
  39303. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39304. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39305. */
  39306. useClonedMeshMap?: boolean;
  39307. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39308. virtual?: boolean;
  39309. }
  39310. /**
  39311. * Represents a scene to be rendered by the engine.
  39312. * @see https://doc.babylonjs.com/features/scene
  39313. */
  39314. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39315. /** The fog is deactivated */
  39316. static readonly FOGMODE_NONE: number;
  39317. /** The fog density is following an exponential function */
  39318. static readonly FOGMODE_EXP: number;
  39319. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39320. static readonly FOGMODE_EXP2: number;
  39321. /** The fog density is following a linear function. */
  39322. static readonly FOGMODE_LINEAR: number;
  39323. /**
  39324. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39325. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39326. */
  39327. static MinDeltaTime: number;
  39328. /**
  39329. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39330. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39331. */
  39332. static MaxDeltaTime: number;
  39333. /**
  39334. * Factory used to create the default material.
  39335. * @param name The name of the material to create
  39336. * @param scene The scene to create the material for
  39337. * @returns The default material
  39338. */
  39339. static DefaultMaterialFactory(scene: Scene): Material;
  39340. /**
  39341. * Factory used to create the a collision coordinator.
  39342. * @returns The collision coordinator
  39343. */
  39344. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39345. /** @hidden */
  39346. _inputManager: InputManager;
  39347. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39348. cameraToUseForPointers: Nullable<Camera>;
  39349. /** @hidden */
  39350. readonly _isScene: boolean;
  39351. /** @hidden */
  39352. _blockEntityCollection: boolean;
  39353. /**
  39354. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39355. */
  39356. autoClear: boolean;
  39357. /**
  39358. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39359. */
  39360. autoClearDepthAndStencil: boolean;
  39361. /**
  39362. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39363. */
  39364. clearColor: Color4;
  39365. /**
  39366. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39367. */
  39368. ambientColor: Color3;
  39369. /**
  39370. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39371. * It should only be one of the following (if not the default embedded one):
  39372. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39373. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39374. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39375. * The material properties need to be setup according to the type of texture in use.
  39376. */
  39377. environmentBRDFTexture: BaseTexture;
  39378. /**
  39379. * Texture used in all pbr material as the reflection texture.
  39380. * As in the majority of the scene they are the same (exception for multi room and so on),
  39381. * this is easier to reference from here than from all the materials.
  39382. */
  39383. get environmentTexture(): Nullable<BaseTexture>;
  39384. /**
  39385. * Texture used in all pbr material as the reflection texture.
  39386. * As in the majority of the scene they are the same (exception for multi room and so on),
  39387. * this is easier to set here than in all the materials.
  39388. */
  39389. set environmentTexture(value: Nullable<BaseTexture>);
  39390. /** @hidden */
  39391. protected _environmentIntensity: number;
  39392. /**
  39393. * Intensity of the environment in all pbr material.
  39394. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39395. * As in the majority of the scene they are the same (exception for multi room and so on),
  39396. * this is easier to reference from here than from all the materials.
  39397. */
  39398. get environmentIntensity(): number;
  39399. /**
  39400. * Intensity of the environment in all pbr material.
  39401. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39402. * As in the majority of the scene they are the same (exception for multi room and so on),
  39403. * this is easier to set here than in all the materials.
  39404. */
  39405. set environmentIntensity(value: number);
  39406. /** @hidden */
  39407. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39408. /**
  39409. * Default image processing configuration used either in the rendering
  39410. * Forward main pass or through the imageProcessingPostProcess if present.
  39411. * As in the majority of the scene they are the same (exception for multi camera),
  39412. * this is easier to reference from here than from all the materials and post process.
  39413. *
  39414. * No setter as we it is a shared configuration, you can set the values instead.
  39415. */
  39416. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39417. private _forceWireframe;
  39418. /**
  39419. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39420. */
  39421. set forceWireframe(value: boolean);
  39422. get forceWireframe(): boolean;
  39423. private _skipFrustumClipping;
  39424. /**
  39425. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39426. */
  39427. set skipFrustumClipping(value: boolean);
  39428. get skipFrustumClipping(): boolean;
  39429. private _forcePointsCloud;
  39430. /**
  39431. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39432. */
  39433. set forcePointsCloud(value: boolean);
  39434. get forcePointsCloud(): boolean;
  39435. /**
  39436. * Gets or sets the active clipplane 1
  39437. */
  39438. clipPlane: Nullable<Plane>;
  39439. /**
  39440. * Gets or sets the active clipplane 2
  39441. */
  39442. clipPlane2: Nullable<Plane>;
  39443. /**
  39444. * Gets or sets the active clipplane 3
  39445. */
  39446. clipPlane3: Nullable<Plane>;
  39447. /**
  39448. * Gets or sets the active clipplane 4
  39449. */
  39450. clipPlane4: Nullable<Plane>;
  39451. /**
  39452. * Gets or sets the active clipplane 5
  39453. */
  39454. clipPlane5: Nullable<Plane>;
  39455. /**
  39456. * Gets or sets the active clipplane 6
  39457. */
  39458. clipPlane6: Nullable<Plane>;
  39459. /**
  39460. * Gets or sets a boolean indicating if animations are enabled
  39461. */
  39462. animationsEnabled: boolean;
  39463. private _animationPropertiesOverride;
  39464. /**
  39465. * Gets or sets the animation properties override
  39466. */
  39467. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39468. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39469. /**
  39470. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39471. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39472. */
  39473. useConstantAnimationDeltaTime: boolean;
  39474. /**
  39475. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39476. * Please note that it requires to run a ray cast through the scene on every frame
  39477. */
  39478. constantlyUpdateMeshUnderPointer: boolean;
  39479. /**
  39480. * Defines the HTML cursor to use when hovering over interactive elements
  39481. */
  39482. hoverCursor: string;
  39483. /**
  39484. * Defines the HTML default cursor to use (empty by default)
  39485. */
  39486. defaultCursor: string;
  39487. /**
  39488. * Defines whether cursors are handled by the scene.
  39489. */
  39490. doNotHandleCursors: boolean;
  39491. /**
  39492. * This is used to call preventDefault() on pointer down
  39493. * in order to block unwanted artifacts like system double clicks
  39494. */
  39495. preventDefaultOnPointerDown: boolean;
  39496. /**
  39497. * This is used to call preventDefault() on pointer up
  39498. * in order to block unwanted artifacts like system double clicks
  39499. */
  39500. preventDefaultOnPointerUp: boolean;
  39501. /**
  39502. * Gets or sets user defined metadata
  39503. */
  39504. metadata: any;
  39505. /**
  39506. * For internal use only. Please do not use.
  39507. */
  39508. reservedDataStore: any;
  39509. /**
  39510. * Gets the name of the plugin used to load this scene (null by default)
  39511. */
  39512. loadingPluginName: string;
  39513. /**
  39514. * Use this array to add regular expressions used to disable offline support for specific urls
  39515. */
  39516. disableOfflineSupportExceptionRules: RegExp[];
  39517. /**
  39518. * An event triggered when the scene is disposed.
  39519. */
  39520. onDisposeObservable: Observable<Scene>;
  39521. private _onDisposeObserver;
  39522. /** Sets a function to be executed when this scene is disposed. */
  39523. set onDispose(callback: () => void);
  39524. /**
  39525. * An event triggered before rendering the scene (right after animations and physics)
  39526. */
  39527. onBeforeRenderObservable: Observable<Scene>;
  39528. private _onBeforeRenderObserver;
  39529. /** Sets a function to be executed before rendering this scene */
  39530. set beforeRender(callback: Nullable<() => void>);
  39531. /**
  39532. * An event triggered after rendering the scene
  39533. */
  39534. onAfterRenderObservable: Observable<Scene>;
  39535. /**
  39536. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39537. */
  39538. onAfterRenderCameraObservable: Observable<Camera>;
  39539. private _onAfterRenderObserver;
  39540. /** Sets a function to be executed after rendering this scene */
  39541. set afterRender(callback: Nullable<() => void>);
  39542. /**
  39543. * An event triggered before animating the scene
  39544. */
  39545. onBeforeAnimationsObservable: Observable<Scene>;
  39546. /**
  39547. * An event triggered after animations processing
  39548. */
  39549. onAfterAnimationsObservable: Observable<Scene>;
  39550. /**
  39551. * An event triggered before draw calls are ready to be sent
  39552. */
  39553. onBeforeDrawPhaseObservable: Observable<Scene>;
  39554. /**
  39555. * An event triggered after draw calls have been sent
  39556. */
  39557. onAfterDrawPhaseObservable: Observable<Scene>;
  39558. /**
  39559. * An event triggered when the scene is ready
  39560. */
  39561. onReadyObservable: Observable<Scene>;
  39562. /**
  39563. * An event triggered before rendering a camera
  39564. */
  39565. onBeforeCameraRenderObservable: Observable<Camera>;
  39566. private _onBeforeCameraRenderObserver;
  39567. /** Sets a function to be executed before rendering a camera*/
  39568. set beforeCameraRender(callback: () => void);
  39569. /**
  39570. * An event triggered after rendering a camera
  39571. */
  39572. onAfterCameraRenderObservable: Observable<Camera>;
  39573. private _onAfterCameraRenderObserver;
  39574. /** Sets a function to be executed after rendering a camera*/
  39575. set afterCameraRender(callback: () => void);
  39576. /**
  39577. * An event triggered when active meshes evaluation is about to start
  39578. */
  39579. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39580. /**
  39581. * An event triggered when active meshes evaluation is done
  39582. */
  39583. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39584. /**
  39585. * An event triggered when particles rendering is about to start
  39586. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39587. */
  39588. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39589. /**
  39590. * An event triggered when particles rendering is done
  39591. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39592. */
  39593. onAfterParticlesRenderingObservable: Observable<Scene>;
  39594. /**
  39595. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39596. */
  39597. onDataLoadedObservable: Observable<Scene>;
  39598. /**
  39599. * An event triggered when a camera is created
  39600. */
  39601. onNewCameraAddedObservable: Observable<Camera>;
  39602. /**
  39603. * An event triggered when a camera is removed
  39604. */
  39605. onCameraRemovedObservable: Observable<Camera>;
  39606. /**
  39607. * An event triggered when a light is created
  39608. */
  39609. onNewLightAddedObservable: Observable<Light>;
  39610. /**
  39611. * An event triggered when a light is removed
  39612. */
  39613. onLightRemovedObservable: Observable<Light>;
  39614. /**
  39615. * An event triggered when a geometry is created
  39616. */
  39617. onNewGeometryAddedObservable: Observable<Geometry>;
  39618. /**
  39619. * An event triggered when a geometry is removed
  39620. */
  39621. onGeometryRemovedObservable: Observable<Geometry>;
  39622. /**
  39623. * An event triggered when a transform node is created
  39624. */
  39625. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39626. /**
  39627. * An event triggered when a transform node is removed
  39628. */
  39629. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39630. /**
  39631. * An event triggered when a mesh is created
  39632. */
  39633. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39634. /**
  39635. * An event triggered when a mesh is removed
  39636. */
  39637. onMeshRemovedObservable: Observable<AbstractMesh>;
  39638. /**
  39639. * An event triggered when a skeleton is created
  39640. */
  39641. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39642. /**
  39643. * An event triggered when a skeleton is removed
  39644. */
  39645. onSkeletonRemovedObservable: Observable<Skeleton>;
  39646. /**
  39647. * An event triggered when a material is created
  39648. */
  39649. onNewMaterialAddedObservable: Observable<Material>;
  39650. /**
  39651. * An event triggered when a material is removed
  39652. */
  39653. onMaterialRemovedObservable: Observable<Material>;
  39654. /**
  39655. * An event triggered when a texture is created
  39656. */
  39657. onNewTextureAddedObservable: Observable<BaseTexture>;
  39658. /**
  39659. * An event triggered when a texture is removed
  39660. */
  39661. onTextureRemovedObservable: Observable<BaseTexture>;
  39662. /**
  39663. * An event triggered when render targets are about to be rendered
  39664. * Can happen multiple times per frame.
  39665. */
  39666. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39667. /**
  39668. * An event triggered when render targets were rendered.
  39669. * Can happen multiple times per frame.
  39670. */
  39671. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39672. /**
  39673. * An event triggered before calculating deterministic simulation step
  39674. */
  39675. onBeforeStepObservable: Observable<Scene>;
  39676. /**
  39677. * An event triggered after calculating deterministic simulation step
  39678. */
  39679. onAfterStepObservable: Observable<Scene>;
  39680. /**
  39681. * An event triggered when the activeCamera property is updated
  39682. */
  39683. onActiveCameraChanged: Observable<Scene>;
  39684. /**
  39685. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39686. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39687. * 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)
  39688. */
  39689. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39690. /**
  39691. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39692. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39693. * 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)
  39694. */
  39695. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39696. /**
  39697. * This Observable will when a mesh has been imported into the scene.
  39698. */
  39699. onMeshImportedObservable: Observable<AbstractMesh>;
  39700. /**
  39701. * This Observable will when an animation file has been imported into the scene.
  39702. */
  39703. onAnimationFileImportedObservable: Observable<Scene>;
  39704. /**
  39705. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39706. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39707. */
  39708. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39709. /** @hidden */
  39710. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39711. /**
  39712. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39713. */
  39714. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39715. /**
  39716. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39717. */
  39718. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39719. /**
  39720. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39721. */
  39722. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39723. /** Callback called when a pointer move is detected */
  39724. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39725. /** Callback called when a pointer down is detected */
  39726. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39727. /** Callback called when a pointer up is detected */
  39728. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39729. /** Callback called when a pointer pick is detected */
  39730. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39731. /**
  39732. * 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).
  39733. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39734. */
  39735. onPrePointerObservable: Observable<PointerInfoPre>;
  39736. /**
  39737. * Observable event triggered each time an input event is received from the rendering canvas
  39738. */
  39739. onPointerObservable: Observable<PointerInfo>;
  39740. /**
  39741. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39742. */
  39743. get unTranslatedPointer(): Vector2;
  39744. /**
  39745. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39746. */
  39747. static get DragMovementThreshold(): number;
  39748. static set DragMovementThreshold(value: number);
  39749. /**
  39750. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39751. */
  39752. static get LongPressDelay(): number;
  39753. static set LongPressDelay(value: number);
  39754. /**
  39755. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39756. */
  39757. static get DoubleClickDelay(): number;
  39758. static set DoubleClickDelay(value: number);
  39759. /** If you need to check double click without raising a single click at first click, enable this flag */
  39760. static get ExclusiveDoubleClickMode(): boolean;
  39761. static set ExclusiveDoubleClickMode(value: boolean);
  39762. /** @hidden */
  39763. _mirroredCameraPosition: Nullable<Vector3>;
  39764. /**
  39765. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39766. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39767. */
  39768. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39769. /**
  39770. * Observable event triggered each time an keyboard event is received from the hosting window
  39771. */
  39772. onKeyboardObservable: Observable<KeyboardInfo>;
  39773. private _useRightHandedSystem;
  39774. /**
  39775. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39776. */
  39777. set useRightHandedSystem(value: boolean);
  39778. get useRightHandedSystem(): boolean;
  39779. private _timeAccumulator;
  39780. private _currentStepId;
  39781. private _currentInternalStep;
  39782. /**
  39783. * Sets the step Id used by deterministic lock step
  39784. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39785. * @param newStepId defines the step Id
  39786. */
  39787. setStepId(newStepId: number): void;
  39788. /**
  39789. * Gets the step Id used by deterministic lock step
  39790. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39791. * @returns the step Id
  39792. */
  39793. getStepId(): number;
  39794. /**
  39795. * Gets the internal step used by deterministic lock step
  39796. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39797. * @returns the internal step
  39798. */
  39799. getInternalStep(): number;
  39800. private _fogEnabled;
  39801. /**
  39802. * Gets or sets a boolean indicating if fog is enabled on this scene
  39803. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39804. * (Default is true)
  39805. */
  39806. set fogEnabled(value: boolean);
  39807. get fogEnabled(): boolean;
  39808. private _fogMode;
  39809. /**
  39810. * Gets or sets the fog mode to use
  39811. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39812. * | mode | value |
  39813. * | --- | --- |
  39814. * | FOGMODE_NONE | 0 |
  39815. * | FOGMODE_EXP | 1 |
  39816. * | FOGMODE_EXP2 | 2 |
  39817. * | FOGMODE_LINEAR | 3 |
  39818. */
  39819. set fogMode(value: number);
  39820. get fogMode(): number;
  39821. /**
  39822. * Gets or sets the fog color to use
  39823. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39824. * (Default is Color3(0.2, 0.2, 0.3))
  39825. */
  39826. fogColor: Color3;
  39827. /**
  39828. * Gets or sets the fog density to use
  39829. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39830. * (Default is 0.1)
  39831. */
  39832. fogDensity: number;
  39833. /**
  39834. * Gets or sets the fog start distance to use
  39835. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39836. * (Default is 0)
  39837. */
  39838. fogStart: number;
  39839. /**
  39840. * Gets or sets the fog end distance to use
  39841. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39842. * (Default is 1000)
  39843. */
  39844. fogEnd: number;
  39845. /**
  39846. * Flag indicating that the frame buffer binding is handled by another component
  39847. */
  39848. prePass: boolean;
  39849. private _shadowsEnabled;
  39850. /**
  39851. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39852. */
  39853. set shadowsEnabled(value: boolean);
  39854. get shadowsEnabled(): boolean;
  39855. private _lightsEnabled;
  39856. /**
  39857. * Gets or sets a boolean indicating if lights are enabled on this scene
  39858. */
  39859. set lightsEnabled(value: boolean);
  39860. get lightsEnabled(): boolean;
  39861. /** All of the active cameras added to this scene. */
  39862. activeCameras: Camera[];
  39863. /** @hidden */
  39864. _activeCamera: Nullable<Camera>;
  39865. /** Gets or sets the current active camera */
  39866. get activeCamera(): Nullable<Camera>;
  39867. set activeCamera(value: Nullable<Camera>);
  39868. private _defaultMaterial;
  39869. /** The default material used on meshes when no material is affected */
  39870. get defaultMaterial(): Material;
  39871. /** The default material used on meshes when no material is affected */
  39872. set defaultMaterial(value: Material);
  39873. private _texturesEnabled;
  39874. /**
  39875. * Gets or sets a boolean indicating if textures are enabled on this scene
  39876. */
  39877. set texturesEnabled(value: boolean);
  39878. get texturesEnabled(): boolean;
  39879. /**
  39880. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39881. */
  39882. physicsEnabled: boolean;
  39883. /**
  39884. * Gets or sets a boolean indicating if particles are enabled on this scene
  39885. */
  39886. particlesEnabled: boolean;
  39887. /**
  39888. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39889. */
  39890. spritesEnabled: boolean;
  39891. private _skeletonsEnabled;
  39892. /**
  39893. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39894. */
  39895. set skeletonsEnabled(value: boolean);
  39896. get skeletonsEnabled(): boolean;
  39897. /**
  39898. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39899. */
  39900. lensFlaresEnabled: boolean;
  39901. /**
  39902. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39903. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39904. */
  39905. collisionsEnabled: boolean;
  39906. private _collisionCoordinator;
  39907. /** @hidden */
  39908. get collisionCoordinator(): ICollisionCoordinator;
  39909. /**
  39910. * Defines the gravity applied to this scene (used only for collisions)
  39911. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39912. */
  39913. gravity: Vector3;
  39914. /**
  39915. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39916. */
  39917. postProcessesEnabled: boolean;
  39918. /**
  39919. * Gets the current postprocess manager
  39920. */
  39921. postProcessManager: PostProcessManager;
  39922. /**
  39923. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39924. */
  39925. renderTargetsEnabled: boolean;
  39926. /**
  39927. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39928. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39929. */
  39930. dumpNextRenderTargets: boolean;
  39931. /**
  39932. * The list of user defined render targets added to the scene
  39933. */
  39934. customRenderTargets: RenderTargetTexture[];
  39935. /**
  39936. * Defines if texture loading must be delayed
  39937. * If true, textures will only be loaded when they need to be rendered
  39938. */
  39939. useDelayedTextureLoading: boolean;
  39940. /**
  39941. * Gets the list of meshes imported to the scene through SceneLoader
  39942. */
  39943. importedMeshesFiles: String[];
  39944. /**
  39945. * Gets or sets a boolean indicating if probes are enabled on this scene
  39946. */
  39947. probesEnabled: boolean;
  39948. /**
  39949. * Gets or sets the current offline provider to use to store scene data
  39950. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39951. */
  39952. offlineProvider: IOfflineProvider;
  39953. /**
  39954. * Gets or sets the action manager associated with the scene
  39955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39956. */
  39957. actionManager: AbstractActionManager;
  39958. private _meshesForIntersections;
  39959. /**
  39960. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39961. */
  39962. proceduralTexturesEnabled: boolean;
  39963. private _engine;
  39964. private _totalVertices;
  39965. /** @hidden */
  39966. _activeIndices: PerfCounter;
  39967. /** @hidden */
  39968. _activeParticles: PerfCounter;
  39969. /** @hidden */
  39970. _activeBones: PerfCounter;
  39971. private _animationRatio;
  39972. /** @hidden */
  39973. _animationTimeLast: number;
  39974. /** @hidden */
  39975. _animationTime: number;
  39976. /**
  39977. * Gets or sets a general scale for animation speed
  39978. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39979. */
  39980. animationTimeScale: number;
  39981. /** @hidden */
  39982. _cachedMaterial: Nullable<Material>;
  39983. /** @hidden */
  39984. _cachedEffect: Nullable<Effect>;
  39985. /** @hidden */
  39986. _cachedVisibility: Nullable<number>;
  39987. private _renderId;
  39988. private _frameId;
  39989. private _executeWhenReadyTimeoutId;
  39990. private _intermediateRendering;
  39991. private _viewUpdateFlag;
  39992. private _projectionUpdateFlag;
  39993. /** @hidden */
  39994. _toBeDisposed: Nullable<IDisposable>[];
  39995. private _activeRequests;
  39996. /** @hidden */
  39997. _pendingData: any[];
  39998. private _isDisposed;
  39999. /**
  40000. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40001. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40002. */
  40003. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40004. private _activeMeshes;
  40005. private _processedMaterials;
  40006. private _renderTargets;
  40007. /** @hidden */
  40008. _activeParticleSystems: SmartArray<IParticleSystem>;
  40009. private _activeSkeletons;
  40010. private _softwareSkinnedMeshes;
  40011. private _renderingManager;
  40012. /** @hidden */
  40013. _activeAnimatables: Animatable[];
  40014. private _transformMatrix;
  40015. private _sceneUbo;
  40016. /** @hidden */
  40017. _viewMatrix: Matrix;
  40018. private _projectionMatrix;
  40019. /** @hidden */
  40020. _forcedViewPosition: Nullable<Vector3>;
  40021. /** @hidden */
  40022. _frustumPlanes: Plane[];
  40023. /**
  40024. * Gets the list of frustum planes (built from the active camera)
  40025. */
  40026. get frustumPlanes(): Plane[];
  40027. /**
  40028. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40029. * This is useful if there are more lights that the maximum simulteanous authorized
  40030. */
  40031. requireLightSorting: boolean;
  40032. /** @hidden */
  40033. readonly useMaterialMeshMap: boolean;
  40034. /** @hidden */
  40035. readonly useClonedMeshMap: boolean;
  40036. private _externalData;
  40037. private _uid;
  40038. /**
  40039. * @hidden
  40040. * Backing store of defined scene components.
  40041. */
  40042. _components: ISceneComponent[];
  40043. /**
  40044. * @hidden
  40045. * Backing store of defined scene components.
  40046. */
  40047. _serializableComponents: ISceneSerializableComponent[];
  40048. /**
  40049. * List of components to register on the next registration step.
  40050. */
  40051. private _transientComponents;
  40052. /**
  40053. * Registers the transient components if needed.
  40054. */
  40055. private _registerTransientComponents;
  40056. /**
  40057. * @hidden
  40058. * Add a component to the scene.
  40059. * Note that the ccomponent could be registered on th next frame if this is called after
  40060. * the register component stage.
  40061. * @param component Defines the component to add to the scene
  40062. */
  40063. _addComponent(component: ISceneComponent): void;
  40064. /**
  40065. * @hidden
  40066. * Gets a component from the scene.
  40067. * @param name defines the name of the component to retrieve
  40068. * @returns the component or null if not present
  40069. */
  40070. _getComponent(name: string): Nullable<ISceneComponent>;
  40071. /**
  40072. * @hidden
  40073. * Defines the actions happening before camera updates.
  40074. */
  40075. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40076. /**
  40077. * @hidden
  40078. * Defines the actions happening before clear the canvas.
  40079. */
  40080. _beforeClearStage: Stage<SimpleStageAction>;
  40081. /**
  40082. * @hidden
  40083. * Defines the actions when collecting render targets for the frame.
  40084. */
  40085. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40086. /**
  40087. * @hidden
  40088. * Defines the actions happening for one camera in the frame.
  40089. */
  40090. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40091. /**
  40092. * @hidden
  40093. * Defines the actions happening during the per mesh ready checks.
  40094. */
  40095. _isReadyForMeshStage: Stage<MeshStageAction>;
  40096. /**
  40097. * @hidden
  40098. * Defines the actions happening before evaluate active mesh checks.
  40099. */
  40100. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40101. /**
  40102. * @hidden
  40103. * Defines the actions happening during the evaluate sub mesh checks.
  40104. */
  40105. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40106. /**
  40107. * @hidden
  40108. * Defines the actions happening during the active mesh stage.
  40109. */
  40110. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40111. /**
  40112. * @hidden
  40113. * Defines the actions happening during the per camera render target step.
  40114. */
  40115. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40116. /**
  40117. * @hidden
  40118. * Defines the actions happening just before the active camera is drawing.
  40119. */
  40120. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40121. /**
  40122. * @hidden
  40123. * Defines the actions happening just before a render target is drawing.
  40124. */
  40125. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40126. /**
  40127. * @hidden
  40128. * Defines the actions happening just before a rendering group is drawing.
  40129. */
  40130. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40131. /**
  40132. * @hidden
  40133. * Defines the actions happening just before a mesh is drawing.
  40134. */
  40135. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40136. /**
  40137. * @hidden
  40138. * Defines the actions happening just after a mesh has been drawn.
  40139. */
  40140. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40141. /**
  40142. * @hidden
  40143. * Defines the actions happening just after a rendering group has been drawn.
  40144. */
  40145. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40146. /**
  40147. * @hidden
  40148. * Defines the actions happening just after the active camera has been drawn.
  40149. */
  40150. _afterCameraDrawStage: Stage<CameraStageAction>;
  40151. /**
  40152. * @hidden
  40153. * Defines the actions happening just after a render target has been drawn.
  40154. */
  40155. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40156. /**
  40157. * @hidden
  40158. * Defines the actions happening just after rendering all cameras and computing intersections.
  40159. */
  40160. _afterRenderStage: Stage<SimpleStageAction>;
  40161. /**
  40162. * @hidden
  40163. * Defines the actions happening when a pointer move event happens.
  40164. */
  40165. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40166. /**
  40167. * @hidden
  40168. * Defines the actions happening when a pointer down event happens.
  40169. */
  40170. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40171. /**
  40172. * @hidden
  40173. * Defines the actions happening when a pointer up event happens.
  40174. */
  40175. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40176. /**
  40177. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40178. */
  40179. private geometriesByUniqueId;
  40180. /**
  40181. * Creates a new Scene
  40182. * @param engine defines the engine to use to render this scene
  40183. * @param options defines the scene options
  40184. */
  40185. constructor(engine: Engine, options?: SceneOptions);
  40186. /**
  40187. * Gets a string identifying the name of the class
  40188. * @returns "Scene" string
  40189. */
  40190. getClassName(): string;
  40191. private _defaultMeshCandidates;
  40192. /**
  40193. * @hidden
  40194. */
  40195. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40196. private _defaultSubMeshCandidates;
  40197. /**
  40198. * @hidden
  40199. */
  40200. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40201. /**
  40202. * Sets the default candidate providers for the scene.
  40203. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40204. * and getCollidingSubMeshCandidates to their default function
  40205. */
  40206. setDefaultCandidateProviders(): void;
  40207. /**
  40208. * Gets the mesh that is currently under the pointer
  40209. */
  40210. get meshUnderPointer(): Nullable<AbstractMesh>;
  40211. /**
  40212. * Gets or sets the current on-screen X position of the pointer
  40213. */
  40214. get pointerX(): number;
  40215. set pointerX(value: number);
  40216. /**
  40217. * Gets or sets the current on-screen Y position of the pointer
  40218. */
  40219. get pointerY(): number;
  40220. set pointerY(value: number);
  40221. /**
  40222. * Gets the cached material (ie. the latest rendered one)
  40223. * @returns the cached material
  40224. */
  40225. getCachedMaterial(): Nullable<Material>;
  40226. /**
  40227. * Gets the cached effect (ie. the latest rendered one)
  40228. * @returns the cached effect
  40229. */
  40230. getCachedEffect(): Nullable<Effect>;
  40231. /**
  40232. * Gets the cached visibility state (ie. the latest rendered one)
  40233. * @returns the cached visibility state
  40234. */
  40235. getCachedVisibility(): Nullable<number>;
  40236. /**
  40237. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40238. * @param material defines the current material
  40239. * @param effect defines the current effect
  40240. * @param visibility defines the current visibility state
  40241. * @returns true if one parameter is not cached
  40242. */
  40243. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40244. /**
  40245. * Gets the engine associated with the scene
  40246. * @returns an Engine
  40247. */
  40248. getEngine(): Engine;
  40249. /**
  40250. * Gets the total number of vertices rendered per frame
  40251. * @returns the total number of vertices rendered per frame
  40252. */
  40253. getTotalVertices(): number;
  40254. /**
  40255. * Gets the performance counter for total vertices
  40256. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40257. */
  40258. get totalVerticesPerfCounter(): PerfCounter;
  40259. /**
  40260. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40261. * @returns the total number of active indices rendered per frame
  40262. */
  40263. getActiveIndices(): number;
  40264. /**
  40265. * Gets the performance counter for active indices
  40266. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40267. */
  40268. get totalActiveIndicesPerfCounter(): PerfCounter;
  40269. /**
  40270. * Gets the total number of active particles rendered per frame
  40271. * @returns the total number of active particles rendered per frame
  40272. */
  40273. getActiveParticles(): number;
  40274. /**
  40275. * Gets the performance counter for active particles
  40276. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40277. */
  40278. get activeParticlesPerfCounter(): PerfCounter;
  40279. /**
  40280. * Gets the total number of active bones rendered per frame
  40281. * @returns the total number of active bones rendered per frame
  40282. */
  40283. getActiveBones(): number;
  40284. /**
  40285. * Gets the performance counter for active bones
  40286. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40287. */
  40288. get activeBonesPerfCounter(): PerfCounter;
  40289. /**
  40290. * Gets the array of active meshes
  40291. * @returns an array of AbstractMesh
  40292. */
  40293. getActiveMeshes(): SmartArray<AbstractMesh>;
  40294. /**
  40295. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40296. * @returns a number
  40297. */
  40298. getAnimationRatio(): number;
  40299. /**
  40300. * Gets an unique Id for the current render phase
  40301. * @returns a number
  40302. */
  40303. getRenderId(): number;
  40304. /**
  40305. * Gets an unique Id for the current frame
  40306. * @returns a number
  40307. */
  40308. getFrameId(): number;
  40309. /** Call this function if you want to manually increment the render Id*/
  40310. incrementRenderId(): void;
  40311. private _createUbo;
  40312. /**
  40313. * Use this method to simulate a pointer move on a mesh
  40314. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40315. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40316. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40317. * @returns the current scene
  40318. */
  40319. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40320. /**
  40321. * Use this method to simulate a pointer down on a mesh
  40322. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40323. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40324. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40325. * @returns the current scene
  40326. */
  40327. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40328. /**
  40329. * Use this method to simulate a pointer up on a mesh
  40330. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40331. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40332. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40333. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40334. * @returns the current scene
  40335. */
  40336. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40337. /**
  40338. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40339. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40340. * @returns true if the pointer was captured
  40341. */
  40342. isPointerCaptured(pointerId?: number): boolean;
  40343. /**
  40344. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40345. * @param attachUp defines if you want to attach events to pointerup
  40346. * @param attachDown defines if you want to attach events to pointerdown
  40347. * @param attachMove defines if you want to attach events to pointermove
  40348. */
  40349. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40350. /** Detaches all event handlers*/
  40351. detachControl(): void;
  40352. /**
  40353. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40354. * Delay loaded resources are not taking in account
  40355. * @return true if all required resources are ready
  40356. */
  40357. isReady(): boolean;
  40358. /** Resets all cached information relative to material (including effect and visibility) */
  40359. resetCachedMaterial(): void;
  40360. /**
  40361. * Registers a function to be called before every frame render
  40362. * @param func defines the function to register
  40363. */
  40364. registerBeforeRender(func: () => void): void;
  40365. /**
  40366. * Unregisters a function called before every frame render
  40367. * @param func defines the function to unregister
  40368. */
  40369. unregisterBeforeRender(func: () => void): void;
  40370. /**
  40371. * Registers a function to be called after every frame render
  40372. * @param func defines the function to register
  40373. */
  40374. registerAfterRender(func: () => void): void;
  40375. /**
  40376. * Unregisters a function called after every frame render
  40377. * @param func defines the function to unregister
  40378. */
  40379. unregisterAfterRender(func: () => void): void;
  40380. private _executeOnceBeforeRender;
  40381. /**
  40382. * The provided function will run before render once and will be disposed afterwards.
  40383. * A timeout delay can be provided so that the function will be executed in N ms.
  40384. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40385. * @param func The function to be executed.
  40386. * @param timeout optional delay in ms
  40387. */
  40388. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40389. /** @hidden */
  40390. _addPendingData(data: any): void;
  40391. /** @hidden */
  40392. _removePendingData(data: any): void;
  40393. /**
  40394. * Returns the number of items waiting to be loaded
  40395. * @returns the number of items waiting to be loaded
  40396. */
  40397. getWaitingItemsCount(): number;
  40398. /**
  40399. * Returns a boolean indicating if the scene is still loading data
  40400. */
  40401. get isLoading(): boolean;
  40402. /**
  40403. * Registers a function to be executed when the scene is ready
  40404. * @param {Function} func - the function to be executed
  40405. */
  40406. executeWhenReady(func: () => void): void;
  40407. /**
  40408. * Returns a promise that resolves when the scene is ready
  40409. * @returns A promise that resolves when the scene is ready
  40410. */
  40411. whenReadyAsync(): Promise<void>;
  40412. /** @hidden */
  40413. _checkIsReady(): void;
  40414. /**
  40415. * Gets all animatable attached to the scene
  40416. */
  40417. get animatables(): Animatable[];
  40418. /**
  40419. * Resets the last animation time frame.
  40420. * Useful to override when animations start running when loading a scene for the first time.
  40421. */
  40422. resetLastAnimationTimeFrame(): void;
  40423. /**
  40424. * Gets the current view matrix
  40425. * @returns a Matrix
  40426. */
  40427. getViewMatrix(): Matrix;
  40428. /**
  40429. * Gets the current projection matrix
  40430. * @returns a Matrix
  40431. */
  40432. getProjectionMatrix(): Matrix;
  40433. /**
  40434. * Gets the current transform matrix
  40435. * @returns a Matrix made of View * Projection
  40436. */
  40437. getTransformMatrix(): Matrix;
  40438. /**
  40439. * Sets the current transform matrix
  40440. * @param viewL defines the View matrix to use
  40441. * @param projectionL defines the Projection matrix to use
  40442. * @param viewR defines the right View matrix to use (if provided)
  40443. * @param projectionR defines the right Projection matrix to use (if provided)
  40444. */
  40445. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40446. /**
  40447. * Gets the uniform buffer used to store scene data
  40448. * @returns a UniformBuffer
  40449. */
  40450. getSceneUniformBuffer(): UniformBuffer;
  40451. /**
  40452. * Gets an unique (relatively to the current scene) Id
  40453. * @returns an unique number for the scene
  40454. */
  40455. getUniqueId(): number;
  40456. /**
  40457. * Add a mesh to the list of scene's meshes
  40458. * @param newMesh defines the mesh to add
  40459. * @param recursive if all child meshes should also be added to the scene
  40460. */
  40461. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40462. /**
  40463. * Remove a mesh for the list of scene's meshes
  40464. * @param toRemove defines the mesh to remove
  40465. * @param recursive if all child meshes should also be removed from the scene
  40466. * @returns the index where the mesh was in the mesh list
  40467. */
  40468. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40469. /**
  40470. * Add a transform node to the list of scene's transform nodes
  40471. * @param newTransformNode defines the transform node to add
  40472. */
  40473. addTransformNode(newTransformNode: TransformNode): void;
  40474. /**
  40475. * Remove a transform node for the list of scene's transform nodes
  40476. * @param toRemove defines the transform node to remove
  40477. * @returns the index where the transform node was in the transform node list
  40478. */
  40479. removeTransformNode(toRemove: TransformNode): number;
  40480. /**
  40481. * Remove a skeleton for the list of scene's skeletons
  40482. * @param toRemove defines the skeleton to remove
  40483. * @returns the index where the skeleton was in the skeleton list
  40484. */
  40485. removeSkeleton(toRemove: Skeleton): number;
  40486. /**
  40487. * Remove a morph target for the list of scene's morph targets
  40488. * @param toRemove defines the morph target to remove
  40489. * @returns the index where the morph target was in the morph target list
  40490. */
  40491. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40492. /**
  40493. * Remove a light for the list of scene's lights
  40494. * @param toRemove defines the light to remove
  40495. * @returns the index where the light was in the light list
  40496. */
  40497. removeLight(toRemove: Light): number;
  40498. /**
  40499. * Remove a camera for the list of scene's cameras
  40500. * @param toRemove defines the camera to remove
  40501. * @returns the index where the camera was in the camera list
  40502. */
  40503. removeCamera(toRemove: Camera): number;
  40504. /**
  40505. * Remove a particle system for the list of scene's particle systems
  40506. * @param toRemove defines the particle system to remove
  40507. * @returns the index where the particle system was in the particle system list
  40508. */
  40509. removeParticleSystem(toRemove: IParticleSystem): number;
  40510. /**
  40511. * Remove a animation for the list of scene's animations
  40512. * @param toRemove defines the animation to remove
  40513. * @returns the index where the animation was in the animation list
  40514. */
  40515. removeAnimation(toRemove: Animation): number;
  40516. /**
  40517. * Will stop the animation of the given target
  40518. * @param target - the target
  40519. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40520. * @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)
  40521. */
  40522. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40523. /**
  40524. * Removes the given animation group from this scene.
  40525. * @param toRemove The animation group to remove
  40526. * @returns The index of the removed animation group
  40527. */
  40528. removeAnimationGroup(toRemove: AnimationGroup): number;
  40529. /**
  40530. * Removes the given multi-material from this scene.
  40531. * @param toRemove The multi-material to remove
  40532. * @returns The index of the removed multi-material
  40533. */
  40534. removeMultiMaterial(toRemove: MultiMaterial): number;
  40535. /**
  40536. * Removes the given material from this scene.
  40537. * @param toRemove The material to remove
  40538. * @returns The index of the removed material
  40539. */
  40540. removeMaterial(toRemove: Material): number;
  40541. /**
  40542. * Removes the given action manager from this scene.
  40543. * @param toRemove The action manager to remove
  40544. * @returns The index of the removed action manager
  40545. */
  40546. removeActionManager(toRemove: AbstractActionManager): number;
  40547. /**
  40548. * Removes the given texture from this scene.
  40549. * @param toRemove The texture to remove
  40550. * @returns The index of the removed texture
  40551. */
  40552. removeTexture(toRemove: BaseTexture): number;
  40553. /**
  40554. * Adds the given light to this scene
  40555. * @param newLight The light to add
  40556. */
  40557. addLight(newLight: Light): void;
  40558. /**
  40559. * Sorts the list list based on light priorities
  40560. */
  40561. sortLightsByPriority(): void;
  40562. /**
  40563. * Adds the given camera to this scene
  40564. * @param newCamera The camera to add
  40565. */
  40566. addCamera(newCamera: Camera): void;
  40567. /**
  40568. * Adds the given skeleton to this scene
  40569. * @param newSkeleton The skeleton to add
  40570. */
  40571. addSkeleton(newSkeleton: Skeleton): void;
  40572. /**
  40573. * Adds the given particle system to this scene
  40574. * @param newParticleSystem The particle system to add
  40575. */
  40576. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40577. /**
  40578. * Adds the given animation to this scene
  40579. * @param newAnimation The animation to add
  40580. */
  40581. addAnimation(newAnimation: Animation): void;
  40582. /**
  40583. * Adds the given animation group to this scene.
  40584. * @param newAnimationGroup The animation group to add
  40585. */
  40586. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40587. /**
  40588. * Adds the given multi-material to this scene
  40589. * @param newMultiMaterial The multi-material to add
  40590. */
  40591. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40592. /**
  40593. * Adds the given material to this scene
  40594. * @param newMaterial The material to add
  40595. */
  40596. addMaterial(newMaterial: Material): void;
  40597. /**
  40598. * Adds the given morph target to this scene
  40599. * @param newMorphTargetManager The morph target to add
  40600. */
  40601. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40602. /**
  40603. * Adds the given geometry to this scene
  40604. * @param newGeometry The geometry to add
  40605. */
  40606. addGeometry(newGeometry: Geometry): void;
  40607. /**
  40608. * Adds the given action manager to this scene
  40609. * @param newActionManager The action manager to add
  40610. */
  40611. addActionManager(newActionManager: AbstractActionManager): void;
  40612. /**
  40613. * Adds the given texture to this scene.
  40614. * @param newTexture The texture to add
  40615. */
  40616. addTexture(newTexture: BaseTexture): void;
  40617. /**
  40618. * Switch active camera
  40619. * @param newCamera defines the new active camera
  40620. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40621. */
  40622. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40623. /**
  40624. * sets the active camera of the scene using its ID
  40625. * @param id defines the camera's ID
  40626. * @return the new active camera or null if none found.
  40627. */
  40628. setActiveCameraByID(id: string): Nullable<Camera>;
  40629. /**
  40630. * sets the active camera of the scene using its name
  40631. * @param name defines the camera's name
  40632. * @returns the new active camera or null if none found.
  40633. */
  40634. setActiveCameraByName(name: string): Nullable<Camera>;
  40635. /**
  40636. * get an animation group using its name
  40637. * @param name defines the material's name
  40638. * @return the animation group or null if none found.
  40639. */
  40640. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40641. /**
  40642. * Get a material using its unique id
  40643. * @param uniqueId defines the material's unique id
  40644. * @return the material or null if none found.
  40645. */
  40646. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40647. /**
  40648. * get a material using its id
  40649. * @param id defines the material's ID
  40650. * @return the material or null if none found.
  40651. */
  40652. getMaterialByID(id: string): Nullable<Material>;
  40653. /**
  40654. * Gets a the last added material using a given id
  40655. * @param id defines the material's ID
  40656. * @return the last material with the given id or null if none found.
  40657. */
  40658. getLastMaterialByID(id: string): Nullable<Material>;
  40659. /**
  40660. * Gets a material using its name
  40661. * @param name defines the material's name
  40662. * @return the material or null if none found.
  40663. */
  40664. getMaterialByName(name: string): Nullable<Material>;
  40665. /**
  40666. * Get a texture using its unique id
  40667. * @param uniqueId defines the texture's unique id
  40668. * @return the texture or null if none found.
  40669. */
  40670. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40671. /**
  40672. * Gets a camera using its id
  40673. * @param id defines the id to look for
  40674. * @returns the camera or null if not found
  40675. */
  40676. getCameraByID(id: string): Nullable<Camera>;
  40677. /**
  40678. * Gets a camera using its unique id
  40679. * @param uniqueId defines the unique id to look for
  40680. * @returns the camera or null if not found
  40681. */
  40682. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40683. /**
  40684. * Gets a camera using its name
  40685. * @param name defines the camera's name
  40686. * @return the camera or null if none found.
  40687. */
  40688. getCameraByName(name: string): Nullable<Camera>;
  40689. /**
  40690. * Gets a bone using its id
  40691. * @param id defines the bone's id
  40692. * @return the bone or null if not found
  40693. */
  40694. getBoneByID(id: string): Nullable<Bone>;
  40695. /**
  40696. * Gets a bone using its id
  40697. * @param name defines the bone's name
  40698. * @return the bone or null if not found
  40699. */
  40700. getBoneByName(name: string): Nullable<Bone>;
  40701. /**
  40702. * Gets a light node using its name
  40703. * @param name defines the the light's name
  40704. * @return the light or null if none found.
  40705. */
  40706. getLightByName(name: string): Nullable<Light>;
  40707. /**
  40708. * Gets a light node using its id
  40709. * @param id defines the light's id
  40710. * @return the light or null if none found.
  40711. */
  40712. getLightByID(id: string): Nullable<Light>;
  40713. /**
  40714. * Gets a light node using its scene-generated unique ID
  40715. * @param uniqueId defines the light's unique id
  40716. * @return the light or null if none found.
  40717. */
  40718. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40719. /**
  40720. * Gets a particle system by id
  40721. * @param id defines the particle system id
  40722. * @return the corresponding system or null if none found
  40723. */
  40724. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40725. /**
  40726. * Gets a geometry using its ID
  40727. * @param id defines the geometry's id
  40728. * @return the geometry or null if none found.
  40729. */
  40730. getGeometryByID(id: string): Nullable<Geometry>;
  40731. private _getGeometryByUniqueID;
  40732. /**
  40733. * Add a new geometry to this scene
  40734. * @param geometry defines the geometry to be added to the scene.
  40735. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40736. * @return a boolean defining if the geometry was added or not
  40737. */
  40738. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40739. /**
  40740. * Removes an existing geometry
  40741. * @param geometry defines the geometry to be removed from the scene
  40742. * @return a boolean defining if the geometry was removed or not
  40743. */
  40744. removeGeometry(geometry: Geometry): boolean;
  40745. /**
  40746. * Gets the list of geometries attached to the scene
  40747. * @returns an array of Geometry
  40748. */
  40749. getGeometries(): Geometry[];
  40750. /**
  40751. * Gets the first added mesh found of a given ID
  40752. * @param id defines the id to search for
  40753. * @return the mesh found or null if not found at all
  40754. */
  40755. getMeshByID(id: string): Nullable<AbstractMesh>;
  40756. /**
  40757. * Gets a list of meshes using their id
  40758. * @param id defines the id to search for
  40759. * @returns a list of meshes
  40760. */
  40761. getMeshesByID(id: string): Array<AbstractMesh>;
  40762. /**
  40763. * Gets the first added transform node found of a given ID
  40764. * @param id defines the id to search for
  40765. * @return the found transform node or null if not found at all.
  40766. */
  40767. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40768. /**
  40769. * Gets a transform node with its auto-generated unique id
  40770. * @param uniqueId efines the unique id to search for
  40771. * @return the found transform node or null if not found at all.
  40772. */
  40773. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40774. /**
  40775. * Gets a list of transform nodes using their id
  40776. * @param id defines the id to search for
  40777. * @returns a list of transform nodes
  40778. */
  40779. getTransformNodesByID(id: string): Array<TransformNode>;
  40780. /**
  40781. * Gets a mesh with its auto-generated unique id
  40782. * @param uniqueId defines the unique id to search for
  40783. * @return the found mesh or null if not found at all.
  40784. */
  40785. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40786. /**
  40787. * Gets a the last added mesh using a given id
  40788. * @param id defines the id to search for
  40789. * @return the found mesh or null if not found at all.
  40790. */
  40791. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40792. /**
  40793. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40794. * @param id defines the id to search for
  40795. * @return the found node or null if not found at all
  40796. */
  40797. getLastEntryByID(id: string): Nullable<Node>;
  40798. /**
  40799. * Gets a node (Mesh, Camera, Light) using a given id
  40800. * @param id defines the id to search for
  40801. * @return the found node or null if not found at all
  40802. */
  40803. getNodeByID(id: string): Nullable<Node>;
  40804. /**
  40805. * Gets a node (Mesh, Camera, Light) using a given name
  40806. * @param name defines the name to search for
  40807. * @return the found node or null if not found at all.
  40808. */
  40809. getNodeByName(name: string): Nullable<Node>;
  40810. /**
  40811. * Gets a mesh using a given name
  40812. * @param name defines the name to search for
  40813. * @return the found mesh or null if not found at all.
  40814. */
  40815. getMeshByName(name: string): Nullable<AbstractMesh>;
  40816. /**
  40817. * Gets a transform node using a given name
  40818. * @param name defines the name to search for
  40819. * @return the found transform node or null if not found at all.
  40820. */
  40821. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40822. /**
  40823. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40824. * @param id defines the id to search for
  40825. * @return the found skeleton or null if not found at all.
  40826. */
  40827. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40828. /**
  40829. * Gets a skeleton using a given auto generated unique id
  40830. * @param uniqueId defines the unique id to search for
  40831. * @return the found skeleton or null if not found at all.
  40832. */
  40833. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40834. /**
  40835. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40836. * @param id defines the id to search for
  40837. * @return the found skeleton or null if not found at all.
  40838. */
  40839. getSkeletonById(id: string): Nullable<Skeleton>;
  40840. /**
  40841. * Gets a skeleton using a given name
  40842. * @param name defines the name to search for
  40843. * @return the found skeleton or null if not found at all.
  40844. */
  40845. getSkeletonByName(name: string): Nullable<Skeleton>;
  40846. /**
  40847. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40848. * @param id defines the id to search for
  40849. * @return the found morph target manager or null if not found at all.
  40850. */
  40851. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40852. /**
  40853. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40854. * @param id defines the id to search for
  40855. * @return the found morph target or null if not found at all.
  40856. */
  40857. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40858. /**
  40859. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40860. * @param name defines the name to search for
  40861. * @return the found morph target or null if not found at all.
  40862. */
  40863. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40864. /**
  40865. * Gets a post process using a given name (if many are found, this function will pick the first one)
  40866. * @param name defines the name to search for
  40867. * @return the found post process or null if not found at all.
  40868. */
  40869. getPostProcessByName(name: string): Nullable<PostProcess>;
  40870. /**
  40871. * Gets a boolean indicating if the given mesh is active
  40872. * @param mesh defines the mesh to look for
  40873. * @returns true if the mesh is in the active list
  40874. */
  40875. isActiveMesh(mesh: AbstractMesh): boolean;
  40876. /**
  40877. * Return a unique id as a string which can serve as an identifier for the scene
  40878. */
  40879. get uid(): string;
  40880. /**
  40881. * Add an externaly attached data from its key.
  40882. * This method call will fail and return false, if such key already exists.
  40883. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40884. * @param key the unique key that identifies the data
  40885. * @param data the data object to associate to the key for this Engine instance
  40886. * @return true if no such key were already present and the data was added successfully, false otherwise
  40887. */
  40888. addExternalData<T>(key: string, data: T): boolean;
  40889. /**
  40890. * Get an externaly attached data from its key
  40891. * @param key the unique key that identifies the data
  40892. * @return the associated data, if present (can be null), or undefined if not present
  40893. */
  40894. getExternalData<T>(key: string): Nullable<T>;
  40895. /**
  40896. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40897. * @param key the unique key that identifies the data
  40898. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40899. * @return the associated data, can be null if the factory returned null.
  40900. */
  40901. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40902. /**
  40903. * Remove an externaly attached data from the Engine instance
  40904. * @param key the unique key that identifies the data
  40905. * @return true if the data was successfully removed, false if it doesn't exist
  40906. */
  40907. removeExternalData(key: string): boolean;
  40908. private _evaluateSubMesh;
  40909. /**
  40910. * Clear the processed materials smart array preventing retention point in material dispose.
  40911. */
  40912. freeProcessedMaterials(): void;
  40913. private _preventFreeActiveMeshesAndRenderingGroups;
  40914. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40915. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40916. * when disposing several meshes in a row or a hierarchy of meshes.
  40917. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40918. */
  40919. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40920. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40921. /**
  40922. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40923. */
  40924. freeActiveMeshes(): void;
  40925. /**
  40926. * Clear the info related to rendering groups preventing retention points during dispose.
  40927. */
  40928. freeRenderingGroups(): void;
  40929. /** @hidden */
  40930. _isInIntermediateRendering(): boolean;
  40931. /**
  40932. * Lambda returning the list of potentially active meshes.
  40933. */
  40934. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40935. /**
  40936. * Lambda returning the list of potentially active sub meshes.
  40937. */
  40938. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40939. /**
  40940. * Lambda returning the list of potentially intersecting sub meshes.
  40941. */
  40942. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40943. /**
  40944. * Lambda returning the list of potentially colliding sub meshes.
  40945. */
  40946. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40947. private _activeMeshesFrozen;
  40948. private _skipEvaluateActiveMeshesCompletely;
  40949. /**
  40950. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40951. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40952. * @returns the current scene
  40953. */
  40954. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40955. /**
  40956. * Use this function to restart evaluating active meshes on every frame
  40957. * @returns the current scene
  40958. */
  40959. unfreezeActiveMeshes(): Scene;
  40960. private _evaluateActiveMeshes;
  40961. private _activeMesh;
  40962. /**
  40963. * Update the transform matrix to update from the current active camera
  40964. * @param force defines a boolean used to force the update even if cache is up to date
  40965. */
  40966. updateTransformMatrix(force?: boolean): void;
  40967. private _bindFrameBuffer;
  40968. /** @hidden */
  40969. _allowPostProcessClearColor: boolean;
  40970. /** @hidden */
  40971. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40972. private _processSubCameras;
  40973. private _checkIntersections;
  40974. /** @hidden */
  40975. _advancePhysicsEngineStep(step: number): void;
  40976. /**
  40977. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40978. */
  40979. getDeterministicFrameTime: () => number;
  40980. /** @hidden */
  40981. _animate(): void;
  40982. /** Execute all animations (for a frame) */
  40983. animate(): void;
  40984. /**
  40985. * Render the scene
  40986. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40987. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40988. */
  40989. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40990. /**
  40991. * Freeze all materials
  40992. * A frozen material will not be updatable but should be faster to render
  40993. */
  40994. freezeMaterials(): void;
  40995. /**
  40996. * Unfreeze all materials
  40997. * A frozen material will not be updatable but should be faster to render
  40998. */
  40999. unfreezeMaterials(): void;
  41000. /**
  41001. * Releases all held ressources
  41002. */
  41003. dispose(): void;
  41004. /**
  41005. * Gets if the scene is already disposed
  41006. */
  41007. get isDisposed(): boolean;
  41008. /**
  41009. * Call this function to reduce memory footprint of the scene.
  41010. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41011. */
  41012. clearCachedVertexData(): void;
  41013. /**
  41014. * This function will remove the local cached buffer data from texture.
  41015. * It will save memory but will prevent the texture from being rebuilt
  41016. */
  41017. cleanCachedTextureBuffer(): void;
  41018. /**
  41019. * Get the world extend vectors with an optional filter
  41020. *
  41021. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41022. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41023. */
  41024. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41025. min: Vector3;
  41026. max: Vector3;
  41027. };
  41028. /**
  41029. * Creates a ray that can be used to pick in the scene
  41030. * @param x defines the x coordinate of the origin (on-screen)
  41031. * @param y defines the y coordinate of the origin (on-screen)
  41032. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41033. * @param camera defines the camera to use for the picking
  41034. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41035. * @returns a Ray
  41036. */
  41037. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41038. /**
  41039. * Creates a ray that can be used to pick in the scene
  41040. * @param x defines the x coordinate of the origin (on-screen)
  41041. * @param y defines the y coordinate of the origin (on-screen)
  41042. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41043. * @param result defines the ray where to store the picking ray
  41044. * @param camera defines the camera to use for the picking
  41045. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41046. * @returns the current scene
  41047. */
  41048. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41049. /**
  41050. * Creates a ray that can be used to pick in the scene
  41051. * @param x defines the x coordinate of the origin (on-screen)
  41052. * @param y defines the y coordinate of the origin (on-screen)
  41053. * @param camera defines the camera to use for the picking
  41054. * @returns a Ray
  41055. */
  41056. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41057. /**
  41058. * Creates a ray that can be used to pick in the scene
  41059. * @param x defines the x coordinate of the origin (on-screen)
  41060. * @param y defines the y coordinate of the origin (on-screen)
  41061. * @param result defines the ray where to store the picking ray
  41062. * @param camera defines the camera to use for the picking
  41063. * @returns the current scene
  41064. */
  41065. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41066. /** Launch a ray to try to pick a mesh in the scene
  41067. * @param x position on screen
  41068. * @param y position on screen
  41069. * @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
  41070. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41071. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41072. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41073. * @returns a PickingInfo
  41074. */
  41075. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41076. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41077. * @param x position on screen
  41078. * @param y position on screen
  41079. * @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
  41080. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41081. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41082. * @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)
  41083. */
  41084. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41085. /** Use the given ray to pick a mesh in the scene
  41086. * @param ray The ray to use to pick meshes
  41087. * @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
  41088. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41089. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41090. * @returns a PickingInfo
  41091. */
  41092. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41093. /**
  41094. * Launch a ray to try to pick a mesh in the scene
  41095. * @param x X position on screen
  41096. * @param y Y position on screen
  41097. * @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
  41098. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41099. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41100. * @returns an array of PickingInfo
  41101. */
  41102. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41103. /**
  41104. * Launch a ray to try to pick a mesh in the scene
  41105. * @param ray Ray to use
  41106. * @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
  41107. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41108. * @returns an array of PickingInfo
  41109. */
  41110. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41111. /**
  41112. * Force the value of meshUnderPointer
  41113. * @param mesh defines the mesh to use
  41114. * @param pointerId optional pointer id when using more than one pointer
  41115. */
  41116. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  41117. /**
  41118. * Gets the mesh under the pointer
  41119. * @returns a Mesh or null if no mesh is under the pointer
  41120. */
  41121. getPointerOverMesh(): Nullable<AbstractMesh>;
  41122. /** @hidden */
  41123. _rebuildGeometries(): void;
  41124. /** @hidden */
  41125. _rebuildTextures(): void;
  41126. private _getByTags;
  41127. /**
  41128. * Get a list of meshes by tags
  41129. * @param tagsQuery defines the tags query to use
  41130. * @param forEach defines a predicate used to filter results
  41131. * @returns an array of Mesh
  41132. */
  41133. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41134. /**
  41135. * Get a list of cameras by tags
  41136. * @param tagsQuery defines the tags query to use
  41137. * @param forEach defines a predicate used to filter results
  41138. * @returns an array of Camera
  41139. */
  41140. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41141. /**
  41142. * Get a list of lights by tags
  41143. * @param tagsQuery defines the tags query to use
  41144. * @param forEach defines a predicate used to filter results
  41145. * @returns an array of Light
  41146. */
  41147. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41148. /**
  41149. * Get a list of materials by tags
  41150. * @param tagsQuery defines the tags query to use
  41151. * @param forEach defines a predicate used to filter results
  41152. * @returns an array of Material
  41153. */
  41154. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41155. /**
  41156. * Get a list of transform nodes by tags
  41157. * @param tagsQuery defines the tags query to use
  41158. * @param forEach defines a predicate used to filter results
  41159. * @returns an array of TransformNode
  41160. */
  41161. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  41162. /**
  41163. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41164. * This allowed control for front to back rendering or reversly depending of the special needs.
  41165. *
  41166. * @param renderingGroupId The rendering group id corresponding to its index
  41167. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41168. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41169. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41170. */
  41171. 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;
  41172. /**
  41173. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41174. *
  41175. * @param renderingGroupId The rendering group id corresponding to its index
  41176. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41177. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41178. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41179. */
  41180. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41181. /**
  41182. * Gets the current auto clear configuration for one rendering group of the rendering
  41183. * manager.
  41184. * @param index the rendering group index to get the information for
  41185. * @returns The auto clear setup for the requested rendering group
  41186. */
  41187. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41188. private _blockMaterialDirtyMechanism;
  41189. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41190. get blockMaterialDirtyMechanism(): boolean;
  41191. set blockMaterialDirtyMechanism(value: boolean);
  41192. /**
  41193. * Will flag all materials as dirty to trigger new shader compilation
  41194. * @param flag defines the flag used to specify which material part must be marked as dirty
  41195. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41196. */
  41197. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41198. /** @hidden */
  41199. _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;
  41200. /** @hidden */
  41201. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41202. /** @hidden */
  41203. _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;
  41204. /** @hidden */
  41205. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41206. /** @hidden */
  41207. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41208. /** @hidden */
  41209. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41210. }
  41211. }
  41212. declare module BABYLON {
  41213. /**
  41214. * Set of assets to keep when moving a scene into an asset container.
  41215. */
  41216. export class KeepAssets extends AbstractScene {
  41217. }
  41218. /**
  41219. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41220. */
  41221. export class InstantiatedEntries {
  41222. /**
  41223. * List of new root nodes (eg. nodes with no parent)
  41224. */
  41225. rootNodes: TransformNode[];
  41226. /**
  41227. * List of new skeletons
  41228. */
  41229. skeletons: Skeleton[];
  41230. /**
  41231. * List of new animation groups
  41232. */
  41233. animationGroups: AnimationGroup[];
  41234. }
  41235. /**
  41236. * Container with a set of assets that can be added or removed from a scene.
  41237. */
  41238. export class AssetContainer extends AbstractScene {
  41239. private _wasAddedToScene;
  41240. /**
  41241. * The scene the AssetContainer belongs to.
  41242. */
  41243. scene: Scene;
  41244. /**
  41245. * Instantiates an AssetContainer.
  41246. * @param scene The scene the AssetContainer belongs to.
  41247. */
  41248. constructor(scene: Scene);
  41249. /**
  41250. * Instantiate or clone all meshes and add the new ones to the scene.
  41251. * Skeletons and animation groups will all be cloned
  41252. * @param nameFunction defines an optional function used to get new names for clones
  41253. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41254. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41255. */
  41256. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41257. /**
  41258. * Adds all the assets from the container to the scene.
  41259. */
  41260. addAllToScene(): void;
  41261. /**
  41262. * Removes all the assets in the container from the scene
  41263. */
  41264. removeAllFromScene(): void;
  41265. /**
  41266. * Disposes all the assets in the container
  41267. */
  41268. dispose(): void;
  41269. private _moveAssets;
  41270. /**
  41271. * Removes all the assets contained in the scene and adds them to the container.
  41272. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41273. */
  41274. moveAllFromScene(keepAssets?: KeepAssets): void;
  41275. /**
  41276. * 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.
  41277. * @returns the root mesh
  41278. */
  41279. createRootMesh(): Mesh;
  41280. /**
  41281. * Merge animations (direct and animation groups) from this asset container into a scene
  41282. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41283. * @param animatables set of animatables to retarget to a node from the scene
  41284. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41285. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41286. */
  41287. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41288. }
  41289. }
  41290. declare module BABYLON {
  41291. /**
  41292. * Defines how the parser contract is defined.
  41293. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41294. */
  41295. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41296. /**
  41297. * Defines how the individual parser contract is defined.
  41298. * These parser can parse an individual asset
  41299. */
  41300. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41301. /**
  41302. * Base class of the scene acting as a container for the different elements composing a scene.
  41303. * This class is dynamically extended by the different components of the scene increasing
  41304. * flexibility and reducing coupling
  41305. */
  41306. export abstract class AbstractScene {
  41307. /**
  41308. * Stores the list of available parsers in the application.
  41309. */
  41310. private static _BabylonFileParsers;
  41311. /**
  41312. * Stores the list of available individual parsers in the application.
  41313. */
  41314. private static _IndividualBabylonFileParsers;
  41315. /**
  41316. * Adds a parser in the list of available ones
  41317. * @param name Defines the name of the parser
  41318. * @param parser Defines the parser to add
  41319. */
  41320. static AddParser(name: string, parser: BabylonFileParser): void;
  41321. /**
  41322. * Gets a general parser from the list of avaialble ones
  41323. * @param name Defines the name of the parser
  41324. * @returns the requested parser or null
  41325. */
  41326. static GetParser(name: string): Nullable<BabylonFileParser>;
  41327. /**
  41328. * Adds n individual parser in the list of available ones
  41329. * @param name Defines the name of the parser
  41330. * @param parser Defines the parser to add
  41331. */
  41332. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41333. /**
  41334. * Gets an individual parser from the list of avaialble ones
  41335. * @param name Defines the name of the parser
  41336. * @returns the requested parser or null
  41337. */
  41338. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41339. /**
  41340. * Parser json data and populate both a scene and its associated container object
  41341. * @param jsonData Defines the data to parse
  41342. * @param scene Defines the scene to parse the data for
  41343. * @param container Defines the container attached to the parsing sequence
  41344. * @param rootUrl Defines the root url of the data
  41345. */
  41346. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41347. /**
  41348. * Gets the list of root nodes (ie. nodes with no parent)
  41349. */
  41350. rootNodes: Node[];
  41351. /** All of the cameras added to this scene
  41352. * @see https://doc.babylonjs.com/babylon101/cameras
  41353. */
  41354. cameras: Camera[];
  41355. /**
  41356. * All of the lights added to this scene
  41357. * @see https://doc.babylonjs.com/babylon101/lights
  41358. */
  41359. lights: Light[];
  41360. /**
  41361. * All of the (abstract) meshes added to this scene
  41362. */
  41363. meshes: AbstractMesh[];
  41364. /**
  41365. * The list of skeletons added to the scene
  41366. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41367. */
  41368. skeletons: Skeleton[];
  41369. /**
  41370. * All of the particle systems added to this scene
  41371. * @see https://doc.babylonjs.com/babylon101/particles
  41372. */
  41373. particleSystems: IParticleSystem[];
  41374. /**
  41375. * Gets a list of Animations associated with the scene
  41376. */
  41377. animations: Animation[];
  41378. /**
  41379. * All of the animation groups added to this scene
  41380. * @see https://doc.babylonjs.com/how_to/group
  41381. */
  41382. animationGroups: AnimationGroup[];
  41383. /**
  41384. * All of the multi-materials added to this scene
  41385. * @see https://doc.babylonjs.com/how_to/multi_materials
  41386. */
  41387. multiMaterials: MultiMaterial[];
  41388. /**
  41389. * All of the materials added to this scene
  41390. * In the context of a Scene, it is not supposed to be modified manually.
  41391. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41392. * Note also that the order of the Material within the array is not significant and might change.
  41393. * @see https://doc.babylonjs.com/babylon101/materials
  41394. */
  41395. materials: Material[];
  41396. /**
  41397. * The list of morph target managers added to the scene
  41398. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41399. */
  41400. morphTargetManagers: MorphTargetManager[];
  41401. /**
  41402. * The list of geometries used in the scene.
  41403. */
  41404. geometries: Geometry[];
  41405. /**
  41406. * All of the tranform nodes added to this scene
  41407. * In the context of a Scene, it is not supposed to be modified manually.
  41408. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41409. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41410. * @see https://doc.babylonjs.com/how_to/transformnode
  41411. */
  41412. transformNodes: TransformNode[];
  41413. /**
  41414. * ActionManagers available on the scene.
  41415. */
  41416. actionManagers: AbstractActionManager[];
  41417. /**
  41418. * Textures to keep.
  41419. */
  41420. textures: BaseTexture[];
  41421. /** @hidden */
  41422. protected _environmentTexture: Nullable<BaseTexture>;
  41423. /**
  41424. * Texture used in all pbr material as the reflection texture.
  41425. * As in the majority of the scene they are the same (exception for multi room and so on),
  41426. * this is easier to reference from here than from all the materials.
  41427. */
  41428. get environmentTexture(): Nullable<BaseTexture>;
  41429. set environmentTexture(value: Nullable<BaseTexture>);
  41430. /**
  41431. * The list of postprocesses added to the scene
  41432. */
  41433. postProcesses: PostProcess[];
  41434. /**
  41435. * @returns all meshes, lights, cameras, transformNodes and bones
  41436. */
  41437. getNodes(): Array<Node>;
  41438. }
  41439. }
  41440. declare module BABYLON {
  41441. /**
  41442. * Interface used to define options for Sound class
  41443. */
  41444. export interface ISoundOptions {
  41445. /**
  41446. * Does the sound autoplay once loaded.
  41447. */
  41448. autoplay?: boolean;
  41449. /**
  41450. * Does the sound loop after it finishes playing once.
  41451. */
  41452. loop?: boolean;
  41453. /**
  41454. * Sound's volume
  41455. */
  41456. volume?: number;
  41457. /**
  41458. * Is it a spatial sound?
  41459. */
  41460. spatialSound?: boolean;
  41461. /**
  41462. * Maximum distance to hear that sound
  41463. */
  41464. maxDistance?: number;
  41465. /**
  41466. * Uses user defined attenuation function
  41467. */
  41468. useCustomAttenuation?: boolean;
  41469. /**
  41470. * Define the roll off factor of spatial sounds.
  41471. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41472. */
  41473. rolloffFactor?: number;
  41474. /**
  41475. * Define the reference distance the sound should be heard perfectly.
  41476. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41477. */
  41478. refDistance?: number;
  41479. /**
  41480. * Define the distance attenuation model the sound will follow.
  41481. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41482. */
  41483. distanceModel?: string;
  41484. /**
  41485. * Defines the playback speed (1 by default)
  41486. */
  41487. playbackRate?: number;
  41488. /**
  41489. * Defines if the sound is from a streaming source
  41490. */
  41491. streaming?: boolean;
  41492. /**
  41493. * Defines an optional length (in seconds) inside the sound file
  41494. */
  41495. length?: number;
  41496. /**
  41497. * Defines an optional offset (in seconds) inside the sound file
  41498. */
  41499. offset?: number;
  41500. /**
  41501. * If true, URLs will not be required to state the audio file codec to use.
  41502. */
  41503. skipCodecCheck?: boolean;
  41504. }
  41505. /**
  41506. * Defines a sound that can be played in the application.
  41507. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41508. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41509. */
  41510. export class Sound {
  41511. /**
  41512. * The name of the sound in the scene.
  41513. */
  41514. name: string;
  41515. /**
  41516. * Does the sound autoplay once loaded.
  41517. */
  41518. autoplay: boolean;
  41519. /**
  41520. * Does the sound loop after it finishes playing once.
  41521. */
  41522. loop: boolean;
  41523. /**
  41524. * Does the sound use a custom attenuation curve to simulate the falloff
  41525. * happening when the source gets further away from the camera.
  41526. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41527. */
  41528. useCustomAttenuation: boolean;
  41529. /**
  41530. * The sound track id this sound belongs to.
  41531. */
  41532. soundTrackId: number;
  41533. /**
  41534. * Is this sound currently played.
  41535. */
  41536. isPlaying: boolean;
  41537. /**
  41538. * Is this sound currently paused.
  41539. */
  41540. isPaused: boolean;
  41541. /**
  41542. * Does this sound enables spatial sound.
  41543. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41544. */
  41545. spatialSound: boolean;
  41546. /**
  41547. * Define the reference distance the sound should be heard perfectly.
  41548. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41549. */
  41550. refDistance: number;
  41551. /**
  41552. * Define the roll off factor of spatial sounds.
  41553. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41554. */
  41555. rolloffFactor: number;
  41556. /**
  41557. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41558. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41559. */
  41560. maxDistance: number;
  41561. /**
  41562. * Define the distance attenuation model the sound will follow.
  41563. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41564. */
  41565. distanceModel: string;
  41566. /**
  41567. * @hidden
  41568. * Back Compat
  41569. **/
  41570. onended: () => any;
  41571. /**
  41572. * Gets or sets an object used to store user defined information for the sound.
  41573. */
  41574. metadata: any;
  41575. /**
  41576. * Observable event when the current playing sound finishes.
  41577. */
  41578. onEndedObservable: Observable<Sound>;
  41579. private _panningModel;
  41580. private _playbackRate;
  41581. private _streaming;
  41582. private _startTime;
  41583. private _startOffset;
  41584. private _position;
  41585. /** @hidden */
  41586. _positionInEmitterSpace: boolean;
  41587. private _localDirection;
  41588. private _volume;
  41589. private _isReadyToPlay;
  41590. private _isDirectional;
  41591. private _readyToPlayCallback;
  41592. private _audioBuffer;
  41593. private _soundSource;
  41594. private _streamingSource;
  41595. private _soundPanner;
  41596. private _soundGain;
  41597. private _inputAudioNode;
  41598. private _outputAudioNode;
  41599. private _coneInnerAngle;
  41600. private _coneOuterAngle;
  41601. private _coneOuterGain;
  41602. private _scene;
  41603. private _connectedTransformNode;
  41604. private _customAttenuationFunction;
  41605. private _registerFunc;
  41606. private _isOutputConnected;
  41607. private _htmlAudioElement;
  41608. private _urlType;
  41609. private _length?;
  41610. private _offset?;
  41611. /** @hidden */
  41612. static _SceneComponentInitialization: (scene: Scene) => void;
  41613. /**
  41614. * Create a sound and attach it to a scene
  41615. * @param name Name of your sound
  41616. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41617. * @param scene defines the scene the sound belongs to
  41618. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41619. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41620. */
  41621. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41622. /**
  41623. * Release the sound and its associated resources
  41624. */
  41625. dispose(): void;
  41626. /**
  41627. * Gets if the sounds is ready to be played or not.
  41628. * @returns true if ready, otherwise false
  41629. */
  41630. isReady(): boolean;
  41631. private _soundLoaded;
  41632. /**
  41633. * Sets the data of the sound from an audiobuffer
  41634. * @param audioBuffer The audioBuffer containing the data
  41635. */
  41636. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41637. /**
  41638. * Updates the current sounds options such as maxdistance, loop...
  41639. * @param options A JSON object containing values named as the object properties
  41640. */
  41641. updateOptions(options: ISoundOptions): void;
  41642. private _createSpatialParameters;
  41643. private _updateSpatialParameters;
  41644. /**
  41645. * Switch the panning model to HRTF:
  41646. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41647. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41648. */
  41649. switchPanningModelToHRTF(): void;
  41650. /**
  41651. * Switch the panning model to Equal Power:
  41652. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41653. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41654. */
  41655. switchPanningModelToEqualPower(): void;
  41656. private _switchPanningModel;
  41657. /**
  41658. * Connect this sound to a sound track audio node like gain...
  41659. * @param soundTrackAudioNode the sound track audio node to connect to
  41660. */
  41661. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41662. /**
  41663. * Transform this sound into a directional source
  41664. * @param coneInnerAngle Size of the inner cone in degree
  41665. * @param coneOuterAngle Size of the outer cone in degree
  41666. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41667. */
  41668. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41669. /**
  41670. * Gets or sets the inner angle for the directional cone.
  41671. */
  41672. get directionalConeInnerAngle(): number;
  41673. /**
  41674. * Gets or sets the inner angle for the directional cone.
  41675. */
  41676. set directionalConeInnerAngle(value: number);
  41677. /**
  41678. * Gets or sets the outer angle for the directional cone.
  41679. */
  41680. get directionalConeOuterAngle(): number;
  41681. /**
  41682. * Gets or sets the outer angle for the directional cone.
  41683. */
  41684. set directionalConeOuterAngle(value: number);
  41685. /**
  41686. * Sets the position of the emitter if spatial sound is enabled
  41687. * @param newPosition Defines the new posisiton
  41688. */
  41689. setPosition(newPosition: Vector3): void;
  41690. /**
  41691. * Sets the local direction of the emitter if spatial sound is enabled
  41692. * @param newLocalDirection Defines the new local direction
  41693. */
  41694. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41695. private _updateDirection;
  41696. /** @hidden */
  41697. updateDistanceFromListener(): void;
  41698. /**
  41699. * Sets a new custom attenuation function for the sound.
  41700. * @param callback Defines the function used for the attenuation
  41701. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41702. */
  41703. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41704. /**
  41705. * Play the sound
  41706. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41707. * @param offset (optional) Start the sound at a specific time in seconds
  41708. * @param length (optional) Sound duration (in seconds)
  41709. */
  41710. play(time?: number, offset?: number, length?: number): void;
  41711. private _onended;
  41712. /**
  41713. * Stop the sound
  41714. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41715. */
  41716. stop(time?: number): void;
  41717. /**
  41718. * Put the sound in pause
  41719. */
  41720. pause(): void;
  41721. /**
  41722. * Sets a dedicated volume for this sounds
  41723. * @param newVolume Define the new volume of the sound
  41724. * @param time Define time for gradual change to new volume
  41725. */
  41726. setVolume(newVolume: number, time?: number): void;
  41727. /**
  41728. * Set the sound play back rate
  41729. * @param newPlaybackRate Define the playback rate the sound should be played at
  41730. */
  41731. setPlaybackRate(newPlaybackRate: number): void;
  41732. /**
  41733. * Gets the volume of the sound.
  41734. * @returns the volume of the sound
  41735. */
  41736. getVolume(): number;
  41737. /**
  41738. * Attach the sound to a dedicated mesh
  41739. * @param transformNode The transform node to connect the sound with
  41740. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41741. */
  41742. attachToMesh(transformNode: TransformNode): void;
  41743. /**
  41744. * Detach the sound from the previously attached mesh
  41745. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41746. */
  41747. detachFromMesh(): void;
  41748. private _onRegisterAfterWorldMatrixUpdate;
  41749. /**
  41750. * Clone the current sound in the scene.
  41751. * @returns the new sound clone
  41752. */
  41753. clone(): Nullable<Sound>;
  41754. /**
  41755. * Gets the current underlying audio buffer containing the data
  41756. * @returns the audio buffer
  41757. */
  41758. getAudioBuffer(): Nullable<AudioBuffer>;
  41759. /**
  41760. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41761. * @returns the source node
  41762. */
  41763. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41764. /**
  41765. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41766. * @returns the gain node
  41767. */
  41768. getSoundGain(): Nullable<GainNode>;
  41769. /**
  41770. * Serializes the Sound in a JSON representation
  41771. * @returns the JSON representation of the sound
  41772. */
  41773. serialize(): any;
  41774. /**
  41775. * Parse a JSON representation of a sound to innstantiate in a given scene
  41776. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41777. * @param scene Define the scene the new parsed sound should be created in
  41778. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41779. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41780. * @returns the newly parsed sound
  41781. */
  41782. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41783. }
  41784. }
  41785. declare module BABYLON {
  41786. /**
  41787. * This defines an action helpful to play a defined sound on a triggered action.
  41788. */
  41789. export class PlaySoundAction extends Action {
  41790. private _sound;
  41791. /**
  41792. * Instantiate the action
  41793. * @param triggerOptions defines the trigger options
  41794. * @param sound defines the sound to play
  41795. * @param condition defines the trigger related conditions
  41796. */
  41797. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41798. /** @hidden */
  41799. _prepare(): void;
  41800. /**
  41801. * Execute the action and play the sound.
  41802. */
  41803. execute(): void;
  41804. /**
  41805. * Serializes the actions and its related information.
  41806. * @param parent defines the object to serialize in
  41807. * @returns the serialized object
  41808. */
  41809. serialize(parent: any): any;
  41810. }
  41811. /**
  41812. * This defines an action helpful to stop a defined sound on a triggered action.
  41813. */
  41814. export class StopSoundAction extends Action {
  41815. private _sound;
  41816. /**
  41817. * Instantiate the action
  41818. * @param triggerOptions defines the trigger options
  41819. * @param sound defines the sound to stop
  41820. * @param condition defines the trigger related conditions
  41821. */
  41822. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41823. /** @hidden */
  41824. _prepare(): void;
  41825. /**
  41826. * Execute the action and stop the sound.
  41827. */
  41828. execute(): void;
  41829. /**
  41830. * Serializes the actions and its related information.
  41831. * @param parent defines the object to serialize in
  41832. * @returns the serialized object
  41833. */
  41834. serialize(parent: any): any;
  41835. }
  41836. }
  41837. declare module BABYLON {
  41838. /**
  41839. * This defines an action responsible to change the value of a property
  41840. * by interpolating between its current value and the newly set one once triggered.
  41841. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41842. */
  41843. export class InterpolateValueAction extends Action {
  41844. /**
  41845. * Defines the path of the property where the value should be interpolated
  41846. */
  41847. propertyPath: string;
  41848. /**
  41849. * Defines the target value at the end of the interpolation.
  41850. */
  41851. value: any;
  41852. /**
  41853. * Defines the time it will take for the property to interpolate to the value.
  41854. */
  41855. duration: number;
  41856. /**
  41857. * Defines if the other scene animations should be stopped when the action has been triggered
  41858. */
  41859. stopOtherAnimations?: boolean;
  41860. /**
  41861. * Defines a callback raised once the interpolation animation has been done.
  41862. */
  41863. onInterpolationDone?: () => void;
  41864. /**
  41865. * Observable triggered once the interpolation animation has been done.
  41866. */
  41867. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41868. private _target;
  41869. private _effectiveTarget;
  41870. private _property;
  41871. /**
  41872. * Instantiate the action
  41873. * @param triggerOptions defines the trigger options
  41874. * @param target defines the object containing the value to interpolate
  41875. * @param propertyPath defines the path to the property in the target object
  41876. * @param value defines the target value at the end of the interpolation
  41877. * @param duration deines the time it will take for the property to interpolate to the value.
  41878. * @param condition defines the trigger related conditions
  41879. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41880. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41881. */
  41882. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41883. /** @hidden */
  41884. _prepare(): void;
  41885. /**
  41886. * Execute the action starts the value interpolation.
  41887. */
  41888. execute(): void;
  41889. /**
  41890. * Serializes the actions and its related information.
  41891. * @param parent defines the object to serialize in
  41892. * @returns the serialized object
  41893. */
  41894. serialize(parent: any): any;
  41895. }
  41896. }
  41897. declare module BABYLON {
  41898. /**
  41899. * Options allowed during the creation of a sound track.
  41900. */
  41901. export interface ISoundTrackOptions {
  41902. /**
  41903. * The volume the sound track should take during creation
  41904. */
  41905. volume?: number;
  41906. /**
  41907. * Define if the sound track is the main sound track of the scene
  41908. */
  41909. mainTrack?: boolean;
  41910. }
  41911. /**
  41912. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41913. * It will be also used in a future release to apply effects on a specific track.
  41914. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41915. */
  41916. export class SoundTrack {
  41917. /**
  41918. * The unique identifier of the sound track in the scene.
  41919. */
  41920. id: number;
  41921. /**
  41922. * The list of sounds included in the sound track.
  41923. */
  41924. soundCollection: Array<Sound>;
  41925. private _outputAudioNode;
  41926. private _scene;
  41927. private _connectedAnalyser;
  41928. private _options;
  41929. private _isInitialized;
  41930. /**
  41931. * Creates a new sound track.
  41932. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41933. * @param scene Define the scene the sound track belongs to
  41934. * @param options
  41935. */
  41936. constructor(scene: Scene, options?: ISoundTrackOptions);
  41937. private _initializeSoundTrackAudioGraph;
  41938. /**
  41939. * Release the sound track and its associated resources
  41940. */
  41941. dispose(): void;
  41942. /**
  41943. * Adds a sound to this sound track
  41944. * @param sound define the cound to add
  41945. * @ignoreNaming
  41946. */
  41947. AddSound(sound: Sound): void;
  41948. /**
  41949. * Removes a sound to this sound track
  41950. * @param sound define the cound to remove
  41951. * @ignoreNaming
  41952. */
  41953. RemoveSound(sound: Sound): void;
  41954. /**
  41955. * Set a global volume for the full sound track.
  41956. * @param newVolume Define the new volume of the sound track
  41957. */
  41958. setVolume(newVolume: number): void;
  41959. /**
  41960. * Switch the panning model to HRTF:
  41961. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41962. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41963. */
  41964. switchPanningModelToHRTF(): void;
  41965. /**
  41966. * Switch the panning model to Equal Power:
  41967. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41968. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41969. */
  41970. switchPanningModelToEqualPower(): void;
  41971. /**
  41972. * Connect the sound track to an audio analyser allowing some amazing
  41973. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41974. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41975. * @param analyser The analyser to connect to the engine
  41976. */
  41977. connectToAnalyser(analyser: Analyser): void;
  41978. }
  41979. }
  41980. declare module BABYLON {
  41981. interface AbstractScene {
  41982. /**
  41983. * The list of sounds used in the scene.
  41984. */
  41985. sounds: Nullable<Array<Sound>>;
  41986. }
  41987. interface Scene {
  41988. /**
  41989. * @hidden
  41990. * Backing field
  41991. */
  41992. _mainSoundTrack: SoundTrack;
  41993. /**
  41994. * The main sound track played by the scene.
  41995. * It cotains your primary collection of sounds.
  41996. */
  41997. mainSoundTrack: SoundTrack;
  41998. /**
  41999. * The list of sound tracks added to the scene
  42000. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42001. */
  42002. soundTracks: Nullable<Array<SoundTrack>>;
  42003. /**
  42004. * Gets a sound using a given name
  42005. * @param name defines the name to search for
  42006. * @return the found sound or null if not found at all.
  42007. */
  42008. getSoundByName(name: string): Nullable<Sound>;
  42009. /**
  42010. * Gets or sets if audio support is enabled
  42011. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42012. */
  42013. audioEnabled: boolean;
  42014. /**
  42015. * Gets or sets if audio will be output to headphones
  42016. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42017. */
  42018. headphone: boolean;
  42019. /**
  42020. * Gets or sets custom audio listener position provider
  42021. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42022. */
  42023. audioListenerPositionProvider: Nullable<() => Vector3>;
  42024. /**
  42025. * Gets or sets a refresh rate when using 3D audio positioning
  42026. */
  42027. audioPositioningRefreshRate: number;
  42028. }
  42029. /**
  42030. * Defines the sound scene component responsible to manage any sounds
  42031. * in a given scene.
  42032. */
  42033. export class AudioSceneComponent implements ISceneSerializableComponent {
  42034. /**
  42035. * The component name helpfull to identify the component in the list of scene components.
  42036. */
  42037. readonly name: string;
  42038. /**
  42039. * The scene the component belongs to.
  42040. */
  42041. scene: Scene;
  42042. private _audioEnabled;
  42043. /**
  42044. * Gets whether audio is enabled or not.
  42045. * Please use related enable/disable method to switch state.
  42046. */
  42047. get audioEnabled(): boolean;
  42048. private _headphone;
  42049. /**
  42050. * Gets whether audio is outputing to headphone or not.
  42051. * Please use the according Switch methods to change output.
  42052. */
  42053. get headphone(): boolean;
  42054. /**
  42055. * Gets or sets a refresh rate when using 3D audio positioning
  42056. */
  42057. audioPositioningRefreshRate: number;
  42058. private _audioListenerPositionProvider;
  42059. /**
  42060. * Gets the current audio listener position provider
  42061. */
  42062. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42063. /**
  42064. * Sets a custom listener position for all sounds in the scene
  42065. * By default, this is the position of the first active camera
  42066. */
  42067. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42068. /**
  42069. * Creates a new instance of the component for the given scene
  42070. * @param scene Defines the scene to register the component in
  42071. */
  42072. constructor(scene: Scene);
  42073. /**
  42074. * Registers the component in a given scene
  42075. */
  42076. register(): void;
  42077. /**
  42078. * Rebuilds the elements related to this component in case of
  42079. * context lost for instance.
  42080. */
  42081. rebuild(): void;
  42082. /**
  42083. * Serializes the component data to the specified json object
  42084. * @param serializationObject The object to serialize to
  42085. */
  42086. serialize(serializationObject: any): void;
  42087. /**
  42088. * Adds all the elements from the container to the scene
  42089. * @param container the container holding the elements
  42090. */
  42091. addFromContainer(container: AbstractScene): void;
  42092. /**
  42093. * Removes all the elements in the container from the scene
  42094. * @param container contains the elements to remove
  42095. * @param dispose if the removed element should be disposed (default: false)
  42096. */
  42097. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42098. /**
  42099. * Disposes the component and the associated ressources.
  42100. */
  42101. dispose(): void;
  42102. /**
  42103. * Disables audio in the associated scene.
  42104. */
  42105. disableAudio(): void;
  42106. /**
  42107. * Enables audio in the associated scene.
  42108. */
  42109. enableAudio(): void;
  42110. /**
  42111. * Switch audio to headphone output.
  42112. */
  42113. switchAudioModeForHeadphones(): void;
  42114. /**
  42115. * Switch audio to normal speakers.
  42116. */
  42117. switchAudioModeForNormalSpeakers(): void;
  42118. private _cachedCameraDirection;
  42119. private _cachedCameraPosition;
  42120. private _lastCheck;
  42121. private _afterRender;
  42122. }
  42123. }
  42124. declare module BABYLON {
  42125. /**
  42126. * Wraps one or more Sound objects and selects one with random weight for playback.
  42127. */
  42128. export class WeightedSound {
  42129. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42130. loop: boolean;
  42131. private _coneInnerAngle;
  42132. private _coneOuterAngle;
  42133. private _volume;
  42134. /** A Sound is currently playing. */
  42135. isPlaying: boolean;
  42136. /** A Sound is currently paused. */
  42137. isPaused: boolean;
  42138. private _sounds;
  42139. private _weights;
  42140. private _currentIndex?;
  42141. /**
  42142. * Creates a new WeightedSound from the list of sounds given.
  42143. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42144. * @param sounds Array of Sounds that will be selected from.
  42145. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42146. */
  42147. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42148. /**
  42149. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42150. */
  42151. get directionalConeInnerAngle(): number;
  42152. /**
  42153. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42154. */
  42155. set directionalConeInnerAngle(value: number);
  42156. /**
  42157. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42158. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42159. */
  42160. get directionalConeOuterAngle(): number;
  42161. /**
  42162. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42163. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42164. */
  42165. set directionalConeOuterAngle(value: number);
  42166. /**
  42167. * Playback volume.
  42168. */
  42169. get volume(): number;
  42170. /**
  42171. * Playback volume.
  42172. */
  42173. set volume(value: number);
  42174. private _onended;
  42175. /**
  42176. * Suspend playback
  42177. */
  42178. pause(): void;
  42179. /**
  42180. * Stop playback
  42181. */
  42182. stop(): void;
  42183. /**
  42184. * Start playback.
  42185. * @param startOffset Position the clip head at a specific time in seconds.
  42186. */
  42187. play(startOffset?: number): void;
  42188. }
  42189. }
  42190. declare module BABYLON {
  42191. /**
  42192. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42193. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42194. */
  42195. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42196. /**
  42197. * Gets the name of the behavior.
  42198. */
  42199. get name(): string;
  42200. /**
  42201. * The easing function used by animations
  42202. */
  42203. static EasingFunction: BackEase;
  42204. /**
  42205. * The easing mode used by animations
  42206. */
  42207. static EasingMode: number;
  42208. /**
  42209. * The duration of the animation, in milliseconds
  42210. */
  42211. transitionDuration: number;
  42212. /**
  42213. * Length of the distance animated by the transition when lower radius is reached
  42214. */
  42215. lowerRadiusTransitionRange: number;
  42216. /**
  42217. * Length of the distance animated by the transition when upper radius is reached
  42218. */
  42219. upperRadiusTransitionRange: number;
  42220. private _autoTransitionRange;
  42221. /**
  42222. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42223. */
  42224. get autoTransitionRange(): boolean;
  42225. /**
  42226. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42227. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42228. */
  42229. set autoTransitionRange(value: boolean);
  42230. private _attachedCamera;
  42231. private _onAfterCheckInputsObserver;
  42232. private _onMeshTargetChangedObserver;
  42233. /**
  42234. * Initializes the behavior.
  42235. */
  42236. init(): void;
  42237. /**
  42238. * Attaches the behavior to its arc rotate camera.
  42239. * @param camera Defines the camera to attach the behavior to
  42240. */
  42241. attach(camera: ArcRotateCamera): void;
  42242. /**
  42243. * Detaches the behavior from its current arc rotate camera.
  42244. */
  42245. detach(): void;
  42246. private _radiusIsAnimating;
  42247. private _radiusBounceTransition;
  42248. private _animatables;
  42249. private _cachedWheelPrecision;
  42250. /**
  42251. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42252. * @param radiusLimit The limit to check against.
  42253. * @return Bool to indicate if at limit.
  42254. */
  42255. private _isRadiusAtLimit;
  42256. /**
  42257. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42258. * @param radiusDelta The delta by which to animate to. Can be negative.
  42259. */
  42260. private _applyBoundRadiusAnimation;
  42261. /**
  42262. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42263. */
  42264. protected _clearAnimationLocks(): void;
  42265. /**
  42266. * Stops and removes all animations that have been applied to the camera
  42267. */
  42268. stopAllAnimations(): void;
  42269. }
  42270. }
  42271. declare module BABYLON {
  42272. /**
  42273. * 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.
  42274. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42275. */
  42276. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42277. /**
  42278. * Gets the name of the behavior.
  42279. */
  42280. get name(): string;
  42281. private _mode;
  42282. private _radiusScale;
  42283. private _positionScale;
  42284. private _defaultElevation;
  42285. private _elevationReturnTime;
  42286. private _elevationReturnWaitTime;
  42287. private _zoomStopsAnimation;
  42288. private _framingTime;
  42289. /**
  42290. * The easing function used by animations
  42291. */
  42292. static EasingFunction: ExponentialEase;
  42293. /**
  42294. * The easing mode used by animations
  42295. */
  42296. static EasingMode: number;
  42297. /**
  42298. * Sets the current mode used by the behavior
  42299. */
  42300. set mode(mode: number);
  42301. /**
  42302. * Gets current mode used by the behavior.
  42303. */
  42304. get mode(): number;
  42305. /**
  42306. * Sets the scale applied to the radius (1 by default)
  42307. */
  42308. set radiusScale(radius: number);
  42309. /**
  42310. * Gets the scale applied to the radius
  42311. */
  42312. get radiusScale(): number;
  42313. /**
  42314. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42315. */
  42316. set positionScale(scale: number);
  42317. /**
  42318. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42319. */
  42320. get positionScale(): number;
  42321. /**
  42322. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42323. * behaviour is triggered, in radians.
  42324. */
  42325. set defaultElevation(elevation: number);
  42326. /**
  42327. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42328. * behaviour is triggered, in radians.
  42329. */
  42330. get defaultElevation(): number;
  42331. /**
  42332. * Sets the time (in milliseconds) taken to return to the default beta position.
  42333. * Negative value indicates camera should not return to default.
  42334. */
  42335. set elevationReturnTime(speed: number);
  42336. /**
  42337. * Gets the time (in milliseconds) taken to return to the default beta position.
  42338. * Negative value indicates camera should not return to default.
  42339. */
  42340. get elevationReturnTime(): number;
  42341. /**
  42342. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42343. */
  42344. set elevationReturnWaitTime(time: number);
  42345. /**
  42346. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42347. */
  42348. get elevationReturnWaitTime(): number;
  42349. /**
  42350. * Sets the flag that indicates if user zooming should stop animation.
  42351. */
  42352. set zoomStopsAnimation(flag: boolean);
  42353. /**
  42354. * Gets the flag that indicates if user zooming should stop animation.
  42355. */
  42356. get zoomStopsAnimation(): boolean;
  42357. /**
  42358. * Sets the transition time when framing the mesh, in milliseconds
  42359. */
  42360. set framingTime(time: number);
  42361. /**
  42362. * Gets the transition time when framing the mesh, in milliseconds
  42363. */
  42364. get framingTime(): number;
  42365. /**
  42366. * Define if the behavior should automatically change the configured
  42367. * camera limits and sensibilities.
  42368. */
  42369. autoCorrectCameraLimitsAndSensibility: boolean;
  42370. private _onPrePointerObservableObserver;
  42371. private _onAfterCheckInputsObserver;
  42372. private _onMeshTargetChangedObserver;
  42373. private _attachedCamera;
  42374. private _isPointerDown;
  42375. private _lastInteractionTime;
  42376. /**
  42377. * Initializes the behavior.
  42378. */
  42379. init(): void;
  42380. /**
  42381. * Attaches the behavior to its arc rotate camera.
  42382. * @param camera Defines the camera to attach the behavior to
  42383. */
  42384. attach(camera: ArcRotateCamera): void;
  42385. /**
  42386. * Detaches the behavior from its current arc rotate camera.
  42387. */
  42388. detach(): void;
  42389. private _animatables;
  42390. private _betaIsAnimating;
  42391. private _betaTransition;
  42392. private _radiusTransition;
  42393. private _vectorTransition;
  42394. /**
  42395. * Targets the given mesh and updates zoom level accordingly.
  42396. * @param mesh The mesh to target.
  42397. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42398. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42399. */
  42400. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42401. /**
  42402. * Targets the given mesh with its children and updates zoom level accordingly.
  42403. * @param mesh The mesh to target.
  42404. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42405. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42406. */
  42407. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42408. /**
  42409. * Targets the given meshes with their children and updates zoom level accordingly.
  42410. * @param meshes The mesh to target.
  42411. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42412. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42413. */
  42414. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42415. /**
  42416. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42417. * @param minimumWorld Determines the smaller position of the bounding box extend
  42418. * @param maximumWorld Determines the bigger position of the bounding box extend
  42419. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42420. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42421. */
  42422. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42423. /**
  42424. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42425. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42426. * frustum width.
  42427. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42428. * to fully enclose the mesh in the viewing frustum.
  42429. */
  42430. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42431. /**
  42432. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42433. * is automatically returned to its default position (expected to be above ground plane).
  42434. */
  42435. private _maintainCameraAboveGround;
  42436. /**
  42437. * Returns the frustum slope based on the canvas ratio and camera FOV
  42438. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42439. */
  42440. private _getFrustumSlope;
  42441. /**
  42442. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42443. */
  42444. private _clearAnimationLocks;
  42445. /**
  42446. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42447. */
  42448. private _applyUserInteraction;
  42449. /**
  42450. * Stops and removes all animations that have been applied to the camera
  42451. */
  42452. stopAllAnimations(): void;
  42453. /**
  42454. * Gets a value indicating if the user is moving the camera
  42455. */
  42456. get isUserIsMoving(): boolean;
  42457. /**
  42458. * The camera can move all the way towards the mesh.
  42459. */
  42460. static IgnoreBoundsSizeMode: number;
  42461. /**
  42462. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42463. */
  42464. static FitFrustumSidesMode: number;
  42465. }
  42466. }
  42467. declare module BABYLON {
  42468. /**
  42469. * Base class for Camera Pointer Inputs.
  42470. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42471. * for example usage.
  42472. */
  42473. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42474. /**
  42475. * Defines the camera the input is attached to.
  42476. */
  42477. abstract camera: Camera;
  42478. /**
  42479. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42480. */
  42481. protected _altKey: boolean;
  42482. protected _ctrlKey: boolean;
  42483. protected _metaKey: boolean;
  42484. protected _shiftKey: boolean;
  42485. /**
  42486. * Which mouse buttons were pressed at time of last mouse event.
  42487. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42488. */
  42489. protected _buttonsPressed: number;
  42490. /**
  42491. * Defines the buttons associated with the input to handle camera move.
  42492. */
  42493. buttons: number[];
  42494. /**
  42495. * Attach the input controls to a specific dom element to get the input from.
  42496. * @param element Defines the element the controls should be listened from
  42497. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42498. */
  42499. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42500. /**
  42501. * Detach the current controls from the specified dom element.
  42502. * @param element Defines the element to stop listening the inputs from
  42503. */
  42504. detachControl(element: Nullable<HTMLElement>): void;
  42505. /**
  42506. * Gets the class name of the current input.
  42507. * @returns the class name
  42508. */
  42509. getClassName(): string;
  42510. /**
  42511. * Get the friendly name associated with the input class.
  42512. * @returns the input friendly name
  42513. */
  42514. getSimpleName(): string;
  42515. /**
  42516. * Called on pointer POINTERDOUBLETAP event.
  42517. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42518. */
  42519. protected onDoubleTap(type: string): void;
  42520. /**
  42521. * Called on pointer POINTERMOVE event if only a single touch is active.
  42522. * Override this method to provide functionality.
  42523. */
  42524. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42525. /**
  42526. * Called on pointer POINTERMOVE event if multiple touches are active.
  42527. * Override this method to provide functionality.
  42528. */
  42529. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42530. /**
  42531. * Called on JS contextmenu event.
  42532. * Override this method to provide functionality.
  42533. */
  42534. protected onContextMenu(evt: PointerEvent): void;
  42535. /**
  42536. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42537. * press.
  42538. * Override this method to provide functionality.
  42539. */
  42540. protected onButtonDown(evt: PointerEvent): void;
  42541. /**
  42542. * Called each time a new POINTERUP event occurs. Ie, for each button
  42543. * release.
  42544. * Override this method to provide functionality.
  42545. */
  42546. protected onButtonUp(evt: PointerEvent): void;
  42547. /**
  42548. * Called when window becomes inactive.
  42549. * Override this method to provide functionality.
  42550. */
  42551. protected onLostFocus(): void;
  42552. private _pointerInput;
  42553. private _observer;
  42554. private _onLostFocus;
  42555. private pointA;
  42556. private pointB;
  42557. }
  42558. }
  42559. declare module BABYLON {
  42560. /**
  42561. * Manage the pointers inputs to control an arc rotate camera.
  42562. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42563. */
  42564. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42565. /**
  42566. * Defines the camera the input is attached to.
  42567. */
  42568. camera: ArcRotateCamera;
  42569. /**
  42570. * Gets the class name of the current input.
  42571. * @returns the class name
  42572. */
  42573. getClassName(): string;
  42574. /**
  42575. * Defines the buttons associated with the input to handle camera move.
  42576. */
  42577. buttons: number[];
  42578. /**
  42579. * Defines the pointer angular sensibility along the X axis or how fast is
  42580. * the camera rotating.
  42581. */
  42582. angularSensibilityX: number;
  42583. /**
  42584. * Defines the pointer angular sensibility along the Y axis or how fast is
  42585. * the camera rotating.
  42586. */
  42587. angularSensibilityY: number;
  42588. /**
  42589. * Defines the pointer pinch precision or how fast is the camera zooming.
  42590. */
  42591. pinchPrecision: number;
  42592. /**
  42593. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42594. * from 0.
  42595. * It defines the percentage of current camera.radius to use as delta when
  42596. * pinch zoom is used.
  42597. */
  42598. pinchDeltaPercentage: number;
  42599. /**
  42600. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42601. * that any object in the plane at the camera's target point will scale
  42602. * perfectly with finger motion.
  42603. * Overrides pinchDeltaPercentage and pinchPrecision.
  42604. */
  42605. useNaturalPinchZoom: boolean;
  42606. /**
  42607. * Defines the pointer panning sensibility or how fast is the camera moving.
  42608. */
  42609. panningSensibility: number;
  42610. /**
  42611. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42612. */
  42613. multiTouchPanning: boolean;
  42614. /**
  42615. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42616. * zoom (pinch) through multitouch.
  42617. */
  42618. multiTouchPanAndZoom: boolean;
  42619. /**
  42620. * Revers pinch action direction.
  42621. */
  42622. pinchInwards: boolean;
  42623. private _isPanClick;
  42624. private _twoFingerActivityCount;
  42625. private _isPinching;
  42626. /**
  42627. * Called on pointer POINTERMOVE event if only a single touch is active.
  42628. */
  42629. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42630. /**
  42631. * Called on pointer POINTERDOUBLETAP event.
  42632. */
  42633. protected onDoubleTap(type: string): void;
  42634. /**
  42635. * Called on pointer POINTERMOVE event if multiple touches are active.
  42636. */
  42637. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42638. /**
  42639. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42640. * press.
  42641. */
  42642. protected onButtonDown(evt: PointerEvent): void;
  42643. /**
  42644. * Called each time a new POINTERUP event occurs. Ie, for each button
  42645. * release.
  42646. */
  42647. protected onButtonUp(evt: PointerEvent): void;
  42648. /**
  42649. * Called when window becomes inactive.
  42650. */
  42651. protected onLostFocus(): void;
  42652. }
  42653. }
  42654. declare module BABYLON {
  42655. /**
  42656. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42657. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42658. */
  42659. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42660. /**
  42661. * Defines the camera the input is attached to.
  42662. */
  42663. camera: ArcRotateCamera;
  42664. /**
  42665. * Defines the list of key codes associated with the up action (increase alpha)
  42666. */
  42667. keysUp: number[];
  42668. /**
  42669. * Defines the list of key codes associated with the down action (decrease alpha)
  42670. */
  42671. keysDown: number[];
  42672. /**
  42673. * Defines the list of key codes associated with the left action (increase beta)
  42674. */
  42675. keysLeft: number[];
  42676. /**
  42677. * Defines the list of key codes associated with the right action (decrease beta)
  42678. */
  42679. keysRight: number[];
  42680. /**
  42681. * Defines the list of key codes associated with the reset action.
  42682. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42683. */
  42684. keysReset: number[];
  42685. /**
  42686. * Defines the panning sensibility of the inputs.
  42687. * (How fast is the camera panning)
  42688. */
  42689. panningSensibility: number;
  42690. /**
  42691. * Defines the zooming sensibility of the inputs.
  42692. * (How fast is the camera zooming)
  42693. */
  42694. zoomingSensibility: number;
  42695. /**
  42696. * Defines whether maintaining the alt key down switch the movement mode from
  42697. * orientation to zoom.
  42698. */
  42699. useAltToZoom: boolean;
  42700. /**
  42701. * Rotation speed of the camera
  42702. */
  42703. angularSpeed: number;
  42704. private _keys;
  42705. private _ctrlPressed;
  42706. private _altPressed;
  42707. private _onCanvasBlurObserver;
  42708. private _onKeyboardObserver;
  42709. private _engine;
  42710. private _scene;
  42711. /**
  42712. * Attach the input controls to a specific dom element to get the input from.
  42713. * @param element Defines the element the controls should be listened from
  42714. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42715. */
  42716. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42717. /**
  42718. * Detach the current controls from the specified dom element.
  42719. * @param element Defines the element to stop listening the inputs from
  42720. */
  42721. detachControl(element: Nullable<HTMLElement>): void;
  42722. /**
  42723. * Update the current camera state depending on the inputs that have been used this frame.
  42724. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42725. */
  42726. checkInputs(): void;
  42727. /**
  42728. * Gets the class name of the current intput.
  42729. * @returns the class name
  42730. */
  42731. getClassName(): string;
  42732. /**
  42733. * Get the friendly name associated with the input class.
  42734. * @returns the input friendly name
  42735. */
  42736. getSimpleName(): string;
  42737. }
  42738. }
  42739. declare module BABYLON {
  42740. /**
  42741. * Manage the mouse wheel inputs to control an arc rotate camera.
  42742. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42743. */
  42744. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42745. /**
  42746. * Defines the camera the input is attached to.
  42747. */
  42748. camera: ArcRotateCamera;
  42749. /**
  42750. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42751. */
  42752. wheelPrecision: number;
  42753. /**
  42754. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42755. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42756. */
  42757. wheelDeltaPercentage: number;
  42758. private _wheel;
  42759. private _observer;
  42760. private computeDeltaFromMouseWheelLegacyEvent;
  42761. /**
  42762. * Attach the input controls to a specific dom element to get the input from.
  42763. * @param element Defines the element the controls should be listened from
  42764. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42765. */
  42766. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42767. /**
  42768. * Detach the current controls from the specified dom element.
  42769. * @param element Defines the element to stop listening the inputs from
  42770. */
  42771. detachControl(element: Nullable<HTMLElement>): void;
  42772. /**
  42773. * Gets the class name of the current intput.
  42774. * @returns the class name
  42775. */
  42776. getClassName(): string;
  42777. /**
  42778. * Get the friendly name associated with the input class.
  42779. * @returns the input friendly name
  42780. */
  42781. getSimpleName(): string;
  42782. }
  42783. }
  42784. declare module BABYLON {
  42785. /**
  42786. * Default Inputs manager for the ArcRotateCamera.
  42787. * It groups all the default supported inputs for ease of use.
  42788. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42789. */
  42790. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42791. /**
  42792. * Instantiates a new ArcRotateCameraInputsManager.
  42793. * @param camera Defines the camera the inputs belong to
  42794. */
  42795. constructor(camera: ArcRotateCamera);
  42796. /**
  42797. * Add mouse wheel input support to the input manager.
  42798. * @returns the current input manager
  42799. */
  42800. addMouseWheel(): ArcRotateCameraInputsManager;
  42801. /**
  42802. * Add pointers input support to the input manager.
  42803. * @returns the current input manager
  42804. */
  42805. addPointers(): ArcRotateCameraInputsManager;
  42806. /**
  42807. * Add keyboard input support to the input manager.
  42808. * @returns the current input manager
  42809. */
  42810. addKeyboard(): ArcRotateCameraInputsManager;
  42811. }
  42812. }
  42813. declare module BABYLON {
  42814. /**
  42815. * This represents an orbital type of camera.
  42816. *
  42817. * 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.
  42818. * 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.
  42819. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42820. */
  42821. export class ArcRotateCamera extends TargetCamera {
  42822. /**
  42823. * Defines the rotation angle of the camera along the longitudinal axis.
  42824. */
  42825. alpha: number;
  42826. /**
  42827. * Defines the rotation angle of the camera along the latitudinal axis.
  42828. */
  42829. beta: number;
  42830. /**
  42831. * Defines the radius of the camera from it s target point.
  42832. */
  42833. radius: number;
  42834. protected _target: Vector3;
  42835. protected _targetHost: Nullable<AbstractMesh>;
  42836. /**
  42837. * Defines the target point of the camera.
  42838. * The camera looks towards it form the radius distance.
  42839. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  42840. */
  42841. get target(): Vector3;
  42842. set target(value: Vector3);
  42843. /**
  42844. * Define the current local position of the camera in the scene
  42845. */
  42846. get position(): Vector3;
  42847. set position(newPosition: Vector3);
  42848. protected _upToYMatrix: Matrix;
  42849. protected _YToUpMatrix: Matrix;
  42850. /**
  42851. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42852. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42853. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42854. */
  42855. set upVector(vec: Vector3);
  42856. get upVector(): Vector3;
  42857. /**
  42858. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42859. */
  42860. setMatUp(): void;
  42861. /**
  42862. * Current inertia value on the longitudinal axis.
  42863. * The bigger this number the longer it will take for the camera to stop.
  42864. */
  42865. inertialAlphaOffset: number;
  42866. /**
  42867. * Current inertia value on the latitudinal axis.
  42868. * The bigger this number the longer it will take for the camera to stop.
  42869. */
  42870. inertialBetaOffset: number;
  42871. /**
  42872. * Current inertia value on the radius axis.
  42873. * The bigger this number the longer it will take for the camera to stop.
  42874. */
  42875. inertialRadiusOffset: number;
  42876. /**
  42877. * Minimum allowed angle on the longitudinal axis.
  42878. * This can help limiting how the Camera is able to move in the scene.
  42879. */
  42880. lowerAlphaLimit: Nullable<number>;
  42881. /**
  42882. * Maximum allowed angle on the longitudinal axis.
  42883. * This can help limiting how the Camera is able to move in the scene.
  42884. */
  42885. upperAlphaLimit: Nullable<number>;
  42886. /**
  42887. * Minimum allowed angle on the latitudinal axis.
  42888. * This can help limiting how the Camera is able to move in the scene.
  42889. */
  42890. lowerBetaLimit: number;
  42891. /**
  42892. * Maximum allowed angle on the latitudinal axis.
  42893. * This can help limiting how the Camera is able to move in the scene.
  42894. */
  42895. upperBetaLimit: number;
  42896. /**
  42897. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42898. * This can help limiting how the Camera is able to move in the scene.
  42899. */
  42900. lowerRadiusLimit: Nullable<number>;
  42901. /**
  42902. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42903. * This can help limiting how the Camera is able to move in the scene.
  42904. */
  42905. upperRadiusLimit: Nullable<number>;
  42906. /**
  42907. * Defines the current inertia value used during panning of the camera along the X axis.
  42908. */
  42909. inertialPanningX: number;
  42910. /**
  42911. * Defines the current inertia value used during panning of the camera along the Y axis.
  42912. */
  42913. inertialPanningY: number;
  42914. /**
  42915. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42916. * Basically if your fingers moves away from more than this distance you will be considered
  42917. * in pinch mode.
  42918. */
  42919. pinchToPanMaxDistance: number;
  42920. /**
  42921. * Defines the maximum distance the camera can pan.
  42922. * This could help keeping the cammera always in your scene.
  42923. */
  42924. panningDistanceLimit: Nullable<number>;
  42925. /**
  42926. * Defines the target of the camera before paning.
  42927. */
  42928. panningOriginTarget: Vector3;
  42929. /**
  42930. * Defines the value of the inertia used during panning.
  42931. * 0 would mean stop inertia and one would mean no decelleration at all.
  42932. */
  42933. panningInertia: number;
  42934. /**
  42935. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42936. */
  42937. get angularSensibilityX(): number;
  42938. set angularSensibilityX(value: number);
  42939. /**
  42940. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42941. */
  42942. get angularSensibilityY(): number;
  42943. set angularSensibilityY(value: number);
  42944. /**
  42945. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42946. */
  42947. get pinchPrecision(): number;
  42948. set pinchPrecision(value: number);
  42949. /**
  42950. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42951. * It will be used instead of pinchDeltaPrecision if different from 0.
  42952. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42953. */
  42954. get pinchDeltaPercentage(): number;
  42955. set pinchDeltaPercentage(value: number);
  42956. /**
  42957. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42958. * and pinch delta percentage.
  42959. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42960. * that any object in the plane at the camera's target point will scale
  42961. * perfectly with finger motion.
  42962. */
  42963. get useNaturalPinchZoom(): boolean;
  42964. set useNaturalPinchZoom(value: boolean);
  42965. /**
  42966. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42967. */
  42968. get panningSensibility(): number;
  42969. set panningSensibility(value: number);
  42970. /**
  42971. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42972. */
  42973. get keysUp(): number[];
  42974. set keysUp(value: number[]);
  42975. /**
  42976. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42977. */
  42978. get keysDown(): number[];
  42979. set keysDown(value: number[]);
  42980. /**
  42981. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42982. */
  42983. get keysLeft(): number[];
  42984. set keysLeft(value: number[]);
  42985. /**
  42986. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42987. */
  42988. get keysRight(): number[];
  42989. set keysRight(value: number[]);
  42990. /**
  42991. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42992. */
  42993. get wheelPrecision(): number;
  42994. set wheelPrecision(value: number);
  42995. /**
  42996. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42997. * It will be used instead of pinchDeltaPrecision if different from 0.
  42998. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42999. */
  43000. get wheelDeltaPercentage(): number;
  43001. set wheelDeltaPercentage(value: number);
  43002. /**
  43003. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43004. */
  43005. zoomOnFactor: number;
  43006. /**
  43007. * Defines a screen offset for the camera position.
  43008. */
  43009. targetScreenOffset: Vector2;
  43010. /**
  43011. * Allows the camera to be completely reversed.
  43012. * If false the camera can not arrive upside down.
  43013. */
  43014. allowUpsideDown: boolean;
  43015. /**
  43016. * Define if double tap/click is used to restore the previously saved state of the camera.
  43017. */
  43018. useInputToRestoreState: boolean;
  43019. /** @hidden */
  43020. _viewMatrix: Matrix;
  43021. /** @hidden */
  43022. _useCtrlForPanning: boolean;
  43023. /** @hidden */
  43024. _panningMouseButton: number;
  43025. /**
  43026. * Defines the input associated to the camera.
  43027. */
  43028. inputs: ArcRotateCameraInputsManager;
  43029. /** @hidden */
  43030. _reset: () => void;
  43031. /**
  43032. * Defines the allowed panning axis.
  43033. */
  43034. panningAxis: Vector3;
  43035. protected _localDirection: Vector3;
  43036. protected _transformedDirection: Vector3;
  43037. private _bouncingBehavior;
  43038. /**
  43039. * Gets the bouncing behavior of the camera if it has been enabled.
  43040. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43041. */
  43042. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43043. /**
  43044. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43045. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43046. */
  43047. get useBouncingBehavior(): boolean;
  43048. set useBouncingBehavior(value: boolean);
  43049. private _framingBehavior;
  43050. /**
  43051. * Gets the framing behavior of the camera if it has been enabled.
  43052. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43053. */
  43054. get framingBehavior(): Nullable<FramingBehavior>;
  43055. /**
  43056. * Defines if the framing behavior of the camera is enabled on the camera.
  43057. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43058. */
  43059. get useFramingBehavior(): boolean;
  43060. set useFramingBehavior(value: boolean);
  43061. private _autoRotationBehavior;
  43062. /**
  43063. * Gets the auto rotation behavior of the camera if it has been enabled.
  43064. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43065. */
  43066. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43067. /**
  43068. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43069. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43070. */
  43071. get useAutoRotationBehavior(): boolean;
  43072. set useAutoRotationBehavior(value: boolean);
  43073. /**
  43074. * Observable triggered when the mesh target has been changed on the camera.
  43075. */
  43076. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43077. /**
  43078. * Event raised when the camera is colliding with a mesh.
  43079. */
  43080. onCollide: (collidedMesh: AbstractMesh) => void;
  43081. /**
  43082. * Defines whether the camera should check collision with the objects oh the scene.
  43083. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43084. */
  43085. checkCollisions: boolean;
  43086. /**
  43087. * Defines the collision radius of the camera.
  43088. * This simulates a sphere around the camera.
  43089. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43090. */
  43091. collisionRadius: Vector3;
  43092. protected _collider: Collider;
  43093. protected _previousPosition: Vector3;
  43094. protected _collisionVelocity: Vector3;
  43095. protected _newPosition: Vector3;
  43096. protected _previousAlpha: number;
  43097. protected _previousBeta: number;
  43098. protected _previousRadius: number;
  43099. protected _collisionTriggered: boolean;
  43100. protected _targetBoundingCenter: Nullable<Vector3>;
  43101. private _computationVector;
  43102. /**
  43103. * Instantiates a new ArcRotateCamera in a given scene
  43104. * @param name Defines the name of the camera
  43105. * @param alpha Defines the camera rotation along the logitudinal axis
  43106. * @param beta Defines the camera rotation along the latitudinal axis
  43107. * @param radius Defines the camera distance from its target
  43108. * @param target Defines the camera target
  43109. * @param scene Defines the scene the camera belongs to
  43110. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43111. */
  43112. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43113. /** @hidden */
  43114. _initCache(): void;
  43115. /** @hidden */
  43116. _updateCache(ignoreParentClass?: boolean): void;
  43117. protected _getTargetPosition(): Vector3;
  43118. private _storedAlpha;
  43119. private _storedBeta;
  43120. private _storedRadius;
  43121. private _storedTarget;
  43122. private _storedTargetScreenOffset;
  43123. /**
  43124. * Stores the current state of the camera (alpha, beta, radius and target)
  43125. * @returns the camera itself
  43126. */
  43127. storeState(): Camera;
  43128. /**
  43129. * @hidden
  43130. * Restored camera state. You must call storeState() first
  43131. */
  43132. _restoreStateValues(): boolean;
  43133. /** @hidden */
  43134. _isSynchronizedViewMatrix(): boolean;
  43135. /**
  43136. * Attached controls to the current camera.
  43137. * @param element Defines the element the controls should be listened from
  43138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43139. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43140. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43141. */
  43142. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43143. /**
  43144. * Detach the current controls from the camera.
  43145. * The camera will stop reacting to inputs.
  43146. * @param element Defines the element to stop listening the inputs from
  43147. */
  43148. detachControl(element: HTMLElement): void;
  43149. /** @hidden */
  43150. _checkInputs(): void;
  43151. protected _checkLimits(): void;
  43152. /**
  43153. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43154. */
  43155. rebuildAnglesAndRadius(): void;
  43156. /**
  43157. * Use a position to define the current camera related information like alpha, beta and radius
  43158. * @param position Defines the position to set the camera at
  43159. */
  43160. setPosition(position: Vector3): void;
  43161. /**
  43162. * Defines the target the camera should look at.
  43163. * This will automatically adapt alpha beta and radius to fit within the new target.
  43164. * @param target Defines the new target as a Vector or a mesh
  43165. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43166. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43167. */
  43168. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43169. /** @hidden */
  43170. _getViewMatrix(): Matrix;
  43171. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43172. /**
  43173. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43174. * @param meshes Defines the mesh to zoom on
  43175. * @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)
  43176. */
  43177. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43178. /**
  43179. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43180. * The target will be changed but the radius
  43181. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43182. * @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)
  43183. */
  43184. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43185. min: Vector3;
  43186. max: Vector3;
  43187. distance: number;
  43188. }, doNotUpdateMaxZ?: boolean): void;
  43189. /**
  43190. * @override
  43191. * Override Camera.createRigCamera
  43192. */
  43193. createRigCamera(name: string, cameraIndex: number): Camera;
  43194. /**
  43195. * @hidden
  43196. * @override
  43197. * Override Camera._updateRigCameras
  43198. */
  43199. _updateRigCameras(): void;
  43200. /**
  43201. * Destroy the camera and release the current resources hold by it.
  43202. */
  43203. dispose(): void;
  43204. /**
  43205. * Gets the current object class name.
  43206. * @return the class name
  43207. */
  43208. getClassName(): string;
  43209. }
  43210. }
  43211. declare module BABYLON {
  43212. /**
  43213. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43214. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43215. */
  43216. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43217. /**
  43218. * Gets the name of the behavior.
  43219. */
  43220. get name(): string;
  43221. private _zoomStopsAnimation;
  43222. private _idleRotationSpeed;
  43223. private _idleRotationWaitTime;
  43224. private _idleRotationSpinupTime;
  43225. /**
  43226. * Sets the flag that indicates if user zooming should stop animation.
  43227. */
  43228. set zoomStopsAnimation(flag: boolean);
  43229. /**
  43230. * Gets the flag that indicates if user zooming should stop animation.
  43231. */
  43232. get zoomStopsAnimation(): boolean;
  43233. /**
  43234. * Sets the default speed at which the camera rotates around the model.
  43235. */
  43236. set idleRotationSpeed(speed: number);
  43237. /**
  43238. * Gets the default speed at which the camera rotates around the model.
  43239. */
  43240. get idleRotationSpeed(): number;
  43241. /**
  43242. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43243. */
  43244. set idleRotationWaitTime(time: number);
  43245. /**
  43246. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43247. */
  43248. get idleRotationWaitTime(): number;
  43249. /**
  43250. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43251. */
  43252. set idleRotationSpinupTime(time: number);
  43253. /**
  43254. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43255. */
  43256. get idleRotationSpinupTime(): number;
  43257. /**
  43258. * Gets a value indicating if the camera is currently rotating because of this behavior
  43259. */
  43260. get rotationInProgress(): boolean;
  43261. private _onPrePointerObservableObserver;
  43262. private _onAfterCheckInputsObserver;
  43263. private _attachedCamera;
  43264. private _isPointerDown;
  43265. private _lastFrameTime;
  43266. private _lastInteractionTime;
  43267. private _cameraRotationSpeed;
  43268. /**
  43269. * Initializes the behavior.
  43270. */
  43271. init(): void;
  43272. /**
  43273. * Attaches the behavior to its arc rotate camera.
  43274. * @param camera Defines the camera to attach the behavior to
  43275. */
  43276. attach(camera: ArcRotateCamera): void;
  43277. /**
  43278. * Detaches the behavior from its current arc rotate camera.
  43279. */
  43280. detach(): void;
  43281. /**
  43282. * Returns true if user is scrolling.
  43283. * @return true if user is scrolling.
  43284. */
  43285. private _userIsZooming;
  43286. private _lastFrameRadius;
  43287. private _shouldAnimationStopForInteraction;
  43288. /**
  43289. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43290. */
  43291. private _applyUserInteraction;
  43292. private _userIsMoving;
  43293. }
  43294. }
  43295. declare module BABYLON {
  43296. /**
  43297. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43298. */
  43299. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43300. private ui;
  43301. /**
  43302. * The name of the behavior
  43303. */
  43304. name: string;
  43305. /**
  43306. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43307. */
  43308. distanceAwayFromFace: number;
  43309. /**
  43310. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43311. */
  43312. distanceAwayFromBottomOfFace: number;
  43313. private _faceVectors;
  43314. private _target;
  43315. private _scene;
  43316. private _onRenderObserver;
  43317. private _tmpMatrix;
  43318. private _tmpVector;
  43319. /**
  43320. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43321. * @param ui The transform node that should be attched to the mesh
  43322. */
  43323. constructor(ui: TransformNode);
  43324. /**
  43325. * Initializes the behavior
  43326. */
  43327. init(): void;
  43328. private _closestFace;
  43329. private _zeroVector;
  43330. private _lookAtTmpMatrix;
  43331. private _lookAtToRef;
  43332. /**
  43333. * Attaches the AttachToBoxBehavior to the passed in mesh
  43334. * @param target The mesh that the specified node will be attached to
  43335. */
  43336. attach(target: Mesh): void;
  43337. /**
  43338. * Detaches the behavior from the mesh
  43339. */
  43340. detach(): void;
  43341. }
  43342. }
  43343. declare module BABYLON {
  43344. /**
  43345. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43346. */
  43347. export class FadeInOutBehavior implements Behavior<Mesh> {
  43348. /**
  43349. * Time in milliseconds to delay before fading in (Default: 0)
  43350. */
  43351. delay: number;
  43352. /**
  43353. * Time in milliseconds for the mesh to fade in (Default: 300)
  43354. */
  43355. fadeInTime: number;
  43356. private _millisecondsPerFrame;
  43357. private _hovered;
  43358. private _hoverValue;
  43359. private _ownerNode;
  43360. /**
  43361. * Instatiates the FadeInOutBehavior
  43362. */
  43363. constructor();
  43364. /**
  43365. * The name of the behavior
  43366. */
  43367. get name(): string;
  43368. /**
  43369. * Initializes the behavior
  43370. */
  43371. init(): void;
  43372. /**
  43373. * Attaches the fade behavior on the passed in mesh
  43374. * @param ownerNode The mesh that will be faded in/out once attached
  43375. */
  43376. attach(ownerNode: Mesh): void;
  43377. /**
  43378. * Detaches the behavior from the mesh
  43379. */
  43380. detach(): void;
  43381. /**
  43382. * Triggers the mesh to begin fading in or out
  43383. * @param value if the object should fade in or out (true to fade in)
  43384. */
  43385. fadeIn(value: boolean): void;
  43386. private _update;
  43387. private _setAllVisibility;
  43388. }
  43389. }
  43390. declare module BABYLON {
  43391. /**
  43392. * Class containing a set of static utilities functions for managing Pivots
  43393. * @hidden
  43394. */
  43395. export class PivotTools {
  43396. private static _PivotCached;
  43397. private static _OldPivotPoint;
  43398. private static _PivotTranslation;
  43399. private static _PivotTmpVector;
  43400. /** @hidden */
  43401. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43402. /** @hidden */
  43403. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43404. }
  43405. }
  43406. declare module BABYLON {
  43407. /**
  43408. * Class containing static functions to help procedurally build meshes
  43409. */
  43410. export class PlaneBuilder {
  43411. /**
  43412. * Creates a plane mesh
  43413. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43414. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43415. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43417. * * 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
  43418. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43419. * @param name defines the name of the mesh
  43420. * @param options defines the options used to create the mesh
  43421. * @param scene defines the hosting scene
  43422. * @returns the plane mesh
  43423. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43424. */
  43425. static CreatePlane(name: string, options: {
  43426. size?: number;
  43427. width?: number;
  43428. height?: number;
  43429. sideOrientation?: number;
  43430. frontUVs?: Vector4;
  43431. backUVs?: Vector4;
  43432. updatable?: boolean;
  43433. sourcePlane?: Plane;
  43434. }, scene?: Nullable<Scene>): Mesh;
  43435. }
  43436. }
  43437. declare module BABYLON {
  43438. /**
  43439. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43440. */
  43441. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43442. private static _AnyMouseID;
  43443. /**
  43444. * Abstract mesh the behavior is set on
  43445. */
  43446. attachedNode: AbstractMesh;
  43447. private _dragPlane;
  43448. private _scene;
  43449. private _pointerObserver;
  43450. private _beforeRenderObserver;
  43451. private static _planeScene;
  43452. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43453. /**
  43454. * 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)
  43455. */
  43456. maxDragAngle: number;
  43457. /**
  43458. * @hidden
  43459. */
  43460. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43461. /**
  43462. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43463. */
  43464. currentDraggingPointerID: number;
  43465. /**
  43466. * The last position where the pointer hit the drag plane in world space
  43467. */
  43468. lastDragPosition: Vector3;
  43469. /**
  43470. * If the behavior is currently in a dragging state
  43471. */
  43472. dragging: boolean;
  43473. /**
  43474. * 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)
  43475. */
  43476. dragDeltaRatio: number;
  43477. /**
  43478. * If the drag plane orientation should be updated during the dragging (Default: true)
  43479. */
  43480. updateDragPlane: boolean;
  43481. private _debugMode;
  43482. private _moving;
  43483. /**
  43484. * Fires each time the attached mesh is dragged with the pointer
  43485. * * delta between last drag position and current drag position in world space
  43486. * * dragDistance along the drag axis
  43487. * * dragPlaneNormal normal of the current drag plane used during the drag
  43488. * * dragPlanePoint in world space where the drag intersects the drag plane
  43489. */
  43490. onDragObservable: Observable<{
  43491. delta: Vector3;
  43492. dragPlanePoint: Vector3;
  43493. dragPlaneNormal: Vector3;
  43494. dragDistance: number;
  43495. pointerId: number;
  43496. }>;
  43497. /**
  43498. * Fires each time a drag begins (eg. mouse down on mesh)
  43499. */
  43500. onDragStartObservable: Observable<{
  43501. dragPlanePoint: Vector3;
  43502. pointerId: number;
  43503. }>;
  43504. /**
  43505. * Fires each time a drag ends (eg. mouse release after drag)
  43506. */
  43507. onDragEndObservable: Observable<{
  43508. dragPlanePoint: Vector3;
  43509. pointerId: number;
  43510. }>;
  43511. /**
  43512. * If the attached mesh should be moved when dragged
  43513. */
  43514. moveAttached: boolean;
  43515. /**
  43516. * If the drag behavior will react to drag events (Default: true)
  43517. */
  43518. enabled: boolean;
  43519. /**
  43520. * If pointer events should start and release the drag (Default: true)
  43521. */
  43522. startAndReleaseDragOnPointerEvents: boolean;
  43523. /**
  43524. * If camera controls should be detached during the drag
  43525. */
  43526. detachCameraControls: boolean;
  43527. /**
  43528. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43529. */
  43530. useObjectOrientationForDragging: boolean;
  43531. private _options;
  43532. /**
  43533. * Gets the options used by the behavior
  43534. */
  43535. get options(): {
  43536. dragAxis?: Vector3;
  43537. dragPlaneNormal?: Vector3;
  43538. };
  43539. /**
  43540. * Sets the options used by the behavior
  43541. */
  43542. set options(options: {
  43543. dragAxis?: Vector3;
  43544. dragPlaneNormal?: Vector3;
  43545. });
  43546. /**
  43547. * Creates a pointer drag behavior that can be attached to a mesh
  43548. * @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)
  43549. */
  43550. constructor(options?: {
  43551. dragAxis?: Vector3;
  43552. dragPlaneNormal?: Vector3;
  43553. });
  43554. /**
  43555. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43556. */
  43557. validateDrag: (targetPosition: Vector3) => boolean;
  43558. /**
  43559. * The name of the behavior
  43560. */
  43561. get name(): string;
  43562. /**
  43563. * Initializes the behavior
  43564. */
  43565. init(): void;
  43566. private _tmpVector;
  43567. private _alternatePickedPoint;
  43568. private _worldDragAxis;
  43569. private _targetPosition;
  43570. private _attachedElement;
  43571. /**
  43572. * Attaches the drag behavior the passed in mesh
  43573. * @param ownerNode The mesh that will be dragged around once attached
  43574. * @param predicate Predicate to use for pick filtering
  43575. */
  43576. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43577. /**
  43578. * Force relase the drag action by code.
  43579. */
  43580. releaseDrag(): void;
  43581. private _startDragRay;
  43582. private _lastPointerRay;
  43583. /**
  43584. * Simulates the start of a pointer drag event on the behavior
  43585. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43586. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43587. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43588. */
  43589. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43590. private _startDrag;
  43591. private _dragDelta;
  43592. private _moveDrag;
  43593. private _pickWithRayOnDragPlane;
  43594. private _pointA;
  43595. private _pointC;
  43596. private _localAxis;
  43597. private _lookAt;
  43598. private _updateDragPlanePosition;
  43599. /**
  43600. * Detaches the behavior from the mesh
  43601. */
  43602. detach(): void;
  43603. }
  43604. }
  43605. declare module BABYLON {
  43606. /**
  43607. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43608. */
  43609. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43610. private _dragBehaviorA;
  43611. private _dragBehaviorB;
  43612. private _startDistance;
  43613. private _initialScale;
  43614. private _targetScale;
  43615. private _ownerNode;
  43616. private _sceneRenderObserver;
  43617. /**
  43618. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43619. */
  43620. constructor();
  43621. /**
  43622. * The name of the behavior
  43623. */
  43624. get name(): string;
  43625. /**
  43626. * Initializes the behavior
  43627. */
  43628. init(): void;
  43629. private _getCurrentDistance;
  43630. /**
  43631. * Attaches the scale behavior the passed in mesh
  43632. * @param ownerNode The mesh that will be scaled around once attached
  43633. */
  43634. attach(ownerNode: Mesh): void;
  43635. /**
  43636. * Detaches the behavior from the mesh
  43637. */
  43638. detach(): void;
  43639. }
  43640. }
  43641. declare module BABYLON {
  43642. /**
  43643. * 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
  43644. */
  43645. export class SixDofDragBehavior implements Behavior<Mesh> {
  43646. private static _virtualScene;
  43647. private _ownerNode;
  43648. private _sceneRenderObserver;
  43649. private _scene;
  43650. private _targetPosition;
  43651. private _virtualOriginMesh;
  43652. private _virtualDragMesh;
  43653. private _pointerObserver;
  43654. private _moving;
  43655. private _startingOrientation;
  43656. private _attachedElement;
  43657. /**
  43658. * 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)
  43659. */
  43660. private zDragFactor;
  43661. /**
  43662. * If the object should rotate to face the drag origin
  43663. */
  43664. rotateDraggedObject: boolean;
  43665. /**
  43666. * If the behavior is currently in a dragging state
  43667. */
  43668. dragging: boolean;
  43669. /**
  43670. * 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)
  43671. */
  43672. dragDeltaRatio: number;
  43673. /**
  43674. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43675. */
  43676. currentDraggingPointerID: number;
  43677. /**
  43678. * If camera controls should be detached during the drag
  43679. */
  43680. detachCameraControls: boolean;
  43681. /**
  43682. * Fires each time a drag starts
  43683. */
  43684. onDragStartObservable: Observable<{}>;
  43685. /**
  43686. * Fires each time a drag ends (eg. mouse release after drag)
  43687. */
  43688. onDragEndObservable: Observable<{}>;
  43689. /**
  43690. * 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
  43691. */
  43692. constructor();
  43693. /**
  43694. * The name of the behavior
  43695. */
  43696. get name(): string;
  43697. /**
  43698. * Initializes the behavior
  43699. */
  43700. init(): void;
  43701. /**
  43702. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43703. */
  43704. private get _pointerCamera();
  43705. /**
  43706. * Attaches the scale behavior the passed in mesh
  43707. * @param ownerNode The mesh that will be scaled around once attached
  43708. */
  43709. attach(ownerNode: Mesh): void;
  43710. /**
  43711. * Detaches the behavior from the mesh
  43712. */
  43713. detach(): void;
  43714. }
  43715. }
  43716. declare module BABYLON {
  43717. /**
  43718. * Class used to apply inverse kinematics to bones
  43719. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43720. */
  43721. export class BoneIKController {
  43722. private static _tmpVecs;
  43723. private static _tmpQuat;
  43724. private static _tmpMats;
  43725. /**
  43726. * Gets or sets the target mesh
  43727. */
  43728. targetMesh: AbstractMesh;
  43729. /** Gets or sets the mesh used as pole */
  43730. poleTargetMesh: AbstractMesh;
  43731. /**
  43732. * Gets or sets the bone used as pole
  43733. */
  43734. poleTargetBone: Nullable<Bone>;
  43735. /**
  43736. * Gets or sets the target position
  43737. */
  43738. targetPosition: Vector3;
  43739. /**
  43740. * Gets or sets the pole target position
  43741. */
  43742. poleTargetPosition: Vector3;
  43743. /**
  43744. * Gets or sets the pole target local offset
  43745. */
  43746. poleTargetLocalOffset: Vector3;
  43747. /**
  43748. * Gets or sets the pole angle
  43749. */
  43750. poleAngle: number;
  43751. /**
  43752. * Gets or sets the mesh associated with the controller
  43753. */
  43754. mesh: AbstractMesh;
  43755. /**
  43756. * 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)
  43757. */
  43758. slerpAmount: number;
  43759. private _bone1Quat;
  43760. private _bone1Mat;
  43761. private _bone2Ang;
  43762. private _bone1;
  43763. private _bone2;
  43764. private _bone1Length;
  43765. private _bone2Length;
  43766. private _maxAngle;
  43767. private _maxReach;
  43768. private _rightHandedSystem;
  43769. private _bendAxis;
  43770. private _slerping;
  43771. private _adjustRoll;
  43772. /**
  43773. * Gets or sets maximum allowed angle
  43774. */
  43775. get maxAngle(): number;
  43776. set maxAngle(value: number);
  43777. /**
  43778. * Creates a new BoneIKController
  43779. * @param mesh defines the mesh to control
  43780. * @param bone defines the bone to control
  43781. * @param options defines options to set up the controller
  43782. */
  43783. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43784. targetMesh?: AbstractMesh;
  43785. poleTargetMesh?: AbstractMesh;
  43786. poleTargetBone?: Bone;
  43787. poleTargetLocalOffset?: Vector3;
  43788. poleAngle?: number;
  43789. bendAxis?: Vector3;
  43790. maxAngle?: number;
  43791. slerpAmount?: number;
  43792. });
  43793. private _setMaxAngle;
  43794. /**
  43795. * Force the controller to update the bones
  43796. */
  43797. update(): void;
  43798. }
  43799. }
  43800. declare module BABYLON {
  43801. /**
  43802. * Class used to make a bone look toward a point in space
  43803. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43804. */
  43805. export class BoneLookController {
  43806. private static _tmpVecs;
  43807. private static _tmpQuat;
  43808. private static _tmpMats;
  43809. /**
  43810. * The target Vector3 that the bone will look at
  43811. */
  43812. target: Vector3;
  43813. /**
  43814. * The mesh that the bone is attached to
  43815. */
  43816. mesh: AbstractMesh;
  43817. /**
  43818. * The bone that will be looking to the target
  43819. */
  43820. bone: Bone;
  43821. /**
  43822. * The up axis of the coordinate system that is used when the bone is rotated
  43823. */
  43824. upAxis: Vector3;
  43825. /**
  43826. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43827. */
  43828. upAxisSpace: Space;
  43829. /**
  43830. * Used to make an adjustment to the yaw of the bone
  43831. */
  43832. adjustYaw: number;
  43833. /**
  43834. * Used to make an adjustment to the pitch of the bone
  43835. */
  43836. adjustPitch: number;
  43837. /**
  43838. * Used to make an adjustment to the roll of the bone
  43839. */
  43840. adjustRoll: number;
  43841. /**
  43842. * 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)
  43843. */
  43844. slerpAmount: number;
  43845. private _minYaw;
  43846. private _maxYaw;
  43847. private _minPitch;
  43848. private _maxPitch;
  43849. private _minYawSin;
  43850. private _minYawCos;
  43851. private _maxYawSin;
  43852. private _maxYawCos;
  43853. private _midYawConstraint;
  43854. private _minPitchTan;
  43855. private _maxPitchTan;
  43856. private _boneQuat;
  43857. private _slerping;
  43858. private _transformYawPitch;
  43859. private _transformYawPitchInv;
  43860. private _firstFrameSkipped;
  43861. private _yawRange;
  43862. private _fowardAxis;
  43863. /**
  43864. * Gets or sets the minimum yaw angle that the bone can look to
  43865. */
  43866. get minYaw(): number;
  43867. set minYaw(value: number);
  43868. /**
  43869. * Gets or sets the maximum yaw angle that the bone can look to
  43870. */
  43871. get maxYaw(): number;
  43872. set maxYaw(value: number);
  43873. /**
  43874. * Gets or sets the minimum pitch angle that the bone can look to
  43875. */
  43876. get minPitch(): number;
  43877. set minPitch(value: number);
  43878. /**
  43879. * Gets or sets the maximum pitch angle that the bone can look to
  43880. */
  43881. get maxPitch(): number;
  43882. set maxPitch(value: number);
  43883. /**
  43884. * Create a BoneLookController
  43885. * @param mesh the mesh that the bone belongs to
  43886. * @param bone the bone that will be looking to the target
  43887. * @param target the target Vector3 to look at
  43888. * @param options optional settings:
  43889. * * maxYaw: the maximum angle the bone will yaw to
  43890. * * minYaw: the minimum angle the bone will yaw to
  43891. * * maxPitch: the maximum angle the bone will pitch to
  43892. * * minPitch: the minimum angle the bone will yaw to
  43893. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43894. * * upAxis: the up axis of the coordinate system
  43895. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43896. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43897. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43898. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43899. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43900. * * adjustRoll: used to make an adjustment to the roll of the bone
  43901. **/
  43902. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43903. maxYaw?: number;
  43904. minYaw?: number;
  43905. maxPitch?: number;
  43906. minPitch?: number;
  43907. slerpAmount?: number;
  43908. upAxis?: Vector3;
  43909. upAxisSpace?: Space;
  43910. yawAxis?: Vector3;
  43911. pitchAxis?: Vector3;
  43912. adjustYaw?: number;
  43913. adjustPitch?: number;
  43914. adjustRoll?: number;
  43915. });
  43916. /**
  43917. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43918. */
  43919. update(): void;
  43920. private _getAngleDiff;
  43921. private _getAngleBetween;
  43922. private _isAngleBetween;
  43923. }
  43924. }
  43925. declare module BABYLON {
  43926. /**
  43927. * Manage the gamepad inputs to control an arc rotate camera.
  43928. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43929. */
  43930. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43931. /**
  43932. * Defines the camera the input is attached to.
  43933. */
  43934. camera: ArcRotateCamera;
  43935. /**
  43936. * Defines the gamepad the input is gathering event from.
  43937. */
  43938. gamepad: Nullable<Gamepad>;
  43939. /**
  43940. * Defines the gamepad rotation sensiblity.
  43941. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43942. */
  43943. gamepadRotationSensibility: number;
  43944. /**
  43945. * Defines the gamepad move sensiblity.
  43946. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43947. */
  43948. gamepadMoveSensibility: number;
  43949. private _yAxisScale;
  43950. /**
  43951. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43952. */
  43953. get invertYAxis(): boolean;
  43954. set invertYAxis(value: boolean);
  43955. private _onGamepadConnectedObserver;
  43956. private _onGamepadDisconnectedObserver;
  43957. /**
  43958. * Attach the input controls to a specific dom element to get the input from.
  43959. * @param element Defines the element the controls should be listened from
  43960. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43961. */
  43962. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43963. /**
  43964. * Detach the current controls from the specified dom element.
  43965. * @param element Defines the element to stop listening the inputs from
  43966. */
  43967. detachControl(element: Nullable<HTMLElement>): void;
  43968. /**
  43969. * Update the current camera state depending on the inputs that have been used this frame.
  43970. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43971. */
  43972. checkInputs(): void;
  43973. /**
  43974. * Gets the class name of the current intput.
  43975. * @returns the class name
  43976. */
  43977. getClassName(): string;
  43978. /**
  43979. * Get the friendly name associated with the input class.
  43980. * @returns the input friendly name
  43981. */
  43982. getSimpleName(): string;
  43983. }
  43984. }
  43985. declare module BABYLON {
  43986. interface ArcRotateCameraInputsManager {
  43987. /**
  43988. * Add orientation input support to the input manager.
  43989. * @returns the current input manager
  43990. */
  43991. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43992. }
  43993. /**
  43994. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43995. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43996. */
  43997. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43998. /**
  43999. * Defines the camera the input is attached to.
  44000. */
  44001. camera: ArcRotateCamera;
  44002. /**
  44003. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44004. */
  44005. alphaCorrection: number;
  44006. /**
  44007. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44008. */
  44009. gammaCorrection: number;
  44010. private _alpha;
  44011. private _gamma;
  44012. private _dirty;
  44013. private _deviceOrientationHandler;
  44014. /**
  44015. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44016. */
  44017. constructor();
  44018. /**
  44019. * Attach the input controls to a specific dom element to get the input from.
  44020. * @param element Defines the element the controls should be listened from
  44021. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44022. */
  44023. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44024. /** @hidden */
  44025. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44026. /**
  44027. * Update the current camera state depending on the inputs that have been used this frame.
  44028. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44029. */
  44030. checkInputs(): void;
  44031. /**
  44032. * Detach the current controls from the specified dom element.
  44033. * @param element Defines the element to stop listening the inputs from
  44034. */
  44035. detachControl(element: Nullable<HTMLElement>): void;
  44036. /**
  44037. * Gets the class name of the current intput.
  44038. * @returns the class name
  44039. */
  44040. getClassName(): string;
  44041. /**
  44042. * Get the friendly name associated with the input class.
  44043. * @returns the input friendly name
  44044. */
  44045. getSimpleName(): string;
  44046. }
  44047. }
  44048. declare module BABYLON {
  44049. /**
  44050. * Listen to mouse events to control the camera.
  44051. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44052. */
  44053. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44054. /**
  44055. * Defines the camera the input is attached to.
  44056. */
  44057. camera: FlyCamera;
  44058. /**
  44059. * Defines if touch is enabled. (Default is true.)
  44060. */
  44061. touchEnabled: boolean;
  44062. /**
  44063. * Defines the buttons associated with the input to handle camera rotation.
  44064. */
  44065. buttons: number[];
  44066. /**
  44067. * Assign buttons for Yaw control.
  44068. */
  44069. buttonsYaw: number[];
  44070. /**
  44071. * Assign buttons for Pitch control.
  44072. */
  44073. buttonsPitch: number[];
  44074. /**
  44075. * Assign buttons for Roll control.
  44076. */
  44077. buttonsRoll: number[];
  44078. /**
  44079. * Detect if any button is being pressed while mouse is moved.
  44080. * -1 = Mouse locked.
  44081. * 0 = Left button.
  44082. * 1 = Middle Button.
  44083. * 2 = Right Button.
  44084. */
  44085. activeButton: number;
  44086. /**
  44087. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44088. * Higher values reduce its sensitivity.
  44089. */
  44090. angularSensibility: number;
  44091. private _mousemoveCallback;
  44092. private _observer;
  44093. private _rollObserver;
  44094. private previousPosition;
  44095. private noPreventDefault;
  44096. private element;
  44097. /**
  44098. * Listen to mouse events to control the camera.
  44099. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44100. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44101. */
  44102. constructor(touchEnabled?: boolean);
  44103. /**
  44104. * Attach the mouse control to the HTML DOM element.
  44105. * @param element Defines the element that listens to the input events.
  44106. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44107. */
  44108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44109. /**
  44110. * Detach the current controls from the specified dom element.
  44111. * @param element Defines the element to stop listening the inputs from
  44112. */
  44113. detachControl(element: Nullable<HTMLElement>): void;
  44114. /**
  44115. * Gets the class name of the current input.
  44116. * @returns the class name.
  44117. */
  44118. getClassName(): string;
  44119. /**
  44120. * Get the friendly name associated with the input class.
  44121. * @returns the input's friendly name.
  44122. */
  44123. getSimpleName(): string;
  44124. private _pointerInput;
  44125. private _onMouseMove;
  44126. /**
  44127. * Rotate camera by mouse offset.
  44128. */
  44129. private rotateCamera;
  44130. }
  44131. }
  44132. declare module BABYLON {
  44133. /**
  44134. * Default Inputs manager for the FlyCamera.
  44135. * It groups all the default supported inputs for ease of use.
  44136. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44137. */
  44138. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44139. /**
  44140. * Instantiates a new FlyCameraInputsManager.
  44141. * @param camera Defines the camera the inputs belong to.
  44142. */
  44143. constructor(camera: FlyCamera);
  44144. /**
  44145. * Add keyboard input support to the input manager.
  44146. * @returns the new FlyCameraKeyboardMoveInput().
  44147. */
  44148. addKeyboard(): FlyCameraInputsManager;
  44149. /**
  44150. * Add mouse input support to the input manager.
  44151. * @param touchEnabled Enable touch screen support.
  44152. * @returns the new FlyCameraMouseInput().
  44153. */
  44154. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44155. }
  44156. }
  44157. declare module BABYLON {
  44158. /**
  44159. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44160. * such as in a 3D Space Shooter or a Flight Simulator.
  44161. */
  44162. export class FlyCamera extends TargetCamera {
  44163. /**
  44164. * Define the collision ellipsoid of the camera.
  44165. * This is helpful for simulating a camera body, like a player's body.
  44166. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44167. */
  44168. ellipsoid: Vector3;
  44169. /**
  44170. * Define an offset for the position of the ellipsoid around the camera.
  44171. * This can be helpful if the camera is attached away from the player's body center,
  44172. * such as at its head.
  44173. */
  44174. ellipsoidOffset: Vector3;
  44175. /**
  44176. * Enable or disable collisions of the camera with the rest of the scene objects.
  44177. */
  44178. checkCollisions: boolean;
  44179. /**
  44180. * Enable or disable gravity on the camera.
  44181. */
  44182. applyGravity: boolean;
  44183. /**
  44184. * Define the current direction the camera is moving to.
  44185. */
  44186. cameraDirection: Vector3;
  44187. /**
  44188. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44189. * This overrides and empties cameraRotation.
  44190. */
  44191. rotationQuaternion: Quaternion;
  44192. /**
  44193. * Track Roll to maintain the wanted Rolling when looking around.
  44194. */
  44195. _trackRoll: number;
  44196. /**
  44197. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44198. */
  44199. rollCorrect: number;
  44200. /**
  44201. * Mimic a banked turn, Rolling the camera when Yawing.
  44202. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44203. */
  44204. bankedTurn: boolean;
  44205. /**
  44206. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44207. */
  44208. bankedTurnLimit: number;
  44209. /**
  44210. * Value of 0 disables the banked Roll.
  44211. * Value of 1 is equal to the Yaw angle in radians.
  44212. */
  44213. bankedTurnMultiplier: number;
  44214. /**
  44215. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44216. */
  44217. inputs: FlyCameraInputsManager;
  44218. /**
  44219. * Gets the input sensibility for mouse input.
  44220. * Higher values reduce sensitivity.
  44221. */
  44222. get angularSensibility(): number;
  44223. /**
  44224. * Sets the input sensibility for a mouse input.
  44225. * Higher values reduce sensitivity.
  44226. */
  44227. set angularSensibility(value: number);
  44228. /**
  44229. * Get the keys for camera movement forward.
  44230. */
  44231. get keysForward(): number[];
  44232. /**
  44233. * Set the keys for camera movement forward.
  44234. */
  44235. set keysForward(value: number[]);
  44236. /**
  44237. * Get the keys for camera movement backward.
  44238. */
  44239. get keysBackward(): number[];
  44240. set keysBackward(value: number[]);
  44241. /**
  44242. * Get the keys for camera movement up.
  44243. */
  44244. get keysUp(): number[];
  44245. /**
  44246. * Set the keys for camera movement up.
  44247. */
  44248. set keysUp(value: number[]);
  44249. /**
  44250. * Get the keys for camera movement down.
  44251. */
  44252. get keysDown(): number[];
  44253. /**
  44254. * Set the keys for camera movement down.
  44255. */
  44256. set keysDown(value: number[]);
  44257. /**
  44258. * Get the keys for camera movement left.
  44259. */
  44260. get keysLeft(): number[];
  44261. /**
  44262. * Set the keys for camera movement left.
  44263. */
  44264. set keysLeft(value: number[]);
  44265. /**
  44266. * Set the keys for camera movement right.
  44267. */
  44268. get keysRight(): number[];
  44269. /**
  44270. * Set the keys for camera movement right.
  44271. */
  44272. set keysRight(value: number[]);
  44273. /**
  44274. * Event raised when the camera collides with a mesh in the scene.
  44275. */
  44276. onCollide: (collidedMesh: AbstractMesh) => void;
  44277. private _collider;
  44278. private _needMoveForGravity;
  44279. private _oldPosition;
  44280. private _diffPosition;
  44281. private _newPosition;
  44282. /** @hidden */
  44283. _localDirection: Vector3;
  44284. /** @hidden */
  44285. _transformedDirection: Vector3;
  44286. /**
  44287. * Instantiates a FlyCamera.
  44288. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44289. * such as in a 3D Space Shooter or a Flight Simulator.
  44290. * @param name Define the name of the camera in the scene.
  44291. * @param position Define the starting position of the camera in the scene.
  44292. * @param scene Define the scene the camera belongs to.
  44293. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44294. */
  44295. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44296. /**
  44297. * Attach a control to the HTML DOM element.
  44298. * @param element Defines the element that listens to the input events.
  44299. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44300. */
  44301. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44302. /**
  44303. * Detach a control from the HTML DOM element.
  44304. * The camera will stop reacting to that input.
  44305. * @param element Defines the element that listens to the input events.
  44306. */
  44307. detachControl(element: HTMLElement): void;
  44308. private _collisionMask;
  44309. /**
  44310. * Get the mask that the camera ignores in collision events.
  44311. */
  44312. get collisionMask(): number;
  44313. /**
  44314. * Set the mask that the camera ignores in collision events.
  44315. */
  44316. set collisionMask(mask: number);
  44317. /** @hidden */
  44318. _collideWithWorld(displacement: Vector3): void;
  44319. /** @hidden */
  44320. private _onCollisionPositionChange;
  44321. /** @hidden */
  44322. _checkInputs(): void;
  44323. /** @hidden */
  44324. _decideIfNeedsToMove(): boolean;
  44325. /** @hidden */
  44326. _updatePosition(): void;
  44327. /**
  44328. * Restore the Roll to its target value at the rate specified.
  44329. * @param rate - Higher means slower restoring.
  44330. * @hidden
  44331. */
  44332. restoreRoll(rate: number): void;
  44333. /**
  44334. * Destroy the camera and release the current resources held by it.
  44335. */
  44336. dispose(): void;
  44337. /**
  44338. * Get the current object class name.
  44339. * @returns the class name.
  44340. */
  44341. getClassName(): string;
  44342. }
  44343. }
  44344. declare module BABYLON {
  44345. /**
  44346. * Listen to keyboard events to control the camera.
  44347. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44348. */
  44349. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44350. /**
  44351. * Defines the camera the input is attached to.
  44352. */
  44353. camera: FlyCamera;
  44354. /**
  44355. * The list of keyboard keys used to control the forward move of the camera.
  44356. */
  44357. keysForward: number[];
  44358. /**
  44359. * The list of keyboard keys used to control the backward move of the camera.
  44360. */
  44361. keysBackward: number[];
  44362. /**
  44363. * The list of keyboard keys used to control the forward move of the camera.
  44364. */
  44365. keysUp: number[];
  44366. /**
  44367. * The list of keyboard keys used to control the backward move of the camera.
  44368. */
  44369. keysDown: number[];
  44370. /**
  44371. * The list of keyboard keys used to control the right strafe move of the camera.
  44372. */
  44373. keysRight: number[];
  44374. /**
  44375. * The list of keyboard keys used to control the left strafe move of the camera.
  44376. */
  44377. keysLeft: number[];
  44378. private _keys;
  44379. private _onCanvasBlurObserver;
  44380. private _onKeyboardObserver;
  44381. private _engine;
  44382. private _scene;
  44383. /**
  44384. * Attach the input controls to a specific dom element to get the input from.
  44385. * @param element Defines the element the controls should be listened from
  44386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44387. */
  44388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44389. /**
  44390. * Detach the current controls from the specified dom element.
  44391. * @param element Defines the element to stop listening the inputs from
  44392. */
  44393. detachControl(element: Nullable<HTMLElement>): void;
  44394. /**
  44395. * Gets the class name of the current intput.
  44396. * @returns the class name
  44397. */
  44398. getClassName(): string;
  44399. /** @hidden */
  44400. _onLostFocus(e: FocusEvent): void;
  44401. /**
  44402. * Get the friendly name associated with the input class.
  44403. * @returns the input friendly name
  44404. */
  44405. getSimpleName(): string;
  44406. /**
  44407. * Update the current camera state depending on the inputs that have been used this frame.
  44408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44409. */
  44410. checkInputs(): void;
  44411. }
  44412. }
  44413. declare module BABYLON {
  44414. /**
  44415. * Manage the mouse wheel inputs to control a follow camera.
  44416. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44417. */
  44418. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44419. /**
  44420. * Defines the camera the input is attached to.
  44421. */
  44422. camera: FollowCamera;
  44423. /**
  44424. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44425. */
  44426. axisControlRadius: boolean;
  44427. /**
  44428. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44429. */
  44430. axisControlHeight: boolean;
  44431. /**
  44432. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44433. */
  44434. axisControlRotation: boolean;
  44435. /**
  44436. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44437. * relation to mouseWheel events.
  44438. */
  44439. wheelPrecision: number;
  44440. /**
  44441. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44442. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44443. */
  44444. wheelDeltaPercentage: number;
  44445. private _wheel;
  44446. private _observer;
  44447. /**
  44448. * Attach the input controls to a specific dom element to get the input from.
  44449. * @param element Defines the element the controls should be listened from
  44450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44451. */
  44452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44453. /**
  44454. * Detach the current controls from the specified dom element.
  44455. * @param element Defines the element to stop listening the inputs from
  44456. */
  44457. detachControl(element: Nullable<HTMLElement>): void;
  44458. /**
  44459. * Gets the class name of the current intput.
  44460. * @returns the class name
  44461. */
  44462. getClassName(): string;
  44463. /**
  44464. * Get the friendly name associated with the input class.
  44465. * @returns the input friendly name
  44466. */
  44467. getSimpleName(): string;
  44468. }
  44469. }
  44470. declare module BABYLON {
  44471. /**
  44472. * Manage the pointers inputs to control an follow camera.
  44473. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44474. */
  44475. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44476. /**
  44477. * Defines the camera the input is attached to.
  44478. */
  44479. camera: FollowCamera;
  44480. /**
  44481. * Gets the class name of the current input.
  44482. * @returns the class name
  44483. */
  44484. getClassName(): string;
  44485. /**
  44486. * Defines the pointer angular sensibility along the X axis or how fast is
  44487. * the camera rotating.
  44488. * A negative number will reverse the axis direction.
  44489. */
  44490. angularSensibilityX: number;
  44491. /**
  44492. * Defines the pointer angular sensibility along the Y axis or how fast is
  44493. * the camera rotating.
  44494. * A negative number will reverse the axis direction.
  44495. */
  44496. angularSensibilityY: number;
  44497. /**
  44498. * Defines the pointer pinch precision or how fast is the camera zooming.
  44499. * A negative number will reverse the axis direction.
  44500. */
  44501. pinchPrecision: number;
  44502. /**
  44503. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44504. * from 0.
  44505. * It defines the percentage of current camera.radius to use as delta when
  44506. * pinch zoom is used.
  44507. */
  44508. pinchDeltaPercentage: number;
  44509. /**
  44510. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44511. */
  44512. axisXControlRadius: boolean;
  44513. /**
  44514. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44515. */
  44516. axisXControlHeight: boolean;
  44517. /**
  44518. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44519. */
  44520. axisXControlRotation: boolean;
  44521. /**
  44522. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44523. */
  44524. axisYControlRadius: boolean;
  44525. /**
  44526. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44527. */
  44528. axisYControlHeight: boolean;
  44529. /**
  44530. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44531. */
  44532. axisYControlRotation: boolean;
  44533. /**
  44534. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44535. */
  44536. axisPinchControlRadius: boolean;
  44537. /**
  44538. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44539. */
  44540. axisPinchControlHeight: boolean;
  44541. /**
  44542. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44543. */
  44544. axisPinchControlRotation: boolean;
  44545. /**
  44546. * Log error messages if basic misconfiguration has occurred.
  44547. */
  44548. warningEnable: boolean;
  44549. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44550. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44551. private _warningCounter;
  44552. private _warning;
  44553. }
  44554. }
  44555. declare module BABYLON {
  44556. /**
  44557. * Default Inputs manager for the FollowCamera.
  44558. * It groups all the default supported inputs for ease of use.
  44559. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44560. */
  44561. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44562. /**
  44563. * Instantiates a new FollowCameraInputsManager.
  44564. * @param camera Defines the camera the inputs belong to
  44565. */
  44566. constructor(camera: FollowCamera);
  44567. /**
  44568. * Add keyboard input support to the input manager.
  44569. * @returns the current input manager
  44570. */
  44571. addKeyboard(): FollowCameraInputsManager;
  44572. /**
  44573. * Add mouse wheel input support to the input manager.
  44574. * @returns the current input manager
  44575. */
  44576. addMouseWheel(): FollowCameraInputsManager;
  44577. /**
  44578. * Add pointers input support to the input manager.
  44579. * @returns the current input manager
  44580. */
  44581. addPointers(): FollowCameraInputsManager;
  44582. /**
  44583. * Add orientation input support to the input manager.
  44584. * @returns the current input manager
  44585. */
  44586. addVRDeviceOrientation(): FollowCameraInputsManager;
  44587. }
  44588. }
  44589. declare module BABYLON {
  44590. /**
  44591. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44592. * an arc rotate version arcFollowCamera are available.
  44593. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44594. */
  44595. export class FollowCamera extends TargetCamera {
  44596. /**
  44597. * Distance the follow camera should follow an object at
  44598. */
  44599. radius: number;
  44600. /**
  44601. * Minimum allowed distance of the camera to the axis of rotation
  44602. * (The camera can not get closer).
  44603. * This can help limiting how the Camera is able to move in the scene.
  44604. */
  44605. lowerRadiusLimit: Nullable<number>;
  44606. /**
  44607. * Maximum allowed distance of the camera to the axis of rotation
  44608. * (The camera can not get further).
  44609. * This can help limiting how the Camera is able to move in the scene.
  44610. */
  44611. upperRadiusLimit: Nullable<number>;
  44612. /**
  44613. * Define a rotation offset between the camera and the object it follows
  44614. */
  44615. rotationOffset: number;
  44616. /**
  44617. * Minimum allowed angle to camera position relative to target object.
  44618. * This can help limiting how the Camera is able to move in the scene.
  44619. */
  44620. lowerRotationOffsetLimit: Nullable<number>;
  44621. /**
  44622. * Maximum allowed angle to camera position relative to target object.
  44623. * This can help limiting how the Camera is able to move in the scene.
  44624. */
  44625. upperRotationOffsetLimit: Nullable<number>;
  44626. /**
  44627. * Define a height offset between the camera and the object it follows.
  44628. * It can help following an object from the top (like a car chaing a plane)
  44629. */
  44630. heightOffset: number;
  44631. /**
  44632. * Minimum allowed height of camera position relative to target object.
  44633. * This can help limiting how the Camera is able to move in the scene.
  44634. */
  44635. lowerHeightOffsetLimit: Nullable<number>;
  44636. /**
  44637. * Maximum allowed height of camera position relative to target object.
  44638. * This can help limiting how the Camera is able to move in the scene.
  44639. */
  44640. upperHeightOffsetLimit: Nullable<number>;
  44641. /**
  44642. * Define how fast the camera can accelerate to follow it s target.
  44643. */
  44644. cameraAcceleration: number;
  44645. /**
  44646. * Define the speed limit of the camera following an object.
  44647. */
  44648. maxCameraSpeed: number;
  44649. /**
  44650. * Define the target of the camera.
  44651. */
  44652. lockedTarget: Nullable<AbstractMesh>;
  44653. /**
  44654. * Defines the input associated with the camera.
  44655. */
  44656. inputs: FollowCameraInputsManager;
  44657. /**
  44658. * Instantiates the follow camera.
  44659. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44660. * @param name Define the name of the camera in the scene
  44661. * @param position Define the position of the camera
  44662. * @param scene Define the scene the camera belong to
  44663. * @param lockedTarget Define the target of the camera
  44664. */
  44665. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44666. private _follow;
  44667. /**
  44668. * Attached controls to the current camera.
  44669. * @param element Defines the element the controls should be listened from
  44670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44671. */
  44672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44673. /**
  44674. * Detach the current controls from the camera.
  44675. * The camera will stop reacting to inputs.
  44676. * @param element Defines the element to stop listening the inputs from
  44677. */
  44678. detachControl(element: HTMLElement): void;
  44679. /** @hidden */
  44680. _checkInputs(): void;
  44681. private _checkLimits;
  44682. /**
  44683. * Gets the camera class name.
  44684. * @returns the class name
  44685. */
  44686. getClassName(): string;
  44687. }
  44688. /**
  44689. * Arc Rotate version of the follow camera.
  44690. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44691. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44692. */
  44693. export class ArcFollowCamera extends TargetCamera {
  44694. /** The longitudinal angle of the camera */
  44695. alpha: number;
  44696. /** The latitudinal angle of the camera */
  44697. beta: number;
  44698. /** The radius of the camera from its target */
  44699. radius: number;
  44700. private _cartesianCoordinates;
  44701. /** Define the camera target (the mesh it should follow) */
  44702. private _meshTarget;
  44703. /**
  44704. * Instantiates a new ArcFollowCamera
  44705. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44706. * @param name Define the name of the camera
  44707. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44708. * @param beta Define the rotation angle of the camera around the elevation axis
  44709. * @param radius Define the radius of the camera from its target point
  44710. * @param target Define the target of the camera
  44711. * @param scene Define the scene the camera belongs to
  44712. */
  44713. constructor(name: string,
  44714. /** The longitudinal angle of the camera */
  44715. alpha: number,
  44716. /** The latitudinal angle of the camera */
  44717. beta: number,
  44718. /** The radius of the camera from its target */
  44719. radius: number,
  44720. /** Define the camera target (the mesh it should follow) */
  44721. target: Nullable<AbstractMesh>, scene: Scene);
  44722. private _follow;
  44723. /** @hidden */
  44724. _checkInputs(): void;
  44725. /**
  44726. * Returns the class name of the object.
  44727. * It is mostly used internally for serialization purposes.
  44728. */
  44729. getClassName(): string;
  44730. }
  44731. }
  44732. declare module BABYLON {
  44733. /**
  44734. * Manage the keyboard inputs to control the movement of a follow camera.
  44735. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44736. */
  44737. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44738. /**
  44739. * Defines the camera the input is attached to.
  44740. */
  44741. camera: FollowCamera;
  44742. /**
  44743. * Defines the list of key codes associated with the up action (increase heightOffset)
  44744. */
  44745. keysHeightOffsetIncr: number[];
  44746. /**
  44747. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44748. */
  44749. keysHeightOffsetDecr: number[];
  44750. /**
  44751. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44752. */
  44753. keysHeightOffsetModifierAlt: boolean;
  44754. /**
  44755. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44756. */
  44757. keysHeightOffsetModifierCtrl: boolean;
  44758. /**
  44759. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44760. */
  44761. keysHeightOffsetModifierShift: boolean;
  44762. /**
  44763. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44764. */
  44765. keysRotationOffsetIncr: number[];
  44766. /**
  44767. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44768. */
  44769. keysRotationOffsetDecr: number[];
  44770. /**
  44771. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44772. */
  44773. keysRotationOffsetModifierAlt: boolean;
  44774. /**
  44775. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44776. */
  44777. keysRotationOffsetModifierCtrl: boolean;
  44778. /**
  44779. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44780. */
  44781. keysRotationOffsetModifierShift: boolean;
  44782. /**
  44783. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44784. */
  44785. keysRadiusIncr: number[];
  44786. /**
  44787. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44788. */
  44789. keysRadiusDecr: number[];
  44790. /**
  44791. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44792. */
  44793. keysRadiusModifierAlt: boolean;
  44794. /**
  44795. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44796. */
  44797. keysRadiusModifierCtrl: boolean;
  44798. /**
  44799. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44800. */
  44801. keysRadiusModifierShift: boolean;
  44802. /**
  44803. * Defines the rate of change of heightOffset.
  44804. */
  44805. heightSensibility: number;
  44806. /**
  44807. * Defines the rate of change of rotationOffset.
  44808. */
  44809. rotationSensibility: number;
  44810. /**
  44811. * Defines the rate of change of radius.
  44812. */
  44813. radiusSensibility: number;
  44814. private _keys;
  44815. private _ctrlPressed;
  44816. private _altPressed;
  44817. private _shiftPressed;
  44818. private _onCanvasBlurObserver;
  44819. private _onKeyboardObserver;
  44820. private _engine;
  44821. private _scene;
  44822. /**
  44823. * Attach the input controls to a specific dom element to get the input from.
  44824. * @param element Defines the element the controls should be listened from
  44825. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44826. */
  44827. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44828. /**
  44829. * Detach the current controls from the specified dom element.
  44830. * @param element Defines the element to stop listening the inputs from
  44831. */
  44832. detachControl(element: Nullable<HTMLElement>): void;
  44833. /**
  44834. * Update the current camera state depending on the inputs that have been used this frame.
  44835. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44836. */
  44837. checkInputs(): void;
  44838. /**
  44839. * Gets the class name of the current input.
  44840. * @returns the class name
  44841. */
  44842. getClassName(): string;
  44843. /**
  44844. * Get the friendly name associated with the input class.
  44845. * @returns the input friendly name
  44846. */
  44847. getSimpleName(): string;
  44848. /**
  44849. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44850. * allow modification of the heightOffset value.
  44851. */
  44852. private _modifierHeightOffset;
  44853. /**
  44854. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44855. * allow modification of the rotationOffset value.
  44856. */
  44857. private _modifierRotationOffset;
  44858. /**
  44859. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44860. * allow modification of the radius value.
  44861. */
  44862. private _modifierRadius;
  44863. }
  44864. }
  44865. declare module BABYLON {
  44866. interface FreeCameraInputsManager {
  44867. /**
  44868. * @hidden
  44869. */
  44870. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44871. /**
  44872. * Add orientation input support to the input manager.
  44873. * @returns the current input manager
  44874. */
  44875. addDeviceOrientation(): FreeCameraInputsManager;
  44876. }
  44877. /**
  44878. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44879. * Screen rotation is taken into account.
  44880. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44881. */
  44882. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44883. private _camera;
  44884. private _screenOrientationAngle;
  44885. private _constantTranform;
  44886. private _screenQuaternion;
  44887. private _alpha;
  44888. private _beta;
  44889. private _gamma;
  44890. /**
  44891. * Can be used to detect if a device orientation sensor is available on a device
  44892. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44893. * @returns a promise that will resolve on orientation change
  44894. */
  44895. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44896. /**
  44897. * @hidden
  44898. */
  44899. _onDeviceOrientationChangedObservable: Observable<void>;
  44900. /**
  44901. * Instantiates a new input
  44902. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44903. */
  44904. constructor();
  44905. /**
  44906. * Define the camera controlled by the input.
  44907. */
  44908. get camera(): FreeCamera;
  44909. set camera(camera: FreeCamera);
  44910. /**
  44911. * Attach the input controls to a specific dom element to get the input from.
  44912. * @param element Defines the element the controls should be listened from
  44913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44914. */
  44915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44916. private _orientationChanged;
  44917. private _deviceOrientation;
  44918. /**
  44919. * Detach the current controls from the specified dom element.
  44920. * @param element Defines the element to stop listening the inputs from
  44921. */
  44922. detachControl(element: Nullable<HTMLElement>): void;
  44923. /**
  44924. * Update the current camera state depending on the inputs that have been used this frame.
  44925. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44926. */
  44927. checkInputs(): void;
  44928. /**
  44929. * Gets the class name of the current intput.
  44930. * @returns the class name
  44931. */
  44932. getClassName(): string;
  44933. /**
  44934. * Get the friendly name associated with the input class.
  44935. * @returns the input friendly name
  44936. */
  44937. getSimpleName(): string;
  44938. }
  44939. }
  44940. declare module BABYLON {
  44941. /**
  44942. * Manage the gamepad inputs to control a free camera.
  44943. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44944. */
  44945. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44946. /**
  44947. * Define the camera the input is attached to.
  44948. */
  44949. camera: FreeCamera;
  44950. /**
  44951. * Define the Gamepad controlling the input
  44952. */
  44953. gamepad: Nullable<Gamepad>;
  44954. /**
  44955. * Defines the gamepad rotation sensiblity.
  44956. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44957. */
  44958. gamepadAngularSensibility: number;
  44959. /**
  44960. * Defines the gamepad move sensiblity.
  44961. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44962. */
  44963. gamepadMoveSensibility: number;
  44964. private _yAxisScale;
  44965. /**
  44966. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44967. */
  44968. get invertYAxis(): boolean;
  44969. set invertYAxis(value: boolean);
  44970. private _onGamepadConnectedObserver;
  44971. private _onGamepadDisconnectedObserver;
  44972. private _cameraTransform;
  44973. private _deltaTransform;
  44974. private _vector3;
  44975. private _vector2;
  44976. /**
  44977. * Attach the input controls to a specific dom element to get the input from.
  44978. * @param element Defines the element the controls should be listened from
  44979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44980. */
  44981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44982. /**
  44983. * Detach the current controls from the specified dom element.
  44984. * @param element Defines the element to stop listening the inputs from
  44985. */
  44986. detachControl(element: Nullable<HTMLElement>): void;
  44987. /**
  44988. * Update the current camera state depending on the inputs that have been used this frame.
  44989. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44990. */
  44991. checkInputs(): void;
  44992. /**
  44993. * Gets the class name of the current intput.
  44994. * @returns the class name
  44995. */
  44996. getClassName(): string;
  44997. /**
  44998. * Get the friendly name associated with the input class.
  44999. * @returns the input friendly name
  45000. */
  45001. getSimpleName(): string;
  45002. }
  45003. }
  45004. declare module BABYLON {
  45005. /**
  45006. * Defines the potential axis of a Joystick
  45007. */
  45008. export enum JoystickAxis {
  45009. /** X axis */
  45010. X = 0,
  45011. /** Y axis */
  45012. Y = 1,
  45013. /** Z axis */
  45014. Z = 2
  45015. }
  45016. /**
  45017. * Represents the different customization options available
  45018. * for VirtualJoystick
  45019. */
  45020. interface VirtualJoystickCustomizations {
  45021. /**
  45022. * Size of the joystick's puck
  45023. */
  45024. puckSize: number;
  45025. /**
  45026. * Size of the joystick's container
  45027. */
  45028. containerSize: number;
  45029. /**
  45030. * Color of the joystick && puck
  45031. */
  45032. color: string;
  45033. /**
  45034. * Image URL for the joystick's puck
  45035. */
  45036. puckImage?: string;
  45037. /**
  45038. * Image URL for the joystick's container
  45039. */
  45040. containerImage?: string;
  45041. /**
  45042. * Defines the unmoving position of the joystick container
  45043. */
  45044. position?: {
  45045. x: number;
  45046. y: number;
  45047. };
  45048. /**
  45049. * Defines whether or not the joystick container is always visible
  45050. */
  45051. alwaysVisible: boolean;
  45052. /**
  45053. * Defines whether or not to limit the movement of the puck to the joystick's container
  45054. */
  45055. limitToContainer: boolean;
  45056. }
  45057. /**
  45058. * Class used to define virtual joystick (used in touch mode)
  45059. */
  45060. export class VirtualJoystick {
  45061. /**
  45062. * Gets or sets a boolean indicating that left and right values must be inverted
  45063. */
  45064. reverseLeftRight: boolean;
  45065. /**
  45066. * Gets or sets a boolean indicating that up and down values must be inverted
  45067. */
  45068. reverseUpDown: boolean;
  45069. /**
  45070. * Gets the offset value for the position (ie. the change of the position value)
  45071. */
  45072. deltaPosition: Vector3;
  45073. /**
  45074. * Gets a boolean indicating if the virtual joystick was pressed
  45075. */
  45076. pressed: boolean;
  45077. /**
  45078. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45079. */
  45080. static Canvas: Nullable<HTMLCanvasElement>;
  45081. /**
  45082. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45083. */
  45084. limitToContainer: boolean;
  45085. private static _globalJoystickIndex;
  45086. private static _alwaysVisibleSticks;
  45087. private static vjCanvasContext;
  45088. private static vjCanvasWidth;
  45089. private static vjCanvasHeight;
  45090. private static halfWidth;
  45091. private static _GetDefaultOptions;
  45092. private _action;
  45093. private _axisTargetedByLeftAndRight;
  45094. private _axisTargetedByUpAndDown;
  45095. private _joystickSensibility;
  45096. private _inversedSensibility;
  45097. private _joystickPointerID;
  45098. private _joystickColor;
  45099. private _joystickPointerPos;
  45100. private _joystickPreviousPointerPos;
  45101. private _joystickPointerStartPos;
  45102. private _deltaJoystickVector;
  45103. private _leftJoystick;
  45104. private _touches;
  45105. private _joystickPosition;
  45106. private _alwaysVisible;
  45107. private _puckImage;
  45108. private _containerImage;
  45109. private _joystickPuckSize;
  45110. private _joystickContainerSize;
  45111. private _clearPuckSize;
  45112. private _clearContainerSize;
  45113. private _clearPuckSizeOffset;
  45114. private _clearContainerSizeOffset;
  45115. private _onPointerDownHandlerRef;
  45116. private _onPointerMoveHandlerRef;
  45117. private _onPointerUpHandlerRef;
  45118. private _onResize;
  45119. /**
  45120. * Creates a new virtual joystick
  45121. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45122. * @param customizations Defines the options we want to customize the VirtualJoystick
  45123. */
  45124. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45125. /**
  45126. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45127. * @param newJoystickSensibility defines the new sensibility
  45128. */
  45129. setJoystickSensibility(newJoystickSensibility: number): void;
  45130. private _onPointerDown;
  45131. private _onPointerMove;
  45132. private _onPointerUp;
  45133. /**
  45134. * Change the color of the virtual joystick
  45135. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45136. */
  45137. setJoystickColor(newColor: string): void;
  45138. /**
  45139. * Size of the joystick's container
  45140. */
  45141. set containerSize(newSize: number);
  45142. get containerSize(): number;
  45143. /**
  45144. * Size of the joystick's puck
  45145. */
  45146. set puckSize(newSize: number);
  45147. get puckSize(): number;
  45148. /**
  45149. * Clears the set position of the joystick
  45150. */
  45151. clearPosition(): void;
  45152. /**
  45153. * Defines whether or not the joystick container is always visible
  45154. */
  45155. set alwaysVisible(value: boolean);
  45156. get alwaysVisible(): boolean;
  45157. /**
  45158. * Sets the constant position of the Joystick container
  45159. * @param x X axis coordinate
  45160. * @param y Y axis coordinate
  45161. */
  45162. setPosition(x: number, y: number): void;
  45163. /**
  45164. * Defines a callback to call when the joystick is touched
  45165. * @param action defines the callback
  45166. */
  45167. setActionOnTouch(action: () => any): void;
  45168. /**
  45169. * Defines which axis you'd like to control for left & right
  45170. * @param axis defines the axis to use
  45171. */
  45172. setAxisForLeftRight(axis: JoystickAxis): void;
  45173. /**
  45174. * Defines which axis you'd like to control for up & down
  45175. * @param axis defines the axis to use
  45176. */
  45177. setAxisForUpDown(axis: JoystickAxis): void;
  45178. /**
  45179. * Clears the canvas from the previous puck / container draw
  45180. */
  45181. private _clearPreviousDraw;
  45182. /**
  45183. * Loads `urlPath` to be used for the container's image
  45184. * @param urlPath defines the urlPath of an image to use
  45185. */
  45186. setContainerImage(urlPath: string): void;
  45187. /**
  45188. * Loads `urlPath` to be used for the puck's image
  45189. * @param urlPath defines the urlPath of an image to use
  45190. */
  45191. setPuckImage(urlPath: string): void;
  45192. /**
  45193. * Draws the Virtual Joystick's container
  45194. */
  45195. private _drawContainer;
  45196. /**
  45197. * Draws the Virtual Joystick's puck
  45198. */
  45199. private _drawPuck;
  45200. private _drawVirtualJoystick;
  45201. /**
  45202. * Release internal HTML canvas
  45203. */
  45204. releaseCanvas(): void;
  45205. }
  45206. }
  45207. declare module BABYLON {
  45208. interface FreeCameraInputsManager {
  45209. /**
  45210. * Add virtual joystick input support to the input manager.
  45211. * @returns the current input manager
  45212. */
  45213. addVirtualJoystick(): FreeCameraInputsManager;
  45214. }
  45215. /**
  45216. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45217. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45218. */
  45219. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45220. /**
  45221. * Defines the camera the input is attached to.
  45222. */
  45223. camera: FreeCamera;
  45224. private _leftjoystick;
  45225. private _rightjoystick;
  45226. /**
  45227. * Gets the left stick of the virtual joystick.
  45228. * @returns The virtual Joystick
  45229. */
  45230. getLeftJoystick(): VirtualJoystick;
  45231. /**
  45232. * Gets the right stick of the virtual joystick.
  45233. * @returns The virtual Joystick
  45234. */
  45235. getRightJoystick(): VirtualJoystick;
  45236. /**
  45237. * Update the current camera state depending on the inputs that have been used this frame.
  45238. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45239. */
  45240. checkInputs(): void;
  45241. /**
  45242. * Attach the input controls to a specific dom element to get the input from.
  45243. * @param element Defines the element the controls should be listened from
  45244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45245. */
  45246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45247. /**
  45248. * Detach the current controls from the specified dom element.
  45249. * @param element Defines the element to stop listening the inputs from
  45250. */
  45251. detachControl(element: Nullable<HTMLElement>): void;
  45252. /**
  45253. * Gets the class name of the current intput.
  45254. * @returns the class name
  45255. */
  45256. getClassName(): string;
  45257. /**
  45258. * Get the friendly name associated with the input class.
  45259. * @returns the input friendly name
  45260. */
  45261. getSimpleName(): string;
  45262. }
  45263. }
  45264. declare module BABYLON {
  45265. /**
  45266. * This represents a FPS type of camera controlled by touch.
  45267. * This is like a universal camera minus the Gamepad controls.
  45268. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45269. */
  45270. export class TouchCamera extends FreeCamera {
  45271. /**
  45272. * Defines the touch sensibility for rotation.
  45273. * The higher the faster.
  45274. */
  45275. get touchAngularSensibility(): number;
  45276. set touchAngularSensibility(value: number);
  45277. /**
  45278. * Defines the touch sensibility for move.
  45279. * The higher the faster.
  45280. */
  45281. get touchMoveSensibility(): number;
  45282. set touchMoveSensibility(value: number);
  45283. /**
  45284. * Instantiates a new touch camera.
  45285. * This represents a FPS type of camera controlled by touch.
  45286. * This is like a universal camera minus the Gamepad controls.
  45287. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45288. * @param name Define the name of the camera in the scene
  45289. * @param position Define the start position of the camera in the scene
  45290. * @param scene Define the scene the camera belongs to
  45291. */
  45292. constructor(name: string, position: Vector3, scene: Scene);
  45293. /**
  45294. * Gets the current object class name.
  45295. * @return the class name
  45296. */
  45297. getClassName(): string;
  45298. /** @hidden */
  45299. _setupInputs(): void;
  45300. }
  45301. }
  45302. declare module BABYLON {
  45303. /**
  45304. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45305. * being tilted forward or back and left or right.
  45306. */
  45307. export class DeviceOrientationCamera extends FreeCamera {
  45308. private _initialQuaternion;
  45309. private _quaternionCache;
  45310. private _tmpDragQuaternion;
  45311. private _disablePointerInputWhenUsingDeviceOrientation;
  45312. /**
  45313. * Creates a new device orientation camera
  45314. * @param name The name of the camera
  45315. * @param position The start position camera
  45316. * @param scene The scene the camera belongs to
  45317. */
  45318. constructor(name: string, position: Vector3, scene: Scene);
  45319. /**
  45320. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45321. */
  45322. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45323. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45324. private _dragFactor;
  45325. /**
  45326. * Enabled turning on the y axis when the orientation sensor is active
  45327. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45328. */
  45329. enableHorizontalDragging(dragFactor?: number): void;
  45330. /**
  45331. * Gets the current instance class name ("DeviceOrientationCamera").
  45332. * This helps avoiding instanceof at run time.
  45333. * @returns the class name
  45334. */
  45335. getClassName(): string;
  45336. /**
  45337. * @hidden
  45338. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45339. */
  45340. _checkInputs(): void;
  45341. /**
  45342. * Reset the camera to its default orientation on the specified axis only.
  45343. * @param axis The axis to reset
  45344. */
  45345. resetToCurrentRotation(axis?: Axis): void;
  45346. }
  45347. }
  45348. declare module BABYLON {
  45349. /**
  45350. * Defines supported buttons for XBox360 compatible gamepads
  45351. */
  45352. export enum Xbox360Button {
  45353. /** A */
  45354. A = 0,
  45355. /** B */
  45356. B = 1,
  45357. /** X */
  45358. X = 2,
  45359. /** Y */
  45360. Y = 3,
  45361. /** Left button */
  45362. LB = 4,
  45363. /** Right button */
  45364. RB = 5,
  45365. /** Back */
  45366. Back = 8,
  45367. /** Start */
  45368. Start = 9,
  45369. /** Left stick */
  45370. LeftStick = 10,
  45371. /** Right stick */
  45372. RightStick = 11
  45373. }
  45374. /** Defines values for XBox360 DPad */
  45375. export enum Xbox360Dpad {
  45376. /** Up */
  45377. Up = 12,
  45378. /** Down */
  45379. Down = 13,
  45380. /** Left */
  45381. Left = 14,
  45382. /** Right */
  45383. Right = 15
  45384. }
  45385. /**
  45386. * Defines a XBox360 gamepad
  45387. */
  45388. export class Xbox360Pad extends Gamepad {
  45389. private _leftTrigger;
  45390. private _rightTrigger;
  45391. private _onlefttriggerchanged;
  45392. private _onrighttriggerchanged;
  45393. private _onbuttondown;
  45394. private _onbuttonup;
  45395. private _ondpaddown;
  45396. private _ondpadup;
  45397. /** Observable raised when a button is pressed */
  45398. onButtonDownObservable: Observable<Xbox360Button>;
  45399. /** Observable raised when a button is released */
  45400. onButtonUpObservable: Observable<Xbox360Button>;
  45401. /** Observable raised when a pad is pressed */
  45402. onPadDownObservable: Observable<Xbox360Dpad>;
  45403. /** Observable raised when a pad is released */
  45404. onPadUpObservable: Observable<Xbox360Dpad>;
  45405. private _buttonA;
  45406. private _buttonB;
  45407. private _buttonX;
  45408. private _buttonY;
  45409. private _buttonBack;
  45410. private _buttonStart;
  45411. private _buttonLB;
  45412. private _buttonRB;
  45413. private _buttonLeftStick;
  45414. private _buttonRightStick;
  45415. private _dPadUp;
  45416. private _dPadDown;
  45417. private _dPadLeft;
  45418. private _dPadRight;
  45419. private _isXboxOnePad;
  45420. /**
  45421. * Creates a new XBox360 gamepad object
  45422. * @param id defines the id of this gamepad
  45423. * @param index defines its index
  45424. * @param gamepad defines the internal HTML gamepad object
  45425. * @param xboxOne defines if it is a XBox One gamepad
  45426. */
  45427. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45428. /**
  45429. * Defines the callback to call when left trigger is pressed
  45430. * @param callback defines the callback to use
  45431. */
  45432. onlefttriggerchanged(callback: (value: number) => void): void;
  45433. /**
  45434. * Defines the callback to call when right trigger is pressed
  45435. * @param callback defines the callback to use
  45436. */
  45437. onrighttriggerchanged(callback: (value: number) => void): void;
  45438. /**
  45439. * Gets the left trigger value
  45440. */
  45441. get leftTrigger(): number;
  45442. /**
  45443. * Sets the left trigger value
  45444. */
  45445. set leftTrigger(newValue: number);
  45446. /**
  45447. * Gets the right trigger value
  45448. */
  45449. get rightTrigger(): number;
  45450. /**
  45451. * Sets the right trigger value
  45452. */
  45453. set rightTrigger(newValue: number);
  45454. /**
  45455. * Defines the callback to call when a button is pressed
  45456. * @param callback defines the callback to use
  45457. */
  45458. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45459. /**
  45460. * Defines the callback to call when a button is released
  45461. * @param callback defines the callback to use
  45462. */
  45463. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45464. /**
  45465. * Defines the callback to call when a pad is pressed
  45466. * @param callback defines the callback to use
  45467. */
  45468. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45469. /**
  45470. * Defines the callback to call when a pad is released
  45471. * @param callback defines the callback to use
  45472. */
  45473. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45474. private _setButtonValue;
  45475. private _setDPadValue;
  45476. /**
  45477. * Gets the value of the `A` button
  45478. */
  45479. get buttonA(): number;
  45480. /**
  45481. * Sets the value of the `A` button
  45482. */
  45483. set buttonA(value: number);
  45484. /**
  45485. * Gets the value of the `B` button
  45486. */
  45487. get buttonB(): number;
  45488. /**
  45489. * Sets the value of the `B` button
  45490. */
  45491. set buttonB(value: number);
  45492. /**
  45493. * Gets the value of the `X` button
  45494. */
  45495. get buttonX(): number;
  45496. /**
  45497. * Sets the value of the `X` button
  45498. */
  45499. set buttonX(value: number);
  45500. /**
  45501. * Gets the value of the `Y` button
  45502. */
  45503. get buttonY(): number;
  45504. /**
  45505. * Sets the value of the `Y` button
  45506. */
  45507. set buttonY(value: number);
  45508. /**
  45509. * Gets the value of the `Start` button
  45510. */
  45511. get buttonStart(): number;
  45512. /**
  45513. * Sets the value of the `Start` button
  45514. */
  45515. set buttonStart(value: number);
  45516. /**
  45517. * Gets the value of the `Back` button
  45518. */
  45519. get buttonBack(): number;
  45520. /**
  45521. * Sets the value of the `Back` button
  45522. */
  45523. set buttonBack(value: number);
  45524. /**
  45525. * Gets the value of the `Left` button
  45526. */
  45527. get buttonLB(): number;
  45528. /**
  45529. * Sets the value of the `Left` button
  45530. */
  45531. set buttonLB(value: number);
  45532. /**
  45533. * Gets the value of the `Right` button
  45534. */
  45535. get buttonRB(): number;
  45536. /**
  45537. * Sets the value of the `Right` button
  45538. */
  45539. set buttonRB(value: number);
  45540. /**
  45541. * Gets the value of the Left joystick
  45542. */
  45543. get buttonLeftStick(): number;
  45544. /**
  45545. * Sets the value of the Left joystick
  45546. */
  45547. set buttonLeftStick(value: number);
  45548. /**
  45549. * Gets the value of the Right joystick
  45550. */
  45551. get buttonRightStick(): number;
  45552. /**
  45553. * Sets the value of the Right joystick
  45554. */
  45555. set buttonRightStick(value: number);
  45556. /**
  45557. * Gets the value of D-pad up
  45558. */
  45559. get dPadUp(): number;
  45560. /**
  45561. * Sets the value of D-pad up
  45562. */
  45563. set dPadUp(value: number);
  45564. /**
  45565. * Gets the value of D-pad down
  45566. */
  45567. get dPadDown(): number;
  45568. /**
  45569. * Sets the value of D-pad down
  45570. */
  45571. set dPadDown(value: number);
  45572. /**
  45573. * Gets the value of D-pad left
  45574. */
  45575. get dPadLeft(): number;
  45576. /**
  45577. * Sets the value of D-pad left
  45578. */
  45579. set dPadLeft(value: number);
  45580. /**
  45581. * Gets the value of D-pad right
  45582. */
  45583. get dPadRight(): number;
  45584. /**
  45585. * Sets the value of D-pad right
  45586. */
  45587. set dPadRight(value: number);
  45588. /**
  45589. * Force the gamepad to synchronize with device values
  45590. */
  45591. update(): void;
  45592. /**
  45593. * Disposes the gamepad
  45594. */
  45595. dispose(): void;
  45596. }
  45597. }
  45598. declare module BABYLON {
  45599. /**
  45600. * Defines supported buttons for DualShock compatible gamepads
  45601. */
  45602. export enum DualShockButton {
  45603. /** Cross */
  45604. Cross = 0,
  45605. /** Circle */
  45606. Circle = 1,
  45607. /** Square */
  45608. Square = 2,
  45609. /** Triangle */
  45610. Triangle = 3,
  45611. /** L1 */
  45612. L1 = 4,
  45613. /** R1 */
  45614. R1 = 5,
  45615. /** Share */
  45616. Share = 8,
  45617. /** Options */
  45618. Options = 9,
  45619. /** Left stick */
  45620. LeftStick = 10,
  45621. /** Right stick */
  45622. RightStick = 11
  45623. }
  45624. /** Defines values for DualShock DPad */
  45625. export enum DualShockDpad {
  45626. /** Up */
  45627. Up = 12,
  45628. /** Down */
  45629. Down = 13,
  45630. /** Left */
  45631. Left = 14,
  45632. /** Right */
  45633. Right = 15
  45634. }
  45635. /**
  45636. * Defines a DualShock gamepad
  45637. */
  45638. export class DualShockPad extends Gamepad {
  45639. private _leftTrigger;
  45640. private _rightTrigger;
  45641. private _onlefttriggerchanged;
  45642. private _onrighttriggerchanged;
  45643. private _onbuttondown;
  45644. private _onbuttonup;
  45645. private _ondpaddown;
  45646. private _ondpadup;
  45647. /** Observable raised when a button is pressed */
  45648. onButtonDownObservable: Observable<DualShockButton>;
  45649. /** Observable raised when a button is released */
  45650. onButtonUpObservable: Observable<DualShockButton>;
  45651. /** Observable raised when a pad is pressed */
  45652. onPadDownObservable: Observable<DualShockDpad>;
  45653. /** Observable raised when a pad is released */
  45654. onPadUpObservable: Observable<DualShockDpad>;
  45655. private _buttonCross;
  45656. private _buttonCircle;
  45657. private _buttonSquare;
  45658. private _buttonTriangle;
  45659. private _buttonShare;
  45660. private _buttonOptions;
  45661. private _buttonL1;
  45662. private _buttonR1;
  45663. private _buttonLeftStick;
  45664. private _buttonRightStick;
  45665. private _dPadUp;
  45666. private _dPadDown;
  45667. private _dPadLeft;
  45668. private _dPadRight;
  45669. /**
  45670. * Creates a new DualShock gamepad object
  45671. * @param id defines the id of this gamepad
  45672. * @param index defines its index
  45673. * @param gamepad defines the internal HTML gamepad object
  45674. */
  45675. constructor(id: string, index: number, gamepad: any);
  45676. /**
  45677. * Defines the callback to call when left trigger is pressed
  45678. * @param callback defines the callback to use
  45679. */
  45680. onlefttriggerchanged(callback: (value: number) => void): void;
  45681. /**
  45682. * Defines the callback to call when right trigger is pressed
  45683. * @param callback defines the callback to use
  45684. */
  45685. onrighttriggerchanged(callback: (value: number) => void): void;
  45686. /**
  45687. * Gets the left trigger value
  45688. */
  45689. get leftTrigger(): number;
  45690. /**
  45691. * Sets the left trigger value
  45692. */
  45693. set leftTrigger(newValue: number);
  45694. /**
  45695. * Gets the right trigger value
  45696. */
  45697. get rightTrigger(): number;
  45698. /**
  45699. * Sets the right trigger value
  45700. */
  45701. set rightTrigger(newValue: number);
  45702. /**
  45703. * Defines the callback to call when a button is pressed
  45704. * @param callback defines the callback to use
  45705. */
  45706. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45707. /**
  45708. * Defines the callback to call when a button is released
  45709. * @param callback defines the callback to use
  45710. */
  45711. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45712. /**
  45713. * Defines the callback to call when a pad is pressed
  45714. * @param callback defines the callback to use
  45715. */
  45716. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45717. /**
  45718. * Defines the callback to call when a pad is released
  45719. * @param callback defines the callback to use
  45720. */
  45721. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45722. private _setButtonValue;
  45723. private _setDPadValue;
  45724. /**
  45725. * Gets the value of the `Cross` button
  45726. */
  45727. get buttonCross(): number;
  45728. /**
  45729. * Sets the value of the `Cross` button
  45730. */
  45731. set buttonCross(value: number);
  45732. /**
  45733. * Gets the value of the `Circle` button
  45734. */
  45735. get buttonCircle(): number;
  45736. /**
  45737. * Sets the value of the `Circle` button
  45738. */
  45739. set buttonCircle(value: number);
  45740. /**
  45741. * Gets the value of the `Square` button
  45742. */
  45743. get buttonSquare(): number;
  45744. /**
  45745. * Sets the value of the `Square` button
  45746. */
  45747. set buttonSquare(value: number);
  45748. /**
  45749. * Gets the value of the `Triangle` button
  45750. */
  45751. get buttonTriangle(): number;
  45752. /**
  45753. * Sets the value of the `Triangle` button
  45754. */
  45755. set buttonTriangle(value: number);
  45756. /**
  45757. * Gets the value of the `Options` button
  45758. */
  45759. get buttonOptions(): number;
  45760. /**
  45761. * Sets the value of the `Options` button
  45762. */
  45763. set buttonOptions(value: number);
  45764. /**
  45765. * Gets the value of the `Share` button
  45766. */
  45767. get buttonShare(): number;
  45768. /**
  45769. * Sets the value of the `Share` button
  45770. */
  45771. set buttonShare(value: number);
  45772. /**
  45773. * Gets the value of the `L1` button
  45774. */
  45775. get buttonL1(): number;
  45776. /**
  45777. * Sets the value of the `L1` button
  45778. */
  45779. set buttonL1(value: number);
  45780. /**
  45781. * Gets the value of the `R1` button
  45782. */
  45783. get buttonR1(): number;
  45784. /**
  45785. * Sets the value of the `R1` button
  45786. */
  45787. set buttonR1(value: number);
  45788. /**
  45789. * Gets the value of the Left joystick
  45790. */
  45791. get buttonLeftStick(): number;
  45792. /**
  45793. * Sets the value of the Left joystick
  45794. */
  45795. set buttonLeftStick(value: number);
  45796. /**
  45797. * Gets the value of the Right joystick
  45798. */
  45799. get buttonRightStick(): number;
  45800. /**
  45801. * Sets the value of the Right joystick
  45802. */
  45803. set buttonRightStick(value: number);
  45804. /**
  45805. * Gets the value of D-pad up
  45806. */
  45807. get dPadUp(): number;
  45808. /**
  45809. * Sets the value of D-pad up
  45810. */
  45811. set dPadUp(value: number);
  45812. /**
  45813. * Gets the value of D-pad down
  45814. */
  45815. get dPadDown(): number;
  45816. /**
  45817. * Sets the value of D-pad down
  45818. */
  45819. set dPadDown(value: number);
  45820. /**
  45821. * Gets the value of D-pad left
  45822. */
  45823. get dPadLeft(): number;
  45824. /**
  45825. * Sets the value of D-pad left
  45826. */
  45827. set dPadLeft(value: number);
  45828. /**
  45829. * Gets the value of D-pad right
  45830. */
  45831. get dPadRight(): number;
  45832. /**
  45833. * Sets the value of D-pad right
  45834. */
  45835. set dPadRight(value: number);
  45836. /**
  45837. * Force the gamepad to synchronize with device values
  45838. */
  45839. update(): void;
  45840. /**
  45841. * Disposes the gamepad
  45842. */
  45843. dispose(): void;
  45844. }
  45845. }
  45846. declare module BABYLON {
  45847. /**
  45848. * Manager for handling gamepads
  45849. */
  45850. export class GamepadManager {
  45851. private _scene?;
  45852. private _babylonGamepads;
  45853. private _oneGamepadConnected;
  45854. /** @hidden */
  45855. _isMonitoring: boolean;
  45856. private _gamepadEventSupported;
  45857. private _gamepadSupport?;
  45858. /**
  45859. * observable to be triggered when the gamepad controller has been connected
  45860. */
  45861. onGamepadConnectedObservable: Observable<Gamepad>;
  45862. /**
  45863. * observable to be triggered when the gamepad controller has been disconnected
  45864. */
  45865. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45866. private _onGamepadConnectedEvent;
  45867. private _onGamepadDisconnectedEvent;
  45868. /**
  45869. * Initializes the gamepad manager
  45870. * @param _scene BabylonJS scene
  45871. */
  45872. constructor(_scene?: Scene | undefined);
  45873. /**
  45874. * The gamepads in the game pad manager
  45875. */
  45876. get gamepads(): Gamepad[];
  45877. /**
  45878. * Get the gamepad controllers based on type
  45879. * @param type The type of gamepad controller
  45880. * @returns Nullable gamepad
  45881. */
  45882. getGamepadByType(type?: number): Nullable<Gamepad>;
  45883. /**
  45884. * Disposes the gamepad manager
  45885. */
  45886. dispose(): void;
  45887. private _addNewGamepad;
  45888. private _startMonitoringGamepads;
  45889. private _stopMonitoringGamepads;
  45890. /** @hidden */
  45891. _checkGamepadsStatus(): void;
  45892. private _updateGamepadObjects;
  45893. }
  45894. }
  45895. declare module BABYLON {
  45896. interface Scene {
  45897. /** @hidden */
  45898. _gamepadManager: Nullable<GamepadManager>;
  45899. /**
  45900. * Gets the gamepad manager associated with the scene
  45901. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45902. */
  45903. gamepadManager: GamepadManager;
  45904. }
  45905. /**
  45906. * Interface representing a free camera inputs manager
  45907. */
  45908. interface FreeCameraInputsManager {
  45909. /**
  45910. * Adds gamepad input support to the FreeCameraInputsManager.
  45911. * @returns the FreeCameraInputsManager
  45912. */
  45913. addGamepad(): FreeCameraInputsManager;
  45914. }
  45915. /**
  45916. * Interface representing an arc rotate camera inputs manager
  45917. */
  45918. interface ArcRotateCameraInputsManager {
  45919. /**
  45920. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45921. * @returns the camera inputs manager
  45922. */
  45923. addGamepad(): ArcRotateCameraInputsManager;
  45924. }
  45925. /**
  45926. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45927. */
  45928. export class GamepadSystemSceneComponent implements ISceneComponent {
  45929. /**
  45930. * The component name helpfull to identify the component in the list of scene components.
  45931. */
  45932. readonly name: string;
  45933. /**
  45934. * The scene the component belongs to.
  45935. */
  45936. scene: Scene;
  45937. /**
  45938. * Creates a new instance of the component for the given scene
  45939. * @param scene Defines the scene to register the component in
  45940. */
  45941. constructor(scene: Scene);
  45942. /**
  45943. * Registers the component in a given scene
  45944. */
  45945. register(): void;
  45946. /**
  45947. * Rebuilds the elements related to this component in case of
  45948. * context lost for instance.
  45949. */
  45950. rebuild(): void;
  45951. /**
  45952. * Disposes the component and the associated ressources
  45953. */
  45954. dispose(): void;
  45955. private _beforeCameraUpdate;
  45956. }
  45957. }
  45958. declare module BABYLON {
  45959. /**
  45960. * 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,
  45961. * which still works and will still be found in many Playgrounds.
  45962. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45963. */
  45964. export class UniversalCamera extends TouchCamera {
  45965. /**
  45966. * Defines the gamepad rotation sensiblity.
  45967. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45968. */
  45969. get gamepadAngularSensibility(): number;
  45970. set gamepadAngularSensibility(value: number);
  45971. /**
  45972. * Defines the gamepad move sensiblity.
  45973. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45974. */
  45975. get gamepadMoveSensibility(): number;
  45976. set gamepadMoveSensibility(value: number);
  45977. /**
  45978. * 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,
  45979. * which still works and will still be found in many Playgrounds.
  45980. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45981. * @param name Define the name of the camera in the scene
  45982. * @param position Define the start position of the camera in the scene
  45983. * @param scene Define the scene the camera belongs to
  45984. */
  45985. constructor(name: string, position: Vector3, scene: Scene);
  45986. /**
  45987. * Gets the current object class name.
  45988. * @return the class name
  45989. */
  45990. getClassName(): string;
  45991. }
  45992. }
  45993. declare module BABYLON {
  45994. /**
  45995. * This represents a FPS type of camera. This is only here for back compat purpose.
  45996. * Please use the UniversalCamera instead as both are identical.
  45997. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45998. */
  45999. export class GamepadCamera extends UniversalCamera {
  46000. /**
  46001. * Instantiates a new Gamepad Camera
  46002. * This represents a FPS type of camera. This is only here for back compat purpose.
  46003. * Please use the UniversalCamera instead as both are identical.
  46004. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46005. * @param name Define the name of the camera in the scene
  46006. * @param position Define the start position of the camera in the scene
  46007. * @param scene Define the scene the camera belongs to
  46008. */
  46009. constructor(name: string, position: Vector3, scene: Scene);
  46010. /**
  46011. * Gets the current object class name.
  46012. * @return the class name
  46013. */
  46014. getClassName(): string;
  46015. }
  46016. }
  46017. declare module BABYLON {
  46018. /** @hidden */
  46019. export var passPixelShader: {
  46020. name: string;
  46021. shader: string;
  46022. };
  46023. }
  46024. declare module BABYLON {
  46025. /** @hidden */
  46026. export var passCubePixelShader: {
  46027. name: string;
  46028. shader: string;
  46029. };
  46030. }
  46031. declare module BABYLON {
  46032. /**
  46033. * PassPostProcess which produces an output the same as it's input
  46034. */
  46035. export class PassPostProcess extends PostProcess {
  46036. /**
  46037. * Gets a string identifying the name of the class
  46038. * @returns "PassPostProcess" string
  46039. */
  46040. getClassName(): string;
  46041. /**
  46042. * Creates the PassPostProcess
  46043. * @param name The name of the effect.
  46044. * @param options The required width/height ratio to downsize to before computing the render pass.
  46045. * @param camera The camera to apply the render pass to.
  46046. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46047. * @param engine The engine which the post process will be applied. (default: current engine)
  46048. * @param reusable If the post process can be reused on the same frame. (default: false)
  46049. * @param textureType The type of texture to be used when performing the post processing.
  46050. * @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)
  46051. */
  46052. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46053. /** @hidden */
  46054. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46055. }
  46056. /**
  46057. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46058. */
  46059. export class PassCubePostProcess extends PostProcess {
  46060. private _face;
  46061. /**
  46062. * Gets or sets the cube face to display.
  46063. * * 0 is +X
  46064. * * 1 is -X
  46065. * * 2 is +Y
  46066. * * 3 is -Y
  46067. * * 4 is +Z
  46068. * * 5 is -Z
  46069. */
  46070. get face(): number;
  46071. set face(value: number);
  46072. /**
  46073. * Gets a string identifying the name of the class
  46074. * @returns "PassCubePostProcess" string
  46075. */
  46076. getClassName(): string;
  46077. /**
  46078. * Creates the PassCubePostProcess
  46079. * @param name The name of the effect.
  46080. * @param options The required width/height ratio to downsize to before computing the render pass.
  46081. * @param camera The camera to apply the render pass to.
  46082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46083. * @param engine The engine which the post process will be applied. (default: current engine)
  46084. * @param reusable If the post process can be reused on the same frame. (default: false)
  46085. * @param textureType The type of texture to be used when performing the post processing.
  46086. * @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)
  46087. */
  46088. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46089. /** @hidden */
  46090. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46091. }
  46092. }
  46093. declare module BABYLON {
  46094. /** @hidden */
  46095. export var anaglyphPixelShader: {
  46096. name: string;
  46097. shader: string;
  46098. };
  46099. }
  46100. declare module BABYLON {
  46101. /**
  46102. * Postprocess used to generate anaglyphic rendering
  46103. */
  46104. export class AnaglyphPostProcess extends PostProcess {
  46105. private _passedProcess;
  46106. /**
  46107. * Gets a string identifying the name of the class
  46108. * @returns "AnaglyphPostProcess" string
  46109. */
  46110. getClassName(): string;
  46111. /**
  46112. * Creates a new AnaglyphPostProcess
  46113. * @param name defines postprocess name
  46114. * @param options defines creation options or target ratio scale
  46115. * @param rigCameras defines cameras using this postprocess
  46116. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46117. * @param engine defines hosting engine
  46118. * @param reusable defines if the postprocess will be reused multiple times per frame
  46119. */
  46120. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46121. }
  46122. }
  46123. declare module BABYLON {
  46124. /**
  46125. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46126. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46127. */
  46128. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46129. /**
  46130. * Creates a new AnaglyphArcRotateCamera
  46131. * @param name defines camera name
  46132. * @param alpha defines alpha angle (in radians)
  46133. * @param beta defines beta angle (in radians)
  46134. * @param radius defines radius
  46135. * @param target defines camera target
  46136. * @param interaxialDistance defines distance between each color axis
  46137. * @param scene defines the hosting scene
  46138. */
  46139. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46140. /**
  46141. * Gets camera class name
  46142. * @returns AnaglyphArcRotateCamera
  46143. */
  46144. getClassName(): string;
  46145. }
  46146. }
  46147. declare module BABYLON {
  46148. /**
  46149. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46150. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46151. */
  46152. export class AnaglyphFreeCamera extends FreeCamera {
  46153. /**
  46154. * Creates a new AnaglyphFreeCamera
  46155. * @param name defines camera name
  46156. * @param position defines initial position
  46157. * @param interaxialDistance defines distance between each color axis
  46158. * @param scene defines the hosting scene
  46159. */
  46160. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46161. /**
  46162. * Gets camera class name
  46163. * @returns AnaglyphFreeCamera
  46164. */
  46165. getClassName(): string;
  46166. }
  46167. }
  46168. declare module BABYLON {
  46169. /**
  46170. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46171. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46172. */
  46173. export class AnaglyphGamepadCamera extends GamepadCamera {
  46174. /**
  46175. * Creates a new AnaglyphGamepadCamera
  46176. * @param name defines camera name
  46177. * @param position defines initial position
  46178. * @param interaxialDistance defines distance between each color axis
  46179. * @param scene defines the hosting scene
  46180. */
  46181. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46182. /**
  46183. * Gets camera class name
  46184. * @returns AnaglyphGamepadCamera
  46185. */
  46186. getClassName(): string;
  46187. }
  46188. }
  46189. declare module BABYLON {
  46190. /**
  46191. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46192. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46193. */
  46194. export class AnaglyphUniversalCamera extends UniversalCamera {
  46195. /**
  46196. * Creates a new AnaglyphUniversalCamera
  46197. * @param name defines camera name
  46198. * @param position defines initial position
  46199. * @param interaxialDistance defines distance between each color axis
  46200. * @param scene defines the hosting scene
  46201. */
  46202. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46203. /**
  46204. * Gets camera class name
  46205. * @returns AnaglyphUniversalCamera
  46206. */
  46207. getClassName(): string;
  46208. }
  46209. }
  46210. declare module BABYLON {
  46211. /**
  46212. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46213. * @see https://doc.babylonjs.com/features/cameras
  46214. */
  46215. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46216. /**
  46217. * Creates a new StereoscopicArcRotateCamera
  46218. * @param name defines camera name
  46219. * @param alpha defines alpha angle (in radians)
  46220. * @param beta defines beta angle (in radians)
  46221. * @param radius defines radius
  46222. * @param target defines camera target
  46223. * @param interaxialDistance defines distance between each color axis
  46224. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46225. * @param scene defines the hosting scene
  46226. */
  46227. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46228. /**
  46229. * Gets camera class name
  46230. * @returns StereoscopicArcRotateCamera
  46231. */
  46232. getClassName(): string;
  46233. }
  46234. }
  46235. declare module BABYLON {
  46236. /**
  46237. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46238. * @see https://doc.babylonjs.com/features/cameras
  46239. */
  46240. export class StereoscopicFreeCamera extends FreeCamera {
  46241. /**
  46242. * Creates a new StereoscopicFreeCamera
  46243. * @param name defines camera name
  46244. * @param position defines initial position
  46245. * @param interaxialDistance defines distance between each color axis
  46246. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46247. * @param scene defines the hosting scene
  46248. */
  46249. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46250. /**
  46251. * Gets camera class name
  46252. * @returns StereoscopicFreeCamera
  46253. */
  46254. getClassName(): string;
  46255. }
  46256. }
  46257. declare module BABYLON {
  46258. /**
  46259. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46260. * @see https://doc.babylonjs.com/features/cameras
  46261. */
  46262. export class StereoscopicGamepadCamera extends GamepadCamera {
  46263. /**
  46264. * Creates a new StereoscopicGamepadCamera
  46265. * @param name defines camera name
  46266. * @param position defines initial position
  46267. * @param interaxialDistance defines distance between each color axis
  46268. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46269. * @param scene defines the hosting scene
  46270. */
  46271. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46272. /**
  46273. * Gets camera class name
  46274. * @returns StereoscopicGamepadCamera
  46275. */
  46276. getClassName(): string;
  46277. }
  46278. }
  46279. declare module BABYLON {
  46280. /**
  46281. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46282. * @see https://doc.babylonjs.com/features/cameras
  46283. */
  46284. export class StereoscopicUniversalCamera extends UniversalCamera {
  46285. /**
  46286. * Creates a new StereoscopicUniversalCamera
  46287. * @param name defines camera name
  46288. * @param position defines initial position
  46289. * @param interaxialDistance defines distance between each color axis
  46290. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46291. * @param scene defines the hosting scene
  46292. */
  46293. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46294. /**
  46295. * Gets camera class name
  46296. * @returns StereoscopicUniversalCamera
  46297. */
  46298. getClassName(): string;
  46299. }
  46300. }
  46301. declare module BABYLON {
  46302. /**
  46303. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46304. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46305. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46306. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46307. */
  46308. export class VirtualJoysticksCamera extends FreeCamera {
  46309. /**
  46310. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46311. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46312. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46313. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46314. * @param name Define the name of the camera in the scene
  46315. * @param position Define the start position of the camera in the scene
  46316. * @param scene Define the scene the camera belongs to
  46317. */
  46318. constructor(name: string, position: Vector3, scene: Scene);
  46319. /**
  46320. * Gets the current object class name.
  46321. * @return the class name
  46322. */
  46323. getClassName(): string;
  46324. }
  46325. }
  46326. declare module BABYLON {
  46327. /**
  46328. * This represents all the required metrics to create a VR camera.
  46329. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46330. */
  46331. export class VRCameraMetrics {
  46332. /**
  46333. * Define the horizontal resolution off the screen.
  46334. */
  46335. hResolution: number;
  46336. /**
  46337. * Define the vertical resolution off the screen.
  46338. */
  46339. vResolution: number;
  46340. /**
  46341. * Define the horizontal screen size.
  46342. */
  46343. hScreenSize: number;
  46344. /**
  46345. * Define the vertical screen size.
  46346. */
  46347. vScreenSize: number;
  46348. /**
  46349. * Define the vertical screen center position.
  46350. */
  46351. vScreenCenter: number;
  46352. /**
  46353. * Define the distance of the eyes to the screen.
  46354. */
  46355. eyeToScreenDistance: number;
  46356. /**
  46357. * Define the distance between both lenses
  46358. */
  46359. lensSeparationDistance: number;
  46360. /**
  46361. * Define the distance between both viewer's eyes.
  46362. */
  46363. interpupillaryDistance: number;
  46364. /**
  46365. * Define the distortion factor of the VR postprocess.
  46366. * Please, touch with care.
  46367. */
  46368. distortionK: number[];
  46369. /**
  46370. * Define the chromatic aberration correction factors for the VR post process.
  46371. */
  46372. chromaAbCorrection: number[];
  46373. /**
  46374. * Define the scale factor of the post process.
  46375. * The smaller the better but the slower.
  46376. */
  46377. postProcessScaleFactor: number;
  46378. /**
  46379. * Define an offset for the lens center.
  46380. */
  46381. lensCenterOffset: number;
  46382. /**
  46383. * Define if the current vr camera should compensate the distortion of the lense or not.
  46384. */
  46385. compensateDistortion: boolean;
  46386. /**
  46387. * Defines if multiview should be enabled when rendering (Default: false)
  46388. */
  46389. multiviewEnabled: boolean;
  46390. /**
  46391. * Gets the rendering aspect ratio based on the provided resolutions.
  46392. */
  46393. get aspectRatio(): number;
  46394. /**
  46395. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46396. */
  46397. get aspectRatioFov(): number;
  46398. /**
  46399. * @hidden
  46400. */
  46401. get leftHMatrix(): Matrix;
  46402. /**
  46403. * @hidden
  46404. */
  46405. get rightHMatrix(): Matrix;
  46406. /**
  46407. * @hidden
  46408. */
  46409. get leftPreViewMatrix(): Matrix;
  46410. /**
  46411. * @hidden
  46412. */
  46413. get rightPreViewMatrix(): Matrix;
  46414. /**
  46415. * Get the default VRMetrics based on the most generic setup.
  46416. * @returns the default vr metrics
  46417. */
  46418. static GetDefault(): VRCameraMetrics;
  46419. }
  46420. }
  46421. declare module BABYLON {
  46422. /** @hidden */
  46423. export var vrDistortionCorrectionPixelShader: {
  46424. name: string;
  46425. shader: string;
  46426. };
  46427. }
  46428. declare module BABYLON {
  46429. /**
  46430. * VRDistortionCorrectionPostProcess used for mobile VR
  46431. */
  46432. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46433. private _isRightEye;
  46434. private _distortionFactors;
  46435. private _postProcessScaleFactor;
  46436. private _lensCenterOffset;
  46437. private _scaleIn;
  46438. private _scaleFactor;
  46439. private _lensCenter;
  46440. /**
  46441. * Gets a string identifying the name of the class
  46442. * @returns "VRDistortionCorrectionPostProcess" string
  46443. */
  46444. getClassName(): string;
  46445. /**
  46446. * Initializes the VRDistortionCorrectionPostProcess
  46447. * @param name The name of the effect.
  46448. * @param camera The camera to apply the render pass to.
  46449. * @param isRightEye If this is for the right eye distortion
  46450. * @param vrMetrics All the required metrics for the VR camera
  46451. */
  46452. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46453. }
  46454. }
  46455. declare module BABYLON {
  46456. /**
  46457. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46458. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46459. */
  46460. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46461. /**
  46462. * Creates a new VRDeviceOrientationArcRotateCamera
  46463. * @param name defines camera name
  46464. * @param alpha defines the camera rotation along the logitudinal axis
  46465. * @param beta defines the camera rotation along the latitudinal axis
  46466. * @param radius defines the camera distance from its target
  46467. * @param target defines the camera target
  46468. * @param scene defines the scene the camera belongs to
  46469. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46470. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46471. */
  46472. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46473. /**
  46474. * Gets camera class name
  46475. * @returns VRDeviceOrientationArcRotateCamera
  46476. */
  46477. getClassName(): string;
  46478. }
  46479. }
  46480. declare module BABYLON {
  46481. /**
  46482. * Camera used to simulate VR rendering (based on FreeCamera)
  46483. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46484. */
  46485. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46486. /**
  46487. * Creates a new VRDeviceOrientationFreeCamera
  46488. * @param name defines camera name
  46489. * @param position defines the start position of the camera
  46490. * @param scene defines the scene the camera belongs to
  46491. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46492. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46493. */
  46494. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46495. /**
  46496. * Gets camera class name
  46497. * @returns VRDeviceOrientationFreeCamera
  46498. */
  46499. getClassName(): string;
  46500. }
  46501. }
  46502. declare module BABYLON {
  46503. /**
  46504. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46505. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46506. */
  46507. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46508. /**
  46509. * Creates a new VRDeviceOrientationGamepadCamera
  46510. * @param name defines camera name
  46511. * @param position defines the start position of the camera
  46512. * @param scene defines the scene the camera belongs to
  46513. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46514. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46515. */
  46516. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46517. /**
  46518. * Gets camera class name
  46519. * @returns VRDeviceOrientationGamepadCamera
  46520. */
  46521. getClassName(): string;
  46522. }
  46523. }
  46524. declare module BABYLON {
  46525. /**
  46526. * A class extending Texture allowing drawing on a texture
  46527. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46528. */
  46529. export class DynamicTexture extends Texture {
  46530. private _generateMipMaps;
  46531. private _canvas;
  46532. private _context;
  46533. /**
  46534. * Creates a DynamicTexture
  46535. * @param name defines the name of the texture
  46536. * @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
  46537. * @param scene defines the scene where you want the texture
  46538. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46539. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46540. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46541. */
  46542. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46543. /**
  46544. * Get the current class name of the texture useful for serialization or dynamic coding.
  46545. * @returns "DynamicTexture"
  46546. */
  46547. getClassName(): string;
  46548. /**
  46549. * Gets the current state of canRescale
  46550. */
  46551. get canRescale(): boolean;
  46552. private _recreate;
  46553. /**
  46554. * Scales the texture
  46555. * @param ratio the scale factor to apply to both width and height
  46556. */
  46557. scale(ratio: number): void;
  46558. /**
  46559. * Resizes the texture
  46560. * @param width the new width
  46561. * @param height the new height
  46562. */
  46563. scaleTo(width: number, height: number): void;
  46564. /**
  46565. * Gets the context of the canvas used by the texture
  46566. * @returns the canvas context of the dynamic texture
  46567. */
  46568. getContext(): CanvasRenderingContext2D;
  46569. /**
  46570. * Clears the texture
  46571. */
  46572. clear(): void;
  46573. /**
  46574. * Updates the texture
  46575. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46576. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46577. */
  46578. update(invertY?: boolean, premulAlpha?: boolean): void;
  46579. /**
  46580. * Draws text onto the texture
  46581. * @param text defines the text to be drawn
  46582. * @param x defines the placement of the text from the left
  46583. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46584. * @param font defines the font to be used with font-style, font-size, font-name
  46585. * @param color defines the color used for the text
  46586. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46587. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46588. * @param update defines whether texture is immediately update (default is true)
  46589. */
  46590. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46591. /**
  46592. * Clones the texture
  46593. * @returns the clone of the texture.
  46594. */
  46595. clone(): DynamicTexture;
  46596. /**
  46597. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46598. * @returns a serialized dynamic texture object
  46599. */
  46600. serialize(): any;
  46601. private _IsCanvasElement;
  46602. /** @hidden */
  46603. _rebuild(): void;
  46604. }
  46605. }
  46606. declare module BABYLON {
  46607. /**
  46608. * Class containing static functions to help procedurally build meshes
  46609. */
  46610. export class GroundBuilder {
  46611. /**
  46612. * Creates a ground mesh
  46613. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46614. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46616. * @param name defines the name of the mesh
  46617. * @param options defines the options used to create the mesh
  46618. * @param scene defines the hosting scene
  46619. * @returns the ground mesh
  46620. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46621. */
  46622. static CreateGround(name: string, options: {
  46623. width?: number;
  46624. height?: number;
  46625. subdivisions?: number;
  46626. subdivisionsX?: number;
  46627. subdivisionsY?: number;
  46628. updatable?: boolean;
  46629. }, scene: any): Mesh;
  46630. /**
  46631. * Creates a tiled ground mesh
  46632. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46633. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46634. * * 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
  46635. * * 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
  46636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46637. * @param name defines the name of the mesh
  46638. * @param options defines the options used to create the mesh
  46639. * @param scene defines the hosting scene
  46640. * @returns the tiled ground mesh
  46641. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46642. */
  46643. static CreateTiledGround(name: string, options: {
  46644. xmin: number;
  46645. zmin: number;
  46646. xmax: number;
  46647. zmax: number;
  46648. subdivisions?: {
  46649. w: number;
  46650. h: number;
  46651. };
  46652. precision?: {
  46653. w: number;
  46654. h: number;
  46655. };
  46656. updatable?: boolean;
  46657. }, scene?: Nullable<Scene>): Mesh;
  46658. /**
  46659. * Creates a ground mesh from a height map
  46660. * * The parameter `url` sets the URL of the height map image resource.
  46661. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46662. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46663. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46664. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46665. * * 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.
  46666. * * 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).
  46667. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46669. * @param name defines the name of the mesh
  46670. * @param url defines the url to the height map
  46671. * @param options defines the options used to create the mesh
  46672. * @param scene defines the hosting scene
  46673. * @returns the ground mesh
  46674. * @see https://doc.babylonjs.com/babylon101/height_map
  46675. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46676. */
  46677. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46678. width?: number;
  46679. height?: number;
  46680. subdivisions?: number;
  46681. minHeight?: number;
  46682. maxHeight?: number;
  46683. colorFilter?: Color3;
  46684. alphaFilter?: number;
  46685. updatable?: boolean;
  46686. onReady?: (mesh: GroundMesh) => void;
  46687. }, scene?: Nullable<Scene>): GroundMesh;
  46688. }
  46689. }
  46690. declare module BABYLON {
  46691. /**
  46692. * Class containing static functions to help procedurally build meshes
  46693. */
  46694. export class TorusBuilder {
  46695. /**
  46696. * Creates a torus mesh
  46697. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46698. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46699. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46701. * * 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
  46702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46703. * @param name defines the name of the mesh
  46704. * @param options defines the options used to create the mesh
  46705. * @param scene defines the hosting scene
  46706. * @returns the torus mesh
  46707. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46708. */
  46709. static CreateTorus(name: string, options: {
  46710. diameter?: number;
  46711. thickness?: number;
  46712. tessellation?: number;
  46713. updatable?: boolean;
  46714. sideOrientation?: number;
  46715. frontUVs?: Vector4;
  46716. backUVs?: Vector4;
  46717. }, scene: any): Mesh;
  46718. }
  46719. }
  46720. declare module BABYLON {
  46721. /**
  46722. * Class containing static functions to help procedurally build meshes
  46723. */
  46724. export class CylinderBuilder {
  46725. /**
  46726. * Creates a cylinder or a cone mesh
  46727. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46728. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46729. * * 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.
  46730. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46731. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46732. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46733. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46734. * * 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).
  46735. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46736. * * 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).
  46737. * * 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
  46738. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46739. * * 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
  46740. * * 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.
  46741. * * If `enclose` is false, a ring surface is one element.
  46742. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46743. * * 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
  46744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46745. * * 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
  46746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46747. * @param name defines the name of the mesh
  46748. * @param options defines the options used to create the mesh
  46749. * @param scene defines the hosting scene
  46750. * @returns the cylinder mesh
  46751. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46752. */
  46753. static CreateCylinder(name: string, options: {
  46754. height?: number;
  46755. diameterTop?: number;
  46756. diameterBottom?: number;
  46757. diameter?: number;
  46758. tessellation?: number;
  46759. subdivisions?: number;
  46760. arc?: number;
  46761. faceColors?: Color4[];
  46762. faceUV?: Vector4[];
  46763. updatable?: boolean;
  46764. hasRings?: boolean;
  46765. enclose?: boolean;
  46766. cap?: number;
  46767. sideOrientation?: number;
  46768. frontUVs?: Vector4;
  46769. backUVs?: Vector4;
  46770. }, scene: any): Mesh;
  46771. }
  46772. }
  46773. declare module BABYLON {
  46774. /**
  46775. * States of the webXR experience
  46776. */
  46777. export enum WebXRState {
  46778. /**
  46779. * Transitioning to being in XR mode
  46780. */
  46781. ENTERING_XR = 0,
  46782. /**
  46783. * Transitioning to non XR mode
  46784. */
  46785. EXITING_XR = 1,
  46786. /**
  46787. * In XR mode and presenting
  46788. */
  46789. IN_XR = 2,
  46790. /**
  46791. * Not entered XR mode
  46792. */
  46793. NOT_IN_XR = 3
  46794. }
  46795. /**
  46796. * Abstraction of the XR render target
  46797. */
  46798. export interface WebXRRenderTarget extends IDisposable {
  46799. /**
  46800. * xrpresent context of the canvas which can be used to display/mirror xr content
  46801. */
  46802. canvasContext: WebGLRenderingContext;
  46803. /**
  46804. * xr layer for the canvas
  46805. */
  46806. xrLayer: Nullable<XRWebGLLayer>;
  46807. /**
  46808. * Initializes the xr layer for the session
  46809. * @param xrSession xr session
  46810. * @returns a promise that will resolve once the XR Layer has been created
  46811. */
  46812. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46813. }
  46814. }
  46815. declare module BABYLON {
  46816. /**
  46817. * COnfiguration object for WebXR output canvas
  46818. */
  46819. export class WebXRManagedOutputCanvasOptions {
  46820. /**
  46821. * An optional canvas in case you wish to create it yourself and provide it here.
  46822. * If not provided, a new canvas will be created
  46823. */
  46824. canvasElement?: HTMLCanvasElement;
  46825. /**
  46826. * Options for this XR Layer output
  46827. */
  46828. canvasOptions?: XRWebGLLayerOptions;
  46829. /**
  46830. * CSS styling for a newly created canvas (if not provided)
  46831. */
  46832. newCanvasCssStyle?: string;
  46833. /**
  46834. * Get the default values of the configuration object
  46835. * @param engine defines the engine to use (can be null)
  46836. * @returns default values of this configuration object
  46837. */
  46838. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  46839. }
  46840. /**
  46841. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46842. */
  46843. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46844. private _options;
  46845. private _canvas;
  46846. private _engine;
  46847. private _originalCanvasSize;
  46848. /**
  46849. * Rendering context of the canvas which can be used to display/mirror xr content
  46850. */
  46851. canvasContext: WebGLRenderingContext;
  46852. /**
  46853. * xr layer for the canvas
  46854. */
  46855. xrLayer: Nullable<XRWebGLLayer>;
  46856. /**
  46857. * Obseervers registered here will be triggered when the xr layer was initialized
  46858. */
  46859. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46860. /**
  46861. * Initializes the canvas to be added/removed upon entering/exiting xr
  46862. * @param _xrSessionManager The XR Session manager
  46863. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46864. */
  46865. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46866. /**
  46867. * Disposes of the object
  46868. */
  46869. dispose(): void;
  46870. /**
  46871. * Initializes the xr layer for the session
  46872. * @param xrSession xr session
  46873. * @returns a promise that will resolve once the XR Layer has been created
  46874. */
  46875. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46876. private _addCanvas;
  46877. private _removeCanvas;
  46878. private _setCanvasSize;
  46879. private _setManagedOutputCanvas;
  46880. }
  46881. }
  46882. declare module BABYLON {
  46883. /**
  46884. * Manages an XRSession to work with Babylon's engine
  46885. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46886. */
  46887. export class WebXRSessionManager implements IDisposable {
  46888. /** The scene which the session should be created for */
  46889. scene: Scene;
  46890. private _referenceSpace;
  46891. private _rttProvider;
  46892. private _sessionEnded;
  46893. private _xrNavigator;
  46894. private baseLayer;
  46895. /**
  46896. * The base reference space from which the session started. good if you want to reset your
  46897. * reference space
  46898. */
  46899. baseReferenceSpace: XRReferenceSpace;
  46900. /**
  46901. * Current XR frame
  46902. */
  46903. currentFrame: Nullable<XRFrame>;
  46904. /** WebXR timestamp updated every frame */
  46905. currentTimestamp: number;
  46906. /**
  46907. * Used just in case of a failure to initialize an immersive session.
  46908. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46909. */
  46910. defaultHeightCompensation: number;
  46911. /**
  46912. * Fires every time a new xrFrame arrives which can be used to update the camera
  46913. */
  46914. onXRFrameObservable: Observable<XRFrame>;
  46915. /**
  46916. * Fires when the reference space changed
  46917. */
  46918. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46919. /**
  46920. * Fires when the xr session is ended either by the device or manually done
  46921. */
  46922. onXRSessionEnded: Observable<any>;
  46923. /**
  46924. * Fires when the xr session is ended either by the device or manually done
  46925. */
  46926. onXRSessionInit: Observable<XRSession>;
  46927. /**
  46928. * Underlying xr session
  46929. */
  46930. session: XRSession;
  46931. /**
  46932. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46933. * or get the offset the player is currently at.
  46934. */
  46935. viewerReferenceSpace: XRReferenceSpace;
  46936. /**
  46937. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46938. * @param scene The scene which the session should be created for
  46939. */
  46940. constructor(
  46941. /** The scene which the session should be created for */
  46942. scene: Scene);
  46943. /**
  46944. * The current reference space used in this session. This reference space can constantly change!
  46945. * It is mainly used to offset the camera's position.
  46946. */
  46947. get referenceSpace(): XRReferenceSpace;
  46948. /**
  46949. * Set a new reference space and triggers the observable
  46950. */
  46951. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46952. /**
  46953. * Disposes of the session manager
  46954. */
  46955. dispose(): void;
  46956. /**
  46957. * Stops the xrSession and restores the render loop
  46958. * @returns Promise which resolves after it exits XR
  46959. */
  46960. exitXRAsync(): Promise<void>;
  46961. /**
  46962. * Gets the correct render target texture to be rendered this frame for this eye
  46963. * @param eye the eye for which to get the render target
  46964. * @returns the render target for the specified eye
  46965. */
  46966. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46967. /**
  46968. * Creates a WebXRRenderTarget object for the XR session
  46969. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46970. * @param options optional options to provide when creating a new render target
  46971. * @returns a WebXR render target to which the session can render
  46972. */
  46973. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46974. /**
  46975. * Initializes the manager
  46976. * After initialization enterXR can be called to start an XR session
  46977. * @returns Promise which resolves after it is initialized
  46978. */
  46979. initializeAsync(): Promise<void>;
  46980. /**
  46981. * Initializes an xr session
  46982. * @param xrSessionMode mode to initialize
  46983. * @param xrSessionInit defines optional and required values to pass to the session builder
  46984. * @returns a promise which will resolve once the session has been initialized
  46985. */
  46986. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46987. /**
  46988. * Checks if a session would be supported for the creation options specified
  46989. * @param sessionMode session mode to check if supported eg. immersive-vr
  46990. * @returns A Promise that resolves to true if supported and false if not
  46991. */
  46992. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46993. /**
  46994. * Resets the reference space to the one started the session
  46995. */
  46996. resetReferenceSpace(): void;
  46997. /**
  46998. * Starts rendering to the xr layer
  46999. */
  47000. runXRRenderLoop(): void;
  47001. /**
  47002. * Sets the reference space on the xr session
  47003. * @param referenceSpaceType space to set
  47004. * @returns a promise that will resolve once the reference space has been set
  47005. */
  47006. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47007. /**
  47008. * Updates the render state of the session
  47009. * @param state state to set
  47010. * @returns a promise that resolves once the render state has been updated
  47011. */
  47012. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47013. /**
  47014. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47015. * @param sessionMode defines the session to test
  47016. * @returns a promise with boolean as final value
  47017. */
  47018. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47019. private _createRenderTargetTexture;
  47020. }
  47021. }
  47022. declare module BABYLON {
  47023. /**
  47024. * WebXR Camera which holds the views for the xrSession
  47025. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47026. */
  47027. export class WebXRCamera extends FreeCamera {
  47028. private _xrSessionManager;
  47029. private _firstFrame;
  47030. private _referenceQuaternion;
  47031. private _referencedPosition;
  47032. private _xrInvPositionCache;
  47033. private _xrInvQuaternionCache;
  47034. /**
  47035. * Observable raised before camera teleportation
  47036. */
  47037. onBeforeCameraTeleport: Observable<Vector3>;
  47038. /**
  47039. * Observable raised after camera teleportation
  47040. */
  47041. onAfterCameraTeleport: Observable<Vector3>;
  47042. /**
  47043. * Should position compensation execute on first frame.
  47044. * This is used when copying the position from a native (non XR) camera
  47045. */
  47046. compensateOnFirstFrame: boolean;
  47047. /**
  47048. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47049. * @param name the name of the camera
  47050. * @param scene the scene to add the camera to
  47051. * @param _xrSessionManager a constructed xr session manager
  47052. */
  47053. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47054. /**
  47055. * Return the user's height, unrelated to the current ground.
  47056. * This will be the y position of this camera, when ground level is 0.
  47057. */
  47058. get realWorldHeight(): number;
  47059. /** @hidden */
  47060. _updateForDualEyeDebugging(): void;
  47061. /**
  47062. * Sets this camera's transformation based on a non-vr camera
  47063. * @param otherCamera the non-vr camera to copy the transformation from
  47064. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47065. */
  47066. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47067. /**
  47068. * Gets the current instance class name ("WebXRCamera").
  47069. * @returns the class name
  47070. */
  47071. getClassName(): string;
  47072. private _rotate180;
  47073. private _updateFromXRSession;
  47074. private _updateNumberOfRigCameras;
  47075. private _updateReferenceSpace;
  47076. private _updateReferenceSpaceOffset;
  47077. }
  47078. }
  47079. declare module BABYLON {
  47080. /**
  47081. * Defining the interface required for a (webxr) feature
  47082. */
  47083. export interface IWebXRFeature extends IDisposable {
  47084. /**
  47085. * Is this feature attached
  47086. */
  47087. attached: boolean;
  47088. /**
  47089. * Should auto-attach be disabled?
  47090. */
  47091. disableAutoAttach: boolean;
  47092. /**
  47093. * Attach the feature to the session
  47094. * Will usually be called by the features manager
  47095. *
  47096. * @param force should attachment be forced (even when already attached)
  47097. * @returns true if successful.
  47098. */
  47099. attach(force?: boolean): boolean;
  47100. /**
  47101. * Detach the feature from the session
  47102. * Will usually be called by the features manager
  47103. *
  47104. * @returns true if successful.
  47105. */
  47106. detach(): boolean;
  47107. /**
  47108. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47109. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47110. *
  47111. * @returns whether or not the feature is compatible in this environment
  47112. */
  47113. isCompatible(): boolean;
  47114. /**
  47115. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47116. */
  47117. xrNativeFeatureName?: string;
  47118. /**
  47119. * A list of (Babylon WebXR) features this feature depends on
  47120. */
  47121. dependsOn?: string[];
  47122. }
  47123. /**
  47124. * A list of the currently available features without referencing them
  47125. */
  47126. export class WebXRFeatureName {
  47127. /**
  47128. * The name of the anchor system feature
  47129. */
  47130. static readonly ANCHOR_SYSTEM: string;
  47131. /**
  47132. * The name of the background remover feature
  47133. */
  47134. static readonly BACKGROUND_REMOVER: string;
  47135. /**
  47136. * The name of the hit test feature
  47137. */
  47138. static readonly HIT_TEST: string;
  47139. /**
  47140. * physics impostors for xr controllers feature
  47141. */
  47142. static readonly PHYSICS_CONTROLLERS: string;
  47143. /**
  47144. * The name of the plane detection feature
  47145. */
  47146. static readonly PLANE_DETECTION: string;
  47147. /**
  47148. * The name of the pointer selection feature
  47149. */
  47150. static readonly POINTER_SELECTION: string;
  47151. /**
  47152. * The name of the teleportation feature
  47153. */
  47154. static readonly TELEPORTATION: string;
  47155. /**
  47156. * The name of the feature points feature.
  47157. */
  47158. static readonly FEATURE_POINTS: string;
  47159. /**
  47160. * The name of the hand tracking feature.
  47161. */
  47162. static readonly HAND_TRACKING: string;
  47163. }
  47164. /**
  47165. * Defining the constructor of a feature. Used to register the modules.
  47166. */
  47167. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47168. /**
  47169. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47170. * It is mainly used in AR sessions.
  47171. *
  47172. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47173. */
  47174. export class WebXRFeaturesManager implements IDisposable {
  47175. private _xrSessionManager;
  47176. private static readonly _AvailableFeatures;
  47177. private _features;
  47178. /**
  47179. * constructs a new features manages.
  47180. *
  47181. * @param _xrSessionManager an instance of WebXRSessionManager
  47182. */
  47183. constructor(_xrSessionManager: WebXRSessionManager);
  47184. /**
  47185. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47186. * Mainly used internally.
  47187. *
  47188. * @param featureName the name of the feature to register
  47189. * @param constructorFunction the function used to construct the module
  47190. * @param version the (babylon) version of the module
  47191. * @param stable is that a stable version of this module
  47192. */
  47193. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47194. /**
  47195. * Returns a constructor of a specific feature.
  47196. *
  47197. * @param featureName the name of the feature to construct
  47198. * @param version the version of the feature to load
  47199. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47200. * @param options optional options provided to the module.
  47201. * @returns a function that, when called, will return a new instance of this feature
  47202. */
  47203. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47204. /**
  47205. * Can be used to return the list of features currently registered
  47206. *
  47207. * @returns an Array of available features
  47208. */
  47209. static GetAvailableFeatures(): string[];
  47210. /**
  47211. * Gets the versions available for a specific feature
  47212. * @param featureName the name of the feature
  47213. * @returns an array with the available versions
  47214. */
  47215. static GetAvailableVersions(featureName: string): string[];
  47216. /**
  47217. * Return the latest unstable version of this feature
  47218. * @param featureName the name of the feature to search
  47219. * @returns the version number. if not found will return -1
  47220. */
  47221. static GetLatestVersionOfFeature(featureName: string): number;
  47222. /**
  47223. * Return the latest stable version of this feature
  47224. * @param featureName the name of the feature to search
  47225. * @returns the version number. if not found will return -1
  47226. */
  47227. static GetStableVersionOfFeature(featureName: string): number;
  47228. /**
  47229. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47230. * Can be used during a session to start a feature
  47231. * @param featureName the name of feature to attach
  47232. */
  47233. attachFeature(featureName: string): void;
  47234. /**
  47235. * Can be used inside a session or when the session ends to detach a specific feature
  47236. * @param featureName the name of the feature to detach
  47237. */
  47238. detachFeature(featureName: string): void;
  47239. /**
  47240. * Used to disable an already-enabled feature
  47241. * The feature will be disposed and will be recreated once enabled.
  47242. * @param featureName the feature to disable
  47243. * @returns true if disable was successful
  47244. */
  47245. disableFeature(featureName: string | {
  47246. Name: string;
  47247. }): boolean;
  47248. /**
  47249. * dispose this features manager
  47250. */
  47251. dispose(): void;
  47252. /**
  47253. * 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.
  47254. * 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.
  47255. *
  47256. * @param featureName the name of the feature to load or the class of the feature
  47257. * @param version optional version to load. if not provided the latest version will be enabled
  47258. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47259. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47260. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47261. * @returns a new constructed feature or throws an error if feature not found.
  47262. */
  47263. enableFeature(featureName: string | {
  47264. Name: string;
  47265. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47266. /**
  47267. * get the implementation of an enabled feature.
  47268. * @param featureName the name of the feature to load
  47269. * @returns the feature class, if found
  47270. */
  47271. getEnabledFeature(featureName: string): IWebXRFeature;
  47272. /**
  47273. * Get the list of enabled features
  47274. * @returns an array of enabled features
  47275. */
  47276. getEnabledFeatures(): string[];
  47277. /**
  47278. * This function will exten the session creation configuration object with enabled features.
  47279. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47280. * according to the defined "required" variable, provided during enableFeature call
  47281. * @param xrSessionInit the xr Session init object to extend
  47282. *
  47283. * @returns an extended XRSessionInit object
  47284. */
  47285. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47286. }
  47287. }
  47288. declare module BABYLON {
  47289. /**
  47290. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47291. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47292. */
  47293. export class WebXRExperienceHelper implements IDisposable {
  47294. private scene;
  47295. private _nonVRCamera;
  47296. private _originalSceneAutoClear;
  47297. private _supported;
  47298. /**
  47299. * Camera used to render xr content
  47300. */
  47301. camera: WebXRCamera;
  47302. /** A features manager for this xr session */
  47303. featuresManager: WebXRFeaturesManager;
  47304. /**
  47305. * Observers registered here will be triggered after the camera's initial transformation is set
  47306. * This can be used to set a different ground level or an extra rotation.
  47307. *
  47308. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47309. * to the position set after this observable is done executing.
  47310. */
  47311. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47312. /**
  47313. * Fires when the state of the experience helper has changed
  47314. */
  47315. onStateChangedObservable: Observable<WebXRState>;
  47316. /** Session manager used to keep track of xr session */
  47317. sessionManager: WebXRSessionManager;
  47318. /**
  47319. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47320. */
  47321. state: WebXRState;
  47322. /**
  47323. * Creates a WebXRExperienceHelper
  47324. * @param scene The scene the helper should be created in
  47325. */
  47326. private constructor();
  47327. /**
  47328. * Creates the experience helper
  47329. * @param scene the scene to attach the experience helper to
  47330. * @returns a promise for the experience helper
  47331. */
  47332. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47333. /**
  47334. * Disposes of the experience helper
  47335. */
  47336. dispose(): void;
  47337. /**
  47338. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47339. * @param sessionMode options for the XR session
  47340. * @param referenceSpaceType frame of reference of the XR session
  47341. * @param renderTarget the output canvas that will be used to enter XR mode
  47342. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47343. * @returns promise that resolves after xr mode has entered
  47344. */
  47345. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47346. /**
  47347. * Exits XR mode and returns the scene to its original state
  47348. * @returns promise that resolves after xr mode has exited
  47349. */
  47350. exitXRAsync(): Promise<void>;
  47351. private _nonXRToXRCamera;
  47352. private _setState;
  47353. }
  47354. }
  47355. declare module BABYLON {
  47356. /**
  47357. * X-Y values for axes in WebXR
  47358. */
  47359. export interface IWebXRMotionControllerAxesValue {
  47360. /**
  47361. * The value of the x axis
  47362. */
  47363. x: number;
  47364. /**
  47365. * The value of the y-axis
  47366. */
  47367. y: number;
  47368. }
  47369. /**
  47370. * changed / previous values for the values of this component
  47371. */
  47372. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47373. /**
  47374. * current (this frame) value
  47375. */
  47376. current: T;
  47377. /**
  47378. * previous (last change) value
  47379. */
  47380. previous: T;
  47381. }
  47382. /**
  47383. * Represents changes in the component between current frame and last values recorded
  47384. */
  47385. export interface IWebXRMotionControllerComponentChanges {
  47386. /**
  47387. * will be populated with previous and current values if axes changed
  47388. */
  47389. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47390. /**
  47391. * will be populated with previous and current values if pressed changed
  47392. */
  47393. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47394. /**
  47395. * will be populated with previous and current values if touched changed
  47396. */
  47397. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47398. /**
  47399. * will be populated with previous and current values if value changed
  47400. */
  47401. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47402. }
  47403. /**
  47404. * This class represents a single component (for example button or thumbstick) of a motion controller
  47405. */
  47406. export class WebXRControllerComponent implements IDisposable {
  47407. /**
  47408. * the id of this component
  47409. */
  47410. id: string;
  47411. /**
  47412. * the type of the component
  47413. */
  47414. type: MotionControllerComponentType;
  47415. private _buttonIndex;
  47416. private _axesIndices;
  47417. private _axes;
  47418. private _changes;
  47419. private _currentValue;
  47420. private _hasChanges;
  47421. private _pressed;
  47422. private _touched;
  47423. /**
  47424. * button component type
  47425. */
  47426. static BUTTON_TYPE: MotionControllerComponentType;
  47427. /**
  47428. * squeeze component type
  47429. */
  47430. static SQUEEZE_TYPE: MotionControllerComponentType;
  47431. /**
  47432. * Thumbstick component type
  47433. */
  47434. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47435. /**
  47436. * Touchpad component type
  47437. */
  47438. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47439. /**
  47440. * trigger component type
  47441. */
  47442. static TRIGGER_TYPE: MotionControllerComponentType;
  47443. /**
  47444. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47445. * the axes data changes
  47446. */
  47447. onAxisValueChangedObservable: Observable<{
  47448. x: number;
  47449. y: number;
  47450. }>;
  47451. /**
  47452. * Observers registered here will be triggered when the state of a button changes
  47453. * State change is either pressed / touched / value
  47454. */
  47455. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47456. /**
  47457. * Creates a new component for a motion controller.
  47458. * It is created by the motion controller itself
  47459. *
  47460. * @param id the id of this component
  47461. * @param type the type of the component
  47462. * @param _buttonIndex index in the buttons array of the gamepad
  47463. * @param _axesIndices indices of the values in the axes array of the gamepad
  47464. */
  47465. constructor(
  47466. /**
  47467. * the id of this component
  47468. */
  47469. id: string,
  47470. /**
  47471. * the type of the component
  47472. */
  47473. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47474. /**
  47475. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47476. */
  47477. get axes(): IWebXRMotionControllerAxesValue;
  47478. /**
  47479. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47480. */
  47481. get changes(): IWebXRMotionControllerComponentChanges;
  47482. /**
  47483. * Return whether or not the component changed the last frame
  47484. */
  47485. get hasChanges(): boolean;
  47486. /**
  47487. * is the button currently pressed
  47488. */
  47489. get pressed(): boolean;
  47490. /**
  47491. * is the button currently touched
  47492. */
  47493. get touched(): boolean;
  47494. /**
  47495. * Get the current value of this component
  47496. */
  47497. get value(): number;
  47498. /**
  47499. * Dispose this component
  47500. */
  47501. dispose(): void;
  47502. /**
  47503. * Are there axes correlating to this component
  47504. * @return true is axes data is available
  47505. */
  47506. isAxes(): boolean;
  47507. /**
  47508. * Is this component a button (hence - pressable)
  47509. * @returns true if can be pressed
  47510. */
  47511. isButton(): boolean;
  47512. /**
  47513. * update this component using the gamepad object it is in. Called on every frame
  47514. * @param nativeController the native gamepad controller object
  47515. */
  47516. update(nativeController: IMinimalMotionControllerObject): void;
  47517. }
  47518. }
  47519. declare module BABYLON {
  47520. /**
  47521. * Interface used to represent data loading progression
  47522. */
  47523. export interface ISceneLoaderProgressEvent {
  47524. /**
  47525. * Defines if data length to load can be evaluated
  47526. */
  47527. readonly lengthComputable: boolean;
  47528. /**
  47529. * Defines the loaded data length
  47530. */
  47531. readonly loaded: number;
  47532. /**
  47533. * Defines the data length to load
  47534. */
  47535. readonly total: number;
  47536. }
  47537. /**
  47538. * Interface used by SceneLoader plugins to define supported file extensions
  47539. */
  47540. export interface ISceneLoaderPluginExtensions {
  47541. /**
  47542. * Defines the list of supported extensions
  47543. */
  47544. [extension: string]: {
  47545. isBinary: boolean;
  47546. };
  47547. }
  47548. /**
  47549. * Interface used by SceneLoader plugin factory
  47550. */
  47551. export interface ISceneLoaderPluginFactory {
  47552. /**
  47553. * Defines the name of the factory
  47554. */
  47555. name: string;
  47556. /**
  47557. * Function called to create a new plugin
  47558. * @return the new plugin
  47559. */
  47560. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47561. /**
  47562. * The callback that returns true if the data can be directly loaded.
  47563. * @param data string containing the file data
  47564. * @returns if the data can be loaded directly
  47565. */
  47566. canDirectLoad?(data: string): boolean;
  47567. }
  47568. /**
  47569. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47570. */
  47571. export interface ISceneLoaderPluginBase {
  47572. /**
  47573. * The friendly name of this plugin.
  47574. */
  47575. name: string;
  47576. /**
  47577. * The file extensions supported by this plugin.
  47578. */
  47579. extensions: string | ISceneLoaderPluginExtensions;
  47580. /**
  47581. * The callback called when loading from a url.
  47582. * @param scene scene loading this url
  47583. * @param url url to load
  47584. * @param onSuccess callback called when the file successfully loads
  47585. * @param onProgress callback called while file is loading (if the server supports this mode)
  47586. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47587. * @param onError callback called when the file fails to load
  47588. * @returns a file request object
  47589. */
  47590. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47591. /**
  47592. * The callback called when loading from a file object.
  47593. * @param scene scene loading this file
  47594. * @param file defines the file to load
  47595. * @param onSuccess defines the callback to call when data is loaded
  47596. * @param onProgress defines the callback to call during loading process
  47597. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47598. * @param onError defines the callback to call when an error occurs
  47599. * @returns a file request object
  47600. */
  47601. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47602. /**
  47603. * The callback that returns true if the data can be directly loaded.
  47604. * @param data string containing the file data
  47605. * @returns if the data can be loaded directly
  47606. */
  47607. canDirectLoad?(data: string): boolean;
  47608. /**
  47609. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47610. * @param scene scene loading this data
  47611. * @param data string containing the data
  47612. * @returns data to pass to the plugin
  47613. */
  47614. directLoad?(scene: Scene, data: string): any;
  47615. /**
  47616. * The callback that allows custom handling of the root url based on the response url.
  47617. * @param rootUrl the original root url
  47618. * @param responseURL the response url if available
  47619. * @returns the new root url
  47620. */
  47621. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47622. }
  47623. /**
  47624. * Interface used to define a SceneLoader plugin
  47625. */
  47626. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47627. /**
  47628. * Import meshes into a scene.
  47629. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47630. * @param scene The scene to import into
  47631. * @param data The data to import
  47632. * @param rootUrl The root url for scene and resources
  47633. * @param meshes The meshes array to import into
  47634. * @param particleSystems The particle systems array to import into
  47635. * @param skeletons The skeletons array to import into
  47636. * @param onError The callback when import fails
  47637. * @returns True if successful or false otherwise
  47638. */
  47639. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47640. /**
  47641. * Load into a scene.
  47642. * @param scene The scene to load into
  47643. * @param data The data to import
  47644. * @param rootUrl The root url for scene and resources
  47645. * @param onError The callback when import fails
  47646. * @returns True if successful or false otherwise
  47647. */
  47648. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47649. /**
  47650. * Load into an asset container.
  47651. * @param scene The scene to load into
  47652. * @param data The data to import
  47653. * @param rootUrl The root url for scene and resources
  47654. * @param onError The callback when import fails
  47655. * @returns The loaded asset container
  47656. */
  47657. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47658. }
  47659. /**
  47660. * Interface used to define an async SceneLoader plugin
  47661. */
  47662. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47663. /**
  47664. * Import meshes into a scene.
  47665. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47666. * @param scene The scene to import into
  47667. * @param data The data to import
  47668. * @param rootUrl The root url for scene and resources
  47669. * @param onProgress The callback when the load progresses
  47670. * @param fileName Defines the name of the file to load
  47671. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47672. */
  47673. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47674. meshes: AbstractMesh[];
  47675. particleSystems: IParticleSystem[];
  47676. skeletons: Skeleton[];
  47677. animationGroups: AnimationGroup[];
  47678. }>;
  47679. /**
  47680. * Load into a scene.
  47681. * @param scene The scene to load into
  47682. * @param data The data to import
  47683. * @param rootUrl The root url for scene and resources
  47684. * @param onProgress The callback when the load progresses
  47685. * @param fileName Defines the name of the file to load
  47686. * @returns Nothing
  47687. */
  47688. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47689. /**
  47690. * Load into an asset container.
  47691. * @param scene The scene to load into
  47692. * @param data The data to import
  47693. * @param rootUrl The root url for scene and resources
  47694. * @param onProgress The callback when the load progresses
  47695. * @param fileName Defines the name of the file to load
  47696. * @returns The loaded asset container
  47697. */
  47698. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47699. }
  47700. /**
  47701. * Mode that determines how to handle old animation groups before loading new ones.
  47702. */
  47703. export enum SceneLoaderAnimationGroupLoadingMode {
  47704. /**
  47705. * Reset all old animations to initial state then dispose them.
  47706. */
  47707. Clean = 0,
  47708. /**
  47709. * Stop all old animations.
  47710. */
  47711. Stop = 1,
  47712. /**
  47713. * Restart old animations from first frame.
  47714. */
  47715. Sync = 2,
  47716. /**
  47717. * Old animations remains untouched.
  47718. */
  47719. NoSync = 3
  47720. }
  47721. /**
  47722. * Defines a plugin registered by the SceneLoader
  47723. */
  47724. interface IRegisteredPlugin {
  47725. /**
  47726. * Defines the plugin to use
  47727. */
  47728. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47729. /**
  47730. * Defines if the plugin supports binary data
  47731. */
  47732. isBinary: boolean;
  47733. }
  47734. /**
  47735. * Class used to load scene from various file formats using registered plugins
  47736. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47737. */
  47738. export class SceneLoader {
  47739. /**
  47740. * No logging while loading
  47741. */
  47742. static readonly NO_LOGGING: number;
  47743. /**
  47744. * Minimal logging while loading
  47745. */
  47746. static readonly MINIMAL_LOGGING: number;
  47747. /**
  47748. * Summary logging while loading
  47749. */
  47750. static readonly SUMMARY_LOGGING: number;
  47751. /**
  47752. * Detailled logging while loading
  47753. */
  47754. static readonly DETAILED_LOGGING: number;
  47755. /**
  47756. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47757. */
  47758. static get ForceFullSceneLoadingForIncremental(): boolean;
  47759. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47760. /**
  47761. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47762. */
  47763. static get ShowLoadingScreen(): boolean;
  47764. static set ShowLoadingScreen(value: boolean);
  47765. /**
  47766. * Defines the current logging level (while loading the scene)
  47767. * @ignorenaming
  47768. */
  47769. static get loggingLevel(): number;
  47770. static set loggingLevel(value: number);
  47771. /**
  47772. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47773. */
  47774. static get CleanBoneMatrixWeights(): boolean;
  47775. static set CleanBoneMatrixWeights(value: boolean);
  47776. /**
  47777. * Event raised when a plugin is used to load a scene
  47778. */
  47779. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47780. private static _registeredPlugins;
  47781. private static _showingLoadingScreen;
  47782. /**
  47783. * Gets the default plugin (used to load Babylon files)
  47784. * @returns the .babylon plugin
  47785. */
  47786. static GetDefaultPlugin(): IRegisteredPlugin;
  47787. private static _GetPluginForExtension;
  47788. private static _GetPluginForDirectLoad;
  47789. private static _GetPluginForFilename;
  47790. private static _GetDirectLoad;
  47791. private static _LoadData;
  47792. private static _GetFileInfo;
  47793. /**
  47794. * Gets a plugin that can load the given extension
  47795. * @param extension defines the extension to load
  47796. * @returns a plugin or null if none works
  47797. */
  47798. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47799. /**
  47800. * Gets a boolean indicating that the given extension can be loaded
  47801. * @param extension defines the extension to load
  47802. * @returns true if the extension is supported
  47803. */
  47804. static IsPluginForExtensionAvailable(extension: string): boolean;
  47805. /**
  47806. * Adds a new plugin to the list of registered plugins
  47807. * @param plugin defines the plugin to add
  47808. */
  47809. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47810. /**
  47811. * Import meshes into a scene
  47812. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47813. * @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)
  47814. * @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)
  47815. * @param scene the instance of BABYLON.Scene to append to
  47816. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47817. * @param onProgress a callback with a progress event for each file being loaded
  47818. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47819. * @param pluginExtension the extension used to determine the plugin
  47820. * @returns The loaded plugin
  47821. */
  47822. 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>;
  47823. /**
  47824. * Import meshes into a scene
  47825. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47826. * @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)
  47827. * @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)
  47828. * @param scene the instance of BABYLON.Scene to append to
  47829. * @param onProgress a callback with a progress event for each file being loaded
  47830. * @param pluginExtension the extension used to determine the plugin
  47831. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47832. */
  47833. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47834. meshes: AbstractMesh[];
  47835. particleSystems: IParticleSystem[];
  47836. skeletons: Skeleton[];
  47837. animationGroups: AnimationGroup[];
  47838. }>;
  47839. /**
  47840. * Load a scene
  47841. * @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)
  47842. * @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)
  47843. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47844. * @param onSuccess a callback with the scene when import succeeds
  47845. * @param onProgress a callback with a progress event for each file being loaded
  47846. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47847. * @param pluginExtension the extension used to determine the plugin
  47848. * @returns The loaded plugin
  47849. */
  47850. 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>;
  47851. /**
  47852. * Load a scene
  47853. * @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)
  47854. * @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)
  47855. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47856. * @param onProgress a callback with a progress event for each file being loaded
  47857. * @param pluginExtension the extension used to determine the plugin
  47858. * @returns The loaded scene
  47859. */
  47860. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47861. /**
  47862. * Append a scene
  47863. * @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)
  47864. * @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)
  47865. * @param scene is the instance of BABYLON.Scene to append to
  47866. * @param onSuccess a callback with the scene when import succeeds
  47867. * @param onProgress a callback with a progress event for each file being loaded
  47868. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47869. * @param pluginExtension the extension used to determine the plugin
  47870. * @returns The loaded plugin
  47871. */
  47872. 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>;
  47873. /**
  47874. * Append a scene
  47875. * @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)
  47876. * @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)
  47877. * @param scene is the instance of BABYLON.Scene to append to
  47878. * @param onProgress a callback with a progress event for each file being loaded
  47879. * @param pluginExtension the extension used to determine the plugin
  47880. * @returns The given scene
  47881. */
  47882. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47883. /**
  47884. * Load a scene into an asset container
  47885. * @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)
  47886. * @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)
  47887. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47888. * @param onSuccess a callback with the scene when import succeeds
  47889. * @param onProgress a callback with a progress event for each file being loaded
  47890. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47891. * @param pluginExtension the extension used to determine the plugin
  47892. * @returns The loaded plugin
  47893. */
  47894. 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>;
  47895. /**
  47896. * Load a scene into an asset container
  47897. * @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)
  47898. * @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)
  47899. * @param scene is the instance of Scene to append to
  47900. * @param onProgress a callback with a progress event for each file being loaded
  47901. * @param pluginExtension the extension used to determine the plugin
  47902. * @returns The loaded asset container
  47903. */
  47904. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47905. /**
  47906. * Import animations from a file into a scene
  47907. * @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)
  47908. * @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)
  47909. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47910. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47911. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47912. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47913. * @param onSuccess a callback with the scene when import succeeds
  47914. * @param onProgress a callback with a progress event for each file being loaded
  47915. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47916. * @param pluginExtension the extension used to determine the plugin
  47917. */
  47918. 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;
  47919. /**
  47920. * Import animations from a file into a scene
  47921. * @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)
  47922. * @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)
  47923. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47924. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47925. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47926. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47927. * @param onSuccess a callback with the scene when import succeeds
  47928. * @param onProgress a callback with a progress event for each file being loaded
  47929. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47930. * @param pluginExtension the extension used to determine the plugin
  47931. * @returns the updated scene with imported animations
  47932. */
  47933. 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>;
  47934. }
  47935. }
  47936. declare module BABYLON {
  47937. /**
  47938. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47939. */
  47940. export type MotionControllerHandedness = "none" | "left" | "right";
  47941. /**
  47942. * The type of components available in motion controllers.
  47943. * This is not the name of the component.
  47944. */
  47945. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47946. /**
  47947. * The state of a controller component
  47948. */
  47949. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47950. /**
  47951. * The schema of motion controller layout.
  47952. * No object will be initialized using this interface
  47953. * This is used just to define the profile.
  47954. */
  47955. export interface IMotionControllerLayout {
  47956. /**
  47957. * Path to load the assets. Usually relative to the base path
  47958. */
  47959. assetPath: string;
  47960. /**
  47961. * Available components (unsorted)
  47962. */
  47963. components: {
  47964. /**
  47965. * A map of component Ids
  47966. */
  47967. [componentId: string]: {
  47968. /**
  47969. * The type of input the component outputs
  47970. */
  47971. type: MotionControllerComponentType;
  47972. /**
  47973. * The indices of this component in the gamepad object
  47974. */
  47975. gamepadIndices: {
  47976. /**
  47977. * Index of button
  47978. */
  47979. button?: number;
  47980. /**
  47981. * If available, index of x-axis
  47982. */
  47983. xAxis?: number;
  47984. /**
  47985. * If available, index of y-axis
  47986. */
  47987. yAxis?: number;
  47988. };
  47989. /**
  47990. * The mesh's root node name
  47991. */
  47992. rootNodeName: string;
  47993. /**
  47994. * Animation definitions for this model
  47995. */
  47996. visualResponses: {
  47997. [stateKey: string]: {
  47998. /**
  47999. * What property will be animated
  48000. */
  48001. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48002. /**
  48003. * What states influence this visual response
  48004. */
  48005. states: MotionControllerComponentStateType[];
  48006. /**
  48007. * Type of animation - movement or visibility
  48008. */
  48009. valueNodeProperty: "transform" | "visibility";
  48010. /**
  48011. * Base node name to move. Its position will be calculated according to the min and max nodes
  48012. */
  48013. valueNodeName?: string;
  48014. /**
  48015. * Minimum movement node
  48016. */
  48017. minNodeName?: string;
  48018. /**
  48019. * Max movement node
  48020. */
  48021. maxNodeName?: string;
  48022. };
  48023. };
  48024. /**
  48025. * If touch enabled, what is the name of node to display user feedback
  48026. */
  48027. touchPointNodeName?: string;
  48028. };
  48029. };
  48030. /**
  48031. * Is it xr standard mapping or not
  48032. */
  48033. gamepadMapping: "" | "xr-standard";
  48034. /**
  48035. * Base root node of this entire model
  48036. */
  48037. rootNodeName: string;
  48038. /**
  48039. * Defines the main button component id
  48040. */
  48041. selectComponentId: string;
  48042. }
  48043. /**
  48044. * A definition for the layout map in the input profile
  48045. */
  48046. export interface IMotionControllerLayoutMap {
  48047. /**
  48048. * Layouts with handedness type as a key
  48049. */
  48050. [handedness: string]: IMotionControllerLayout;
  48051. }
  48052. /**
  48053. * The XR Input profile schema
  48054. * Profiles can be found here:
  48055. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48056. */
  48057. export interface IMotionControllerProfile {
  48058. /**
  48059. * fallback profiles for this profileId
  48060. */
  48061. fallbackProfileIds: string[];
  48062. /**
  48063. * The layout map, with handedness as key
  48064. */
  48065. layouts: IMotionControllerLayoutMap;
  48066. /**
  48067. * The id of this profile
  48068. * correlates to the profile(s) in the xrInput.profiles array
  48069. */
  48070. profileId: string;
  48071. }
  48072. /**
  48073. * A helper-interface for the 3 meshes needed for controller button animation
  48074. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48075. */
  48076. export interface IMotionControllerButtonMeshMap {
  48077. /**
  48078. * the mesh that defines the pressed value mesh position.
  48079. * This is used to find the max-position of this button
  48080. */
  48081. pressedMesh: AbstractMesh;
  48082. /**
  48083. * the mesh that defines the unpressed value mesh position.
  48084. * This is used to find the min (or initial) position of this button
  48085. */
  48086. unpressedMesh: AbstractMesh;
  48087. /**
  48088. * The mesh that will be changed when value changes
  48089. */
  48090. valueMesh: AbstractMesh;
  48091. }
  48092. /**
  48093. * A helper-interface for the 3 meshes needed for controller axis animation.
  48094. * This will be expanded when touchpad animations are fully supported
  48095. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48096. */
  48097. export interface IMotionControllerMeshMap {
  48098. /**
  48099. * the mesh that defines the maximum value mesh position.
  48100. */
  48101. maxMesh?: AbstractMesh;
  48102. /**
  48103. * the mesh that defines the minimum value mesh position.
  48104. */
  48105. minMesh?: AbstractMesh;
  48106. /**
  48107. * The mesh that will be changed when axis value changes
  48108. */
  48109. valueMesh?: AbstractMesh;
  48110. }
  48111. /**
  48112. * The elements needed for change-detection of the gamepad objects in motion controllers
  48113. */
  48114. export interface IMinimalMotionControllerObject {
  48115. /**
  48116. * Available axes of this controller
  48117. */
  48118. axes: number[];
  48119. /**
  48120. * An array of available buttons
  48121. */
  48122. buttons: Array<{
  48123. /**
  48124. * Value of the button/trigger
  48125. */
  48126. value: number;
  48127. /**
  48128. * If the button/trigger is currently touched
  48129. */
  48130. touched: boolean;
  48131. /**
  48132. * If the button/trigger is currently pressed
  48133. */
  48134. pressed: boolean;
  48135. }>;
  48136. /**
  48137. * EXPERIMENTAL haptic support.
  48138. */
  48139. hapticActuators?: Array<{
  48140. pulse: (value: number, duration: number) => Promise<boolean>;
  48141. }>;
  48142. }
  48143. /**
  48144. * An Abstract Motion controller
  48145. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48146. * Each component has an observable to check for changes in value and state
  48147. */
  48148. export abstract class WebXRAbstractMotionController implements IDisposable {
  48149. protected scene: Scene;
  48150. protected layout: IMotionControllerLayout;
  48151. /**
  48152. * The gamepad object correlating to this controller
  48153. */
  48154. gamepadObject: IMinimalMotionControllerObject;
  48155. /**
  48156. * handedness (left/right/none) of this controller
  48157. */
  48158. handedness: MotionControllerHandedness;
  48159. private _initComponent;
  48160. private _modelReady;
  48161. /**
  48162. * A map of components (WebXRControllerComponent) in this motion controller
  48163. * Components have a ComponentType and can also have both button and axis definitions
  48164. */
  48165. readonly components: {
  48166. [id: string]: WebXRControllerComponent;
  48167. };
  48168. /**
  48169. * Disable the model's animation. Can be set at any time.
  48170. */
  48171. disableAnimation: boolean;
  48172. /**
  48173. * Observers registered here will be triggered when the model of this controller is done loading
  48174. */
  48175. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48176. /**
  48177. * The profile id of this motion controller
  48178. */
  48179. abstract profileId: string;
  48180. /**
  48181. * The root mesh of the model. It is null if the model was not yet initialized
  48182. */
  48183. rootMesh: Nullable<AbstractMesh>;
  48184. /**
  48185. * constructs a new abstract motion controller
  48186. * @param scene the scene to which the model of the controller will be added
  48187. * @param layout The profile layout to load
  48188. * @param gamepadObject The gamepad object correlating to this controller
  48189. * @param handedness handedness (left/right/none) of this controller
  48190. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48191. */
  48192. constructor(scene: Scene, layout: IMotionControllerLayout,
  48193. /**
  48194. * The gamepad object correlating to this controller
  48195. */
  48196. gamepadObject: IMinimalMotionControllerObject,
  48197. /**
  48198. * handedness (left/right/none) of this controller
  48199. */
  48200. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48201. /**
  48202. * Dispose this controller, the model mesh and all its components
  48203. */
  48204. dispose(): void;
  48205. /**
  48206. * Returns all components of specific type
  48207. * @param type the type to search for
  48208. * @return an array of components with this type
  48209. */
  48210. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48211. /**
  48212. * get a component based an its component id as defined in layout.components
  48213. * @param id the id of the component
  48214. * @returns the component correlates to the id or undefined if not found
  48215. */
  48216. getComponent(id: string): WebXRControllerComponent;
  48217. /**
  48218. * Get the list of components available in this motion controller
  48219. * @returns an array of strings correlating to available components
  48220. */
  48221. getComponentIds(): string[];
  48222. /**
  48223. * Get the first component of specific type
  48224. * @param type type of component to find
  48225. * @return a controller component or null if not found
  48226. */
  48227. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48228. /**
  48229. * Get the main (Select) component of this controller as defined in the layout
  48230. * @returns the main component of this controller
  48231. */
  48232. getMainComponent(): WebXRControllerComponent;
  48233. /**
  48234. * Loads the model correlating to this controller
  48235. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48236. * @returns A promise fulfilled with the result of the model loading
  48237. */
  48238. loadModel(): Promise<boolean>;
  48239. /**
  48240. * Update this model using the current XRFrame
  48241. * @param xrFrame the current xr frame to use and update the model
  48242. */
  48243. updateFromXRFrame(xrFrame: XRFrame): void;
  48244. /**
  48245. * Backwards compatibility due to a deeply-integrated typo
  48246. */
  48247. get handness(): XREye;
  48248. /**
  48249. * Pulse (vibrate) this controller
  48250. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48251. * Consecutive calls to this function will cancel the last pulse call
  48252. *
  48253. * @param value the strength of the pulse in 0.0...1.0 range
  48254. * @param duration Duration of the pulse in milliseconds
  48255. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48256. * @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
  48257. */
  48258. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48259. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48260. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48261. /**
  48262. * Moves the axis on the controller mesh based on its current state
  48263. * @param axis the index of the axis
  48264. * @param axisValue the value of the axis which determines the meshes new position
  48265. * @hidden
  48266. */
  48267. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48268. /**
  48269. * Update the model itself with the current frame data
  48270. * @param xrFrame the frame to use for updating the model mesh
  48271. */
  48272. protected updateModel(xrFrame: XRFrame): void;
  48273. /**
  48274. * Get the filename and path for this controller's model
  48275. * @returns a map of filename and path
  48276. */
  48277. protected abstract _getFilenameAndPath(): {
  48278. filename: string;
  48279. path: string;
  48280. };
  48281. /**
  48282. * This function is called before the mesh is loaded. It checks for loading constraints.
  48283. * For example, this function can check if the GLB loader is available
  48284. * If this function returns false, the generic controller will be loaded instead
  48285. * @returns Is the client ready to load the mesh
  48286. */
  48287. protected abstract _getModelLoadingConstraints(): boolean;
  48288. /**
  48289. * This function will be called after the model was successfully loaded and can be used
  48290. * for mesh transformations before it is available for the user
  48291. * @param meshes the loaded meshes
  48292. */
  48293. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48294. /**
  48295. * Set the root mesh for this controller. Important for the WebXR controller class
  48296. * @param meshes the loaded meshes
  48297. */
  48298. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48299. /**
  48300. * A function executed each frame that updates the mesh (if needed)
  48301. * @param xrFrame the current xrFrame
  48302. */
  48303. protected abstract _updateModel(xrFrame: XRFrame): void;
  48304. private _getGenericFilenameAndPath;
  48305. private _getGenericParentMesh;
  48306. }
  48307. }
  48308. declare module BABYLON {
  48309. /**
  48310. * A generic trigger-only motion controller for WebXR
  48311. */
  48312. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48313. /**
  48314. * Static version of the profile id of this controller
  48315. */
  48316. static ProfileId: string;
  48317. profileId: string;
  48318. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48319. protected _getFilenameAndPath(): {
  48320. filename: string;
  48321. path: string;
  48322. };
  48323. protected _getModelLoadingConstraints(): boolean;
  48324. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48325. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48326. protected _updateModel(): void;
  48327. }
  48328. }
  48329. declare module BABYLON {
  48330. /**
  48331. * Class containing static functions to help procedurally build meshes
  48332. */
  48333. export class SphereBuilder {
  48334. /**
  48335. * Creates a sphere mesh
  48336. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48337. * * 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`)
  48338. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48339. * * 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
  48340. * * 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)
  48341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48342. * * 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
  48343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48344. * @param name defines the name of the mesh
  48345. * @param options defines the options used to create the mesh
  48346. * @param scene defines the hosting scene
  48347. * @returns the sphere mesh
  48348. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48349. */
  48350. static CreateSphere(name: string, options: {
  48351. segments?: number;
  48352. diameter?: number;
  48353. diameterX?: number;
  48354. diameterY?: number;
  48355. diameterZ?: number;
  48356. arc?: number;
  48357. slice?: number;
  48358. sideOrientation?: number;
  48359. frontUVs?: Vector4;
  48360. backUVs?: Vector4;
  48361. updatable?: boolean;
  48362. }, scene?: Nullable<Scene>): Mesh;
  48363. }
  48364. }
  48365. declare module BABYLON {
  48366. /**
  48367. * A profiled motion controller has its profile loaded from an online repository.
  48368. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48369. */
  48370. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48371. private _repositoryUrl;
  48372. private _buttonMeshMapping;
  48373. private _touchDots;
  48374. /**
  48375. * The profile ID of this controller. Will be populated when the controller initializes.
  48376. */
  48377. profileId: string;
  48378. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48379. dispose(): void;
  48380. protected _getFilenameAndPath(): {
  48381. filename: string;
  48382. path: string;
  48383. };
  48384. protected _getModelLoadingConstraints(): boolean;
  48385. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48386. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48387. protected _updateModel(_xrFrame: XRFrame): void;
  48388. }
  48389. }
  48390. declare module BABYLON {
  48391. /**
  48392. * A construction function type to create a new controller based on an xrInput object
  48393. */
  48394. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48395. /**
  48396. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48397. *
  48398. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48399. * it should be replaced with auto-loaded controllers.
  48400. *
  48401. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48402. */
  48403. export class WebXRMotionControllerManager {
  48404. private static _AvailableControllers;
  48405. private static _Fallbacks;
  48406. private static _ProfileLoadingPromises;
  48407. private static _ProfilesList;
  48408. /**
  48409. * The base URL of the online controller repository. Can be changed at any time.
  48410. */
  48411. static BaseRepositoryUrl: string;
  48412. /**
  48413. * Which repository gets priority - local or online
  48414. */
  48415. static PrioritizeOnlineRepository: boolean;
  48416. /**
  48417. * Use the online repository, or use only locally-defined controllers
  48418. */
  48419. static UseOnlineRepository: boolean;
  48420. /**
  48421. * Clear the cache used for profile loading and reload when requested again
  48422. */
  48423. static ClearProfilesCache(): void;
  48424. /**
  48425. * Register the default fallbacks.
  48426. * This function is called automatically when this file is imported.
  48427. */
  48428. static DefaultFallbacks(): void;
  48429. /**
  48430. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48431. * @param profileId the profile to which a fallback needs to be found
  48432. * @return an array with corresponding fallback profiles
  48433. */
  48434. static FindFallbackWithProfileId(profileId: string): string[];
  48435. /**
  48436. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48437. * The order of search:
  48438. *
  48439. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48440. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48441. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48442. * 4) return the generic trigger controller if none were found
  48443. *
  48444. * @param xrInput the xrInput to which a new controller is initialized
  48445. * @param scene the scene to which the model will be added
  48446. * @param forceProfile force a certain profile for this controller
  48447. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48448. */
  48449. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48450. /**
  48451. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48452. *
  48453. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48454. *
  48455. * @param type the profile type to register
  48456. * @param constructFunction the function to be called when loading this profile
  48457. */
  48458. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48459. /**
  48460. * Register a fallback to a specific profile.
  48461. * @param profileId the profileId that will receive the fallbacks
  48462. * @param fallbacks A list of fallback profiles
  48463. */
  48464. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48465. /**
  48466. * Will update the list of profiles available in the repository
  48467. * @return a promise that resolves to a map of profiles available online
  48468. */
  48469. static UpdateProfilesList(): Promise<{
  48470. [profile: string]: string;
  48471. }>;
  48472. private static _LoadProfileFromRepository;
  48473. private static _LoadProfilesFromAvailableControllers;
  48474. }
  48475. }
  48476. declare module BABYLON {
  48477. /**
  48478. * Configuration options for the WebXR controller creation
  48479. */
  48480. export interface IWebXRControllerOptions {
  48481. /**
  48482. * Should the controller mesh be animated when a user interacts with it
  48483. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48484. */
  48485. disableMotionControllerAnimation?: boolean;
  48486. /**
  48487. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48488. */
  48489. doNotLoadControllerMesh?: boolean;
  48490. /**
  48491. * Force a specific controller type for this controller.
  48492. * This can be used when creating your own profile or when testing different controllers
  48493. */
  48494. forceControllerProfile?: string;
  48495. /**
  48496. * Defines a rendering group ID for meshes that will be loaded.
  48497. * This is for the default controllers only.
  48498. */
  48499. renderingGroupId?: number;
  48500. }
  48501. /**
  48502. * Represents an XR controller
  48503. */
  48504. export class WebXRInputSource {
  48505. private _scene;
  48506. /** The underlying input source for the controller */
  48507. inputSource: XRInputSource;
  48508. private _options;
  48509. private _tmpVector;
  48510. private _uniqueId;
  48511. private _disposed;
  48512. /**
  48513. * 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
  48514. */
  48515. grip?: AbstractMesh;
  48516. /**
  48517. * If available, this is the gamepad object related to this controller.
  48518. * Using this object it is possible to get click events and trackpad changes of the
  48519. * webxr controller that is currently being used.
  48520. */
  48521. motionController?: WebXRAbstractMotionController;
  48522. /**
  48523. * Event that fires when the controller is removed/disposed.
  48524. * The object provided as event data is this controller, after associated assets were disposed.
  48525. * uniqueId is still available.
  48526. */
  48527. onDisposeObservable: Observable<WebXRInputSource>;
  48528. /**
  48529. * Will be triggered when the mesh associated with the motion controller is done loading.
  48530. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48531. * A shortened version of controller -> motion controller -> on mesh loaded.
  48532. */
  48533. onMeshLoadedObservable: Observable<AbstractMesh>;
  48534. /**
  48535. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48536. */
  48537. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48538. /**
  48539. * Pointer which can be used to select objects or attach a visible laser to
  48540. */
  48541. pointer: AbstractMesh;
  48542. /**
  48543. * Creates the input source object
  48544. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48545. * @param _scene the scene which the controller should be associated to
  48546. * @param inputSource the underlying input source for the controller
  48547. * @param _options options for this controller creation
  48548. */
  48549. constructor(_scene: Scene,
  48550. /** The underlying input source for the controller */
  48551. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48552. /**
  48553. * Get this controllers unique id
  48554. */
  48555. get uniqueId(): string;
  48556. /**
  48557. * Disposes of the object
  48558. */
  48559. dispose(): void;
  48560. /**
  48561. * Gets a world space ray coming from the pointer or grip
  48562. * @param result the resulting ray
  48563. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48564. */
  48565. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48566. /**
  48567. * Updates the controller pose based on the given XRFrame
  48568. * @param xrFrame xr frame to update the pose with
  48569. * @param referenceSpace reference space to use
  48570. */
  48571. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48572. }
  48573. }
  48574. declare module BABYLON {
  48575. /**
  48576. * The schema for initialization options of the XR Input class
  48577. */
  48578. export interface IWebXRInputOptions {
  48579. /**
  48580. * If set to true no model will be automatically loaded
  48581. */
  48582. doNotLoadControllerMeshes?: boolean;
  48583. /**
  48584. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48585. * If not found, the xr input profile data will be used.
  48586. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48587. */
  48588. forceInputProfile?: string;
  48589. /**
  48590. * Do not send a request to the controller repository to load the profile.
  48591. *
  48592. * Instead, use the controllers available in babylon itself.
  48593. */
  48594. disableOnlineControllerRepository?: boolean;
  48595. /**
  48596. * A custom URL for the controllers repository
  48597. */
  48598. customControllersRepositoryURL?: string;
  48599. /**
  48600. * Should the controller model's components not move according to the user input
  48601. */
  48602. disableControllerAnimation?: boolean;
  48603. /**
  48604. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48605. */
  48606. controllerOptions?: IWebXRControllerOptions;
  48607. }
  48608. /**
  48609. * XR input used to track XR inputs such as controllers/rays
  48610. */
  48611. export class WebXRInput implements IDisposable {
  48612. /**
  48613. * the xr session manager for this session
  48614. */
  48615. xrSessionManager: WebXRSessionManager;
  48616. /**
  48617. * the WebXR camera for this session. Mainly used for teleportation
  48618. */
  48619. xrCamera: WebXRCamera;
  48620. private readonly options;
  48621. /**
  48622. * XR controllers being tracked
  48623. */
  48624. controllers: Array<WebXRInputSource>;
  48625. private _frameObserver;
  48626. private _sessionEndedObserver;
  48627. private _sessionInitObserver;
  48628. /**
  48629. * Event when a controller has been connected/added
  48630. */
  48631. onControllerAddedObservable: Observable<WebXRInputSource>;
  48632. /**
  48633. * Event when a controller has been removed/disconnected
  48634. */
  48635. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48636. /**
  48637. * Initializes the WebXRInput
  48638. * @param xrSessionManager the xr session manager for this session
  48639. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48640. * @param options = initialization options for this xr input
  48641. */
  48642. constructor(
  48643. /**
  48644. * the xr session manager for this session
  48645. */
  48646. xrSessionManager: WebXRSessionManager,
  48647. /**
  48648. * the WebXR camera for this session. Mainly used for teleportation
  48649. */
  48650. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48651. private _onInputSourcesChange;
  48652. private _addAndRemoveControllers;
  48653. /**
  48654. * Disposes of the object
  48655. */
  48656. dispose(): void;
  48657. }
  48658. }
  48659. declare module BABYLON {
  48660. /**
  48661. * This is the base class for all WebXR features.
  48662. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48663. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48664. */
  48665. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48666. protected _xrSessionManager: WebXRSessionManager;
  48667. private _attached;
  48668. private _removeOnDetach;
  48669. /**
  48670. * Should auto-attach be disabled?
  48671. */
  48672. disableAutoAttach: boolean;
  48673. /**
  48674. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48675. */
  48676. xrNativeFeatureName: string;
  48677. /**
  48678. * Construct a new (abstract) WebXR feature
  48679. * @param _xrSessionManager the xr session manager for this feature
  48680. */
  48681. constructor(_xrSessionManager: WebXRSessionManager);
  48682. /**
  48683. * Is this feature attached
  48684. */
  48685. get attached(): boolean;
  48686. /**
  48687. * attach this feature
  48688. *
  48689. * @param force should attachment be forced (even when already attached)
  48690. * @returns true if successful, false is failed or already attached
  48691. */
  48692. attach(force?: boolean): boolean;
  48693. /**
  48694. * detach this feature.
  48695. *
  48696. * @returns true if successful, false if failed or already detached
  48697. */
  48698. detach(): boolean;
  48699. /**
  48700. * Dispose this feature and all of the resources attached
  48701. */
  48702. dispose(): void;
  48703. /**
  48704. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48705. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48706. *
  48707. * @returns whether or not the feature is compatible in this environment
  48708. */
  48709. isCompatible(): boolean;
  48710. /**
  48711. * This is used to register callbacks that will automatically be removed when detach is called.
  48712. * @param observable the observable to which the observer will be attached
  48713. * @param callback the callback to register
  48714. */
  48715. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48716. /**
  48717. * Code in this function will be executed on each xrFrame received from the browser.
  48718. * This function will not execute after the feature is detached.
  48719. * @param _xrFrame the current frame
  48720. */
  48721. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48722. }
  48723. }
  48724. declare module BABYLON {
  48725. /**
  48726. * Renders a layer on top of an existing scene
  48727. */
  48728. export class UtilityLayerRenderer implements IDisposable {
  48729. /** the original scene that will be rendered on top of */
  48730. originalScene: Scene;
  48731. private _pointerCaptures;
  48732. private _lastPointerEvents;
  48733. private static _DefaultUtilityLayer;
  48734. private static _DefaultKeepDepthUtilityLayer;
  48735. private _sharedGizmoLight;
  48736. private _renderCamera;
  48737. /**
  48738. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48739. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48740. * @returns the camera that is used when rendering the utility layer
  48741. */
  48742. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48743. /**
  48744. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48745. * @param cam the camera that should be used when rendering the utility layer
  48746. */
  48747. setRenderCamera(cam: Nullable<Camera>): void;
  48748. /**
  48749. * @hidden
  48750. * Light which used by gizmos to get light shading
  48751. */
  48752. _getSharedGizmoLight(): HemisphericLight;
  48753. /**
  48754. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48755. */
  48756. pickUtilitySceneFirst: boolean;
  48757. /**
  48758. * 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)
  48759. */
  48760. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48761. /**
  48762. * 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)
  48763. */
  48764. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48765. /**
  48766. * The scene that is rendered on top of the original scene
  48767. */
  48768. utilityLayerScene: Scene;
  48769. /**
  48770. * If the utility layer should automatically be rendered on top of existing scene
  48771. */
  48772. shouldRender: boolean;
  48773. /**
  48774. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48775. */
  48776. onlyCheckPointerDownEvents: boolean;
  48777. /**
  48778. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48779. */
  48780. processAllEvents: boolean;
  48781. /**
  48782. * Observable raised when the pointer move from the utility layer scene to the main scene
  48783. */
  48784. onPointerOutObservable: Observable<number>;
  48785. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48786. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48787. private _afterRenderObserver;
  48788. private _sceneDisposeObserver;
  48789. private _originalPointerObserver;
  48790. /**
  48791. * Instantiates a UtilityLayerRenderer
  48792. * @param originalScene the original scene that will be rendered on top of
  48793. * @param handleEvents boolean indicating if the utility layer should handle events
  48794. */
  48795. constructor(
  48796. /** the original scene that will be rendered on top of */
  48797. originalScene: Scene, handleEvents?: boolean);
  48798. private _notifyObservers;
  48799. /**
  48800. * Renders the utility layers scene on top of the original scene
  48801. */
  48802. render(): void;
  48803. /**
  48804. * Disposes of the renderer
  48805. */
  48806. dispose(): void;
  48807. private _updateCamera;
  48808. }
  48809. }
  48810. declare module BABYLON {
  48811. /**
  48812. * Options interface for the pointer selection module
  48813. */
  48814. export interface IWebXRControllerPointerSelectionOptions {
  48815. /**
  48816. * if provided, this scene will be used to render meshes.
  48817. */
  48818. customUtilityLayerScene?: Scene;
  48819. /**
  48820. * 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)
  48821. * If not disabled, the last picked point will be used to execute a pointer up event
  48822. * If disabled, pointer up event will be triggered right after the pointer down event.
  48823. * Used in screen and gaze target ray mode only
  48824. */
  48825. disablePointerUpOnTouchOut: boolean;
  48826. /**
  48827. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48828. */
  48829. forceGazeMode: boolean;
  48830. /**
  48831. * 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
  48832. * to start a new countdown to the pointer down event.
  48833. * Defaults to 1.
  48834. */
  48835. gazeModePointerMovedFactor?: number;
  48836. /**
  48837. * Different button type to use instead of the main component
  48838. */
  48839. overrideButtonId?: string;
  48840. /**
  48841. * use this rendering group id for the meshes (optional)
  48842. */
  48843. renderingGroupId?: number;
  48844. /**
  48845. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48846. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48847. * 3000 means 3 seconds between pointing at something and selecting it
  48848. */
  48849. timeToSelect?: number;
  48850. /**
  48851. * Should meshes created here be added to a utility layer or the main scene
  48852. */
  48853. useUtilityLayer?: boolean;
  48854. /**
  48855. * Optional WebXR camera to be used for gaze selection
  48856. */
  48857. gazeCamera?: WebXRCamera;
  48858. /**
  48859. * the xr input to use with this pointer selection
  48860. */
  48861. xrInput: WebXRInput;
  48862. }
  48863. /**
  48864. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48865. */
  48866. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48867. private readonly _options;
  48868. private static _idCounter;
  48869. private _attachController;
  48870. private _controllers;
  48871. private _scene;
  48872. private _tmpVectorForPickCompare;
  48873. /**
  48874. * The module's name
  48875. */
  48876. static readonly Name: string;
  48877. /**
  48878. * The (Babylon) version of this module.
  48879. * This is an integer representing the implementation version.
  48880. * This number does not correspond to the WebXR specs version
  48881. */
  48882. static readonly Version: number;
  48883. /**
  48884. * Disable lighting on the laser pointer (so it will always be visible)
  48885. */
  48886. disablePointerLighting: boolean;
  48887. /**
  48888. * Disable lighting on the selection mesh (so it will always be visible)
  48889. */
  48890. disableSelectionMeshLighting: boolean;
  48891. /**
  48892. * Should the laser pointer be displayed
  48893. */
  48894. displayLaserPointer: boolean;
  48895. /**
  48896. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48897. */
  48898. displaySelectionMesh: boolean;
  48899. /**
  48900. * This color will be set to the laser pointer when selection is triggered
  48901. */
  48902. laserPointerPickedColor: Color3;
  48903. /**
  48904. * Default color of the laser pointer
  48905. */
  48906. laserPointerDefaultColor: Color3;
  48907. /**
  48908. * default color of the selection ring
  48909. */
  48910. selectionMeshDefaultColor: Color3;
  48911. /**
  48912. * This color will be applied to the selection ring when selection is triggered
  48913. */
  48914. selectionMeshPickedColor: Color3;
  48915. /**
  48916. * Optional filter to be used for ray selection. This predicate shares behavior with
  48917. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48918. */
  48919. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48920. /**
  48921. * constructs a new background remover module
  48922. * @param _xrSessionManager the session manager for this module
  48923. * @param _options read-only options to be used in this module
  48924. */
  48925. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48926. /**
  48927. * attach this feature
  48928. * Will usually be called by the features manager
  48929. *
  48930. * @returns true if successful.
  48931. */
  48932. attach(): boolean;
  48933. /**
  48934. * detach this feature.
  48935. * Will usually be called by the features manager
  48936. *
  48937. * @returns true if successful.
  48938. */
  48939. detach(): boolean;
  48940. /**
  48941. * Will get the mesh under a specific pointer.
  48942. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48943. * @param controllerId the controllerId to check
  48944. * @returns The mesh under pointer or null if no mesh is under the pointer
  48945. */
  48946. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48947. /**
  48948. * Get the xr controller that correlates to the pointer id in the pointer event
  48949. *
  48950. * @param id the pointer id to search for
  48951. * @returns the controller that correlates to this id or null if not found
  48952. */
  48953. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48954. protected _onXRFrame(_xrFrame: XRFrame): void;
  48955. private _attachGazeMode;
  48956. private _attachScreenRayMode;
  48957. private _attachTrackedPointerRayMode;
  48958. private _convertNormalToDirectionOfRay;
  48959. private _detachController;
  48960. private _generateNewMeshPair;
  48961. private _pickingMoved;
  48962. private _updatePointerDistance;
  48963. /** @hidden */
  48964. get lasterPointerDefaultColor(): Color3;
  48965. }
  48966. }
  48967. declare module BABYLON {
  48968. /**
  48969. * Button which can be used to enter a different mode of XR
  48970. */
  48971. export class WebXREnterExitUIButton {
  48972. /** button element */
  48973. element: HTMLElement;
  48974. /** XR initialization options for the button */
  48975. sessionMode: XRSessionMode;
  48976. /** Reference space type */
  48977. referenceSpaceType: XRReferenceSpaceType;
  48978. /**
  48979. * Creates a WebXREnterExitUIButton
  48980. * @param element button element
  48981. * @param sessionMode XR initialization session mode
  48982. * @param referenceSpaceType the type of reference space to be used
  48983. */
  48984. constructor(
  48985. /** button element */
  48986. element: HTMLElement,
  48987. /** XR initialization options for the button */
  48988. sessionMode: XRSessionMode,
  48989. /** Reference space type */
  48990. referenceSpaceType: XRReferenceSpaceType);
  48991. /**
  48992. * Extendable function which can be used to update the button's visuals when the state changes
  48993. * @param activeButton the current active button in the UI
  48994. */
  48995. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48996. }
  48997. /**
  48998. * Options to create the webXR UI
  48999. */
  49000. export class WebXREnterExitUIOptions {
  49001. /**
  49002. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49003. */
  49004. customButtons?: Array<WebXREnterExitUIButton>;
  49005. /**
  49006. * A reference space type to use when creating the default button.
  49007. * Default is local-floor
  49008. */
  49009. referenceSpaceType?: XRReferenceSpaceType;
  49010. /**
  49011. * Context to enter xr with
  49012. */
  49013. renderTarget?: Nullable<WebXRRenderTarget>;
  49014. /**
  49015. * A session mode to use when creating the default button.
  49016. * Default is immersive-vr
  49017. */
  49018. sessionMode?: XRSessionMode;
  49019. /**
  49020. * A list of optional features to init the session with
  49021. */
  49022. optionalFeatures?: string[];
  49023. /**
  49024. * A list of optional features to init the session with
  49025. */
  49026. requiredFeatures?: string[];
  49027. }
  49028. /**
  49029. * UI to allow the user to enter/exit XR mode
  49030. */
  49031. export class WebXREnterExitUI implements IDisposable {
  49032. private scene;
  49033. /** version of the options passed to this UI */
  49034. options: WebXREnterExitUIOptions;
  49035. private _activeButton;
  49036. private _buttons;
  49037. /**
  49038. * The HTML Div Element to which buttons are added.
  49039. */
  49040. readonly overlay: HTMLDivElement;
  49041. /**
  49042. * Fired every time the active button is changed.
  49043. *
  49044. * When xr is entered via a button that launches xr that button will be the callback parameter
  49045. *
  49046. * When exiting xr the callback parameter will be null)
  49047. */
  49048. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49049. /**
  49050. *
  49051. * @param scene babylon scene object to use
  49052. * @param options (read-only) version of the options passed to this UI
  49053. */
  49054. private constructor();
  49055. /**
  49056. * Creates UI to allow the user to enter/exit XR mode
  49057. * @param scene the scene to add the ui to
  49058. * @param helper the xr experience helper to enter/exit xr with
  49059. * @param options options to configure the UI
  49060. * @returns the created ui
  49061. */
  49062. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49063. /**
  49064. * Disposes of the XR UI component
  49065. */
  49066. dispose(): void;
  49067. private _updateButtons;
  49068. }
  49069. }
  49070. declare module BABYLON {
  49071. /**
  49072. * Class containing static functions to help procedurally build meshes
  49073. */
  49074. export class LinesBuilder {
  49075. /**
  49076. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49077. * * 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
  49078. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49079. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49080. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49081. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49082. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49083. * * 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
  49084. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49086. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49087. * @param name defines the name of the new line system
  49088. * @param options defines the options used to create the line system
  49089. * @param scene defines the hosting scene
  49090. * @returns a new line system mesh
  49091. */
  49092. static CreateLineSystem(name: string, options: {
  49093. lines: Vector3[][];
  49094. updatable?: boolean;
  49095. instance?: Nullable<LinesMesh>;
  49096. colors?: Nullable<Color4[][]>;
  49097. useVertexAlpha?: boolean;
  49098. }, scene: Nullable<Scene>): LinesMesh;
  49099. /**
  49100. * Creates a line mesh
  49101. * 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
  49102. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49103. * * The parameter `points` is an array successive Vector3
  49104. * * 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
  49105. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49106. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49107. * * When updating an instance, remember that only point positions can change, not the number of points
  49108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49109. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49110. * @param name defines the name of the new line system
  49111. * @param options defines the options used to create the line system
  49112. * @param scene defines the hosting scene
  49113. * @returns a new line mesh
  49114. */
  49115. static CreateLines(name: string, options: {
  49116. points: Vector3[];
  49117. updatable?: boolean;
  49118. instance?: Nullable<LinesMesh>;
  49119. colors?: Color4[];
  49120. useVertexAlpha?: boolean;
  49121. }, scene?: Nullable<Scene>): LinesMesh;
  49122. /**
  49123. * Creates a dashed line mesh
  49124. * * 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
  49125. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49126. * * The parameter `points` is an array successive Vector3
  49127. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49128. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49129. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49130. * * 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
  49131. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49132. * * When updating an instance, remember that only point positions can change, not the number of points
  49133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49134. * @param name defines the name of the mesh
  49135. * @param options defines the options used to create the mesh
  49136. * @param scene defines the hosting scene
  49137. * @returns the dashed line mesh
  49138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49139. */
  49140. static CreateDashedLines(name: string, options: {
  49141. points: Vector3[];
  49142. dashSize?: number;
  49143. gapSize?: number;
  49144. dashNb?: number;
  49145. updatable?: boolean;
  49146. instance?: LinesMesh;
  49147. useVertexAlpha?: boolean;
  49148. }, scene?: Nullable<Scene>): LinesMesh;
  49149. }
  49150. }
  49151. declare module BABYLON {
  49152. /**
  49153. * Construction options for a timer
  49154. */
  49155. export interface ITimerOptions<T> {
  49156. /**
  49157. * Time-to-end
  49158. */
  49159. timeout: number;
  49160. /**
  49161. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49162. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49163. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49164. */
  49165. contextObservable: Observable<T>;
  49166. /**
  49167. * Optional parameters when adding an observer to the observable
  49168. */
  49169. observableParameters?: {
  49170. mask?: number;
  49171. insertFirst?: boolean;
  49172. scope?: any;
  49173. };
  49174. /**
  49175. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49176. */
  49177. breakCondition?: (data?: ITimerData<T>) => boolean;
  49178. /**
  49179. * Will be triggered when the time condition has met
  49180. */
  49181. onEnded?: (data: ITimerData<any>) => void;
  49182. /**
  49183. * Will be triggered when the break condition has met (prematurely ended)
  49184. */
  49185. onAborted?: (data: ITimerData<any>) => void;
  49186. /**
  49187. * Optional function to execute on each tick (or count)
  49188. */
  49189. onTick?: (data: ITimerData<any>) => void;
  49190. }
  49191. /**
  49192. * An interface defining the data sent by the timer
  49193. */
  49194. export interface ITimerData<T> {
  49195. /**
  49196. * When did it start
  49197. */
  49198. startTime: number;
  49199. /**
  49200. * Time now
  49201. */
  49202. currentTime: number;
  49203. /**
  49204. * Time passed since started
  49205. */
  49206. deltaTime: number;
  49207. /**
  49208. * How much is completed, in [0.0...1.0].
  49209. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49210. */
  49211. completeRate: number;
  49212. /**
  49213. * What the registered observable sent in the last count
  49214. */
  49215. payload: T;
  49216. }
  49217. /**
  49218. * The current state of the timer
  49219. */
  49220. export enum TimerState {
  49221. /**
  49222. * Timer initialized, not yet started
  49223. */
  49224. INIT = 0,
  49225. /**
  49226. * Timer started and counting
  49227. */
  49228. STARTED = 1,
  49229. /**
  49230. * Timer ended (whether aborted or time reached)
  49231. */
  49232. ENDED = 2
  49233. }
  49234. /**
  49235. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49236. *
  49237. * @param options options with which to initialize this timer
  49238. */
  49239. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49240. /**
  49241. * An advanced implementation of a timer class
  49242. */
  49243. export class AdvancedTimer<T = any> implements IDisposable {
  49244. /**
  49245. * Will notify each time the timer calculates the remaining time
  49246. */
  49247. onEachCountObservable: Observable<ITimerData<T>>;
  49248. /**
  49249. * Will trigger when the timer was aborted due to the break condition
  49250. */
  49251. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49252. /**
  49253. * Will trigger when the timer ended successfully
  49254. */
  49255. onTimerEndedObservable: Observable<ITimerData<T>>;
  49256. /**
  49257. * Will trigger when the timer state has changed
  49258. */
  49259. onStateChangedObservable: Observable<TimerState>;
  49260. private _observer;
  49261. private _contextObservable;
  49262. private _observableParameters;
  49263. private _startTime;
  49264. private _timer;
  49265. private _state;
  49266. private _breakCondition;
  49267. private _timeToEnd;
  49268. private _breakOnNextTick;
  49269. /**
  49270. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49271. * @param options construction options for this advanced timer
  49272. */
  49273. constructor(options: ITimerOptions<T>);
  49274. /**
  49275. * set a breaking condition for this timer. Default is to never break during count
  49276. * @param predicate the new break condition. Returns true to break, false otherwise
  49277. */
  49278. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49279. /**
  49280. * Reset ALL associated observables in this advanced timer
  49281. */
  49282. clearObservables(): void;
  49283. /**
  49284. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49285. *
  49286. * @param timeToEnd how much time to measure until timer ended
  49287. */
  49288. start(timeToEnd?: number): void;
  49289. /**
  49290. * Will force a stop on the next tick.
  49291. */
  49292. stop(): void;
  49293. /**
  49294. * Dispose this timer, clearing all resources
  49295. */
  49296. dispose(): void;
  49297. private _setState;
  49298. private _tick;
  49299. private _stop;
  49300. }
  49301. }
  49302. declare module BABYLON {
  49303. /**
  49304. * The options container for the teleportation module
  49305. */
  49306. export interface IWebXRTeleportationOptions {
  49307. /**
  49308. * if provided, this scene will be used to render meshes.
  49309. */
  49310. customUtilityLayerScene?: Scene;
  49311. /**
  49312. * Values to configure the default target mesh
  49313. */
  49314. defaultTargetMeshOptions?: {
  49315. /**
  49316. * Fill color of the teleportation area
  49317. */
  49318. teleportationFillColor?: string;
  49319. /**
  49320. * Border color for the teleportation area
  49321. */
  49322. teleportationBorderColor?: string;
  49323. /**
  49324. * Disable the mesh's animation sequence
  49325. */
  49326. disableAnimation?: boolean;
  49327. /**
  49328. * Disable lighting on the material or the ring and arrow
  49329. */
  49330. disableLighting?: boolean;
  49331. /**
  49332. * Override the default material of the torus and arrow
  49333. */
  49334. torusArrowMaterial?: Material;
  49335. };
  49336. /**
  49337. * A list of meshes to use as floor meshes.
  49338. * Meshes can be added and removed after initializing the feature using the
  49339. * addFloorMesh and removeFloorMesh functions
  49340. * If empty, rotation will still work
  49341. */
  49342. floorMeshes?: AbstractMesh[];
  49343. /**
  49344. * use this rendering group id for the meshes (optional)
  49345. */
  49346. renderingGroupId?: number;
  49347. /**
  49348. * Should teleportation move only to snap points
  49349. */
  49350. snapPointsOnly?: boolean;
  49351. /**
  49352. * An array of points to which the teleportation will snap to.
  49353. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49354. */
  49355. snapPositions?: Vector3[];
  49356. /**
  49357. * How close should the teleportation ray be in order to snap to position.
  49358. * Default to 0.8 units (meters)
  49359. */
  49360. snapToPositionRadius?: number;
  49361. /**
  49362. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49363. * If you want to support rotation, make sure your mesh has a direction indicator.
  49364. *
  49365. * When left untouched, the default mesh will be initialized.
  49366. */
  49367. teleportationTargetMesh?: AbstractMesh;
  49368. /**
  49369. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49370. */
  49371. timeToTeleport?: number;
  49372. /**
  49373. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49374. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49375. */
  49376. useMainComponentOnly?: boolean;
  49377. /**
  49378. * Should meshes created here be added to a utility layer or the main scene
  49379. */
  49380. useUtilityLayer?: boolean;
  49381. /**
  49382. * Babylon XR Input class for controller
  49383. */
  49384. xrInput: WebXRInput;
  49385. }
  49386. /**
  49387. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49388. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49389. * the input of the attached controllers.
  49390. */
  49391. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49392. private _options;
  49393. private _controllers;
  49394. private _currentTeleportationControllerId;
  49395. private _floorMeshes;
  49396. private _quadraticBezierCurve;
  49397. private _selectionFeature;
  49398. private _snapToPositions;
  49399. private _snappedToPoint;
  49400. private _teleportationRingMaterial?;
  49401. private _tmpRay;
  49402. private _tmpVector;
  49403. /**
  49404. * The module's name
  49405. */
  49406. static readonly Name: string;
  49407. /**
  49408. * The (Babylon) version of this module.
  49409. * This is an integer representing the implementation version.
  49410. * This number does not correspond to the webxr specs version
  49411. */
  49412. static readonly Version: number;
  49413. /**
  49414. * Is movement backwards enabled
  49415. */
  49416. backwardsMovementEnabled: boolean;
  49417. /**
  49418. * Distance to travel when moving backwards
  49419. */
  49420. backwardsTeleportationDistance: number;
  49421. /**
  49422. * The distance from the user to the inspection point in the direction of the controller
  49423. * A higher number will allow the user to move further
  49424. * defaults to 5 (meters, in xr units)
  49425. */
  49426. parabolicCheckRadius: number;
  49427. /**
  49428. * Should the module support parabolic ray on top of direct ray
  49429. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49430. * Very helpful when moving between floors / different heights
  49431. */
  49432. parabolicRayEnabled: boolean;
  49433. /**
  49434. * How much rotation should be applied when rotating right and left
  49435. */
  49436. rotationAngle: number;
  49437. /**
  49438. * Is rotation enabled when moving forward?
  49439. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49440. */
  49441. rotationEnabled: boolean;
  49442. /**
  49443. * constructs a new anchor system
  49444. * @param _xrSessionManager an instance of WebXRSessionManager
  49445. * @param _options configuration object for this feature
  49446. */
  49447. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49448. /**
  49449. * Get the snapPointsOnly flag
  49450. */
  49451. get snapPointsOnly(): boolean;
  49452. /**
  49453. * Sets the snapPointsOnly flag
  49454. * @param snapToPoints should teleportation be exclusively to snap points
  49455. */
  49456. set snapPointsOnly(snapToPoints: boolean);
  49457. /**
  49458. * Add a new mesh to the floor meshes array
  49459. * @param mesh the mesh to use as floor mesh
  49460. */
  49461. addFloorMesh(mesh: AbstractMesh): void;
  49462. /**
  49463. * Add a new snap-to point to fix teleportation to this position
  49464. * @param newSnapPoint The new Snap-To point
  49465. */
  49466. addSnapPoint(newSnapPoint: Vector3): void;
  49467. attach(): boolean;
  49468. detach(): boolean;
  49469. dispose(): void;
  49470. /**
  49471. * Remove a mesh from the floor meshes array
  49472. * @param mesh the mesh to remove
  49473. */
  49474. removeFloorMesh(mesh: AbstractMesh): void;
  49475. /**
  49476. * Remove a mesh from the floor meshes array using its name
  49477. * @param name the mesh name to remove
  49478. */
  49479. removeFloorMeshByName(name: string): void;
  49480. /**
  49481. * 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
  49482. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49483. * @returns was the point found and removed or not
  49484. */
  49485. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49486. /**
  49487. * This function sets a selection feature that will be disabled when
  49488. * the forward ray is shown and will be reattached when hidden.
  49489. * This is used to remove the selection rays when moving.
  49490. * @param selectionFeature the feature to disable when forward movement is enabled
  49491. */
  49492. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49493. protected _onXRFrame(_xrFrame: XRFrame): void;
  49494. private _attachController;
  49495. private _createDefaultTargetMesh;
  49496. private _detachController;
  49497. private _findClosestSnapPointWithRadius;
  49498. private _setTargetMeshPosition;
  49499. private _setTargetMeshVisibility;
  49500. private _showParabolicPath;
  49501. private _teleportForward;
  49502. }
  49503. }
  49504. declare module BABYLON {
  49505. /**
  49506. * Options for the default xr helper
  49507. */
  49508. export class WebXRDefaultExperienceOptions {
  49509. /**
  49510. * Enable or disable default UI to enter XR
  49511. */
  49512. disableDefaultUI?: boolean;
  49513. /**
  49514. * Should teleportation not initialize. defaults to false.
  49515. */
  49516. disableTeleportation?: boolean;
  49517. /**
  49518. * Floor meshes that will be used for teleport
  49519. */
  49520. floorMeshes?: Array<AbstractMesh>;
  49521. /**
  49522. * If set to true, the first frame will not be used to reset position
  49523. * The first frame is mainly used when copying transformation from the old camera
  49524. * Mainly used in AR
  49525. */
  49526. ignoreNativeCameraTransformation?: boolean;
  49527. /**
  49528. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49529. */
  49530. inputOptions?: IWebXRInputOptions;
  49531. /**
  49532. * optional configuration for the output canvas
  49533. */
  49534. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49535. /**
  49536. * optional UI options. This can be used among other to change session mode and reference space type
  49537. */
  49538. uiOptions?: WebXREnterExitUIOptions;
  49539. /**
  49540. * When loading teleportation and pointer select, use stable versions instead of latest.
  49541. */
  49542. useStablePlugins?: boolean;
  49543. /**
  49544. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49545. */
  49546. renderingGroupId?: number;
  49547. /**
  49548. * A list of optional features to init the session with
  49549. * If set to true, all features we support will be added
  49550. */
  49551. optionalFeatures?: boolean | string[];
  49552. }
  49553. /**
  49554. * Default experience which provides a similar setup to the previous webVRExperience
  49555. */
  49556. export class WebXRDefaultExperience {
  49557. /**
  49558. * Base experience
  49559. */
  49560. baseExperience: WebXRExperienceHelper;
  49561. /**
  49562. * Enables ui for entering/exiting xr
  49563. */
  49564. enterExitUI: WebXREnterExitUI;
  49565. /**
  49566. * Input experience extension
  49567. */
  49568. input: WebXRInput;
  49569. /**
  49570. * Enables laser pointer and selection
  49571. */
  49572. pointerSelection: WebXRControllerPointerSelection;
  49573. /**
  49574. * Default target xr should render to
  49575. */
  49576. renderTarget: WebXRRenderTarget;
  49577. /**
  49578. * Enables teleportation
  49579. */
  49580. teleportation: WebXRMotionControllerTeleportation;
  49581. private constructor();
  49582. /**
  49583. * Creates the default xr experience
  49584. * @param scene scene
  49585. * @param options options for basic configuration
  49586. * @returns resulting WebXRDefaultExperience
  49587. */
  49588. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49589. /**
  49590. * DIsposes of the experience helper
  49591. */
  49592. dispose(): void;
  49593. }
  49594. }
  49595. declare module BABYLON {
  49596. /**
  49597. * Options to modify the vr teleportation behavior.
  49598. */
  49599. export interface VRTeleportationOptions {
  49600. /**
  49601. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49602. */
  49603. floorMeshName?: string;
  49604. /**
  49605. * A list of meshes to be used as the teleportation floor. (default: empty)
  49606. */
  49607. floorMeshes?: Mesh[];
  49608. /**
  49609. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49610. */
  49611. teleportationMode?: number;
  49612. /**
  49613. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49614. */
  49615. teleportationTime?: number;
  49616. /**
  49617. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49618. */
  49619. teleportationSpeed?: number;
  49620. /**
  49621. * The easing function used in the animation or null for Linear. (default CircleEase)
  49622. */
  49623. easingFunction?: EasingFunction;
  49624. }
  49625. /**
  49626. * Options to modify the vr experience helper's behavior.
  49627. */
  49628. export interface VRExperienceHelperOptions extends WebVROptions {
  49629. /**
  49630. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49631. */
  49632. createDeviceOrientationCamera?: boolean;
  49633. /**
  49634. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49635. */
  49636. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49637. /**
  49638. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49639. */
  49640. laserToggle?: boolean;
  49641. /**
  49642. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49643. */
  49644. floorMeshes?: Mesh[];
  49645. /**
  49646. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49647. */
  49648. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49649. /**
  49650. * Defines if WebXR should be used instead of WebVR (if available)
  49651. */
  49652. useXR?: boolean;
  49653. }
  49654. /**
  49655. * Event containing information after VR has been entered
  49656. */
  49657. export class OnAfterEnteringVRObservableEvent {
  49658. /**
  49659. * If entering vr was successful
  49660. */
  49661. success: boolean;
  49662. }
  49663. /**
  49664. * Helps to quickly add VR support to an existing scene.
  49665. * See https://doc.babylonjs.com/how_to/webvr_helper
  49666. */
  49667. export class VRExperienceHelper {
  49668. /** Options to modify the vr experience helper's behavior. */
  49669. webVROptions: VRExperienceHelperOptions;
  49670. private _scene;
  49671. private _position;
  49672. private _btnVR;
  49673. private _btnVRDisplayed;
  49674. private _webVRsupported;
  49675. private _webVRready;
  49676. private _webVRrequesting;
  49677. private _webVRpresenting;
  49678. private _hasEnteredVR;
  49679. private _fullscreenVRpresenting;
  49680. private _inputElement;
  49681. private _webVRCamera;
  49682. private _vrDeviceOrientationCamera;
  49683. private _deviceOrientationCamera;
  49684. private _existingCamera;
  49685. private _onKeyDown;
  49686. private _onVrDisplayPresentChange;
  49687. private _onVRDisplayChanged;
  49688. private _onVRRequestPresentStart;
  49689. private _onVRRequestPresentComplete;
  49690. /**
  49691. * 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)
  49692. */
  49693. enableGazeEvenWhenNoPointerLock: boolean;
  49694. /**
  49695. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49696. */
  49697. exitVROnDoubleTap: boolean;
  49698. /**
  49699. * Observable raised right before entering VR.
  49700. */
  49701. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49702. /**
  49703. * Observable raised when entering VR has completed.
  49704. */
  49705. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49706. /**
  49707. * Observable raised when exiting VR.
  49708. */
  49709. onExitingVRObservable: Observable<VRExperienceHelper>;
  49710. /**
  49711. * Observable raised when controller mesh is loaded.
  49712. */
  49713. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49714. /** Return this.onEnteringVRObservable
  49715. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49716. */
  49717. get onEnteringVR(): Observable<VRExperienceHelper>;
  49718. /** Return this.onExitingVRObservable
  49719. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49720. */
  49721. get onExitingVR(): Observable<VRExperienceHelper>;
  49722. /** Return this.onControllerMeshLoadedObservable
  49723. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49724. */
  49725. get onControllerMeshLoaded(): Observable<WebVRController>;
  49726. private _rayLength;
  49727. private _useCustomVRButton;
  49728. private _teleportationRequested;
  49729. private _teleportActive;
  49730. private _floorMeshName;
  49731. private _floorMeshesCollection;
  49732. private _teleportationMode;
  49733. private _teleportationTime;
  49734. private _teleportationSpeed;
  49735. private _teleportationEasing;
  49736. private _rotationAllowed;
  49737. private _teleportBackwardsVector;
  49738. private _teleportationTarget;
  49739. private _isDefaultTeleportationTarget;
  49740. private _postProcessMove;
  49741. private _teleportationFillColor;
  49742. private _teleportationBorderColor;
  49743. private _rotationAngle;
  49744. private _haloCenter;
  49745. private _cameraGazer;
  49746. private _padSensibilityUp;
  49747. private _padSensibilityDown;
  49748. private _leftController;
  49749. private _rightController;
  49750. private _gazeColor;
  49751. private _laserColor;
  49752. private _pickedLaserColor;
  49753. private _pickedGazeColor;
  49754. /**
  49755. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49756. */
  49757. onNewMeshSelected: Observable<AbstractMesh>;
  49758. /**
  49759. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49760. * This observable will provide the mesh and the controller used to select the mesh
  49761. */
  49762. onMeshSelectedWithController: Observable<{
  49763. mesh: AbstractMesh;
  49764. controller: WebVRController;
  49765. }>;
  49766. /**
  49767. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49768. */
  49769. onNewMeshPicked: Observable<PickingInfo>;
  49770. private _circleEase;
  49771. /**
  49772. * Observable raised before camera teleportation
  49773. */
  49774. onBeforeCameraTeleport: Observable<Vector3>;
  49775. /**
  49776. * Observable raised after camera teleportation
  49777. */
  49778. onAfterCameraTeleport: Observable<Vector3>;
  49779. /**
  49780. * Observable raised when current selected mesh gets unselected
  49781. */
  49782. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49783. private _raySelectionPredicate;
  49784. /**
  49785. * To be optionaly changed by user to define custom ray selection
  49786. */
  49787. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49788. /**
  49789. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49790. */
  49791. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49792. /**
  49793. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49794. */
  49795. teleportationEnabled: boolean;
  49796. private _defaultHeight;
  49797. private _teleportationInitialized;
  49798. private _interactionsEnabled;
  49799. private _interactionsRequested;
  49800. private _displayGaze;
  49801. private _displayLaserPointer;
  49802. /**
  49803. * The mesh used to display where the user is going to teleport.
  49804. */
  49805. get teleportationTarget(): Mesh;
  49806. /**
  49807. * Sets the mesh to be used to display where the user is going to teleport.
  49808. */
  49809. set teleportationTarget(value: Mesh);
  49810. /**
  49811. * 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
  49812. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49813. * See https://doc.babylonjs.com/resources/baking_transformations
  49814. */
  49815. get gazeTrackerMesh(): Mesh;
  49816. set gazeTrackerMesh(value: Mesh);
  49817. /**
  49818. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49819. */
  49820. updateGazeTrackerScale: boolean;
  49821. /**
  49822. * If the gaze trackers color should be updated when selecting meshes
  49823. */
  49824. updateGazeTrackerColor: boolean;
  49825. /**
  49826. * If the controller laser color should be updated when selecting meshes
  49827. */
  49828. updateControllerLaserColor: boolean;
  49829. /**
  49830. * The gaze tracking mesh corresponding to the left controller
  49831. */
  49832. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49833. /**
  49834. * The gaze tracking mesh corresponding to the right controller
  49835. */
  49836. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49837. /**
  49838. * If the ray of the gaze should be displayed.
  49839. */
  49840. get displayGaze(): boolean;
  49841. /**
  49842. * Sets if the ray of the gaze should be displayed.
  49843. */
  49844. set displayGaze(value: boolean);
  49845. /**
  49846. * If the ray of the LaserPointer should be displayed.
  49847. */
  49848. get displayLaserPointer(): boolean;
  49849. /**
  49850. * Sets if the ray of the LaserPointer should be displayed.
  49851. */
  49852. set displayLaserPointer(value: boolean);
  49853. /**
  49854. * The deviceOrientationCamera used as the camera when not in VR.
  49855. */
  49856. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49857. /**
  49858. * Based on the current WebVR support, returns the current VR camera used.
  49859. */
  49860. get currentVRCamera(): Nullable<Camera>;
  49861. /**
  49862. * The webVRCamera which is used when in VR.
  49863. */
  49864. get webVRCamera(): WebVRFreeCamera;
  49865. /**
  49866. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49867. */
  49868. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49869. /**
  49870. * The html button that is used to trigger entering into VR.
  49871. */
  49872. get vrButton(): Nullable<HTMLButtonElement>;
  49873. private get _teleportationRequestInitiated();
  49874. /**
  49875. * Defines whether or not Pointer lock should be requested when switching to
  49876. * full screen.
  49877. */
  49878. requestPointerLockOnFullScreen: boolean;
  49879. /**
  49880. * If asking to force XR, this will be populated with the default xr experience
  49881. */
  49882. xr: WebXRDefaultExperience;
  49883. /**
  49884. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49885. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49886. */
  49887. xrTestDone: boolean;
  49888. /**
  49889. * Instantiates a VRExperienceHelper.
  49890. * Helps to quickly add VR support to an existing scene.
  49891. * @param scene The scene the VRExperienceHelper belongs to.
  49892. * @param webVROptions Options to modify the vr experience helper's behavior.
  49893. */
  49894. constructor(scene: Scene,
  49895. /** Options to modify the vr experience helper's behavior. */
  49896. webVROptions?: VRExperienceHelperOptions);
  49897. private completeVRInit;
  49898. private _onDefaultMeshLoaded;
  49899. private _onResize;
  49900. private _onFullscreenChange;
  49901. /**
  49902. * Gets a value indicating if we are currently in VR mode.
  49903. */
  49904. get isInVRMode(): boolean;
  49905. private onVrDisplayPresentChange;
  49906. private onVRDisplayChanged;
  49907. private moveButtonToBottomRight;
  49908. private displayVRButton;
  49909. private updateButtonVisibility;
  49910. private _cachedAngularSensibility;
  49911. /**
  49912. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49913. * Otherwise, will use the fullscreen API.
  49914. */
  49915. enterVR(): void;
  49916. /**
  49917. * Attempt to exit VR, or fullscreen.
  49918. */
  49919. exitVR(): void;
  49920. /**
  49921. * The position of the vr experience helper.
  49922. */
  49923. get position(): Vector3;
  49924. /**
  49925. * Sets the position of the vr experience helper.
  49926. */
  49927. set position(value: Vector3);
  49928. /**
  49929. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49930. */
  49931. enableInteractions(): void;
  49932. private get _noControllerIsActive();
  49933. private beforeRender;
  49934. private _isTeleportationFloor;
  49935. /**
  49936. * Adds a floor mesh to be used for teleportation.
  49937. * @param floorMesh the mesh to be used for teleportation.
  49938. */
  49939. addFloorMesh(floorMesh: Mesh): void;
  49940. /**
  49941. * Removes a floor mesh from being used for teleportation.
  49942. * @param floorMesh the mesh to be removed.
  49943. */
  49944. removeFloorMesh(floorMesh: Mesh): void;
  49945. /**
  49946. * Enables interactions and teleportation using the VR controllers and gaze.
  49947. * @param vrTeleportationOptions options to modify teleportation behavior.
  49948. */
  49949. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49950. private _onNewGamepadConnected;
  49951. private _tryEnableInteractionOnController;
  49952. private _onNewGamepadDisconnected;
  49953. private _enableInteractionOnController;
  49954. private _checkTeleportWithRay;
  49955. private _checkRotate;
  49956. private _checkTeleportBackwards;
  49957. private _enableTeleportationOnController;
  49958. private _createTeleportationCircles;
  49959. private _displayTeleportationTarget;
  49960. private _hideTeleportationTarget;
  49961. private _rotateCamera;
  49962. private _moveTeleportationSelectorTo;
  49963. private _workingVector;
  49964. private _workingQuaternion;
  49965. private _workingMatrix;
  49966. /**
  49967. * Time Constant Teleportation Mode
  49968. */
  49969. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49970. /**
  49971. * Speed Constant Teleportation Mode
  49972. */
  49973. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49974. /**
  49975. * Teleports the users feet to the desired location
  49976. * @param location The location where the user's feet should be placed
  49977. */
  49978. teleportCamera(location: Vector3): void;
  49979. private _convertNormalToDirectionOfRay;
  49980. private _castRayAndSelectObject;
  49981. private _notifySelectedMeshUnselected;
  49982. /**
  49983. * Permanently set new colors for the laser pointer
  49984. * @param color the new laser color
  49985. * @param pickedColor the new laser color when picked mesh detected
  49986. */
  49987. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49988. /**
  49989. * Set lighting enabled / disabled on the laser pointer of both controllers
  49990. * @param enabled should the lighting be enabled on the laser pointer
  49991. */
  49992. setLaserLightingState(enabled?: boolean): void;
  49993. /**
  49994. * Permanently set new colors for the gaze pointer
  49995. * @param color the new gaze color
  49996. * @param pickedColor the new gaze color when picked mesh detected
  49997. */
  49998. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49999. /**
  50000. * Sets the color of the laser ray from the vr controllers.
  50001. * @param color new color for the ray.
  50002. */
  50003. changeLaserColor(color: Color3): void;
  50004. /**
  50005. * Sets the color of the ray from the vr headsets gaze.
  50006. * @param color new color for the ray.
  50007. */
  50008. changeGazeColor(color: Color3): void;
  50009. /**
  50010. * Exits VR and disposes of the vr experience helper
  50011. */
  50012. dispose(): void;
  50013. /**
  50014. * Gets the name of the VRExperienceHelper class
  50015. * @returns "VRExperienceHelper"
  50016. */
  50017. getClassName(): string;
  50018. }
  50019. }
  50020. declare module BABYLON {
  50021. /**
  50022. * Contains an array of blocks representing the octree
  50023. */
  50024. export interface IOctreeContainer<T> {
  50025. /**
  50026. * Blocks within the octree
  50027. */
  50028. blocks: Array<OctreeBlock<T>>;
  50029. }
  50030. /**
  50031. * Class used to store a cell in an octree
  50032. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50033. */
  50034. export class OctreeBlock<T> {
  50035. /**
  50036. * Gets the content of the current block
  50037. */
  50038. entries: T[];
  50039. /**
  50040. * Gets the list of block children
  50041. */
  50042. blocks: Array<OctreeBlock<T>>;
  50043. private _depth;
  50044. private _maxDepth;
  50045. private _capacity;
  50046. private _minPoint;
  50047. private _maxPoint;
  50048. private _boundingVectors;
  50049. private _creationFunc;
  50050. /**
  50051. * Creates a new block
  50052. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50053. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50054. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50055. * @param depth defines the current depth of this block in the octree
  50056. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50057. * @param creationFunc defines a callback to call when an element is added to the block
  50058. */
  50059. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50060. /**
  50061. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50062. */
  50063. get capacity(): number;
  50064. /**
  50065. * Gets the minimum vector (in world space) of the block's bounding box
  50066. */
  50067. get minPoint(): Vector3;
  50068. /**
  50069. * Gets the maximum vector (in world space) of the block's bounding box
  50070. */
  50071. get maxPoint(): Vector3;
  50072. /**
  50073. * Add a new element to this block
  50074. * @param entry defines the element to add
  50075. */
  50076. addEntry(entry: T): void;
  50077. /**
  50078. * Remove an element from this block
  50079. * @param entry defines the element to remove
  50080. */
  50081. removeEntry(entry: T): void;
  50082. /**
  50083. * Add an array of elements to this block
  50084. * @param entries defines the array of elements to add
  50085. */
  50086. addEntries(entries: T[]): void;
  50087. /**
  50088. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50089. * @param frustumPlanes defines the frustum planes to test
  50090. * @param selection defines the array to store current content if selection is positive
  50091. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50092. */
  50093. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50094. /**
  50095. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50096. * @param sphereCenter defines the bounding sphere center
  50097. * @param sphereRadius defines the bounding sphere radius
  50098. * @param selection defines the array to store current content if selection is positive
  50099. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50100. */
  50101. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50102. /**
  50103. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50104. * @param ray defines the ray to test with
  50105. * @param selection defines the array to store current content if selection is positive
  50106. */
  50107. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50108. /**
  50109. * Subdivide the content into child blocks (this block will then be empty)
  50110. */
  50111. createInnerBlocks(): void;
  50112. /**
  50113. * @hidden
  50114. */
  50115. 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;
  50116. }
  50117. }
  50118. declare module BABYLON {
  50119. /**
  50120. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50121. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50122. */
  50123. export class Octree<T> {
  50124. /** 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.) */
  50125. maxDepth: number;
  50126. /**
  50127. * Blocks within the octree containing objects
  50128. */
  50129. blocks: Array<OctreeBlock<T>>;
  50130. /**
  50131. * Content stored in the octree
  50132. */
  50133. dynamicContent: T[];
  50134. private _maxBlockCapacity;
  50135. private _selectionContent;
  50136. private _creationFunc;
  50137. /**
  50138. * Creates a octree
  50139. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50140. * @param creationFunc function to be used to instatiate the octree
  50141. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50142. * @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.)
  50143. */
  50144. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50145. /** 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.) */
  50146. maxDepth?: number);
  50147. /**
  50148. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50149. * @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);
  50150. * @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);
  50151. * @param entries meshes to be added to the octree blocks
  50152. */
  50153. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50154. /**
  50155. * Adds a mesh to the octree
  50156. * @param entry Mesh to add to the octree
  50157. */
  50158. addMesh(entry: T): void;
  50159. /**
  50160. * Remove an element from the octree
  50161. * @param entry defines the element to remove
  50162. */
  50163. removeMesh(entry: T): void;
  50164. /**
  50165. * Selects an array of meshes within the frustum
  50166. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50167. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50168. * @returns array of meshes within the frustum
  50169. */
  50170. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50171. /**
  50172. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50173. * @param sphereCenter defines the bounding sphere center
  50174. * @param sphereRadius defines the bounding sphere radius
  50175. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50176. * @returns an array of objects that intersect the sphere
  50177. */
  50178. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50179. /**
  50180. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50181. * @param ray defines the ray to test with
  50182. * @returns array of intersected objects
  50183. */
  50184. intersectsRay(ray: Ray): SmartArray<T>;
  50185. /**
  50186. * Adds a mesh into the octree block if it intersects the block
  50187. */
  50188. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50189. /**
  50190. * Adds a submesh into the octree block if it intersects the block
  50191. */
  50192. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50193. }
  50194. }
  50195. declare module BABYLON {
  50196. interface Scene {
  50197. /**
  50198. * @hidden
  50199. * Backing Filed
  50200. */
  50201. _selectionOctree: Octree<AbstractMesh>;
  50202. /**
  50203. * Gets the octree used to boost mesh selection (picking)
  50204. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50205. */
  50206. selectionOctree: Octree<AbstractMesh>;
  50207. /**
  50208. * Creates or updates the octree used to boost selection (picking)
  50209. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50210. * @param maxCapacity defines the maximum capacity per leaf
  50211. * @param maxDepth defines the maximum depth of the octree
  50212. * @returns an octree of AbstractMesh
  50213. */
  50214. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50215. }
  50216. interface AbstractMesh {
  50217. /**
  50218. * @hidden
  50219. * Backing Field
  50220. */
  50221. _submeshesOctree: Octree<SubMesh>;
  50222. /**
  50223. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50224. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50225. * @param maxCapacity defines the maximum size of each block (64 by default)
  50226. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50227. * @returns the new octree
  50228. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50229. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50230. */
  50231. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50232. }
  50233. /**
  50234. * Defines the octree scene component responsible to manage any octrees
  50235. * in a given scene.
  50236. */
  50237. export class OctreeSceneComponent {
  50238. /**
  50239. * The component name help to identify the component in the list of scene components.
  50240. */
  50241. readonly name: string;
  50242. /**
  50243. * The scene the component belongs to.
  50244. */
  50245. scene: Scene;
  50246. /**
  50247. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50248. */
  50249. readonly checksIsEnabled: boolean;
  50250. /**
  50251. * Creates a new instance of the component for the given scene
  50252. * @param scene Defines the scene to register the component in
  50253. */
  50254. constructor(scene: Scene);
  50255. /**
  50256. * Registers the component in a given scene
  50257. */
  50258. register(): void;
  50259. /**
  50260. * Return the list of active meshes
  50261. * @returns the list of active meshes
  50262. */
  50263. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50264. /**
  50265. * Return the list of active sub meshes
  50266. * @param mesh The mesh to get the candidates sub meshes from
  50267. * @returns the list of active sub meshes
  50268. */
  50269. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50270. private _tempRay;
  50271. /**
  50272. * Return the list of sub meshes intersecting with a given local ray
  50273. * @param mesh defines the mesh to find the submesh for
  50274. * @param localRay defines the ray in local space
  50275. * @returns the list of intersecting sub meshes
  50276. */
  50277. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50278. /**
  50279. * Return the list of sub meshes colliding with a collider
  50280. * @param mesh defines the mesh to find the submesh for
  50281. * @param collider defines the collider to evaluate the collision against
  50282. * @returns the list of colliding sub meshes
  50283. */
  50284. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50285. /**
  50286. * Rebuilds the elements related to this component in case of
  50287. * context lost for instance.
  50288. */
  50289. rebuild(): void;
  50290. /**
  50291. * Disposes the component and the associated ressources.
  50292. */
  50293. dispose(): void;
  50294. }
  50295. }
  50296. declare module BABYLON {
  50297. /**
  50298. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50299. */
  50300. export class Gizmo implements IDisposable {
  50301. /** The utility layer the gizmo will be added to */
  50302. gizmoLayer: UtilityLayerRenderer;
  50303. /**
  50304. * The root mesh of the gizmo
  50305. */
  50306. _rootMesh: Mesh;
  50307. private _attachedMesh;
  50308. private _attachedNode;
  50309. /**
  50310. * Ratio for the scale of the gizmo (Default: 1)
  50311. */
  50312. protected _scaleRatio: number;
  50313. /**
  50314. * Ratio for the scale of the gizmo (Default: 1)
  50315. */
  50316. set scaleRatio(value: number);
  50317. get scaleRatio(): number;
  50318. /**
  50319. * If a custom mesh has been set (Default: false)
  50320. */
  50321. protected _customMeshSet: boolean;
  50322. /**
  50323. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50324. * * When set, interactions will be enabled
  50325. */
  50326. get attachedMesh(): Nullable<AbstractMesh>;
  50327. set attachedMesh(value: Nullable<AbstractMesh>);
  50328. /**
  50329. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50330. * * When set, interactions will be enabled
  50331. */
  50332. get attachedNode(): Nullable<Node>;
  50333. set attachedNode(value: Nullable<Node>);
  50334. /**
  50335. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50336. * @param mesh The mesh to replace the default mesh of the gizmo
  50337. */
  50338. setCustomMesh(mesh: Mesh): void;
  50339. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  50340. /**
  50341. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50342. */
  50343. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50344. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50345. /**
  50346. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50347. */
  50348. updateGizmoPositionToMatchAttachedMesh: boolean;
  50349. /**
  50350. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50351. */
  50352. updateScale: boolean;
  50353. protected _interactionsEnabled: boolean;
  50354. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50355. private _beforeRenderObserver;
  50356. private _tempQuaternion;
  50357. private _tempVector;
  50358. private _tempVector2;
  50359. /**
  50360. * Creates a gizmo
  50361. * @param gizmoLayer The utility layer the gizmo will be added to
  50362. */
  50363. constructor(
  50364. /** The utility layer the gizmo will be added to */
  50365. gizmoLayer?: UtilityLayerRenderer);
  50366. /**
  50367. * Updates the gizmo to match the attached mesh's position/rotation
  50368. */
  50369. protected _update(): void;
  50370. /**
  50371. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50372. * @param value Node, TransformNode or mesh
  50373. */
  50374. protected _matrixChanged(): void;
  50375. /**
  50376. * Disposes of the gizmo
  50377. */
  50378. dispose(): void;
  50379. }
  50380. }
  50381. declare module BABYLON {
  50382. /**
  50383. * Single plane drag gizmo
  50384. */
  50385. export class PlaneDragGizmo extends Gizmo {
  50386. /**
  50387. * Drag behavior responsible for the gizmos dragging interactions
  50388. */
  50389. dragBehavior: PointerDragBehavior;
  50390. private _pointerObserver;
  50391. /**
  50392. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50393. */
  50394. snapDistance: number;
  50395. /**
  50396. * Event that fires each time the gizmo snaps to a new location.
  50397. * * snapDistance is the the change in distance
  50398. */
  50399. onSnapObservable: Observable<{
  50400. snapDistance: number;
  50401. }>;
  50402. private _plane;
  50403. private _coloredMaterial;
  50404. private _hoverMaterial;
  50405. private _isEnabled;
  50406. private _parent;
  50407. /** @hidden */
  50408. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50409. /** @hidden */
  50410. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50411. /**
  50412. * Creates a PlaneDragGizmo
  50413. * @param gizmoLayer The utility layer the gizmo will be added to
  50414. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50415. * @param color The color of the gizmo
  50416. */
  50417. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50418. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50419. /**
  50420. * If the gizmo is enabled
  50421. */
  50422. set isEnabled(value: boolean);
  50423. get isEnabled(): boolean;
  50424. /**
  50425. * Disposes of the gizmo
  50426. */
  50427. dispose(): void;
  50428. }
  50429. }
  50430. declare module BABYLON {
  50431. /**
  50432. * Gizmo that enables dragging a mesh along 3 axis
  50433. */
  50434. export class PositionGizmo extends Gizmo {
  50435. /**
  50436. * Internal gizmo used for interactions on the x axis
  50437. */
  50438. xGizmo: AxisDragGizmo;
  50439. /**
  50440. * Internal gizmo used for interactions on the y axis
  50441. */
  50442. yGizmo: AxisDragGizmo;
  50443. /**
  50444. * Internal gizmo used for interactions on the z axis
  50445. */
  50446. zGizmo: AxisDragGizmo;
  50447. /**
  50448. * Internal gizmo used for interactions on the yz plane
  50449. */
  50450. xPlaneGizmo: PlaneDragGizmo;
  50451. /**
  50452. * Internal gizmo used for interactions on the xz plane
  50453. */
  50454. yPlaneGizmo: PlaneDragGizmo;
  50455. /**
  50456. * Internal gizmo used for interactions on the xy plane
  50457. */
  50458. zPlaneGizmo: PlaneDragGizmo;
  50459. /**
  50460. * private variables
  50461. */
  50462. private _meshAttached;
  50463. private _nodeAttached;
  50464. private _snapDistance;
  50465. /** Fires an event when any of it's sub gizmos are dragged */
  50466. onDragStartObservable: Observable<unknown>;
  50467. /** Fires an event when any of it's sub gizmos are released from dragging */
  50468. onDragEndObservable: Observable<unknown>;
  50469. /**
  50470. * If set to true, planar drag is enabled
  50471. */
  50472. private _planarGizmoEnabled;
  50473. get attachedMesh(): Nullable<AbstractMesh>;
  50474. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50475. get attachedNode(): Nullable<Node>;
  50476. set attachedNode(node: Nullable<Node>);
  50477. /**
  50478. * Creates a PositionGizmo
  50479. * @param gizmoLayer The utility layer the gizmo will be added to
  50480. @param thickness display gizmo axis thickness
  50481. */
  50482. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50483. /**
  50484. * If the planar drag gizmo is enabled
  50485. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50486. */
  50487. set planarGizmoEnabled(value: boolean);
  50488. get planarGizmoEnabled(): boolean;
  50489. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50490. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50491. /**
  50492. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50493. */
  50494. set snapDistance(value: number);
  50495. get snapDistance(): number;
  50496. /**
  50497. * Ratio for the scale of the gizmo (Default: 1)
  50498. */
  50499. set scaleRatio(value: number);
  50500. get scaleRatio(): number;
  50501. /**
  50502. * Disposes of the gizmo
  50503. */
  50504. dispose(): void;
  50505. /**
  50506. * CustomMeshes are not supported by this gizmo
  50507. * @param mesh The mesh to replace the default mesh of the gizmo
  50508. */
  50509. setCustomMesh(mesh: Mesh): void;
  50510. }
  50511. }
  50512. declare module BABYLON {
  50513. /**
  50514. * Single axis drag gizmo
  50515. */
  50516. export class AxisDragGizmo extends Gizmo {
  50517. /**
  50518. * Drag behavior responsible for the gizmos dragging interactions
  50519. */
  50520. dragBehavior: PointerDragBehavior;
  50521. private _pointerObserver;
  50522. /**
  50523. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50524. */
  50525. snapDistance: number;
  50526. /**
  50527. * Event that fires each time the gizmo snaps to a new location.
  50528. * * snapDistance is the the change in distance
  50529. */
  50530. onSnapObservable: Observable<{
  50531. snapDistance: number;
  50532. }>;
  50533. private _isEnabled;
  50534. private _parent;
  50535. private _arrow;
  50536. private _coloredMaterial;
  50537. private _hoverMaterial;
  50538. /** @hidden */
  50539. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50540. /** @hidden */
  50541. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50542. /**
  50543. * Creates an AxisDragGizmo
  50544. * @param gizmoLayer The utility layer the gizmo will be added to
  50545. * @param dragAxis The axis which the gizmo will be able to drag on
  50546. * @param color The color of the gizmo
  50547. * @param thickness display gizmo axis thickness
  50548. */
  50549. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50550. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50551. /**
  50552. * If the gizmo is enabled
  50553. */
  50554. set isEnabled(value: boolean);
  50555. get isEnabled(): boolean;
  50556. /**
  50557. * Disposes of the gizmo
  50558. */
  50559. dispose(): void;
  50560. }
  50561. }
  50562. declare module BABYLON.Debug {
  50563. /**
  50564. * The Axes viewer will show 3 axes in a specific point in space
  50565. */
  50566. export class AxesViewer {
  50567. private _xAxis;
  50568. private _yAxis;
  50569. private _zAxis;
  50570. private _scaleLinesFactor;
  50571. private _instanced;
  50572. /**
  50573. * Gets the hosting scene
  50574. */
  50575. scene: Nullable<Scene>;
  50576. /**
  50577. * Gets or sets a number used to scale line length
  50578. */
  50579. scaleLines: number;
  50580. /** Gets the node hierarchy used to render x-axis */
  50581. get xAxis(): TransformNode;
  50582. /** Gets the node hierarchy used to render y-axis */
  50583. get yAxis(): TransformNode;
  50584. /** Gets the node hierarchy used to render z-axis */
  50585. get zAxis(): TransformNode;
  50586. /**
  50587. * Creates a new AxesViewer
  50588. * @param scene defines the hosting scene
  50589. * @param scaleLines defines a number used to scale line length (1 by default)
  50590. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50591. * @param xAxis defines the node hierarchy used to render the x-axis
  50592. * @param yAxis defines the node hierarchy used to render the y-axis
  50593. * @param zAxis defines the node hierarchy used to render the z-axis
  50594. */
  50595. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50596. /**
  50597. * Force the viewer to update
  50598. * @param position defines the position of the viewer
  50599. * @param xaxis defines the x axis of the viewer
  50600. * @param yaxis defines the y axis of the viewer
  50601. * @param zaxis defines the z axis of the viewer
  50602. */
  50603. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50604. /**
  50605. * Creates an instance of this axes viewer.
  50606. * @returns a new axes viewer with instanced meshes
  50607. */
  50608. createInstance(): AxesViewer;
  50609. /** Releases resources */
  50610. dispose(): void;
  50611. private static _SetRenderingGroupId;
  50612. }
  50613. }
  50614. declare module BABYLON.Debug {
  50615. /**
  50616. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50617. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50618. */
  50619. export class BoneAxesViewer extends AxesViewer {
  50620. /**
  50621. * Gets or sets the target mesh where to display the axes viewer
  50622. */
  50623. mesh: Nullable<Mesh>;
  50624. /**
  50625. * Gets or sets the target bone where to display the axes viewer
  50626. */
  50627. bone: Nullable<Bone>;
  50628. /** Gets current position */
  50629. pos: Vector3;
  50630. /** Gets direction of X axis */
  50631. xaxis: Vector3;
  50632. /** Gets direction of Y axis */
  50633. yaxis: Vector3;
  50634. /** Gets direction of Z axis */
  50635. zaxis: Vector3;
  50636. /**
  50637. * Creates a new BoneAxesViewer
  50638. * @param scene defines the hosting scene
  50639. * @param bone defines the target bone
  50640. * @param mesh defines the target mesh
  50641. * @param scaleLines defines a scaling factor for line length (1 by default)
  50642. */
  50643. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50644. /**
  50645. * Force the viewer to update
  50646. */
  50647. update(): void;
  50648. /** Releases resources */
  50649. dispose(): void;
  50650. }
  50651. }
  50652. declare module BABYLON {
  50653. /**
  50654. * Interface used to define scene explorer extensibility option
  50655. */
  50656. export interface IExplorerExtensibilityOption {
  50657. /**
  50658. * Define the option label
  50659. */
  50660. label: string;
  50661. /**
  50662. * Defines the action to execute on click
  50663. */
  50664. action: (entity: any) => void;
  50665. }
  50666. /**
  50667. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50668. */
  50669. export interface IExplorerExtensibilityGroup {
  50670. /**
  50671. * Defines a predicate to test if a given type mut be extended
  50672. */
  50673. predicate: (entity: any) => boolean;
  50674. /**
  50675. * Gets the list of options added to a type
  50676. */
  50677. entries: IExplorerExtensibilityOption[];
  50678. }
  50679. /**
  50680. * Interface used to define the options to use to create the Inspector
  50681. */
  50682. export interface IInspectorOptions {
  50683. /**
  50684. * Display in overlay mode (default: false)
  50685. */
  50686. overlay?: boolean;
  50687. /**
  50688. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50689. */
  50690. globalRoot?: HTMLElement;
  50691. /**
  50692. * Display the Scene explorer
  50693. */
  50694. showExplorer?: boolean;
  50695. /**
  50696. * Display the property inspector
  50697. */
  50698. showInspector?: boolean;
  50699. /**
  50700. * Display in embed mode (both panes on the right)
  50701. */
  50702. embedMode?: boolean;
  50703. /**
  50704. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50705. */
  50706. handleResize?: boolean;
  50707. /**
  50708. * Allow the panes to popup (default: true)
  50709. */
  50710. enablePopup?: boolean;
  50711. /**
  50712. * Allow the panes to be closed by users (default: true)
  50713. */
  50714. enableClose?: boolean;
  50715. /**
  50716. * Optional list of extensibility entries
  50717. */
  50718. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50719. /**
  50720. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50721. */
  50722. inspectorURL?: string;
  50723. /**
  50724. * Optional initial tab (default to DebugLayerTab.Properties)
  50725. */
  50726. initialTab?: DebugLayerTab;
  50727. }
  50728. interface Scene {
  50729. /**
  50730. * @hidden
  50731. * Backing field
  50732. */
  50733. _debugLayer: DebugLayer;
  50734. /**
  50735. * Gets the debug layer (aka Inspector) associated with the scene
  50736. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50737. */
  50738. debugLayer: DebugLayer;
  50739. }
  50740. /**
  50741. * Enum of inspector action tab
  50742. */
  50743. export enum DebugLayerTab {
  50744. /**
  50745. * Properties tag (default)
  50746. */
  50747. Properties = 0,
  50748. /**
  50749. * Debug tab
  50750. */
  50751. Debug = 1,
  50752. /**
  50753. * Statistics tab
  50754. */
  50755. Statistics = 2,
  50756. /**
  50757. * Tools tab
  50758. */
  50759. Tools = 3,
  50760. /**
  50761. * Settings tab
  50762. */
  50763. Settings = 4
  50764. }
  50765. /**
  50766. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50767. * what is happening in your scene
  50768. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50769. */
  50770. export class DebugLayer {
  50771. /**
  50772. * Define the url to get the inspector script from.
  50773. * By default it uses the babylonjs CDN.
  50774. * @ignoreNaming
  50775. */
  50776. static InspectorURL: string;
  50777. private _scene;
  50778. private BJSINSPECTOR;
  50779. private _onPropertyChangedObservable?;
  50780. /**
  50781. * Observable triggered when a property is changed through the inspector.
  50782. */
  50783. get onPropertyChangedObservable(): any;
  50784. /**
  50785. * Instantiates a new debug layer.
  50786. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50787. * what is happening in your scene
  50788. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50789. * @param scene Defines the scene to inspect
  50790. */
  50791. constructor(scene: Scene);
  50792. /** Creates the inspector window. */
  50793. private _createInspector;
  50794. /**
  50795. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50796. * @param entity defines the entity to select
  50797. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50798. */
  50799. select(entity: any, lineContainerTitles?: string | string[]): void;
  50800. /** Get the inspector from bundle or global */
  50801. private _getGlobalInspector;
  50802. /**
  50803. * Get if the inspector is visible or not.
  50804. * @returns true if visible otherwise, false
  50805. */
  50806. isVisible(): boolean;
  50807. /**
  50808. * Hide the inspector and close its window.
  50809. */
  50810. hide(): void;
  50811. /**
  50812. * Update the scene in the inspector
  50813. */
  50814. setAsActiveScene(): void;
  50815. /**
  50816. * Launch the debugLayer.
  50817. * @param config Define the configuration of the inspector
  50818. * @return a promise fulfilled when the debug layer is visible
  50819. */
  50820. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50821. }
  50822. }
  50823. declare module BABYLON {
  50824. /**
  50825. * Class containing static functions to help procedurally build meshes
  50826. */
  50827. export class BoxBuilder {
  50828. /**
  50829. * Creates a box mesh
  50830. * * The parameter `size` sets the size (float) of each box side (default 1)
  50831. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50832. * * 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)
  50833. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50835. * * 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
  50836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50837. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50838. * @param name defines the name of the mesh
  50839. * @param options defines the options used to create the mesh
  50840. * @param scene defines the hosting scene
  50841. * @returns the box mesh
  50842. */
  50843. static CreateBox(name: string, options: {
  50844. size?: number;
  50845. width?: number;
  50846. height?: number;
  50847. depth?: number;
  50848. faceUV?: Vector4[];
  50849. faceColors?: Color4[];
  50850. sideOrientation?: number;
  50851. frontUVs?: Vector4;
  50852. backUVs?: Vector4;
  50853. wrap?: boolean;
  50854. topBaseAt?: number;
  50855. bottomBaseAt?: number;
  50856. updatable?: boolean;
  50857. }, scene?: Nullable<Scene>): Mesh;
  50858. }
  50859. }
  50860. declare module BABYLON.Debug {
  50861. /**
  50862. * Used to show the physics impostor around the specific mesh
  50863. */
  50864. export class PhysicsViewer {
  50865. /** @hidden */
  50866. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50867. /** @hidden */
  50868. protected _meshes: Array<Nullable<AbstractMesh>>;
  50869. /** @hidden */
  50870. protected _scene: Nullable<Scene>;
  50871. /** @hidden */
  50872. protected _numMeshes: number;
  50873. /** @hidden */
  50874. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50875. private _renderFunction;
  50876. private _utilityLayer;
  50877. private _debugBoxMesh;
  50878. private _debugSphereMesh;
  50879. private _debugCylinderMesh;
  50880. private _debugMaterial;
  50881. private _debugMeshMeshes;
  50882. /**
  50883. * Creates a new PhysicsViewer
  50884. * @param scene defines the hosting scene
  50885. */
  50886. constructor(scene: Scene);
  50887. /** @hidden */
  50888. protected _updateDebugMeshes(): void;
  50889. /**
  50890. * Renders a specified physic impostor
  50891. * @param impostor defines the impostor to render
  50892. * @param targetMesh defines the mesh represented by the impostor
  50893. * @returns the new debug mesh used to render the impostor
  50894. */
  50895. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50896. /**
  50897. * Hides a specified physic impostor
  50898. * @param impostor defines the impostor to hide
  50899. */
  50900. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50901. private _getDebugMaterial;
  50902. private _getDebugBoxMesh;
  50903. private _getDebugSphereMesh;
  50904. private _getDebugCylinderMesh;
  50905. private _getDebugMeshMesh;
  50906. private _getDebugMesh;
  50907. /** Releases all resources */
  50908. dispose(): void;
  50909. }
  50910. }
  50911. declare module BABYLON {
  50912. /**
  50913. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50914. * in order to better appreciate the issue one might have.
  50915. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50916. */
  50917. export class RayHelper {
  50918. /**
  50919. * Defines the ray we are currently tryin to visualize.
  50920. */
  50921. ray: Nullable<Ray>;
  50922. private _renderPoints;
  50923. private _renderLine;
  50924. private _renderFunction;
  50925. private _scene;
  50926. private _onAfterRenderObserver;
  50927. private _onAfterStepObserver;
  50928. private _attachedToMesh;
  50929. private _meshSpaceDirection;
  50930. private _meshSpaceOrigin;
  50931. /**
  50932. * Helper function to create a colored helper in a scene in one line.
  50933. * @param ray Defines the ray we are currently tryin to visualize
  50934. * @param scene Defines the scene the ray is used in
  50935. * @param color Defines the color we want to see the ray in
  50936. * @returns The newly created ray helper.
  50937. */
  50938. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50939. /**
  50940. * Instantiate a new ray helper.
  50941. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50942. * in order to better appreciate the issue one might have.
  50943. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50944. * @param ray Defines the ray we are currently tryin to visualize
  50945. */
  50946. constructor(ray: Ray);
  50947. /**
  50948. * Shows the ray we are willing to debug.
  50949. * @param scene Defines the scene the ray needs to be rendered in
  50950. * @param color Defines the color the ray needs to be rendered in
  50951. */
  50952. show(scene: Scene, color?: Color3): void;
  50953. /**
  50954. * Hides the ray we are debugging.
  50955. */
  50956. hide(): void;
  50957. private _render;
  50958. /**
  50959. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50960. * @param mesh Defines the mesh we want the helper attached to
  50961. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50962. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50963. * @param length Defines the length of the ray
  50964. */
  50965. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50966. /**
  50967. * Detach the ray helper from the mesh it has previously been attached to.
  50968. */
  50969. detachFromMesh(): void;
  50970. private _updateToMesh;
  50971. /**
  50972. * Dispose the helper and release its associated resources.
  50973. */
  50974. dispose(): void;
  50975. }
  50976. }
  50977. declare module BABYLON {
  50978. /**
  50979. * Defines the options associated with the creation of a SkeletonViewer.
  50980. */
  50981. export interface ISkeletonViewerOptions {
  50982. /** Should the system pause animations before building the Viewer? */
  50983. pauseAnimations: boolean;
  50984. /** Should the system return the skeleton to rest before building? */
  50985. returnToRest: boolean;
  50986. /** public Display Mode of the Viewer */
  50987. displayMode: number;
  50988. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50989. displayOptions: ISkeletonViewerDisplayOptions;
  50990. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50991. computeBonesUsingShaders: boolean;
  50992. }
  50993. /**
  50994. * Defines how to display the various bone meshes for the viewer.
  50995. */
  50996. export interface ISkeletonViewerDisplayOptions {
  50997. /** How far down to start tapering the bone spurs */
  50998. midStep?: number;
  50999. /** How big is the midStep? */
  51000. midStepFactor?: number;
  51001. /** Base for the Sphere Size */
  51002. sphereBaseSize?: number;
  51003. /** The ratio of the sphere to the longest bone in units */
  51004. sphereScaleUnit?: number;
  51005. /** Ratio for the Sphere Size */
  51006. sphereFactor?: number;
  51007. }
  51008. }
  51009. declare module BABYLON {
  51010. /**
  51011. * Class containing static functions to help procedurally build meshes
  51012. */
  51013. export class RibbonBuilder {
  51014. /**
  51015. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51016. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51017. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51018. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51019. * * 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
  51020. * * 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
  51021. * * 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
  51022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51023. * * 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
  51024. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51025. * * 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
  51026. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51027. * * 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
  51028. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51030. * @param name defines the name of the mesh
  51031. * @param options defines the options used to create the mesh
  51032. * @param scene defines the hosting scene
  51033. * @returns the ribbon mesh
  51034. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51035. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51036. */
  51037. static CreateRibbon(name: string, options: {
  51038. pathArray: Vector3[][];
  51039. closeArray?: boolean;
  51040. closePath?: boolean;
  51041. offset?: number;
  51042. updatable?: boolean;
  51043. sideOrientation?: number;
  51044. frontUVs?: Vector4;
  51045. backUVs?: Vector4;
  51046. instance?: Mesh;
  51047. invertUV?: boolean;
  51048. uvs?: Vector2[];
  51049. colors?: Color4[];
  51050. }, scene?: Nullable<Scene>): Mesh;
  51051. }
  51052. }
  51053. declare module BABYLON {
  51054. /**
  51055. * Class containing static functions to help procedurally build meshes
  51056. */
  51057. export class ShapeBuilder {
  51058. /**
  51059. * 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.
  51060. * * 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.
  51061. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51062. * * 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.
  51063. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51064. * * 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
  51065. * * 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
  51066. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51068. * * 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
  51069. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51071. * @param name defines the name of the mesh
  51072. * @param options defines the options used to create the mesh
  51073. * @param scene defines the hosting scene
  51074. * @returns the extruded shape mesh
  51075. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51076. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51077. */
  51078. static ExtrudeShape(name: string, options: {
  51079. shape: Vector3[];
  51080. path: Vector3[];
  51081. scale?: number;
  51082. rotation?: number;
  51083. cap?: number;
  51084. updatable?: boolean;
  51085. sideOrientation?: number;
  51086. frontUVs?: Vector4;
  51087. backUVs?: Vector4;
  51088. instance?: Mesh;
  51089. invertUV?: boolean;
  51090. }, scene?: Nullable<Scene>): Mesh;
  51091. /**
  51092. * Creates an custom extruded shape mesh.
  51093. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51094. * * 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.
  51095. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51096. * * 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
  51097. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51098. * * 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
  51099. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51100. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51101. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51102. * * 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
  51103. * * 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
  51104. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51106. * * 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
  51107. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51109. * @param name defines the name of the mesh
  51110. * @param options defines the options used to create the mesh
  51111. * @param scene defines the hosting scene
  51112. * @returns the custom extruded shape mesh
  51113. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51114. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51115. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51116. */
  51117. static ExtrudeShapeCustom(name: string, options: {
  51118. shape: Vector3[];
  51119. path: Vector3[];
  51120. scaleFunction?: any;
  51121. rotationFunction?: any;
  51122. ribbonCloseArray?: boolean;
  51123. ribbonClosePath?: boolean;
  51124. cap?: number;
  51125. updatable?: boolean;
  51126. sideOrientation?: number;
  51127. frontUVs?: Vector4;
  51128. backUVs?: Vector4;
  51129. instance?: Mesh;
  51130. invertUV?: boolean;
  51131. }, scene?: Nullable<Scene>): Mesh;
  51132. private static _ExtrudeShapeGeneric;
  51133. }
  51134. }
  51135. declare module BABYLON.Debug {
  51136. /**
  51137. * Class used to render a debug view of a given skeleton
  51138. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51139. */
  51140. export class SkeletonViewer {
  51141. /** defines the skeleton to render */
  51142. skeleton: Skeleton;
  51143. /** defines the mesh attached to the skeleton */
  51144. mesh: AbstractMesh;
  51145. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51146. autoUpdateBonesMatrices: boolean;
  51147. /** defines the rendering group id to use with the viewer */
  51148. renderingGroupId: number;
  51149. /** is the options for the viewer */
  51150. options: Partial<ISkeletonViewerOptions>;
  51151. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51152. static readonly DISPLAY_LINES: number;
  51153. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51154. static readonly DISPLAY_SPHERES: number;
  51155. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51156. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51157. /** If SkeletonViewer scene scope. */
  51158. private _scene;
  51159. /** Gets or sets the color used to render the skeleton */
  51160. color: Color3;
  51161. /** Array of the points of the skeleton fo the line view. */
  51162. private _debugLines;
  51163. /** The SkeletonViewers Mesh. */
  51164. private _debugMesh;
  51165. /** If SkeletonViewer is enabled. */
  51166. private _isEnabled;
  51167. /** If SkeletonViewer is ready. */
  51168. private _ready;
  51169. /** SkeletonViewer render observable. */
  51170. private _obs;
  51171. /** The Utility Layer to render the gizmos in. */
  51172. private _utilityLayer;
  51173. private _boneIndices;
  51174. /** Gets the Scene. */
  51175. get scene(): Scene;
  51176. /** Gets the utilityLayer. */
  51177. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51178. /** Checks Ready Status. */
  51179. get isReady(): Boolean;
  51180. /** Sets Ready Status. */
  51181. set ready(value: boolean);
  51182. /** Gets the debugMesh */
  51183. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51184. /** Sets the debugMesh */
  51185. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51186. /** Gets the material */
  51187. get material(): StandardMaterial;
  51188. /** Sets the material */
  51189. set material(value: StandardMaterial);
  51190. /** Gets the material */
  51191. get displayMode(): number;
  51192. /** Sets the material */
  51193. set displayMode(value: number);
  51194. /**
  51195. * Creates a new SkeletonViewer
  51196. * @param skeleton defines the skeleton to render
  51197. * @param mesh defines the mesh attached to the skeleton
  51198. * @param scene defines the hosting scene
  51199. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51200. * @param renderingGroupId defines the rendering group id to use with the viewer
  51201. * @param options All of the extra constructor options for the SkeletonViewer
  51202. */
  51203. constructor(
  51204. /** defines the skeleton to render */
  51205. skeleton: Skeleton,
  51206. /** defines the mesh attached to the skeleton */
  51207. mesh: AbstractMesh,
  51208. /** The Scene scope*/
  51209. scene: Scene,
  51210. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51211. autoUpdateBonesMatrices?: boolean,
  51212. /** defines the rendering group id to use with the viewer */
  51213. renderingGroupId?: number,
  51214. /** is the options for the viewer */
  51215. options?: Partial<ISkeletonViewerOptions>);
  51216. /** The Dynamic bindings for the update functions */
  51217. private _bindObs;
  51218. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51219. update(): void;
  51220. /** Gets or sets a boolean indicating if the viewer is enabled */
  51221. set isEnabled(value: boolean);
  51222. get isEnabled(): boolean;
  51223. private _getBonePosition;
  51224. private _getLinesForBonesWithLength;
  51225. private _getLinesForBonesNoLength;
  51226. /** function to revert the mesh and scene back to the initial state. */
  51227. private _revert;
  51228. /** function to build and bind sphere joint points and spur bone representations. */
  51229. private _buildSpheresAndSpurs;
  51230. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51231. private _displayLinesUpdate;
  51232. /** Changes the displayMode of the skeleton viewer
  51233. * @param mode The displayMode numerical value
  51234. */
  51235. changeDisplayMode(mode: number): void;
  51236. /** Changes the displayMode of the skeleton viewer
  51237. * @param option String of the option name
  51238. * @param value The numerical option value
  51239. */
  51240. changeDisplayOptions(option: string, value: number): void;
  51241. /** Release associated resources */
  51242. dispose(): void;
  51243. }
  51244. }
  51245. declare module BABYLON {
  51246. /**
  51247. * Enum for Device Types
  51248. */
  51249. export enum DeviceType {
  51250. /** Generic */
  51251. Generic = 0,
  51252. /** Keyboard */
  51253. Keyboard = 1,
  51254. /** Mouse */
  51255. Mouse = 2,
  51256. /** Touch Pointers */
  51257. Touch = 3,
  51258. /** PS4 Dual Shock */
  51259. DualShock = 4,
  51260. /** Xbox */
  51261. Xbox = 5,
  51262. /** Switch Controller */
  51263. Switch = 6
  51264. }
  51265. /**
  51266. * Enum for All Pointers (Touch/Mouse)
  51267. */
  51268. export enum PointerInput {
  51269. /** Horizontal Axis */
  51270. Horizontal = 0,
  51271. /** Vertical Axis */
  51272. Vertical = 1,
  51273. /** Left Click or Touch */
  51274. LeftClick = 2,
  51275. /** Middle Click */
  51276. MiddleClick = 3,
  51277. /** Right Click */
  51278. RightClick = 4,
  51279. /** Browser Back */
  51280. BrowserBack = 5,
  51281. /** Browser Forward */
  51282. BrowserForward = 6
  51283. }
  51284. /**
  51285. * Enum for Dual Shock Gamepad
  51286. */
  51287. export enum DualShockInput {
  51288. /** Cross */
  51289. Cross = 0,
  51290. /** Circle */
  51291. Circle = 1,
  51292. /** Square */
  51293. Square = 2,
  51294. /** Triangle */
  51295. Triangle = 3,
  51296. /** L1 */
  51297. L1 = 4,
  51298. /** R1 */
  51299. R1 = 5,
  51300. /** L2 */
  51301. L2 = 6,
  51302. /** R2 */
  51303. R2 = 7,
  51304. /** Share */
  51305. Share = 8,
  51306. /** Options */
  51307. Options = 9,
  51308. /** L3 */
  51309. L3 = 10,
  51310. /** R3 */
  51311. R3 = 11,
  51312. /** DPadUp */
  51313. DPadUp = 12,
  51314. /** DPadDown */
  51315. DPadDown = 13,
  51316. /** DPadLeft */
  51317. DPadLeft = 14,
  51318. /** DRight */
  51319. DPadRight = 15,
  51320. /** Home */
  51321. Home = 16,
  51322. /** TouchPad */
  51323. TouchPad = 17,
  51324. /** LStickXAxis */
  51325. LStickXAxis = 18,
  51326. /** LStickYAxis */
  51327. LStickYAxis = 19,
  51328. /** RStickXAxis */
  51329. RStickXAxis = 20,
  51330. /** RStickYAxis */
  51331. RStickYAxis = 21
  51332. }
  51333. /**
  51334. * Enum for Xbox Gamepad
  51335. */
  51336. export enum XboxInput {
  51337. /** A */
  51338. A = 0,
  51339. /** B */
  51340. B = 1,
  51341. /** X */
  51342. X = 2,
  51343. /** Y */
  51344. Y = 3,
  51345. /** LB */
  51346. LB = 4,
  51347. /** RB */
  51348. RB = 5,
  51349. /** LT */
  51350. LT = 6,
  51351. /** RT */
  51352. RT = 7,
  51353. /** Back */
  51354. Back = 8,
  51355. /** Start */
  51356. Start = 9,
  51357. /** LS */
  51358. LS = 10,
  51359. /** RS */
  51360. RS = 11,
  51361. /** DPadUp */
  51362. DPadUp = 12,
  51363. /** DPadDown */
  51364. DPadDown = 13,
  51365. /** DPadLeft */
  51366. DPadLeft = 14,
  51367. /** DRight */
  51368. DPadRight = 15,
  51369. /** Home */
  51370. Home = 16,
  51371. /** LStickXAxis */
  51372. LStickXAxis = 17,
  51373. /** LStickYAxis */
  51374. LStickYAxis = 18,
  51375. /** RStickXAxis */
  51376. RStickXAxis = 19,
  51377. /** RStickYAxis */
  51378. RStickYAxis = 20
  51379. }
  51380. /**
  51381. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51382. */
  51383. export enum SwitchInput {
  51384. /** B */
  51385. B = 0,
  51386. /** A */
  51387. A = 1,
  51388. /** Y */
  51389. Y = 2,
  51390. /** X */
  51391. X = 3,
  51392. /** L */
  51393. L = 4,
  51394. /** R */
  51395. R = 5,
  51396. /** ZL */
  51397. ZL = 6,
  51398. /** ZR */
  51399. ZR = 7,
  51400. /** Minus */
  51401. Minus = 8,
  51402. /** Plus */
  51403. Plus = 9,
  51404. /** LS */
  51405. LS = 10,
  51406. /** RS */
  51407. RS = 11,
  51408. /** DPadUp */
  51409. DPadUp = 12,
  51410. /** DPadDown */
  51411. DPadDown = 13,
  51412. /** DPadLeft */
  51413. DPadLeft = 14,
  51414. /** DRight */
  51415. DPadRight = 15,
  51416. /** Home */
  51417. Home = 16,
  51418. /** Capture */
  51419. Capture = 17,
  51420. /** LStickXAxis */
  51421. LStickXAxis = 18,
  51422. /** LStickYAxis */
  51423. LStickYAxis = 19,
  51424. /** RStickXAxis */
  51425. RStickXAxis = 20,
  51426. /** RStickYAxis */
  51427. RStickYAxis = 21
  51428. }
  51429. }
  51430. declare module BABYLON {
  51431. /**
  51432. * This class will take all inputs from Keyboard, Pointer, and
  51433. * any Gamepads and provide a polling system that all devices
  51434. * will use. This class assumes that there will only be one
  51435. * pointer device and one keyboard.
  51436. */
  51437. export class DeviceInputSystem implements IDisposable {
  51438. /**
  51439. * Callback to be triggered when a device is connected
  51440. */
  51441. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51442. /**
  51443. * Callback to be triggered when a device is disconnected
  51444. */
  51445. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51446. /**
  51447. * Callback to be triggered when event driven input is updated
  51448. */
  51449. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51450. private _inputs;
  51451. private _gamepads;
  51452. private _keyboardActive;
  51453. private _pointerActive;
  51454. private _elementToAttachTo;
  51455. private _keyboardDownEvent;
  51456. private _keyboardUpEvent;
  51457. private _pointerMoveEvent;
  51458. private _pointerDownEvent;
  51459. private _pointerUpEvent;
  51460. private _gamepadConnectedEvent;
  51461. private _gamepadDisconnectedEvent;
  51462. private static _MAX_KEYCODES;
  51463. private static _MAX_POINTER_INPUTS;
  51464. private constructor();
  51465. /**
  51466. * Creates a new DeviceInputSystem instance
  51467. * @param engine Engine to pull input element from
  51468. * @returns The new instance
  51469. */
  51470. static Create(engine: Engine): DeviceInputSystem;
  51471. /**
  51472. * Checks for current device input value, given an id and input index
  51473. * @param deviceName Id of connected device
  51474. * @param inputIndex Index of device input
  51475. * @returns Current value of input
  51476. */
  51477. /**
  51478. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51479. * @param deviceType Enum specifiying device type
  51480. * @param deviceSlot "Slot" or index that device is referenced in
  51481. * @param inputIndex Id of input to be checked
  51482. * @returns Current value of input
  51483. */
  51484. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51485. /**
  51486. * Dispose of all the eventlisteners
  51487. */
  51488. dispose(): void;
  51489. /**
  51490. * Add device and inputs to device array
  51491. * @param deviceType Enum specifiying device type
  51492. * @param deviceSlot "Slot" or index that device is referenced in
  51493. * @param numberOfInputs Number of input entries to create for given device
  51494. */
  51495. private _registerDevice;
  51496. /**
  51497. * Given a specific device name, remove that device from the device map
  51498. * @param deviceType Enum specifiying device type
  51499. * @param deviceSlot "Slot" or index that device is referenced in
  51500. */
  51501. private _unregisterDevice;
  51502. /**
  51503. * Handle all actions that come from keyboard interaction
  51504. */
  51505. private _handleKeyActions;
  51506. /**
  51507. * Handle all actions that come from pointer interaction
  51508. */
  51509. private _handlePointerActions;
  51510. /**
  51511. * Handle all actions that come from gamepad interaction
  51512. */
  51513. private _handleGamepadActions;
  51514. /**
  51515. * Update all non-event based devices with each frame
  51516. * @param deviceType Enum specifiying device type
  51517. * @param deviceSlot "Slot" or index that device is referenced in
  51518. * @param inputIndex Id of input to be checked
  51519. */
  51520. private _updateDevice;
  51521. /**
  51522. * Gets DeviceType from the device name
  51523. * @param deviceName Name of Device from DeviceInputSystem
  51524. * @returns DeviceType enum value
  51525. */
  51526. private _getGamepadDeviceType;
  51527. }
  51528. }
  51529. declare module BABYLON {
  51530. /**
  51531. * Type to handle enforcement of inputs
  51532. */
  51533. 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;
  51534. }
  51535. declare module BABYLON {
  51536. /**
  51537. * Class that handles all input for a specific device
  51538. */
  51539. export class DeviceSource<T extends DeviceType> {
  51540. /** Type of device */
  51541. readonly deviceType: DeviceType;
  51542. /** "Slot" or index that device is referenced in */
  51543. readonly deviceSlot: number;
  51544. /**
  51545. * Observable to handle device input changes per device
  51546. */
  51547. readonly onInputChangedObservable: Observable<{
  51548. inputIndex: DeviceInput<T>;
  51549. previousState: Nullable<number>;
  51550. currentState: Nullable<number>;
  51551. }>;
  51552. private readonly _deviceInputSystem;
  51553. /**
  51554. * Default Constructor
  51555. * @param deviceInputSystem Reference to DeviceInputSystem
  51556. * @param deviceType Type of device
  51557. * @param deviceSlot "Slot" or index that device is referenced in
  51558. */
  51559. constructor(deviceInputSystem: DeviceInputSystem,
  51560. /** Type of device */
  51561. deviceType: DeviceType,
  51562. /** "Slot" or index that device is referenced in */
  51563. deviceSlot?: number);
  51564. /**
  51565. * Get input for specific input
  51566. * @param inputIndex index of specific input on device
  51567. * @returns Input value from DeviceInputSystem
  51568. */
  51569. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51570. }
  51571. /**
  51572. * Class to keep track of devices
  51573. */
  51574. export class DeviceSourceManager implements IDisposable {
  51575. /**
  51576. * Observable to be triggered when before a device is connected
  51577. */
  51578. readonly onBeforeDeviceConnectedObservable: Observable<{
  51579. deviceType: DeviceType;
  51580. deviceSlot: number;
  51581. }>;
  51582. /**
  51583. * Observable to be triggered when before a device is disconnected
  51584. */
  51585. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51586. deviceType: DeviceType;
  51587. deviceSlot: number;
  51588. }>;
  51589. /**
  51590. * Observable to be triggered when after a device is connected
  51591. */
  51592. readonly onAfterDeviceConnectedObservable: Observable<{
  51593. deviceType: DeviceType;
  51594. deviceSlot: number;
  51595. }>;
  51596. /**
  51597. * Observable to be triggered when after a device is disconnected
  51598. */
  51599. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51600. deviceType: DeviceType;
  51601. deviceSlot: number;
  51602. }>;
  51603. private readonly _devices;
  51604. private readonly _firstDevice;
  51605. private readonly _deviceInputSystem;
  51606. /**
  51607. * Default Constructor
  51608. * @param engine engine to pull input element from
  51609. */
  51610. constructor(engine: Engine);
  51611. /**
  51612. * Gets a DeviceSource, given a type and slot
  51613. * @param deviceType Enum specifying device type
  51614. * @param deviceSlot "Slot" or index that device is referenced in
  51615. * @returns DeviceSource object
  51616. */
  51617. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51618. /**
  51619. * Gets an array of DeviceSource objects for a given device type
  51620. * @param deviceType Enum specifying device type
  51621. * @returns Array of DeviceSource objects
  51622. */
  51623. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51624. /**
  51625. * Dispose of DeviceInputSystem and other parts
  51626. */
  51627. dispose(): void;
  51628. /**
  51629. * Function to add device name to device list
  51630. * @param deviceType Enum specifying device type
  51631. * @param deviceSlot "Slot" or index that device is referenced in
  51632. */
  51633. private _addDevice;
  51634. /**
  51635. * Function to remove device name to device list
  51636. * @param deviceType Enum specifying device type
  51637. * @param deviceSlot "Slot" or index that device is referenced in
  51638. */
  51639. private _removeDevice;
  51640. /**
  51641. * Updates array storing first connected device of each type
  51642. * @param type Type of Device
  51643. */
  51644. private _updateFirstDevices;
  51645. }
  51646. }
  51647. declare module BABYLON {
  51648. /**
  51649. * Options to create the null engine
  51650. */
  51651. export class NullEngineOptions {
  51652. /**
  51653. * Render width (Default: 512)
  51654. */
  51655. renderWidth: number;
  51656. /**
  51657. * Render height (Default: 256)
  51658. */
  51659. renderHeight: number;
  51660. /**
  51661. * Texture size (Default: 512)
  51662. */
  51663. textureSize: number;
  51664. /**
  51665. * If delta time between frames should be constant
  51666. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51667. */
  51668. deterministicLockstep: boolean;
  51669. /**
  51670. * Maximum about of steps between frames (Default: 4)
  51671. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51672. */
  51673. lockstepMaxSteps: number;
  51674. /**
  51675. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51676. */
  51677. useHighPrecisionMatrix?: boolean;
  51678. }
  51679. /**
  51680. * The null engine class provides support for headless version of babylon.js.
  51681. * This can be used in server side scenario or for testing purposes
  51682. */
  51683. export class NullEngine extends Engine {
  51684. private _options;
  51685. /**
  51686. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51687. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51688. * @returns true if engine is in deterministic lock step mode
  51689. */
  51690. isDeterministicLockStep(): boolean;
  51691. /**
  51692. * Gets the max steps when engine is running in deterministic lock step
  51693. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51694. * @returns the max steps
  51695. */
  51696. getLockstepMaxSteps(): number;
  51697. /**
  51698. * Gets the current hardware scaling level.
  51699. * By default the hardware scaling level is computed from the window device ratio.
  51700. * 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.
  51701. * @returns a number indicating the current hardware scaling level
  51702. */
  51703. getHardwareScalingLevel(): number;
  51704. constructor(options?: NullEngineOptions);
  51705. /**
  51706. * Creates a vertex buffer
  51707. * @param vertices the data for the vertex buffer
  51708. * @returns the new WebGL static buffer
  51709. */
  51710. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51711. /**
  51712. * Creates a new index buffer
  51713. * @param indices defines the content of the index buffer
  51714. * @param updatable defines if the index buffer must be updatable
  51715. * @returns a new webGL buffer
  51716. */
  51717. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51718. /**
  51719. * Clear the current render buffer or the current render target (if any is set up)
  51720. * @param color defines the color to use
  51721. * @param backBuffer defines if the back buffer must be cleared
  51722. * @param depth defines if the depth buffer must be cleared
  51723. * @param stencil defines if the stencil buffer must be cleared
  51724. */
  51725. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51726. /**
  51727. * Gets the current render width
  51728. * @param useScreen defines if screen size must be used (or the current render target if any)
  51729. * @returns a number defining the current render width
  51730. */
  51731. getRenderWidth(useScreen?: boolean): number;
  51732. /**
  51733. * Gets the current render height
  51734. * @param useScreen defines if screen size must be used (or the current render target if any)
  51735. * @returns a number defining the current render height
  51736. */
  51737. getRenderHeight(useScreen?: boolean): number;
  51738. /**
  51739. * Set the WebGL's viewport
  51740. * @param viewport defines the viewport element to be used
  51741. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51742. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51743. */
  51744. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51745. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51746. /**
  51747. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51748. * @param pipelineContext defines the pipeline context to use
  51749. * @param uniformsNames defines the list of uniform names
  51750. * @returns an array of webGL uniform locations
  51751. */
  51752. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51753. /**
  51754. * Gets the lsit of active attributes for a given webGL program
  51755. * @param pipelineContext defines the pipeline context to use
  51756. * @param attributesNames defines the list of attribute names to get
  51757. * @returns an array of indices indicating the offset of each attribute
  51758. */
  51759. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51760. /**
  51761. * Binds an effect to the webGL context
  51762. * @param effect defines the effect to bind
  51763. */
  51764. bindSamplers(effect: Effect): void;
  51765. /**
  51766. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51767. * @param effect defines the effect to activate
  51768. */
  51769. enableEffect(effect: Effect): void;
  51770. /**
  51771. * Set various states to the webGL context
  51772. * @param culling defines backface culling state
  51773. * @param zOffset defines the value to apply to zOffset (0 by default)
  51774. * @param force defines if states must be applied even if cache is up to date
  51775. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51776. */
  51777. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51778. /**
  51779. * Set the value of an uniform to an array of int32
  51780. * @param uniform defines the webGL uniform location where to store the value
  51781. * @param array defines the array of int32 to store
  51782. */
  51783. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51784. /**
  51785. * Set the value of an uniform to an array of int32 (stored as vec2)
  51786. * @param uniform defines the webGL uniform location where to store the value
  51787. * @param array defines the array of int32 to store
  51788. */
  51789. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51790. /**
  51791. * Set the value of an uniform to an array of int32 (stored as vec3)
  51792. * @param uniform defines the webGL uniform location where to store the value
  51793. * @param array defines the array of int32 to store
  51794. */
  51795. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51796. /**
  51797. * Set the value of an uniform to an array of int32 (stored as vec4)
  51798. * @param uniform defines the webGL uniform location where to store the value
  51799. * @param array defines the array of int32 to store
  51800. */
  51801. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51802. /**
  51803. * Set the value of an uniform to an array of float32
  51804. * @param uniform defines the webGL uniform location where to store the value
  51805. * @param array defines the array of float32 to store
  51806. */
  51807. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51808. /**
  51809. * Set the value of an uniform to an array of float32 (stored as vec2)
  51810. * @param uniform defines the webGL uniform location where to store the value
  51811. * @param array defines the array of float32 to store
  51812. */
  51813. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51814. /**
  51815. * Set the value of an uniform to an array of float32 (stored as vec3)
  51816. * @param uniform defines the webGL uniform location where to store the value
  51817. * @param array defines the array of float32 to store
  51818. */
  51819. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51820. /**
  51821. * Set the value of an uniform to an array of float32 (stored as vec4)
  51822. * @param uniform defines the webGL uniform location where to store the value
  51823. * @param array defines the array of float32 to store
  51824. */
  51825. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51826. /**
  51827. * Set the value of an uniform to an array of number
  51828. * @param uniform defines the webGL uniform location where to store the value
  51829. * @param array defines the array of number to store
  51830. */
  51831. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51832. /**
  51833. * Set the value of an uniform to an array of number (stored as vec2)
  51834. * @param uniform defines the webGL uniform location where to store the value
  51835. * @param array defines the array of number to store
  51836. */
  51837. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51838. /**
  51839. * Set the value of an uniform to an array of number (stored as vec3)
  51840. * @param uniform defines the webGL uniform location where to store the value
  51841. * @param array defines the array of number to store
  51842. */
  51843. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51844. /**
  51845. * Set the value of an uniform to an array of number (stored as vec4)
  51846. * @param uniform defines the webGL uniform location where to store the value
  51847. * @param array defines the array of number to store
  51848. */
  51849. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51850. /**
  51851. * Set the value of an uniform to an array of float32 (stored as matrices)
  51852. * @param uniform defines the webGL uniform location where to store the value
  51853. * @param matrices defines the array of float32 to store
  51854. */
  51855. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51856. /**
  51857. * Set the value of an uniform to a matrix (3x3)
  51858. * @param uniform defines the webGL uniform location where to store the value
  51859. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51860. */
  51861. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51862. /**
  51863. * Set the value of an uniform to a matrix (2x2)
  51864. * @param uniform defines the webGL uniform location where to store the value
  51865. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51866. */
  51867. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51868. /**
  51869. * Set the value of an uniform to a number (float)
  51870. * @param uniform defines the webGL uniform location where to store the value
  51871. * @param value defines the float number to store
  51872. */
  51873. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51874. /**
  51875. * Set the value of an uniform to a vec2
  51876. * @param uniform defines the webGL uniform location where to store the value
  51877. * @param x defines the 1st component of the value
  51878. * @param y defines the 2nd component of the value
  51879. */
  51880. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51881. /**
  51882. * Set the value of an uniform to a vec3
  51883. * @param uniform defines the webGL uniform location where to store the value
  51884. * @param x defines the 1st component of the value
  51885. * @param y defines the 2nd component of the value
  51886. * @param z defines the 3rd component of the value
  51887. */
  51888. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51889. /**
  51890. * Set the value of an uniform to a boolean
  51891. * @param uniform defines the webGL uniform location where to store the value
  51892. * @param bool defines the boolean to store
  51893. */
  51894. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51895. /**
  51896. * Set the value of an uniform to a vec4
  51897. * @param uniform defines the webGL uniform location where to store the value
  51898. * @param x defines the 1st component of the value
  51899. * @param y defines the 2nd component of the value
  51900. * @param z defines the 3rd component of the value
  51901. * @param w defines the 4th component of the value
  51902. */
  51903. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51904. /**
  51905. * Sets the current alpha mode
  51906. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51907. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51908. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51909. */
  51910. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51911. /**
  51912. * Bind webGl buffers directly to the webGL context
  51913. * @param vertexBuffers defines the vertex buffer to bind
  51914. * @param indexBuffer defines the index buffer to bind
  51915. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  51916. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  51917. * @param effect defines the effect associated with the vertex buffer
  51918. */
  51919. bindBuffers(vertexBuffers: {
  51920. [key: string]: VertexBuffer;
  51921. }, indexBuffer: DataBuffer, effect: Effect): void;
  51922. /**
  51923. * Force the entire cache to be cleared
  51924. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  51925. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  51926. */
  51927. wipeCaches(bruteForce?: boolean): void;
  51928. /**
  51929. * Send a draw order
  51930. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  51931. * @param indexStart defines the starting index
  51932. * @param indexCount defines the number of index to draw
  51933. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51934. */
  51935. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  51936. /**
  51937. * Draw a list of indexed primitives
  51938. * @param fillMode defines the primitive to use
  51939. * @param indexStart defines the starting index
  51940. * @param indexCount defines the number of index to draw
  51941. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51942. */
  51943. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51944. /**
  51945. * Draw a list of unindexed primitives
  51946. * @param fillMode defines the primitive to use
  51947. * @param verticesStart defines the index of first vertex to draw
  51948. * @param verticesCount defines the count of vertices to draw
  51949. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51950. */
  51951. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51952. /** @hidden */
  51953. _createTexture(): WebGLTexture;
  51954. /** @hidden */
  51955. _releaseTexture(texture: InternalTexture): void;
  51956. /**
  51957. * Usually called from Texture.ts.
  51958. * Passed information to create a WebGLTexture
  51959. * @param urlArg defines a value which contains one of the following:
  51960. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51961. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51962. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51963. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51964. * @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)
  51965. * @param scene needed for loading to the correct scene
  51966. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51967. * @param onLoad optional callback to be called upon successful completion
  51968. * @param onError optional callback to be called upon failure
  51969. * @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
  51970. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51971. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51972. * @param forcedExtension defines the extension to use to pick the right loader
  51973. * @param mimeType defines an optional mime type
  51974. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51975. */
  51976. 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;
  51977. /**
  51978. * Creates a new render target texture
  51979. * @param size defines the size of the texture
  51980. * @param options defines the options used to create the texture
  51981. * @returns a new render target texture stored in an InternalTexture
  51982. */
  51983. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  51984. /**
  51985. * Update the sampling mode of a given texture
  51986. * @param samplingMode defines the required sampling mode
  51987. * @param texture defines the texture to update
  51988. */
  51989. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51990. /**
  51991. * Binds the frame buffer to the specified texture.
  51992. * @param texture The texture to render to or null for the default canvas
  51993. * @param faceIndex The face of the texture to render to in case of cube texture
  51994. * @param requiredWidth The width of the target to render to
  51995. * @param requiredHeight The height of the target to render to
  51996. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  51997. * @param lodLevel defines le lod level to bind to the frame buffer
  51998. */
  51999. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52000. /**
  52001. * Unbind the current render target texture from the webGL context
  52002. * @param texture defines the render target texture to unbind
  52003. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52004. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52005. */
  52006. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52007. /**
  52008. * Creates a dynamic vertex buffer
  52009. * @param vertices the data for the dynamic vertex buffer
  52010. * @returns the new WebGL dynamic buffer
  52011. */
  52012. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52013. /**
  52014. * Update the content of a dynamic texture
  52015. * @param texture defines the texture to update
  52016. * @param canvas defines the canvas containing the source
  52017. * @param invertY defines if data must be stored with Y axis inverted
  52018. * @param premulAlpha defines if alpha is stored as premultiplied
  52019. * @param format defines the format of the data
  52020. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52021. */
  52022. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52023. /**
  52024. * Gets a boolean indicating if all created effects are ready
  52025. * @returns true if all effects are ready
  52026. */
  52027. areAllEffectsReady(): boolean;
  52028. /**
  52029. * @hidden
  52030. * Get the current error code of the webGL context
  52031. * @returns the error code
  52032. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52033. */
  52034. getError(): number;
  52035. /** @hidden */
  52036. _getUnpackAlignement(): number;
  52037. /** @hidden */
  52038. _unpackFlipY(value: boolean): void;
  52039. /**
  52040. * Update a dynamic index buffer
  52041. * @param indexBuffer defines the target index buffer
  52042. * @param indices defines the data to update
  52043. * @param offset defines the offset in the target index buffer where update should start
  52044. */
  52045. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52046. /**
  52047. * Updates a dynamic vertex buffer.
  52048. * @param vertexBuffer the vertex buffer to update
  52049. * @param vertices the data used to update the vertex buffer
  52050. * @param byteOffset the byte offset of the data (optional)
  52051. * @param byteLength the byte length of the data (optional)
  52052. */
  52053. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52054. /** @hidden */
  52055. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52056. /** @hidden */
  52057. _bindTexture(channel: number, texture: InternalTexture): void;
  52058. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52059. /**
  52060. * 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
  52061. */
  52062. releaseEffects(): void;
  52063. displayLoadingUI(): void;
  52064. hideLoadingUI(): void;
  52065. /** @hidden */
  52066. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52067. /** @hidden */
  52068. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52069. /** @hidden */
  52070. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52071. /** @hidden */
  52072. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52073. }
  52074. }
  52075. declare module BABYLON {
  52076. /**
  52077. * @hidden
  52078. **/
  52079. export class _TimeToken {
  52080. _startTimeQuery: Nullable<WebGLQuery>;
  52081. _endTimeQuery: Nullable<WebGLQuery>;
  52082. _timeElapsedQuery: Nullable<WebGLQuery>;
  52083. _timeElapsedQueryEnded: boolean;
  52084. }
  52085. }
  52086. declare module BABYLON {
  52087. /** @hidden */
  52088. export class _OcclusionDataStorage {
  52089. /** @hidden */
  52090. occlusionInternalRetryCounter: number;
  52091. /** @hidden */
  52092. isOcclusionQueryInProgress: boolean;
  52093. /** @hidden */
  52094. isOccluded: boolean;
  52095. /** @hidden */
  52096. occlusionRetryCount: number;
  52097. /** @hidden */
  52098. occlusionType: number;
  52099. /** @hidden */
  52100. occlusionQueryAlgorithmType: number;
  52101. }
  52102. interface Engine {
  52103. /**
  52104. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52105. * @return the new query
  52106. */
  52107. createQuery(): WebGLQuery;
  52108. /**
  52109. * Delete and release a webGL query
  52110. * @param query defines the query to delete
  52111. * @return the current engine
  52112. */
  52113. deleteQuery(query: WebGLQuery): Engine;
  52114. /**
  52115. * Check if a given query has resolved and got its value
  52116. * @param query defines the query to check
  52117. * @returns true if the query got its value
  52118. */
  52119. isQueryResultAvailable(query: WebGLQuery): boolean;
  52120. /**
  52121. * Gets the value of a given query
  52122. * @param query defines the query to check
  52123. * @returns the value of the query
  52124. */
  52125. getQueryResult(query: WebGLQuery): number;
  52126. /**
  52127. * Initiates an occlusion query
  52128. * @param algorithmType defines the algorithm to use
  52129. * @param query defines the query to use
  52130. * @returns the current engine
  52131. * @see https://doc.babylonjs.com/features/occlusionquery
  52132. */
  52133. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52134. /**
  52135. * Ends an occlusion query
  52136. * @see https://doc.babylonjs.com/features/occlusionquery
  52137. * @param algorithmType defines the algorithm to use
  52138. * @returns the current engine
  52139. */
  52140. endOcclusionQuery(algorithmType: number): Engine;
  52141. /**
  52142. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52143. * Please note that only one query can be issued at a time
  52144. * @returns a time token used to track the time span
  52145. */
  52146. startTimeQuery(): Nullable<_TimeToken>;
  52147. /**
  52148. * Ends a time query
  52149. * @param token defines the token used to measure the time span
  52150. * @returns the time spent (in ns)
  52151. */
  52152. endTimeQuery(token: _TimeToken): int;
  52153. /** @hidden */
  52154. _currentNonTimestampToken: Nullable<_TimeToken>;
  52155. /** @hidden */
  52156. _createTimeQuery(): WebGLQuery;
  52157. /** @hidden */
  52158. _deleteTimeQuery(query: WebGLQuery): void;
  52159. /** @hidden */
  52160. _getGlAlgorithmType(algorithmType: number): number;
  52161. /** @hidden */
  52162. _getTimeQueryResult(query: WebGLQuery): any;
  52163. /** @hidden */
  52164. _getTimeQueryAvailability(query: WebGLQuery): any;
  52165. }
  52166. interface AbstractMesh {
  52167. /**
  52168. * Backing filed
  52169. * @hidden
  52170. */
  52171. __occlusionDataStorage: _OcclusionDataStorage;
  52172. /**
  52173. * Access property
  52174. * @hidden
  52175. */
  52176. _occlusionDataStorage: _OcclusionDataStorage;
  52177. /**
  52178. * 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.
  52179. * The default value is -1 which means don't break the query and wait till the result
  52180. * @see https://doc.babylonjs.com/features/occlusionquery
  52181. */
  52182. occlusionRetryCount: number;
  52183. /**
  52184. * 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:
  52185. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52186. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52187. * * 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.
  52188. * @see https://doc.babylonjs.com/features/occlusionquery
  52189. */
  52190. occlusionType: number;
  52191. /**
  52192. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52193. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52194. * * 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.
  52195. * @see https://doc.babylonjs.com/features/occlusionquery
  52196. */
  52197. occlusionQueryAlgorithmType: number;
  52198. /**
  52199. * 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
  52200. * @see https://doc.babylonjs.com/features/occlusionquery
  52201. */
  52202. isOccluded: boolean;
  52203. /**
  52204. * Flag to check the progress status of the query
  52205. * @see https://doc.babylonjs.com/features/occlusionquery
  52206. */
  52207. isOcclusionQueryInProgress: boolean;
  52208. }
  52209. }
  52210. declare module BABYLON {
  52211. /** @hidden */
  52212. export var _forceTransformFeedbackToBundle: boolean;
  52213. interface Engine {
  52214. /**
  52215. * Creates a webGL transform feedback object
  52216. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52217. * @returns the webGL transform feedback object
  52218. */
  52219. createTransformFeedback(): WebGLTransformFeedback;
  52220. /**
  52221. * Delete a webGL transform feedback object
  52222. * @param value defines the webGL transform feedback object to delete
  52223. */
  52224. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52225. /**
  52226. * Bind a webGL transform feedback object to the webgl context
  52227. * @param value defines the webGL transform feedback object to bind
  52228. */
  52229. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52230. /**
  52231. * Begins a transform feedback operation
  52232. * @param usePoints defines if points or triangles must be used
  52233. */
  52234. beginTransformFeedback(usePoints: boolean): void;
  52235. /**
  52236. * Ends a transform feedback operation
  52237. */
  52238. endTransformFeedback(): void;
  52239. /**
  52240. * Specify the varyings to use with transform feedback
  52241. * @param program defines the associated webGL program
  52242. * @param value defines the list of strings representing the varying names
  52243. */
  52244. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52245. /**
  52246. * Bind a webGL buffer for a transform feedback operation
  52247. * @param value defines the webGL buffer to bind
  52248. */
  52249. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52250. }
  52251. }
  52252. declare module BABYLON {
  52253. /**
  52254. * Class used to define an additional view for the engine
  52255. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52256. */
  52257. export class EngineView {
  52258. /** Defines the canvas where to render the view */
  52259. target: HTMLCanvasElement;
  52260. /** Defines an optional camera used to render the view (will use active camera else) */
  52261. camera?: Camera;
  52262. }
  52263. interface Engine {
  52264. /**
  52265. * Gets or sets the HTML element to use for attaching events
  52266. */
  52267. inputElement: Nullable<HTMLElement>;
  52268. /**
  52269. * Gets the current engine view
  52270. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52271. */
  52272. activeView: Nullable<EngineView>;
  52273. /** Gets or sets the list of views */
  52274. views: EngineView[];
  52275. /**
  52276. * Register a new child canvas
  52277. * @param canvas defines the canvas to register
  52278. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52279. * @returns the associated view
  52280. */
  52281. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52282. /**
  52283. * Remove a registered child canvas
  52284. * @param canvas defines the canvas to remove
  52285. * @returns the current engine
  52286. */
  52287. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52288. }
  52289. }
  52290. declare module BABYLON {
  52291. interface Engine {
  52292. /** @hidden */
  52293. _excludedCompressedTextures: string[];
  52294. /** @hidden */
  52295. _textureFormatInUse: string;
  52296. /**
  52297. * Gets the list of texture formats supported
  52298. */
  52299. readonly texturesSupported: Array<string>;
  52300. /**
  52301. * Gets the texture format in use
  52302. */
  52303. readonly textureFormatInUse: Nullable<string>;
  52304. /**
  52305. * Set the compressed texture extensions or file names to skip.
  52306. *
  52307. * @param skippedFiles defines the list of those texture files you want to skip
  52308. * Example: [".dds", ".env", "myfile.png"]
  52309. */
  52310. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52311. /**
  52312. * Set the compressed texture format to use, based on the formats you have, and the formats
  52313. * supported by the hardware / browser.
  52314. *
  52315. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52316. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52317. * to API arguments needed to compressed textures. This puts the burden on the container
  52318. * generator to house the arcane code for determining these for current & future formats.
  52319. *
  52320. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52321. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52322. *
  52323. * Note: The result of this call is not taken into account when a texture is base64.
  52324. *
  52325. * @param formatsAvailable defines the list of those format families you have created
  52326. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52327. *
  52328. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52329. * @returns The extension selected.
  52330. */
  52331. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52332. }
  52333. }
  52334. declare module BABYLON {
  52335. /**
  52336. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52337. */
  52338. export interface CubeMapInfo {
  52339. /**
  52340. * The pixel array for the front face.
  52341. * This is stored in format, left to right, up to down format.
  52342. */
  52343. front: Nullable<ArrayBufferView>;
  52344. /**
  52345. * The pixel array for the back face.
  52346. * This is stored in format, left to right, up to down format.
  52347. */
  52348. back: Nullable<ArrayBufferView>;
  52349. /**
  52350. * The pixel array for the left face.
  52351. * This is stored in format, left to right, up to down format.
  52352. */
  52353. left: Nullable<ArrayBufferView>;
  52354. /**
  52355. * The pixel array for the right face.
  52356. * This is stored in format, left to right, up to down format.
  52357. */
  52358. right: Nullable<ArrayBufferView>;
  52359. /**
  52360. * The pixel array for the up face.
  52361. * This is stored in format, left to right, up to down format.
  52362. */
  52363. up: Nullable<ArrayBufferView>;
  52364. /**
  52365. * The pixel array for the down face.
  52366. * This is stored in format, left to right, up to down format.
  52367. */
  52368. down: Nullable<ArrayBufferView>;
  52369. /**
  52370. * The size of the cubemap stored.
  52371. *
  52372. * Each faces will be size * size pixels.
  52373. */
  52374. size: number;
  52375. /**
  52376. * The format of the texture.
  52377. *
  52378. * RGBA, RGB.
  52379. */
  52380. format: number;
  52381. /**
  52382. * The type of the texture data.
  52383. *
  52384. * UNSIGNED_INT, FLOAT.
  52385. */
  52386. type: number;
  52387. /**
  52388. * Specifies whether the texture is in gamma space.
  52389. */
  52390. gammaSpace: boolean;
  52391. }
  52392. /**
  52393. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52394. */
  52395. export class PanoramaToCubeMapTools {
  52396. private static FACE_LEFT;
  52397. private static FACE_RIGHT;
  52398. private static FACE_FRONT;
  52399. private static FACE_BACK;
  52400. private static FACE_DOWN;
  52401. private static FACE_UP;
  52402. /**
  52403. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52404. *
  52405. * @param float32Array The source data.
  52406. * @param inputWidth The width of the input panorama.
  52407. * @param inputHeight The height of the input panorama.
  52408. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52409. * @return The cubemap data
  52410. */
  52411. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52412. private static CreateCubemapTexture;
  52413. private static CalcProjectionSpherical;
  52414. }
  52415. }
  52416. declare module BABYLON {
  52417. /**
  52418. * Helper class dealing with the extraction of spherical polynomial dataArray
  52419. * from a cube map.
  52420. */
  52421. export class CubeMapToSphericalPolynomialTools {
  52422. private static FileFaces;
  52423. /**
  52424. * Converts a texture to the according Spherical Polynomial data.
  52425. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52426. *
  52427. * @param texture The texture to extract the information from.
  52428. * @return The Spherical Polynomial data.
  52429. */
  52430. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52431. /**
  52432. * Converts a cubemap to the according Spherical Polynomial data.
  52433. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52434. *
  52435. * @param cubeInfo The Cube map to extract the information from.
  52436. * @return The Spherical Polynomial data.
  52437. */
  52438. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52439. }
  52440. }
  52441. declare module BABYLON {
  52442. interface BaseTexture {
  52443. /**
  52444. * Get the polynomial representation of the texture data.
  52445. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52446. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52447. */
  52448. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52449. }
  52450. }
  52451. declare module BABYLON {
  52452. /** @hidden */
  52453. export var rgbdEncodePixelShader: {
  52454. name: string;
  52455. shader: string;
  52456. };
  52457. }
  52458. declare module BABYLON {
  52459. /** @hidden */
  52460. export var rgbdDecodePixelShader: {
  52461. name: string;
  52462. shader: string;
  52463. };
  52464. }
  52465. declare module BABYLON {
  52466. /**
  52467. * Raw texture data and descriptor sufficient for WebGL texture upload
  52468. */
  52469. export interface EnvironmentTextureInfo {
  52470. /**
  52471. * Version of the environment map
  52472. */
  52473. version: number;
  52474. /**
  52475. * Width of image
  52476. */
  52477. width: number;
  52478. /**
  52479. * Irradiance information stored in the file.
  52480. */
  52481. irradiance: any;
  52482. /**
  52483. * Specular information stored in the file.
  52484. */
  52485. specular: any;
  52486. }
  52487. /**
  52488. * Defines One Image in the file. It requires only the position in the file
  52489. * as well as the length.
  52490. */
  52491. interface BufferImageData {
  52492. /**
  52493. * Length of the image data.
  52494. */
  52495. length: number;
  52496. /**
  52497. * Position of the data from the null terminator delimiting the end of the JSON.
  52498. */
  52499. position: number;
  52500. }
  52501. /**
  52502. * Defines the specular data enclosed in the file.
  52503. * This corresponds to the version 1 of the data.
  52504. */
  52505. export interface EnvironmentTextureSpecularInfoV1 {
  52506. /**
  52507. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52508. */
  52509. specularDataPosition?: number;
  52510. /**
  52511. * This contains all the images data needed to reconstruct the cubemap.
  52512. */
  52513. mipmaps: Array<BufferImageData>;
  52514. /**
  52515. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52516. */
  52517. lodGenerationScale: number;
  52518. }
  52519. /**
  52520. * Sets of helpers addressing the serialization and deserialization of environment texture
  52521. * stored in a BabylonJS env file.
  52522. * Those files are usually stored as .env files.
  52523. */
  52524. export class EnvironmentTextureTools {
  52525. /**
  52526. * Magic number identifying the env file.
  52527. */
  52528. private static _MagicBytes;
  52529. /**
  52530. * Gets the environment info from an env file.
  52531. * @param data The array buffer containing the .env bytes.
  52532. * @returns the environment file info (the json header) if successfully parsed.
  52533. */
  52534. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52535. /**
  52536. * Creates an environment texture from a loaded cube texture.
  52537. * @param texture defines the cube texture to convert in env file
  52538. * @return a promise containing the environment data if succesfull.
  52539. */
  52540. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52541. /**
  52542. * Creates a JSON representation of the spherical data.
  52543. * @param texture defines the texture containing the polynomials
  52544. * @return the JSON representation of the spherical info
  52545. */
  52546. private static _CreateEnvTextureIrradiance;
  52547. /**
  52548. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52549. * @param data the image data
  52550. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52551. * @return the views described by info providing access to the underlying buffer
  52552. */
  52553. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52554. /**
  52555. * Uploads the texture info contained in the env file to the GPU.
  52556. * @param texture defines the internal texture to upload to
  52557. * @param data defines the data to load
  52558. * @param info defines the texture info retrieved through the GetEnvInfo method
  52559. * @returns a promise
  52560. */
  52561. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52562. private static _OnImageReadyAsync;
  52563. /**
  52564. * Uploads the levels of image data to the GPU.
  52565. * @param texture defines the internal texture to upload to
  52566. * @param imageData defines the array buffer views of image data [mipmap][face]
  52567. * @returns a promise
  52568. */
  52569. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52570. /**
  52571. * Uploads spherical polynomials information to the texture.
  52572. * @param texture defines the texture we are trying to upload the information to
  52573. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52574. */
  52575. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52576. /** @hidden */
  52577. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52578. }
  52579. }
  52580. declare module BABYLON {
  52581. /**
  52582. * Class used to inline functions in shader code
  52583. */
  52584. export class ShaderCodeInliner {
  52585. private static readonly _RegexpFindFunctionNameAndType;
  52586. private _sourceCode;
  52587. private _functionDescr;
  52588. private _numMaxIterations;
  52589. /** Gets or sets the token used to mark the functions to inline */
  52590. inlineToken: string;
  52591. /** Gets or sets the debug mode */
  52592. debug: boolean;
  52593. /** Gets the code after the inlining process */
  52594. get code(): string;
  52595. /**
  52596. * Initializes the inliner
  52597. * @param sourceCode shader code source to inline
  52598. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52599. */
  52600. constructor(sourceCode: string, numMaxIterations?: number);
  52601. /**
  52602. * Start the processing of the shader code
  52603. */
  52604. processCode(): void;
  52605. private _collectFunctions;
  52606. private _processInlining;
  52607. private _extractBetweenMarkers;
  52608. private _skipWhitespaces;
  52609. private _removeComments;
  52610. private _replaceFunctionCallsByCode;
  52611. private _findBackward;
  52612. private _escapeRegExp;
  52613. private _replaceNames;
  52614. }
  52615. }
  52616. declare module BABYLON {
  52617. /**
  52618. * Container for accessors for natively-stored mesh data buffers.
  52619. */
  52620. class NativeDataBuffer extends DataBuffer {
  52621. /**
  52622. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52623. */
  52624. nativeIndexBuffer?: any;
  52625. /**
  52626. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52627. */
  52628. nativeVertexBuffer?: any;
  52629. }
  52630. /** @hidden */
  52631. class NativeTexture extends InternalTexture {
  52632. getInternalTexture(): InternalTexture;
  52633. getViewCount(): number;
  52634. }
  52635. /** @hidden */
  52636. export class NativeEngine extends Engine {
  52637. private readonly _native;
  52638. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52639. private readonly INVALID_HANDLE;
  52640. private _boundBuffersVertexArray;
  52641. getHardwareScalingLevel(): number;
  52642. constructor();
  52643. dispose(): void;
  52644. /**
  52645. * Can be used to override the current requestAnimationFrame requester.
  52646. * @hidden
  52647. */
  52648. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52649. /**
  52650. * Override default engine behavior.
  52651. * @param color
  52652. * @param backBuffer
  52653. * @param depth
  52654. * @param stencil
  52655. */
  52656. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52657. /**
  52658. * Gets host document
  52659. * @returns the host document object
  52660. */
  52661. getHostDocument(): Nullable<Document>;
  52662. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52663. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52664. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52665. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52666. [key: string]: VertexBuffer;
  52667. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52668. bindBuffers(vertexBuffers: {
  52669. [key: string]: VertexBuffer;
  52670. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52671. recordVertexArrayObject(vertexBuffers: {
  52672. [key: string]: VertexBuffer;
  52673. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52674. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52675. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52676. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52677. /**
  52678. * Draw a list of indexed primitives
  52679. * @param fillMode defines the primitive to use
  52680. * @param indexStart defines the starting index
  52681. * @param indexCount defines the number of index to draw
  52682. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52683. */
  52684. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52685. /**
  52686. * Draw a list of unindexed primitives
  52687. * @param fillMode defines the primitive to use
  52688. * @param verticesStart defines the index of first vertex to draw
  52689. * @param verticesCount defines the count of vertices to draw
  52690. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52691. */
  52692. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52693. createPipelineContext(): IPipelineContext;
  52694. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52695. /** @hidden */
  52696. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52697. /** @hidden */
  52698. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52699. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52700. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52701. protected _setProgram(program: WebGLProgram): void;
  52702. _releaseEffect(effect: Effect): void;
  52703. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52704. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52705. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52706. bindSamplers(effect: Effect): void;
  52707. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52708. getRenderWidth(useScreen?: boolean): number;
  52709. getRenderHeight(useScreen?: boolean): number;
  52710. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52711. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52712. /**
  52713. * Set the z offset to apply to current rendering
  52714. * @param value defines the offset to apply
  52715. */
  52716. setZOffset(value: number): void;
  52717. /**
  52718. * Gets the current value of the zOffset
  52719. * @returns the current zOffset state
  52720. */
  52721. getZOffset(): number;
  52722. /**
  52723. * Enable or disable depth buffering
  52724. * @param enable defines the state to set
  52725. */
  52726. setDepthBuffer(enable: boolean): void;
  52727. /**
  52728. * Gets a boolean indicating if depth writing is enabled
  52729. * @returns the current depth writing state
  52730. */
  52731. getDepthWrite(): boolean;
  52732. /**
  52733. * Enable or disable depth writing
  52734. * @param enable defines the state to set
  52735. */
  52736. setDepthWrite(enable: boolean): void;
  52737. /**
  52738. * Enable or disable color writing
  52739. * @param enable defines the state to set
  52740. */
  52741. setColorWrite(enable: boolean): void;
  52742. /**
  52743. * Gets a boolean indicating if color writing is enabled
  52744. * @returns the current color writing state
  52745. */
  52746. getColorWrite(): boolean;
  52747. /**
  52748. * Sets alpha constants used by some alpha blending modes
  52749. * @param r defines the red component
  52750. * @param g defines the green component
  52751. * @param b defines the blue component
  52752. * @param a defines the alpha component
  52753. */
  52754. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52755. /**
  52756. * Sets the current alpha mode
  52757. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52758. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52759. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52760. */
  52761. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52762. /**
  52763. * Gets the current alpha mode
  52764. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52765. * @returns the current alpha mode
  52766. */
  52767. getAlphaMode(): number;
  52768. setInt(uniform: WebGLUniformLocation, int: number): void;
  52769. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52770. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52771. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52772. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52773. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52774. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52775. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52776. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52777. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52778. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52779. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52780. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52781. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52782. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52783. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52784. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52785. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52786. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52787. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52788. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52789. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52790. wipeCaches(bruteForce?: boolean): void;
  52791. _createTexture(): WebGLTexture;
  52792. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52793. /**
  52794. * Usually called from Texture.ts.
  52795. * Passed information to create a WebGLTexture
  52796. * @param url defines a value which contains one of the following:
  52797. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52798. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52799. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52800. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52801. * @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)
  52802. * @param scene needed for loading to the correct scene
  52803. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52804. * @param onLoad optional callback to be called upon successful completion
  52805. * @param onError optional callback to be called upon failure
  52806. * @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
  52807. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52808. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52809. * @param forcedExtension defines the extension to use to pick the right loader
  52810. * @param mimeType defines an optional mime type
  52811. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52812. */
  52813. 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;
  52814. /**
  52815. * Creates a cube texture
  52816. * @param rootUrl defines the url where the files to load is located
  52817. * @param scene defines the current scene
  52818. * @param files defines the list of files to load (1 per face)
  52819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52820. * @param onLoad defines an optional callback raised when the texture is loaded
  52821. * @param onError defines an optional callback raised if there is an issue to load the texture
  52822. * @param format defines the format of the data
  52823. * @param forcedExtension defines the extension to use to pick the right loader
  52824. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52825. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52826. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52827. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52828. * @returns the cube texture as an InternalTexture
  52829. */
  52830. 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;
  52831. private _getSamplingFilter;
  52832. private static _GetNativeTextureFormat;
  52833. createRenderTargetTexture(size: number | {
  52834. width: number;
  52835. height: number;
  52836. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52837. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52838. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52839. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52840. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52841. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52842. /**
  52843. * Updates a dynamic vertex buffer.
  52844. * @param vertexBuffer the vertex buffer to update
  52845. * @param data the data used to update the vertex buffer
  52846. * @param byteOffset the byte offset of the data (optional)
  52847. * @param byteLength the byte length of the data (optional)
  52848. */
  52849. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52850. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52851. private _updateAnisotropicLevel;
  52852. private _getAddressMode;
  52853. /** @hidden */
  52854. _bindTexture(channel: number, texture: InternalTexture): void;
  52855. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52856. releaseEffects(): void;
  52857. /** @hidden */
  52858. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52859. /** @hidden */
  52860. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52861. /** @hidden */
  52862. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52863. /** @hidden */
  52864. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52865. }
  52866. }
  52867. declare module BABYLON {
  52868. /**
  52869. * Gather the list of clipboard event types as constants.
  52870. */
  52871. export class ClipboardEventTypes {
  52872. /**
  52873. * The clipboard event is fired when a copy command is active (pressed).
  52874. */
  52875. static readonly COPY: number;
  52876. /**
  52877. * The clipboard event is fired when a cut command is active (pressed).
  52878. */
  52879. static readonly CUT: number;
  52880. /**
  52881. * The clipboard event is fired when a paste command is active (pressed).
  52882. */
  52883. static readonly PASTE: number;
  52884. }
  52885. /**
  52886. * This class is used to store clipboard related info for the onClipboardObservable event.
  52887. */
  52888. export class ClipboardInfo {
  52889. /**
  52890. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52891. */
  52892. type: number;
  52893. /**
  52894. * Defines the related dom event
  52895. */
  52896. event: ClipboardEvent;
  52897. /**
  52898. *Creates an instance of ClipboardInfo.
  52899. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52900. * @param event Defines the related dom event
  52901. */
  52902. constructor(
  52903. /**
  52904. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52905. */
  52906. type: number,
  52907. /**
  52908. * Defines the related dom event
  52909. */
  52910. event: ClipboardEvent);
  52911. /**
  52912. * Get the clipboard event's type from the keycode.
  52913. * @param keyCode Defines the keyCode for the current keyboard event.
  52914. * @return {number}
  52915. */
  52916. static GetTypeFromCharacter(keyCode: number): number;
  52917. }
  52918. }
  52919. declare module BABYLON {
  52920. /**
  52921. * Google Daydream controller
  52922. */
  52923. export class DaydreamController extends WebVRController {
  52924. /**
  52925. * Base Url for the controller model.
  52926. */
  52927. static MODEL_BASE_URL: string;
  52928. /**
  52929. * File name for the controller model.
  52930. */
  52931. static MODEL_FILENAME: string;
  52932. /**
  52933. * Gamepad Id prefix used to identify Daydream Controller.
  52934. */
  52935. static readonly GAMEPAD_ID_PREFIX: string;
  52936. /**
  52937. * Creates a new DaydreamController from a gamepad
  52938. * @param vrGamepad the gamepad that the controller should be created from
  52939. */
  52940. constructor(vrGamepad: any);
  52941. /**
  52942. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52943. * @param scene scene in which to add meshes
  52944. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52945. */
  52946. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52947. /**
  52948. * Called once for each button that changed state since the last frame
  52949. * @param buttonIdx Which button index changed
  52950. * @param state New state of the button
  52951. * @param changes Which properties on the state changed since last frame
  52952. */
  52953. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52954. }
  52955. }
  52956. declare module BABYLON {
  52957. /**
  52958. * Gear VR Controller
  52959. */
  52960. export class GearVRController extends WebVRController {
  52961. /**
  52962. * Base Url for the controller model.
  52963. */
  52964. static MODEL_BASE_URL: string;
  52965. /**
  52966. * File name for the controller model.
  52967. */
  52968. static MODEL_FILENAME: string;
  52969. /**
  52970. * Gamepad Id prefix used to identify this controller.
  52971. */
  52972. static readonly GAMEPAD_ID_PREFIX: string;
  52973. private readonly _buttonIndexToObservableNameMap;
  52974. /**
  52975. * Creates a new GearVRController from a gamepad
  52976. * @param vrGamepad the gamepad that the controller should be created from
  52977. */
  52978. constructor(vrGamepad: any);
  52979. /**
  52980. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52981. * @param scene scene in which to add meshes
  52982. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52983. */
  52984. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52985. /**
  52986. * Called once for each button that changed state since the last frame
  52987. * @param buttonIdx Which button index changed
  52988. * @param state New state of the button
  52989. * @param changes Which properties on the state changed since last frame
  52990. */
  52991. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52992. }
  52993. }
  52994. declare module BABYLON {
  52995. /**
  52996. * Generic Controller
  52997. */
  52998. export class GenericController extends WebVRController {
  52999. /**
  53000. * Base Url for the controller model.
  53001. */
  53002. static readonly MODEL_BASE_URL: string;
  53003. /**
  53004. * File name for the controller model.
  53005. */
  53006. static readonly MODEL_FILENAME: string;
  53007. /**
  53008. * Creates a new GenericController from a gamepad
  53009. * @param vrGamepad the gamepad that the controller should be created from
  53010. */
  53011. constructor(vrGamepad: any);
  53012. /**
  53013. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53014. * @param scene scene in which to add meshes
  53015. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53016. */
  53017. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53018. /**
  53019. * Called once for each button that changed state since the last frame
  53020. * @param buttonIdx Which button index changed
  53021. * @param state New state of the button
  53022. * @param changes Which properties on the state changed since last frame
  53023. */
  53024. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53025. }
  53026. }
  53027. declare module BABYLON {
  53028. /**
  53029. * Oculus Touch Controller
  53030. */
  53031. export class OculusTouchController extends WebVRController {
  53032. /**
  53033. * Base Url for the controller model.
  53034. */
  53035. static MODEL_BASE_URL: string;
  53036. /**
  53037. * File name for the left controller model.
  53038. */
  53039. static MODEL_LEFT_FILENAME: string;
  53040. /**
  53041. * File name for the right controller model.
  53042. */
  53043. static MODEL_RIGHT_FILENAME: string;
  53044. /**
  53045. * Base Url for the Quest controller model.
  53046. */
  53047. static QUEST_MODEL_BASE_URL: string;
  53048. /**
  53049. * @hidden
  53050. * If the controllers are running on a device that needs the updated Quest controller models
  53051. */
  53052. static _IsQuest: boolean;
  53053. /**
  53054. * Fired when the secondary trigger on this controller is modified
  53055. */
  53056. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53057. /**
  53058. * Fired when the thumb rest on this controller is modified
  53059. */
  53060. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53061. /**
  53062. * Creates a new OculusTouchController from a gamepad
  53063. * @param vrGamepad the gamepad that the controller should be created from
  53064. */
  53065. constructor(vrGamepad: any);
  53066. /**
  53067. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53068. * @param scene scene in which to add meshes
  53069. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53070. */
  53071. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53072. /**
  53073. * Fired when the A button on this controller is modified
  53074. */
  53075. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53076. /**
  53077. * Fired when the B button on this controller is modified
  53078. */
  53079. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53080. /**
  53081. * Fired when the X button on this controller is modified
  53082. */
  53083. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53084. /**
  53085. * Fired when the Y button on this controller is modified
  53086. */
  53087. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53088. /**
  53089. * Called once for each button that changed state since the last frame
  53090. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53091. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53092. * 2) secondary trigger (same)
  53093. * 3) A (right) X (left), touch, pressed = value
  53094. * 4) B / Y
  53095. * 5) thumb rest
  53096. * @param buttonIdx Which button index changed
  53097. * @param state New state of the button
  53098. * @param changes Which properties on the state changed since last frame
  53099. */
  53100. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53101. }
  53102. }
  53103. declare module BABYLON {
  53104. /**
  53105. * Vive Controller
  53106. */
  53107. export class ViveController extends WebVRController {
  53108. /**
  53109. * Base Url for the controller model.
  53110. */
  53111. static MODEL_BASE_URL: string;
  53112. /**
  53113. * File name for the controller model.
  53114. */
  53115. static MODEL_FILENAME: string;
  53116. /**
  53117. * Creates a new ViveController from a gamepad
  53118. * @param vrGamepad the gamepad that the controller should be created from
  53119. */
  53120. constructor(vrGamepad: any);
  53121. /**
  53122. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53123. * @param scene scene in which to add meshes
  53124. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53125. */
  53126. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53127. /**
  53128. * Fired when the left button on this controller is modified
  53129. */
  53130. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53131. /**
  53132. * Fired when the right button on this controller is modified
  53133. */
  53134. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53135. /**
  53136. * Fired when the menu button on this controller is modified
  53137. */
  53138. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53139. /**
  53140. * Called once for each button that changed state since the last frame
  53141. * Vive mapping:
  53142. * 0: touchpad
  53143. * 1: trigger
  53144. * 2: left AND right buttons
  53145. * 3: menu button
  53146. * @param buttonIdx Which button index changed
  53147. * @param state New state of the button
  53148. * @param changes Which properties on the state changed since last frame
  53149. */
  53150. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53151. }
  53152. }
  53153. declare module BABYLON {
  53154. /**
  53155. * Defines the WindowsMotionController object that the state of the windows motion controller
  53156. */
  53157. export class WindowsMotionController extends WebVRController {
  53158. /**
  53159. * The base url used to load the left and right controller models
  53160. */
  53161. static MODEL_BASE_URL: string;
  53162. /**
  53163. * The name of the left controller model file
  53164. */
  53165. static MODEL_LEFT_FILENAME: string;
  53166. /**
  53167. * The name of the right controller model file
  53168. */
  53169. static MODEL_RIGHT_FILENAME: string;
  53170. /**
  53171. * The controller name prefix for this controller type
  53172. */
  53173. static readonly GAMEPAD_ID_PREFIX: string;
  53174. /**
  53175. * The controller id pattern for this controller type
  53176. */
  53177. private static readonly GAMEPAD_ID_PATTERN;
  53178. private _loadedMeshInfo;
  53179. protected readonly _mapping: {
  53180. buttons: string[];
  53181. buttonMeshNames: {
  53182. trigger: string;
  53183. menu: string;
  53184. grip: string;
  53185. thumbstick: string;
  53186. trackpad: string;
  53187. };
  53188. buttonObservableNames: {
  53189. trigger: string;
  53190. menu: string;
  53191. grip: string;
  53192. thumbstick: string;
  53193. trackpad: string;
  53194. };
  53195. axisMeshNames: string[];
  53196. pointingPoseMeshName: string;
  53197. };
  53198. /**
  53199. * Fired when the trackpad on this controller is clicked
  53200. */
  53201. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53202. /**
  53203. * Fired when the trackpad on this controller is modified
  53204. */
  53205. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53206. /**
  53207. * The current x and y values of this controller's trackpad
  53208. */
  53209. trackpad: StickValues;
  53210. /**
  53211. * Creates a new WindowsMotionController from a gamepad
  53212. * @param vrGamepad the gamepad that the controller should be created from
  53213. */
  53214. constructor(vrGamepad: any);
  53215. /**
  53216. * Fired when the trigger on this controller is modified
  53217. */
  53218. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53219. /**
  53220. * Fired when the menu button on this controller is modified
  53221. */
  53222. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53223. /**
  53224. * Fired when the grip button on this controller is modified
  53225. */
  53226. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53227. /**
  53228. * Fired when the thumbstick button on this controller is modified
  53229. */
  53230. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53231. /**
  53232. * Fired when the touchpad button on this controller is modified
  53233. */
  53234. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53235. /**
  53236. * Fired when the touchpad values on this controller are modified
  53237. */
  53238. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53239. protected _updateTrackpad(): void;
  53240. /**
  53241. * Called once per frame by the engine.
  53242. */
  53243. update(): void;
  53244. /**
  53245. * Called once for each button that changed state since the last frame
  53246. * @param buttonIdx Which button index changed
  53247. * @param state New state of the button
  53248. * @param changes Which properties on the state changed since last frame
  53249. */
  53250. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53251. /**
  53252. * Moves the buttons on the controller mesh based on their current state
  53253. * @param buttonName the name of the button to move
  53254. * @param buttonValue the value of the button which determines the buttons new position
  53255. */
  53256. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53257. /**
  53258. * Moves the axis on the controller mesh based on its current state
  53259. * @param axis the index of the axis
  53260. * @param axisValue the value of the axis which determines the meshes new position
  53261. * @hidden
  53262. */
  53263. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53264. /**
  53265. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53266. * @param scene scene in which to add meshes
  53267. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53268. */
  53269. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53270. /**
  53271. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53272. * can be transformed by button presses and axes values, based on this._mapping.
  53273. *
  53274. * @param scene scene in which the meshes exist
  53275. * @param meshes list of meshes that make up the controller model to process
  53276. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53277. */
  53278. private processModel;
  53279. private createMeshInfo;
  53280. /**
  53281. * Gets the ray of the controller in the direction the controller is pointing
  53282. * @param length the length the resulting ray should be
  53283. * @returns a ray in the direction the controller is pointing
  53284. */
  53285. getForwardRay(length?: number): Ray;
  53286. /**
  53287. * Disposes of the controller
  53288. */
  53289. dispose(): void;
  53290. }
  53291. /**
  53292. * This class represents a new windows motion controller in XR.
  53293. */
  53294. export class XRWindowsMotionController extends WindowsMotionController {
  53295. /**
  53296. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53297. */
  53298. protected readonly _mapping: {
  53299. buttons: string[];
  53300. buttonMeshNames: {
  53301. trigger: string;
  53302. menu: string;
  53303. grip: string;
  53304. thumbstick: string;
  53305. trackpad: string;
  53306. };
  53307. buttonObservableNames: {
  53308. trigger: string;
  53309. menu: string;
  53310. grip: string;
  53311. thumbstick: string;
  53312. trackpad: string;
  53313. };
  53314. axisMeshNames: string[];
  53315. pointingPoseMeshName: string;
  53316. };
  53317. /**
  53318. * Construct a new XR-Based windows motion controller
  53319. *
  53320. * @param gamepadInfo the gamepad object from the browser
  53321. */
  53322. constructor(gamepadInfo: any);
  53323. /**
  53324. * holds the thumbstick values (X,Y)
  53325. */
  53326. thumbstickValues: StickValues;
  53327. /**
  53328. * Fired when the thumbstick on this controller is clicked
  53329. */
  53330. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53331. /**
  53332. * Fired when the thumbstick on this controller is modified
  53333. */
  53334. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53335. /**
  53336. * Fired when the touchpad button on this controller is modified
  53337. */
  53338. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53339. /**
  53340. * Fired when the touchpad values on this controller are modified
  53341. */
  53342. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53343. /**
  53344. * Fired when the thumbstick button on this controller is modified
  53345. * here to prevent breaking changes
  53346. */
  53347. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53348. /**
  53349. * updating the thumbstick(!) and not the trackpad.
  53350. * This is named this way due to the difference between WebVR and XR and to avoid
  53351. * changing the parent class.
  53352. */
  53353. protected _updateTrackpad(): void;
  53354. /**
  53355. * Disposes the class with joy
  53356. */
  53357. dispose(): void;
  53358. }
  53359. }
  53360. declare module BABYLON {
  53361. /**
  53362. * Class containing static functions to help procedurally build meshes
  53363. */
  53364. export class PolyhedronBuilder {
  53365. /**
  53366. * Creates a polyhedron mesh
  53367. * * 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
  53368. * * The parameter `size` (positive float, default 1) sets the polygon size
  53369. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53370. * * 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`
  53371. * * 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
  53372. * * 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)`)
  53373. * * 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
  53374. * * 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
  53375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53376. * * 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
  53377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53378. * @param name defines the name of the mesh
  53379. * @param options defines the options used to create the mesh
  53380. * @param scene defines the hosting scene
  53381. * @returns the polyhedron mesh
  53382. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53383. */
  53384. static CreatePolyhedron(name: string, options: {
  53385. type?: number;
  53386. size?: number;
  53387. sizeX?: number;
  53388. sizeY?: number;
  53389. sizeZ?: number;
  53390. custom?: any;
  53391. faceUV?: Vector4[];
  53392. faceColors?: Color4[];
  53393. flat?: boolean;
  53394. updatable?: boolean;
  53395. sideOrientation?: number;
  53396. frontUVs?: Vector4;
  53397. backUVs?: Vector4;
  53398. }, scene?: Nullable<Scene>): Mesh;
  53399. }
  53400. }
  53401. declare module BABYLON {
  53402. /**
  53403. * Gizmo that enables scaling a mesh along 3 axis
  53404. */
  53405. export class ScaleGizmo extends Gizmo {
  53406. /**
  53407. * Internal gizmo used for interactions on the x axis
  53408. */
  53409. xGizmo: AxisScaleGizmo;
  53410. /**
  53411. * Internal gizmo used for interactions on the y axis
  53412. */
  53413. yGizmo: AxisScaleGizmo;
  53414. /**
  53415. * Internal gizmo used for interactions on the z axis
  53416. */
  53417. zGizmo: AxisScaleGizmo;
  53418. /**
  53419. * Internal gizmo used to scale all axis equally
  53420. */
  53421. uniformScaleGizmo: AxisScaleGizmo;
  53422. private _meshAttached;
  53423. private _nodeAttached;
  53424. private _snapDistance;
  53425. private _uniformScalingMesh;
  53426. private _octahedron;
  53427. private _sensitivity;
  53428. /** Fires an event when any of it's sub gizmos are dragged */
  53429. onDragStartObservable: Observable<unknown>;
  53430. /** Fires an event when any of it's sub gizmos are released from dragging */
  53431. onDragEndObservable: Observable<unknown>;
  53432. get attachedMesh(): Nullable<AbstractMesh>;
  53433. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53434. get attachedNode(): Nullable<Node>;
  53435. set attachedNode(node: Nullable<Node>);
  53436. /**
  53437. * Creates a ScaleGizmo
  53438. * @param gizmoLayer The utility layer the gizmo will be added to
  53439. * @param thickness display gizmo axis thickness
  53440. */
  53441. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53442. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53443. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53444. /**
  53445. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53446. */
  53447. set snapDistance(value: number);
  53448. get snapDistance(): number;
  53449. /**
  53450. * Ratio for the scale of the gizmo (Default: 1)
  53451. */
  53452. set scaleRatio(value: number);
  53453. get scaleRatio(): number;
  53454. /**
  53455. * Sensitivity factor for dragging (Default: 1)
  53456. */
  53457. set sensitivity(value: number);
  53458. get sensitivity(): number;
  53459. /**
  53460. * Disposes of the gizmo
  53461. */
  53462. dispose(): void;
  53463. }
  53464. }
  53465. declare module BABYLON {
  53466. /**
  53467. * Single axis scale gizmo
  53468. */
  53469. export class AxisScaleGizmo extends Gizmo {
  53470. /**
  53471. * Drag behavior responsible for the gizmos dragging interactions
  53472. */
  53473. dragBehavior: PointerDragBehavior;
  53474. private _pointerObserver;
  53475. /**
  53476. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53477. */
  53478. snapDistance: number;
  53479. /**
  53480. * Event that fires each time the gizmo snaps to a new location.
  53481. * * snapDistance is the the change in distance
  53482. */
  53483. onSnapObservable: Observable<{
  53484. snapDistance: number;
  53485. }>;
  53486. /**
  53487. * If the scaling operation should be done on all axis (default: false)
  53488. */
  53489. uniformScaling: boolean;
  53490. /**
  53491. * Custom sensitivity value for the drag strength
  53492. */
  53493. sensitivity: number;
  53494. private _isEnabled;
  53495. private _parent;
  53496. private _arrow;
  53497. private _coloredMaterial;
  53498. private _hoverMaterial;
  53499. /**
  53500. * Creates an AxisScaleGizmo
  53501. * @param gizmoLayer The utility layer the gizmo will be added to
  53502. * @param dragAxis The axis which the gizmo will be able to scale on
  53503. * @param color The color of the gizmo
  53504. * @param thickness display gizmo axis thickness
  53505. */
  53506. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53507. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53508. /**
  53509. * If the gizmo is enabled
  53510. */
  53511. set isEnabled(value: boolean);
  53512. get isEnabled(): boolean;
  53513. /**
  53514. * Disposes of the gizmo
  53515. */
  53516. dispose(): void;
  53517. /**
  53518. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53519. * @param mesh The mesh to replace the default mesh of the gizmo
  53520. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53521. */
  53522. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53523. }
  53524. }
  53525. declare module BABYLON {
  53526. /**
  53527. * Bounding box gizmo
  53528. */
  53529. export class BoundingBoxGizmo extends Gizmo {
  53530. private _lineBoundingBox;
  53531. private _rotateSpheresParent;
  53532. private _scaleBoxesParent;
  53533. private _boundingDimensions;
  53534. private _renderObserver;
  53535. private _pointerObserver;
  53536. private _scaleDragSpeed;
  53537. private _tmpQuaternion;
  53538. private _tmpVector;
  53539. private _tmpRotationMatrix;
  53540. /**
  53541. * 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)
  53542. */
  53543. ignoreChildren: boolean;
  53544. /**
  53545. * 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)
  53546. */
  53547. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53548. /**
  53549. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53550. */
  53551. rotationSphereSize: number;
  53552. /**
  53553. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53554. */
  53555. scaleBoxSize: number;
  53556. /**
  53557. * 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)
  53558. */
  53559. fixedDragMeshScreenSize: boolean;
  53560. /**
  53561. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53562. */
  53563. fixedDragMeshScreenSizeDistanceFactor: number;
  53564. /**
  53565. * Fired when a rotation sphere or scale box is dragged
  53566. */
  53567. onDragStartObservable: Observable<{}>;
  53568. /**
  53569. * Fired when a scale box is dragged
  53570. */
  53571. onScaleBoxDragObservable: Observable<{}>;
  53572. /**
  53573. * Fired when a scale box drag is ended
  53574. */
  53575. onScaleBoxDragEndObservable: Observable<{}>;
  53576. /**
  53577. * Fired when a rotation sphere is dragged
  53578. */
  53579. onRotationSphereDragObservable: Observable<{}>;
  53580. /**
  53581. * Fired when a rotation sphere drag is ended
  53582. */
  53583. onRotationSphereDragEndObservable: Observable<{}>;
  53584. /**
  53585. * 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)
  53586. */
  53587. scalePivot: Nullable<Vector3>;
  53588. /**
  53589. * Mesh used as a pivot to rotate the attached node
  53590. */
  53591. private _anchorMesh;
  53592. private _existingMeshScale;
  53593. private _dragMesh;
  53594. private pointerDragBehavior;
  53595. private coloredMaterial;
  53596. private hoverColoredMaterial;
  53597. /**
  53598. * Sets the color of the bounding box gizmo
  53599. * @param color the color to set
  53600. */
  53601. setColor(color: Color3): void;
  53602. /**
  53603. * Creates an BoundingBoxGizmo
  53604. * @param gizmoLayer The utility layer the gizmo will be added to
  53605. * @param color The color of the gizmo
  53606. */
  53607. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53608. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53609. private _selectNode;
  53610. /**
  53611. * Updates the bounding box information for the Gizmo
  53612. */
  53613. updateBoundingBox(): void;
  53614. private _updateRotationSpheres;
  53615. private _updateScaleBoxes;
  53616. /**
  53617. * Enables rotation on the specified axis and disables rotation on the others
  53618. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53619. */
  53620. setEnabledRotationAxis(axis: string): void;
  53621. /**
  53622. * Enables/disables scaling
  53623. * @param enable if scaling should be enabled
  53624. * @param homogeneousScaling defines if scaling should only be homogeneous
  53625. */
  53626. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53627. private _updateDummy;
  53628. /**
  53629. * Enables a pointer drag behavior on the bounding box of the gizmo
  53630. */
  53631. enableDragBehavior(): void;
  53632. /**
  53633. * Disposes of the gizmo
  53634. */
  53635. dispose(): void;
  53636. /**
  53637. * 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)
  53638. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53639. * @returns the bounding box mesh with the passed in mesh as a child
  53640. */
  53641. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53642. /**
  53643. * CustomMeshes are not supported by this gizmo
  53644. * @param mesh The mesh to replace the default mesh of the gizmo
  53645. */
  53646. setCustomMesh(mesh: Mesh): void;
  53647. }
  53648. }
  53649. declare module BABYLON {
  53650. /**
  53651. * Single plane rotation gizmo
  53652. */
  53653. export class PlaneRotationGizmo extends Gizmo {
  53654. /**
  53655. * Drag behavior responsible for the gizmos dragging interactions
  53656. */
  53657. dragBehavior: PointerDragBehavior;
  53658. private _pointerObserver;
  53659. /**
  53660. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53661. */
  53662. snapDistance: number;
  53663. /**
  53664. * Event that fires each time the gizmo snaps to a new location.
  53665. * * snapDistance is the the change in distance
  53666. */
  53667. onSnapObservable: Observable<{
  53668. snapDistance: number;
  53669. }>;
  53670. private _isEnabled;
  53671. private _parent;
  53672. /**
  53673. * Creates a PlaneRotationGizmo
  53674. * @param gizmoLayer The utility layer the gizmo will be added to
  53675. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53676. * @param color The color of the gizmo
  53677. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53678. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53679. * @param thickness display gizmo axis thickness
  53680. */
  53681. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53682. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53683. /**
  53684. * If the gizmo is enabled
  53685. */
  53686. set isEnabled(value: boolean);
  53687. get isEnabled(): boolean;
  53688. /**
  53689. * Disposes of the gizmo
  53690. */
  53691. dispose(): void;
  53692. }
  53693. }
  53694. declare module BABYLON {
  53695. /**
  53696. * Gizmo that enables rotating a mesh along 3 axis
  53697. */
  53698. export class RotationGizmo extends Gizmo {
  53699. /**
  53700. * Internal gizmo used for interactions on the x axis
  53701. */
  53702. xGizmo: PlaneRotationGizmo;
  53703. /**
  53704. * Internal gizmo used for interactions on the y axis
  53705. */
  53706. yGizmo: PlaneRotationGizmo;
  53707. /**
  53708. * Internal gizmo used for interactions on the z axis
  53709. */
  53710. zGizmo: PlaneRotationGizmo;
  53711. /** Fires an event when any of it's sub gizmos are dragged */
  53712. onDragStartObservable: Observable<unknown>;
  53713. /** Fires an event when any of it's sub gizmos are released from dragging */
  53714. onDragEndObservable: Observable<unknown>;
  53715. private _meshAttached;
  53716. private _nodeAttached;
  53717. get attachedMesh(): Nullable<AbstractMesh>;
  53718. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53719. get attachedNode(): Nullable<Node>;
  53720. set attachedNode(node: Nullable<Node>);
  53721. /**
  53722. * Creates a RotationGizmo
  53723. * @param gizmoLayer The utility layer the gizmo will be added to
  53724. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53725. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53726. * @param thickness display gizmo axis thickness
  53727. */
  53728. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53729. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53730. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53731. /**
  53732. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53733. */
  53734. set snapDistance(value: number);
  53735. get snapDistance(): number;
  53736. /**
  53737. * Ratio for the scale of the gizmo (Default: 1)
  53738. */
  53739. set scaleRatio(value: number);
  53740. get scaleRatio(): number;
  53741. /**
  53742. * Disposes of the gizmo
  53743. */
  53744. dispose(): void;
  53745. /**
  53746. * CustomMeshes are not supported by this gizmo
  53747. * @param mesh The mesh to replace the default mesh of the gizmo
  53748. */
  53749. setCustomMesh(mesh: Mesh): void;
  53750. }
  53751. }
  53752. declare module BABYLON {
  53753. /**
  53754. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  53755. */
  53756. export class GizmoManager implements IDisposable {
  53757. private scene;
  53758. /**
  53759. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53760. */
  53761. gizmos: {
  53762. positionGizmo: Nullable<PositionGizmo>;
  53763. rotationGizmo: Nullable<RotationGizmo>;
  53764. scaleGizmo: Nullable<ScaleGizmo>;
  53765. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53766. };
  53767. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53768. clearGizmoOnEmptyPointerEvent: boolean;
  53769. /** Fires an event when the manager is attached to a mesh */
  53770. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53771. /** Fires an event when the manager is attached to a node */
  53772. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  53773. private _gizmosEnabled;
  53774. private _pointerObserver;
  53775. private _attachedMesh;
  53776. private _attachedNode;
  53777. private _boundingBoxColor;
  53778. private _defaultUtilityLayer;
  53779. private _defaultKeepDepthUtilityLayer;
  53780. private _thickness;
  53781. /**
  53782. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53783. */
  53784. boundingBoxDragBehavior: SixDofDragBehavior;
  53785. /**
  53786. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53787. */
  53788. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53789. /**
  53790. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  53791. */
  53792. attachableNodes: Nullable<Array<Node>>;
  53793. /**
  53794. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  53795. */
  53796. usePointerToAttachGizmos: boolean;
  53797. /**
  53798. * Utility layer that the bounding box gizmo belongs to
  53799. */
  53800. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53801. /**
  53802. * Utility layer that all gizmos besides bounding box belong to
  53803. */
  53804. get utilityLayer(): UtilityLayerRenderer;
  53805. /**
  53806. * Instatiates a gizmo manager
  53807. * @param scene the scene to overlay the gizmos on top of
  53808. * @param thickness display gizmo axis thickness
  53809. */
  53810. constructor(scene: Scene, thickness?: number);
  53811. /**
  53812. * Attaches a set of gizmos to the specified mesh
  53813. * @param mesh The mesh the gizmo's should be attached to
  53814. */
  53815. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53816. /**
  53817. * Attaches a set of gizmos to the specified node
  53818. * @param node The node the gizmo's should be attached to
  53819. */
  53820. attachToNode(node: Nullable<Node>): void;
  53821. /**
  53822. * If the position gizmo is enabled
  53823. */
  53824. set positionGizmoEnabled(value: boolean);
  53825. get positionGizmoEnabled(): boolean;
  53826. /**
  53827. * If the rotation gizmo is enabled
  53828. */
  53829. set rotationGizmoEnabled(value: boolean);
  53830. get rotationGizmoEnabled(): boolean;
  53831. /**
  53832. * If the scale gizmo is enabled
  53833. */
  53834. set scaleGizmoEnabled(value: boolean);
  53835. get scaleGizmoEnabled(): boolean;
  53836. /**
  53837. * If the boundingBox gizmo is enabled
  53838. */
  53839. set boundingBoxGizmoEnabled(value: boolean);
  53840. get boundingBoxGizmoEnabled(): boolean;
  53841. /**
  53842. * Disposes of the gizmo manager
  53843. */
  53844. dispose(): void;
  53845. }
  53846. }
  53847. declare module BABYLON {
  53848. /**
  53849. * A directional light is defined by a direction (what a surprise!).
  53850. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53851. * 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.
  53852. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53853. */
  53854. export class DirectionalLight extends ShadowLight {
  53855. private _shadowFrustumSize;
  53856. /**
  53857. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53858. */
  53859. get shadowFrustumSize(): number;
  53860. /**
  53861. * Specifies a fix frustum size for the shadow generation.
  53862. */
  53863. set shadowFrustumSize(value: number);
  53864. private _shadowOrthoScale;
  53865. /**
  53866. * Gets the shadow projection scale against the optimal computed one.
  53867. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53868. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53869. */
  53870. get shadowOrthoScale(): number;
  53871. /**
  53872. * Sets the shadow projection scale against the optimal computed one.
  53873. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53874. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53875. */
  53876. set shadowOrthoScale(value: number);
  53877. /**
  53878. * Automatically compute the projection matrix to best fit (including all the casters)
  53879. * on each frame.
  53880. */
  53881. autoUpdateExtends: boolean;
  53882. /**
  53883. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53884. * on each frame. autoUpdateExtends must be set to true for this to work
  53885. */
  53886. autoCalcShadowZBounds: boolean;
  53887. private _orthoLeft;
  53888. private _orthoRight;
  53889. private _orthoTop;
  53890. private _orthoBottom;
  53891. /**
  53892. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53893. * The directional light is emitted from everywhere in the given direction.
  53894. * It can cast shadows.
  53895. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53896. * @param name The friendly name of the light
  53897. * @param direction The direction of the light
  53898. * @param scene The scene the light belongs to
  53899. */
  53900. constructor(name: string, direction: Vector3, scene: Scene);
  53901. /**
  53902. * Returns the string "DirectionalLight".
  53903. * @return The class name
  53904. */
  53905. getClassName(): string;
  53906. /**
  53907. * Returns the integer 1.
  53908. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53909. */
  53910. getTypeID(): number;
  53911. /**
  53912. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53913. * Returns the DirectionalLight Shadow projection matrix.
  53914. */
  53915. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53916. /**
  53917. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53918. * Returns the DirectionalLight Shadow projection matrix.
  53919. */
  53920. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53921. /**
  53922. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  53923. * Returns the DirectionalLight Shadow projection matrix.
  53924. */
  53925. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53926. protected _buildUniformLayout(): void;
  53927. /**
  53928. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  53929. * @param effect The effect to update
  53930. * @param lightIndex The index of the light in the effect to update
  53931. * @returns The directional light
  53932. */
  53933. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  53934. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  53935. /**
  53936. * Gets the minZ used for shadow according to both the scene and the light.
  53937. *
  53938. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53939. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53940. * @param activeCamera The camera we are returning the min for
  53941. * @returns the depth min z
  53942. */
  53943. getDepthMinZ(activeCamera: Camera): number;
  53944. /**
  53945. * Gets the maxZ used for shadow according to both the scene and the light.
  53946. *
  53947. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53948. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53949. * @param activeCamera The camera we are returning the max for
  53950. * @returns the depth max z
  53951. */
  53952. getDepthMaxZ(activeCamera: Camera): number;
  53953. /**
  53954. * Prepares the list of defines specific to the light type.
  53955. * @param defines the list of defines
  53956. * @param lightIndex defines the index of the light for the effect
  53957. */
  53958. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53959. }
  53960. }
  53961. declare module BABYLON {
  53962. /**
  53963. * Class containing static functions to help procedurally build meshes
  53964. */
  53965. export class HemisphereBuilder {
  53966. /**
  53967. * Creates a hemisphere mesh
  53968. * @param name defines the name of the mesh
  53969. * @param options defines the options used to create the mesh
  53970. * @param scene defines the hosting scene
  53971. * @returns the hemisphere mesh
  53972. */
  53973. static CreateHemisphere(name: string, options: {
  53974. segments?: number;
  53975. diameter?: number;
  53976. sideOrientation?: number;
  53977. }, scene: any): Mesh;
  53978. }
  53979. }
  53980. declare module BABYLON {
  53981. /**
  53982. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53983. * These values define a cone of light starting from the position, emitting toward the direction.
  53984. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53985. * and the exponent defines the speed of the decay of the light with distance (reach).
  53986. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53987. */
  53988. export class SpotLight extends ShadowLight {
  53989. private _angle;
  53990. private _innerAngle;
  53991. private _cosHalfAngle;
  53992. private _lightAngleScale;
  53993. private _lightAngleOffset;
  53994. /**
  53995. * Gets the cone angle of the spot light in Radians.
  53996. */
  53997. get angle(): number;
  53998. /**
  53999. * Sets the cone angle of the spot light in Radians.
  54000. */
  54001. set angle(value: number);
  54002. /**
  54003. * Only used in gltf falloff mode, this defines the angle where
  54004. * the directional falloff will start before cutting at angle which could be seen
  54005. * as outer angle.
  54006. */
  54007. get innerAngle(): number;
  54008. /**
  54009. * Only used in gltf falloff mode, this defines the angle where
  54010. * the directional falloff will start before cutting at angle which could be seen
  54011. * as outer angle.
  54012. */
  54013. set innerAngle(value: number);
  54014. private _shadowAngleScale;
  54015. /**
  54016. * Allows scaling the angle of the light for shadow generation only.
  54017. */
  54018. get shadowAngleScale(): number;
  54019. /**
  54020. * Allows scaling the angle of the light for shadow generation only.
  54021. */
  54022. set shadowAngleScale(value: number);
  54023. /**
  54024. * The light decay speed with the distance from the emission spot.
  54025. */
  54026. exponent: number;
  54027. private _projectionTextureMatrix;
  54028. /**
  54029. * Allows reading the projecton texture
  54030. */
  54031. get projectionTextureMatrix(): Matrix;
  54032. protected _projectionTextureLightNear: number;
  54033. /**
  54034. * Gets the near clip of the Spotlight for texture projection.
  54035. */
  54036. get projectionTextureLightNear(): number;
  54037. /**
  54038. * Sets the near clip of the Spotlight for texture projection.
  54039. */
  54040. set projectionTextureLightNear(value: number);
  54041. protected _projectionTextureLightFar: number;
  54042. /**
  54043. * Gets the far clip of the Spotlight for texture projection.
  54044. */
  54045. get projectionTextureLightFar(): number;
  54046. /**
  54047. * Sets the far clip of the Spotlight for texture projection.
  54048. */
  54049. set projectionTextureLightFar(value: number);
  54050. protected _projectionTextureUpDirection: Vector3;
  54051. /**
  54052. * Gets the Up vector of the Spotlight for texture projection.
  54053. */
  54054. get projectionTextureUpDirection(): Vector3;
  54055. /**
  54056. * Sets the Up vector of the Spotlight for texture projection.
  54057. */
  54058. set projectionTextureUpDirection(value: Vector3);
  54059. private _projectionTexture;
  54060. /**
  54061. * Gets the projection texture of the light.
  54062. */
  54063. get projectionTexture(): Nullable<BaseTexture>;
  54064. /**
  54065. * Sets the projection texture of the light.
  54066. */
  54067. set projectionTexture(value: Nullable<BaseTexture>);
  54068. private _projectionTextureViewLightDirty;
  54069. private _projectionTextureProjectionLightDirty;
  54070. private _projectionTextureDirty;
  54071. private _projectionTextureViewTargetVector;
  54072. private _projectionTextureViewLightMatrix;
  54073. private _projectionTextureProjectionLightMatrix;
  54074. private _projectionTextureScalingMatrix;
  54075. /**
  54076. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54077. * It can cast shadows.
  54078. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54079. * @param name The light friendly name
  54080. * @param position The position of the spot light in the scene
  54081. * @param direction The direction of the light in the scene
  54082. * @param angle The cone angle of the light in Radians
  54083. * @param exponent The light decay speed with the distance from the emission spot
  54084. * @param scene The scene the lights belongs to
  54085. */
  54086. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54087. /**
  54088. * Returns the string "SpotLight".
  54089. * @returns the class name
  54090. */
  54091. getClassName(): string;
  54092. /**
  54093. * Returns the integer 2.
  54094. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54095. */
  54096. getTypeID(): number;
  54097. /**
  54098. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54099. */
  54100. protected _setDirection(value: Vector3): void;
  54101. /**
  54102. * Overrides the position setter to recompute the projection texture view light Matrix.
  54103. */
  54104. protected _setPosition(value: Vector3): void;
  54105. /**
  54106. * 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.
  54107. * Returns the SpotLight.
  54108. */
  54109. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54110. protected _computeProjectionTextureViewLightMatrix(): void;
  54111. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54112. /**
  54113. * Main function for light texture projection matrix computing.
  54114. */
  54115. protected _computeProjectionTextureMatrix(): void;
  54116. protected _buildUniformLayout(): void;
  54117. private _computeAngleValues;
  54118. /**
  54119. * Sets the passed Effect "effect" with the Light textures.
  54120. * @param effect The effect to update
  54121. * @param lightIndex The index of the light in the effect to update
  54122. * @returns The light
  54123. */
  54124. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54125. /**
  54126. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54127. * @param effect The effect to update
  54128. * @param lightIndex The index of the light in the effect to update
  54129. * @returns The spot light
  54130. */
  54131. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54132. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54133. /**
  54134. * Disposes the light and the associated resources.
  54135. */
  54136. dispose(): void;
  54137. /**
  54138. * Prepares the list of defines specific to the light type.
  54139. * @param defines the list of defines
  54140. * @param lightIndex defines the index of the light for the effect
  54141. */
  54142. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54143. }
  54144. }
  54145. declare module BABYLON {
  54146. /**
  54147. * Gizmo that enables viewing a light
  54148. */
  54149. export class LightGizmo extends Gizmo {
  54150. private _lightMesh;
  54151. private _material;
  54152. private _cachedPosition;
  54153. private _cachedForward;
  54154. private _attachedMeshParent;
  54155. /**
  54156. * Creates a LightGizmo
  54157. * @param gizmoLayer The utility layer the gizmo will be added to
  54158. */
  54159. constructor(gizmoLayer?: UtilityLayerRenderer);
  54160. private _light;
  54161. /**
  54162. * The light that the gizmo is attached to
  54163. */
  54164. set light(light: Nullable<Light>);
  54165. get light(): Nullable<Light>;
  54166. /**
  54167. * Gets the material used to render the light gizmo
  54168. */
  54169. get material(): StandardMaterial;
  54170. /**
  54171. * @hidden
  54172. * Updates the gizmo to match the attached mesh's position/rotation
  54173. */
  54174. protected _update(): void;
  54175. private static _Scale;
  54176. /**
  54177. * Creates the lines for a light mesh
  54178. */
  54179. private static _CreateLightLines;
  54180. /**
  54181. * Disposes of the light gizmo
  54182. */
  54183. dispose(): void;
  54184. private static _CreateHemisphericLightMesh;
  54185. private static _CreatePointLightMesh;
  54186. private static _CreateSpotLightMesh;
  54187. private static _CreateDirectionalLightMesh;
  54188. }
  54189. }
  54190. declare module BABYLON {
  54191. /**
  54192. * Gizmo that enables viewing a camera
  54193. */
  54194. export class CameraGizmo extends Gizmo {
  54195. private _cameraMesh;
  54196. private _cameraLinesMesh;
  54197. private _material;
  54198. /**
  54199. * Creates a CameraGizmo
  54200. * @param gizmoLayer The utility layer the gizmo will be added to
  54201. */
  54202. constructor(gizmoLayer?: UtilityLayerRenderer);
  54203. private _camera;
  54204. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54205. get displayFrustum(): boolean;
  54206. set displayFrustum(value: boolean);
  54207. /**
  54208. * The camera that the gizmo is attached to
  54209. */
  54210. set camera(camera: Nullable<Camera>);
  54211. get camera(): Nullable<Camera>;
  54212. /**
  54213. * Gets the material used to render the camera gizmo
  54214. */
  54215. get material(): StandardMaterial;
  54216. /**
  54217. * @hidden
  54218. * Updates the gizmo to match the attached mesh's position/rotation
  54219. */
  54220. protected _update(): void;
  54221. private static _Scale;
  54222. private _invProjection;
  54223. /**
  54224. * Disposes of the camera gizmo
  54225. */
  54226. dispose(): void;
  54227. private static _CreateCameraMesh;
  54228. private static _CreateCameraFrustum;
  54229. }
  54230. }
  54231. declare module BABYLON {
  54232. /** @hidden */
  54233. export var backgroundFragmentDeclaration: {
  54234. name: string;
  54235. shader: string;
  54236. };
  54237. }
  54238. declare module BABYLON {
  54239. /** @hidden */
  54240. export var backgroundUboDeclaration: {
  54241. name: string;
  54242. shader: string;
  54243. };
  54244. }
  54245. declare module BABYLON {
  54246. /** @hidden */
  54247. export var backgroundPixelShader: {
  54248. name: string;
  54249. shader: string;
  54250. };
  54251. }
  54252. declare module BABYLON {
  54253. /** @hidden */
  54254. export var backgroundVertexDeclaration: {
  54255. name: string;
  54256. shader: string;
  54257. };
  54258. }
  54259. declare module BABYLON {
  54260. /** @hidden */
  54261. export var backgroundVertexShader: {
  54262. name: string;
  54263. shader: string;
  54264. };
  54265. }
  54266. declare module BABYLON {
  54267. /**
  54268. * Background material used to create an efficient environement around your scene.
  54269. */
  54270. export class BackgroundMaterial extends PushMaterial {
  54271. /**
  54272. * Standard reflectance value at parallel view angle.
  54273. */
  54274. static StandardReflectance0: number;
  54275. /**
  54276. * Standard reflectance value at grazing angle.
  54277. */
  54278. static StandardReflectance90: number;
  54279. protected _primaryColor: Color3;
  54280. /**
  54281. * Key light Color (multiply against the environement texture)
  54282. */
  54283. primaryColor: Color3;
  54284. protected __perceptualColor: Nullable<Color3>;
  54285. /**
  54286. * Experimental Internal Use Only.
  54287. *
  54288. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54289. * This acts as a helper to set the primary color to a more "human friendly" value.
  54290. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54291. * output color as close as possible from the chosen value.
  54292. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54293. * part of lighting setup.)
  54294. */
  54295. get _perceptualColor(): Nullable<Color3>;
  54296. set _perceptualColor(value: Nullable<Color3>);
  54297. protected _primaryColorShadowLevel: float;
  54298. /**
  54299. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54300. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54301. */
  54302. get primaryColorShadowLevel(): float;
  54303. set primaryColorShadowLevel(value: float);
  54304. protected _primaryColorHighlightLevel: float;
  54305. /**
  54306. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54307. * The primary color is used at the level chosen to define what the white area would look.
  54308. */
  54309. get primaryColorHighlightLevel(): float;
  54310. set primaryColorHighlightLevel(value: float);
  54311. protected _reflectionTexture: Nullable<BaseTexture>;
  54312. /**
  54313. * Reflection Texture used in the material.
  54314. * Should be author in a specific way for the best result (refer to the documentation).
  54315. */
  54316. reflectionTexture: Nullable<BaseTexture>;
  54317. protected _reflectionBlur: float;
  54318. /**
  54319. * Reflection Texture level of blur.
  54320. *
  54321. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54322. * texture twice.
  54323. */
  54324. reflectionBlur: float;
  54325. protected _diffuseTexture: Nullable<BaseTexture>;
  54326. /**
  54327. * Diffuse Texture used in the material.
  54328. * Should be author in a specific way for the best result (refer to the documentation).
  54329. */
  54330. diffuseTexture: Nullable<BaseTexture>;
  54331. protected _shadowLights: Nullable<IShadowLight[]>;
  54332. /**
  54333. * Specify the list of lights casting shadow on the material.
  54334. * All scene shadow lights will be included if null.
  54335. */
  54336. shadowLights: Nullable<IShadowLight[]>;
  54337. protected _shadowLevel: float;
  54338. /**
  54339. * Helps adjusting the shadow to a softer level if required.
  54340. * 0 means black shadows and 1 means no shadows.
  54341. */
  54342. shadowLevel: float;
  54343. protected _sceneCenter: Vector3;
  54344. /**
  54345. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54346. * It is usually zero but might be interesting to modify according to your setup.
  54347. */
  54348. sceneCenter: Vector3;
  54349. protected _opacityFresnel: boolean;
  54350. /**
  54351. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54352. * This helps ensuring a nice transition when the camera goes under the ground.
  54353. */
  54354. opacityFresnel: boolean;
  54355. protected _reflectionFresnel: boolean;
  54356. /**
  54357. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54358. * This helps adding a mirror texture on the ground.
  54359. */
  54360. reflectionFresnel: boolean;
  54361. protected _reflectionFalloffDistance: number;
  54362. /**
  54363. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54364. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54365. */
  54366. reflectionFalloffDistance: number;
  54367. protected _reflectionAmount: number;
  54368. /**
  54369. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54370. */
  54371. reflectionAmount: number;
  54372. protected _reflectionReflectance0: number;
  54373. /**
  54374. * This specifies the weight of the reflection at grazing angle.
  54375. */
  54376. reflectionReflectance0: number;
  54377. protected _reflectionReflectance90: number;
  54378. /**
  54379. * This specifies the weight of the reflection at a perpendicular point of view.
  54380. */
  54381. reflectionReflectance90: number;
  54382. /**
  54383. * Sets the reflection reflectance fresnel values according to the default standard
  54384. * empirically know to work well :-)
  54385. */
  54386. set reflectionStandardFresnelWeight(value: number);
  54387. protected _useRGBColor: boolean;
  54388. /**
  54389. * Helps to directly use the maps channels instead of their level.
  54390. */
  54391. useRGBColor: boolean;
  54392. protected _enableNoise: boolean;
  54393. /**
  54394. * This helps reducing the banding effect that could occur on the background.
  54395. */
  54396. enableNoise: boolean;
  54397. /**
  54398. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54399. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54400. * Recommended to be keep at 1.0 except for special cases.
  54401. */
  54402. get fovMultiplier(): number;
  54403. set fovMultiplier(value: number);
  54404. private _fovMultiplier;
  54405. /**
  54406. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54407. */
  54408. useEquirectangularFOV: boolean;
  54409. private _maxSimultaneousLights;
  54410. /**
  54411. * Number of Simultaneous lights allowed on the material.
  54412. */
  54413. maxSimultaneousLights: int;
  54414. private _shadowOnly;
  54415. /**
  54416. * Make the material only render shadows
  54417. */
  54418. shadowOnly: boolean;
  54419. /**
  54420. * Default configuration related to image processing available in the Background Material.
  54421. */
  54422. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54423. /**
  54424. * Keep track of the image processing observer to allow dispose and replace.
  54425. */
  54426. private _imageProcessingObserver;
  54427. /**
  54428. * Attaches a new image processing configuration to the PBR Material.
  54429. * @param configuration (if null the scene configuration will be use)
  54430. */
  54431. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54432. /**
  54433. * Gets the image processing configuration used either in this material.
  54434. */
  54435. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54436. /**
  54437. * Sets the Default image processing configuration used either in the this material.
  54438. *
  54439. * If sets to null, the scene one is in use.
  54440. */
  54441. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54442. /**
  54443. * Gets wether the color curves effect is enabled.
  54444. */
  54445. get cameraColorCurvesEnabled(): boolean;
  54446. /**
  54447. * Sets wether the color curves effect is enabled.
  54448. */
  54449. set cameraColorCurvesEnabled(value: boolean);
  54450. /**
  54451. * Gets wether the color grading effect is enabled.
  54452. */
  54453. get cameraColorGradingEnabled(): boolean;
  54454. /**
  54455. * Gets wether the color grading effect is enabled.
  54456. */
  54457. set cameraColorGradingEnabled(value: boolean);
  54458. /**
  54459. * Gets wether tonemapping is enabled or not.
  54460. */
  54461. get cameraToneMappingEnabled(): boolean;
  54462. /**
  54463. * Sets wether tonemapping is enabled or not
  54464. */
  54465. set cameraToneMappingEnabled(value: boolean);
  54466. /**
  54467. * The camera exposure used on this material.
  54468. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54469. * This corresponds to a photographic exposure.
  54470. */
  54471. get cameraExposure(): float;
  54472. /**
  54473. * The camera exposure used on this material.
  54474. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54475. * This corresponds to a photographic exposure.
  54476. */
  54477. set cameraExposure(value: float);
  54478. /**
  54479. * Gets The camera contrast used on this material.
  54480. */
  54481. get cameraContrast(): float;
  54482. /**
  54483. * Sets The camera contrast used on this material.
  54484. */
  54485. set cameraContrast(value: float);
  54486. /**
  54487. * Gets the Color Grading 2D Lookup Texture.
  54488. */
  54489. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54490. /**
  54491. * Sets the Color Grading 2D Lookup Texture.
  54492. */
  54493. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54494. /**
  54495. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54496. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54497. * 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;
  54498. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54499. */
  54500. get cameraColorCurves(): Nullable<ColorCurves>;
  54501. /**
  54502. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54503. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54504. * 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;
  54505. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54506. */
  54507. set cameraColorCurves(value: Nullable<ColorCurves>);
  54508. /**
  54509. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54510. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54511. */
  54512. switchToBGR: boolean;
  54513. private _renderTargets;
  54514. private _reflectionControls;
  54515. private _white;
  54516. private _primaryShadowColor;
  54517. private _primaryHighlightColor;
  54518. /**
  54519. * Instantiates a Background Material in the given scene
  54520. * @param name The friendly name of the material
  54521. * @param scene The scene to add the material to
  54522. */
  54523. constructor(name: string, scene: Scene);
  54524. /**
  54525. * Gets a boolean indicating that current material needs to register RTT
  54526. */
  54527. get hasRenderTargetTextures(): boolean;
  54528. /**
  54529. * The entire material has been created in order to prevent overdraw.
  54530. * @returns false
  54531. */
  54532. needAlphaTesting(): boolean;
  54533. /**
  54534. * The entire material has been created in order to prevent overdraw.
  54535. * @returns true if blending is enable
  54536. */
  54537. needAlphaBlending(): boolean;
  54538. /**
  54539. * Checks wether the material is ready to be rendered for a given mesh.
  54540. * @param mesh The mesh to render
  54541. * @param subMesh The submesh to check against
  54542. * @param useInstances Specify wether or not the material is used with instances
  54543. * @returns true if all the dependencies are ready (Textures, Effects...)
  54544. */
  54545. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54546. /**
  54547. * Compute the primary color according to the chosen perceptual color.
  54548. */
  54549. private _computePrimaryColorFromPerceptualColor;
  54550. /**
  54551. * Compute the highlights and shadow colors according to their chosen levels.
  54552. */
  54553. private _computePrimaryColors;
  54554. /**
  54555. * Build the uniform buffer used in the material.
  54556. */
  54557. buildUniformLayout(): void;
  54558. /**
  54559. * Unbind the material.
  54560. */
  54561. unbind(): void;
  54562. /**
  54563. * Bind only the world matrix to the material.
  54564. * @param world The world matrix to bind.
  54565. */
  54566. bindOnlyWorldMatrix(world: Matrix): void;
  54567. /**
  54568. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54569. * @param world The world matrix to bind.
  54570. * @param subMesh The submesh to bind for.
  54571. */
  54572. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54573. /**
  54574. * Checks to see if a texture is used in the material.
  54575. * @param texture - Base texture to use.
  54576. * @returns - Boolean specifying if a texture is used in the material.
  54577. */
  54578. hasTexture(texture: BaseTexture): boolean;
  54579. /**
  54580. * Dispose the material.
  54581. * @param forceDisposeEffect Force disposal of the associated effect.
  54582. * @param forceDisposeTextures Force disposal of the associated textures.
  54583. */
  54584. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54585. /**
  54586. * Clones the material.
  54587. * @param name The cloned name.
  54588. * @returns The cloned material.
  54589. */
  54590. clone(name: string): BackgroundMaterial;
  54591. /**
  54592. * Serializes the current material to its JSON representation.
  54593. * @returns The JSON representation.
  54594. */
  54595. serialize(): any;
  54596. /**
  54597. * Gets the class name of the material
  54598. * @returns "BackgroundMaterial"
  54599. */
  54600. getClassName(): string;
  54601. /**
  54602. * Parse a JSON input to create back a background material.
  54603. * @param source The JSON data to parse
  54604. * @param scene The scene to create the parsed material in
  54605. * @param rootUrl The root url of the assets the material depends upon
  54606. * @returns the instantiated BackgroundMaterial.
  54607. */
  54608. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54609. }
  54610. }
  54611. declare module BABYLON {
  54612. /**
  54613. * Represents the different options available during the creation of
  54614. * a Environment helper.
  54615. *
  54616. * This can control the default ground, skybox and image processing setup of your scene.
  54617. */
  54618. export interface IEnvironmentHelperOptions {
  54619. /**
  54620. * Specifies whether or not to create a ground.
  54621. * True by default.
  54622. */
  54623. createGround: boolean;
  54624. /**
  54625. * Specifies the ground size.
  54626. * 15 by default.
  54627. */
  54628. groundSize: number;
  54629. /**
  54630. * The texture used on the ground for the main color.
  54631. * Comes from the BabylonJS CDN by default.
  54632. *
  54633. * Remarks: Can be either a texture or a url.
  54634. */
  54635. groundTexture: string | BaseTexture;
  54636. /**
  54637. * The color mixed in the ground texture by default.
  54638. * BabylonJS clearColor by default.
  54639. */
  54640. groundColor: Color3;
  54641. /**
  54642. * Specifies the ground opacity.
  54643. * 1 by default.
  54644. */
  54645. groundOpacity: number;
  54646. /**
  54647. * Enables the ground to receive shadows.
  54648. * True by default.
  54649. */
  54650. enableGroundShadow: boolean;
  54651. /**
  54652. * Helps preventing the shadow to be fully black on the ground.
  54653. * 0.5 by default.
  54654. */
  54655. groundShadowLevel: number;
  54656. /**
  54657. * Creates a mirror texture attach to the ground.
  54658. * false by default.
  54659. */
  54660. enableGroundMirror: boolean;
  54661. /**
  54662. * Specifies the ground mirror size ratio.
  54663. * 0.3 by default as the default kernel is 64.
  54664. */
  54665. groundMirrorSizeRatio: number;
  54666. /**
  54667. * Specifies the ground mirror blur kernel size.
  54668. * 64 by default.
  54669. */
  54670. groundMirrorBlurKernel: number;
  54671. /**
  54672. * Specifies the ground mirror visibility amount.
  54673. * 1 by default
  54674. */
  54675. groundMirrorAmount: number;
  54676. /**
  54677. * Specifies the ground mirror reflectance weight.
  54678. * This uses the standard weight of the background material to setup the fresnel effect
  54679. * of the mirror.
  54680. * 1 by default.
  54681. */
  54682. groundMirrorFresnelWeight: number;
  54683. /**
  54684. * Specifies the ground mirror Falloff distance.
  54685. * This can helps reducing the size of the reflection.
  54686. * 0 by Default.
  54687. */
  54688. groundMirrorFallOffDistance: number;
  54689. /**
  54690. * Specifies the ground mirror texture type.
  54691. * Unsigned Int by Default.
  54692. */
  54693. groundMirrorTextureType: number;
  54694. /**
  54695. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54696. * the shown objects.
  54697. */
  54698. groundYBias: number;
  54699. /**
  54700. * Specifies whether or not to create a skybox.
  54701. * True by default.
  54702. */
  54703. createSkybox: boolean;
  54704. /**
  54705. * Specifies the skybox size.
  54706. * 20 by default.
  54707. */
  54708. skyboxSize: number;
  54709. /**
  54710. * The texture used on the skybox for the main color.
  54711. * Comes from the BabylonJS CDN by default.
  54712. *
  54713. * Remarks: Can be either a texture or a url.
  54714. */
  54715. skyboxTexture: string | BaseTexture;
  54716. /**
  54717. * The color mixed in the skybox texture by default.
  54718. * BabylonJS clearColor by default.
  54719. */
  54720. skyboxColor: Color3;
  54721. /**
  54722. * The background rotation around the Y axis of the scene.
  54723. * This helps aligning the key lights of your scene with the background.
  54724. * 0 by default.
  54725. */
  54726. backgroundYRotation: number;
  54727. /**
  54728. * Compute automatically the size of the elements to best fit with the scene.
  54729. */
  54730. sizeAuto: boolean;
  54731. /**
  54732. * Default position of the rootMesh if autoSize is not true.
  54733. */
  54734. rootPosition: Vector3;
  54735. /**
  54736. * Sets up the image processing in the scene.
  54737. * true by default.
  54738. */
  54739. setupImageProcessing: boolean;
  54740. /**
  54741. * The texture used as your environment texture in the scene.
  54742. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54743. *
  54744. * Remarks: Can be either a texture or a url.
  54745. */
  54746. environmentTexture: string | BaseTexture;
  54747. /**
  54748. * The value of the exposure to apply to the scene.
  54749. * 0.6 by default if setupImageProcessing is true.
  54750. */
  54751. cameraExposure: number;
  54752. /**
  54753. * The value of the contrast to apply to the scene.
  54754. * 1.6 by default if setupImageProcessing is true.
  54755. */
  54756. cameraContrast: number;
  54757. /**
  54758. * Specifies whether or not tonemapping should be enabled in the scene.
  54759. * true by default if setupImageProcessing is true.
  54760. */
  54761. toneMappingEnabled: boolean;
  54762. }
  54763. /**
  54764. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54765. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54766. * It also helps with the default setup of your imageProcessing configuration.
  54767. */
  54768. export class EnvironmentHelper {
  54769. /**
  54770. * Default ground texture URL.
  54771. */
  54772. private static _groundTextureCDNUrl;
  54773. /**
  54774. * Default skybox texture URL.
  54775. */
  54776. private static _skyboxTextureCDNUrl;
  54777. /**
  54778. * Default environment texture URL.
  54779. */
  54780. private static _environmentTextureCDNUrl;
  54781. /**
  54782. * Creates the default options for the helper.
  54783. */
  54784. private static _getDefaultOptions;
  54785. private _rootMesh;
  54786. /**
  54787. * Gets the root mesh created by the helper.
  54788. */
  54789. get rootMesh(): Mesh;
  54790. private _skybox;
  54791. /**
  54792. * Gets the skybox created by the helper.
  54793. */
  54794. get skybox(): Nullable<Mesh>;
  54795. private _skyboxTexture;
  54796. /**
  54797. * Gets the skybox texture created by the helper.
  54798. */
  54799. get skyboxTexture(): Nullable<BaseTexture>;
  54800. private _skyboxMaterial;
  54801. /**
  54802. * Gets the skybox material created by the helper.
  54803. */
  54804. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54805. private _ground;
  54806. /**
  54807. * Gets the ground mesh created by the helper.
  54808. */
  54809. get ground(): Nullable<Mesh>;
  54810. private _groundTexture;
  54811. /**
  54812. * Gets the ground texture created by the helper.
  54813. */
  54814. get groundTexture(): Nullable<BaseTexture>;
  54815. private _groundMirror;
  54816. /**
  54817. * Gets the ground mirror created by the helper.
  54818. */
  54819. get groundMirror(): Nullable<MirrorTexture>;
  54820. /**
  54821. * Gets the ground mirror render list to helps pushing the meshes
  54822. * you wish in the ground reflection.
  54823. */
  54824. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54825. private _groundMaterial;
  54826. /**
  54827. * Gets the ground material created by the helper.
  54828. */
  54829. get groundMaterial(): Nullable<BackgroundMaterial>;
  54830. /**
  54831. * Stores the creation options.
  54832. */
  54833. private readonly _scene;
  54834. private _options;
  54835. /**
  54836. * This observable will be notified with any error during the creation of the environment,
  54837. * mainly texture creation errors.
  54838. */
  54839. onErrorObservable: Observable<{
  54840. message?: string;
  54841. exception?: any;
  54842. }>;
  54843. /**
  54844. * constructor
  54845. * @param options Defines the options we want to customize the helper
  54846. * @param scene The scene to add the material to
  54847. */
  54848. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54849. /**
  54850. * Updates the background according to the new options
  54851. * @param options
  54852. */
  54853. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54854. /**
  54855. * Sets the primary color of all the available elements.
  54856. * @param color the main color to affect to the ground and the background
  54857. */
  54858. setMainColor(color: Color3): void;
  54859. /**
  54860. * Setup the image processing according to the specified options.
  54861. */
  54862. private _setupImageProcessing;
  54863. /**
  54864. * Setup the environment texture according to the specified options.
  54865. */
  54866. private _setupEnvironmentTexture;
  54867. /**
  54868. * Setup the background according to the specified options.
  54869. */
  54870. private _setupBackground;
  54871. /**
  54872. * Get the scene sizes according to the setup.
  54873. */
  54874. private _getSceneSize;
  54875. /**
  54876. * Setup the ground according to the specified options.
  54877. */
  54878. private _setupGround;
  54879. /**
  54880. * Setup the ground material according to the specified options.
  54881. */
  54882. private _setupGroundMaterial;
  54883. /**
  54884. * Setup the ground diffuse texture according to the specified options.
  54885. */
  54886. private _setupGroundDiffuseTexture;
  54887. /**
  54888. * Setup the ground mirror texture according to the specified options.
  54889. */
  54890. private _setupGroundMirrorTexture;
  54891. /**
  54892. * Setup the ground to receive the mirror texture.
  54893. */
  54894. private _setupMirrorInGroundMaterial;
  54895. /**
  54896. * Setup the skybox according to the specified options.
  54897. */
  54898. private _setupSkybox;
  54899. /**
  54900. * Setup the skybox material according to the specified options.
  54901. */
  54902. private _setupSkyboxMaterial;
  54903. /**
  54904. * Setup the skybox reflection texture according to the specified options.
  54905. */
  54906. private _setupSkyboxReflectionTexture;
  54907. private _errorHandler;
  54908. /**
  54909. * Dispose all the elements created by the Helper.
  54910. */
  54911. dispose(): void;
  54912. }
  54913. }
  54914. declare module BABYLON {
  54915. /**
  54916. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  54917. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  54918. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  54919. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54920. */
  54921. export abstract class TextureDome<T extends Texture> extends TransformNode {
  54922. protected onError: Nullable<(message?: string, exception?: any) => void>;
  54923. /**
  54924. * Define the source as a Monoscopic panoramic 360/180.
  54925. */
  54926. static readonly MODE_MONOSCOPIC: number;
  54927. /**
  54928. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  54929. */
  54930. static readonly MODE_TOPBOTTOM: number;
  54931. /**
  54932. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  54933. */
  54934. static readonly MODE_SIDEBYSIDE: number;
  54935. private _halfDome;
  54936. protected _useDirectMapping: boolean;
  54937. /**
  54938. * The texture being displayed on the sphere
  54939. */
  54940. protected _texture: T;
  54941. /**
  54942. * Gets the texture being displayed on the sphere
  54943. */
  54944. get texture(): T;
  54945. /**
  54946. * Sets the texture being displayed on the sphere
  54947. */
  54948. set texture(newTexture: T);
  54949. /**
  54950. * The skybox material
  54951. */
  54952. protected _material: BackgroundMaterial;
  54953. /**
  54954. * The surface used for the dome
  54955. */
  54956. protected _mesh: Mesh;
  54957. /**
  54958. * Gets the mesh used for the dome.
  54959. */
  54960. get mesh(): Mesh;
  54961. /**
  54962. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  54963. */
  54964. private _halfDomeMask;
  54965. /**
  54966. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54967. * Also see the options.resolution property.
  54968. */
  54969. get fovMultiplier(): number;
  54970. set fovMultiplier(value: number);
  54971. protected _textureMode: number;
  54972. /**
  54973. * Gets or set the current texture mode for the texture. It can be:
  54974. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  54975. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  54976. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  54977. */
  54978. get textureMode(): number;
  54979. /**
  54980. * Sets the current texture mode for the texture. It can be:
  54981. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  54982. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  54983. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  54984. */
  54985. set textureMode(value: number);
  54986. /**
  54987. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  54988. */
  54989. get halfDome(): boolean;
  54990. /**
  54991. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54992. */
  54993. set halfDome(enabled: boolean);
  54994. /**
  54995. * Oberserver used in Stereoscopic VR Mode.
  54996. */
  54997. private _onBeforeCameraRenderObserver;
  54998. /**
  54999. * Observable raised when an error occured while loading the 360 image
  55000. */
  55001. onLoadErrorObservable: Observable<string>;
  55002. /**
  55003. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  55004. * @param name Element's name, child elements will append suffixes for their own names.
  55005. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  55006. * @param options An object containing optional or exposed sub element properties
  55007. */
  55008. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  55009. resolution?: number;
  55010. clickToPlay?: boolean;
  55011. autoPlay?: boolean;
  55012. loop?: boolean;
  55013. size?: number;
  55014. poster?: string;
  55015. faceForward?: boolean;
  55016. useDirectMapping?: boolean;
  55017. halfDomeMode?: boolean;
  55018. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55019. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  55020. protected _changeTextureMode(value: number): void;
  55021. /**
  55022. * Releases resources associated with this node.
  55023. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55024. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55025. */
  55026. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55027. }
  55028. }
  55029. declare module BABYLON {
  55030. /**
  55031. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55032. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55033. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55034. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55035. */
  55036. export class PhotoDome extends TextureDome<Texture> {
  55037. /**
  55038. * Define the image as a Monoscopic panoramic 360 image.
  55039. */
  55040. static readonly MODE_MONOSCOPIC: number;
  55041. /**
  55042. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55043. */
  55044. static readonly MODE_TOPBOTTOM: number;
  55045. /**
  55046. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55047. */
  55048. static readonly MODE_SIDEBYSIDE: number;
  55049. /**
  55050. * Gets or sets the texture being displayed on the sphere
  55051. */
  55052. get photoTexture(): Texture;
  55053. /**
  55054. * sets the texture being displayed on the sphere
  55055. */
  55056. set photoTexture(value: Texture);
  55057. /**
  55058. * Gets the current video mode for the video. It can be:
  55059. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55060. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55061. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55062. */
  55063. get imageMode(): number;
  55064. /**
  55065. * Sets the current video mode for the video. It can be:
  55066. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55067. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55068. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55069. */
  55070. set imageMode(value: number);
  55071. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  55072. }
  55073. }
  55074. declare module BABYLON {
  55075. /**
  55076. * Class used to host RGBD texture specific utilities
  55077. */
  55078. export class RGBDTextureTools {
  55079. /**
  55080. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55081. * @param texture the texture to expand.
  55082. */
  55083. static ExpandRGBDTexture(texture: Texture): void;
  55084. }
  55085. }
  55086. declare module BABYLON {
  55087. /**
  55088. * Class used to host texture specific utilities
  55089. */
  55090. export class BRDFTextureTools {
  55091. /**
  55092. * Prevents texture cache collision
  55093. */
  55094. private static _instanceNumber;
  55095. /**
  55096. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55097. * @param scene defines the hosting scene
  55098. * @returns the environment BRDF texture
  55099. */
  55100. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55101. private static _environmentBRDFBase64Texture;
  55102. }
  55103. }
  55104. declare module BABYLON {
  55105. /**
  55106. * @hidden
  55107. */
  55108. export interface IMaterialClearCoatDefines {
  55109. CLEARCOAT: boolean;
  55110. CLEARCOAT_DEFAULTIOR: boolean;
  55111. CLEARCOAT_TEXTURE: boolean;
  55112. CLEARCOAT_TEXTUREDIRECTUV: number;
  55113. CLEARCOAT_BUMP: boolean;
  55114. CLEARCOAT_BUMPDIRECTUV: number;
  55115. CLEARCOAT_TINT: boolean;
  55116. CLEARCOAT_TINT_TEXTURE: boolean;
  55117. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55118. /** @hidden */
  55119. _areTexturesDirty: boolean;
  55120. }
  55121. /**
  55122. * Define the code related to the clear coat parameters of the pbr material.
  55123. */
  55124. export class PBRClearCoatConfiguration {
  55125. /**
  55126. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55127. * The default fits with a polyurethane material.
  55128. */
  55129. private static readonly _DefaultIndexOfRefraction;
  55130. private _isEnabled;
  55131. /**
  55132. * Defines if the clear coat is enabled in the material.
  55133. */
  55134. isEnabled: boolean;
  55135. /**
  55136. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55137. */
  55138. intensity: number;
  55139. /**
  55140. * Defines the clear coat layer roughness.
  55141. */
  55142. roughness: number;
  55143. private _indexOfRefraction;
  55144. /**
  55145. * Defines the index of refraction of the clear coat.
  55146. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55147. * The default fits with a polyurethane material.
  55148. * Changing the default value is more performance intensive.
  55149. */
  55150. indexOfRefraction: number;
  55151. private _texture;
  55152. /**
  55153. * Stores the clear coat values in a texture.
  55154. */
  55155. texture: Nullable<BaseTexture>;
  55156. private _bumpTexture;
  55157. /**
  55158. * Define the clear coat specific bump texture.
  55159. */
  55160. bumpTexture: Nullable<BaseTexture>;
  55161. private _isTintEnabled;
  55162. /**
  55163. * Defines if the clear coat tint is enabled in the material.
  55164. */
  55165. isTintEnabled: boolean;
  55166. /**
  55167. * Defines the clear coat tint of the material.
  55168. * This is only use if tint is enabled
  55169. */
  55170. tintColor: Color3;
  55171. /**
  55172. * Defines the distance at which the tint color should be found in the
  55173. * clear coat media.
  55174. * This is only use if tint is enabled
  55175. */
  55176. tintColorAtDistance: number;
  55177. /**
  55178. * Defines the clear coat layer thickness.
  55179. * This is only use if tint is enabled
  55180. */
  55181. tintThickness: number;
  55182. private _tintTexture;
  55183. /**
  55184. * Stores the clear tint values in a texture.
  55185. * rgb is tint
  55186. * a is a thickness factor
  55187. */
  55188. tintTexture: Nullable<BaseTexture>;
  55189. /** @hidden */
  55190. private _internalMarkAllSubMeshesAsTexturesDirty;
  55191. /** @hidden */
  55192. _markAllSubMeshesAsTexturesDirty(): void;
  55193. /**
  55194. * Instantiate a new istance of clear coat configuration.
  55195. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55196. */
  55197. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55198. /**
  55199. * Gets wehter the submesh is ready to be used or not.
  55200. * @param defines the list of "defines" to update.
  55201. * @param scene defines the scene the material belongs to.
  55202. * @param engine defines the engine the material belongs to.
  55203. * @param disableBumpMap defines wether the material disables bump or not.
  55204. * @returns - boolean indicating that the submesh is ready or not.
  55205. */
  55206. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55207. /**
  55208. * Checks to see if a texture is used in the material.
  55209. * @param defines the list of "defines" to update.
  55210. * @param scene defines the scene to the material belongs to.
  55211. */
  55212. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55213. /**
  55214. * Binds the material data.
  55215. * @param uniformBuffer defines the Uniform buffer to fill in.
  55216. * @param scene defines the scene the material belongs to.
  55217. * @param engine defines the engine the material belongs to.
  55218. * @param disableBumpMap defines wether the material disables bump or not.
  55219. * @param isFrozen defines wether the material is frozen or not.
  55220. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55221. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55222. */
  55223. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55224. /**
  55225. * Checks to see if a texture is used in the material.
  55226. * @param texture - Base texture to use.
  55227. * @returns - Boolean specifying if a texture is used in the material.
  55228. */
  55229. hasTexture(texture: BaseTexture): boolean;
  55230. /**
  55231. * Returns an array of the actively used textures.
  55232. * @param activeTextures Array of BaseTextures
  55233. */
  55234. getActiveTextures(activeTextures: BaseTexture[]): void;
  55235. /**
  55236. * Returns the animatable textures.
  55237. * @param animatables Array of animatable textures.
  55238. */
  55239. getAnimatables(animatables: IAnimatable[]): void;
  55240. /**
  55241. * Disposes the resources of the material.
  55242. * @param forceDisposeTextures - Forces the disposal of all textures.
  55243. */
  55244. dispose(forceDisposeTextures?: boolean): void;
  55245. /**
  55246. * Get the current class name of the texture useful for serialization or dynamic coding.
  55247. * @returns "PBRClearCoatConfiguration"
  55248. */
  55249. getClassName(): string;
  55250. /**
  55251. * Add fallbacks to the effect fallbacks list.
  55252. * @param defines defines the Base texture to use.
  55253. * @param fallbacks defines the current fallback list.
  55254. * @param currentRank defines the current fallback rank.
  55255. * @returns the new fallback rank.
  55256. */
  55257. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55258. /**
  55259. * Add the required uniforms to the current list.
  55260. * @param uniforms defines the current uniform list.
  55261. */
  55262. static AddUniforms(uniforms: string[]): void;
  55263. /**
  55264. * Add the required samplers to the current list.
  55265. * @param samplers defines the current sampler list.
  55266. */
  55267. static AddSamplers(samplers: string[]): void;
  55268. /**
  55269. * Add the required uniforms to the current buffer.
  55270. * @param uniformBuffer defines the current uniform buffer.
  55271. */
  55272. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55273. /**
  55274. * Makes a duplicate of the current configuration into another one.
  55275. * @param clearCoatConfiguration define the config where to copy the info
  55276. */
  55277. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55278. /**
  55279. * Serializes this clear coat configuration.
  55280. * @returns - An object with the serialized config.
  55281. */
  55282. serialize(): any;
  55283. /**
  55284. * Parses a anisotropy Configuration from a serialized object.
  55285. * @param source - Serialized object.
  55286. * @param scene Defines the scene we are parsing for
  55287. * @param rootUrl Defines the rootUrl to load from
  55288. */
  55289. parse(source: any, scene: Scene, rootUrl: string): void;
  55290. }
  55291. }
  55292. declare module BABYLON {
  55293. /**
  55294. * @hidden
  55295. */
  55296. export interface IMaterialAnisotropicDefines {
  55297. ANISOTROPIC: boolean;
  55298. ANISOTROPIC_TEXTURE: boolean;
  55299. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55300. MAINUV1: boolean;
  55301. _areTexturesDirty: boolean;
  55302. _needUVs: boolean;
  55303. }
  55304. /**
  55305. * Define the code related to the anisotropic parameters of the pbr material.
  55306. */
  55307. export class PBRAnisotropicConfiguration {
  55308. private _isEnabled;
  55309. /**
  55310. * Defines if the anisotropy is enabled in the material.
  55311. */
  55312. isEnabled: boolean;
  55313. /**
  55314. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55315. */
  55316. intensity: number;
  55317. /**
  55318. * Defines if the effect is along the tangents, bitangents or in between.
  55319. * By default, the effect is "strectching" the highlights along the tangents.
  55320. */
  55321. direction: Vector2;
  55322. private _texture;
  55323. /**
  55324. * Stores the anisotropy values in a texture.
  55325. * rg is direction (like normal from -1 to 1)
  55326. * b is a intensity
  55327. */
  55328. texture: Nullable<BaseTexture>;
  55329. /** @hidden */
  55330. private _internalMarkAllSubMeshesAsTexturesDirty;
  55331. /** @hidden */
  55332. _markAllSubMeshesAsTexturesDirty(): void;
  55333. /**
  55334. * Instantiate a new istance of anisotropy configuration.
  55335. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55336. */
  55337. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55338. /**
  55339. * Specifies that the submesh is ready to be used.
  55340. * @param defines the list of "defines" to update.
  55341. * @param scene defines the scene the material belongs to.
  55342. * @returns - boolean indicating that the submesh is ready or not.
  55343. */
  55344. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55345. /**
  55346. * Checks to see if a texture is used in the material.
  55347. * @param defines the list of "defines" to update.
  55348. * @param mesh the mesh we are preparing the defines for.
  55349. * @param scene defines the scene the material belongs to.
  55350. */
  55351. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55352. /**
  55353. * Binds the material data.
  55354. * @param uniformBuffer defines the Uniform buffer to fill in.
  55355. * @param scene defines the scene the material belongs to.
  55356. * @param isFrozen defines wether the material is frozen or not.
  55357. */
  55358. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55359. /**
  55360. * Checks to see if a texture is used in the material.
  55361. * @param texture - Base texture to use.
  55362. * @returns - Boolean specifying if a texture is used in the material.
  55363. */
  55364. hasTexture(texture: BaseTexture): boolean;
  55365. /**
  55366. * Returns an array of the actively used textures.
  55367. * @param activeTextures Array of BaseTextures
  55368. */
  55369. getActiveTextures(activeTextures: BaseTexture[]): void;
  55370. /**
  55371. * Returns the animatable textures.
  55372. * @param animatables Array of animatable textures.
  55373. */
  55374. getAnimatables(animatables: IAnimatable[]): void;
  55375. /**
  55376. * Disposes the resources of the material.
  55377. * @param forceDisposeTextures - Forces the disposal of all textures.
  55378. */
  55379. dispose(forceDisposeTextures?: boolean): void;
  55380. /**
  55381. * Get the current class name of the texture useful for serialization or dynamic coding.
  55382. * @returns "PBRAnisotropicConfiguration"
  55383. */
  55384. getClassName(): string;
  55385. /**
  55386. * Add fallbacks to the effect fallbacks list.
  55387. * @param defines defines the Base texture to use.
  55388. * @param fallbacks defines the current fallback list.
  55389. * @param currentRank defines the current fallback rank.
  55390. * @returns the new fallback rank.
  55391. */
  55392. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55393. /**
  55394. * Add the required uniforms to the current list.
  55395. * @param uniforms defines the current uniform list.
  55396. */
  55397. static AddUniforms(uniforms: string[]): void;
  55398. /**
  55399. * Add the required uniforms to the current buffer.
  55400. * @param uniformBuffer defines the current uniform buffer.
  55401. */
  55402. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55403. /**
  55404. * Add the required samplers to the current list.
  55405. * @param samplers defines the current sampler list.
  55406. */
  55407. static AddSamplers(samplers: string[]): void;
  55408. /**
  55409. * Makes a duplicate of the current configuration into another one.
  55410. * @param anisotropicConfiguration define the config where to copy the info
  55411. */
  55412. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55413. /**
  55414. * Serializes this anisotropy configuration.
  55415. * @returns - An object with the serialized config.
  55416. */
  55417. serialize(): any;
  55418. /**
  55419. * Parses a anisotropy Configuration from a serialized object.
  55420. * @param source - Serialized object.
  55421. * @param scene Defines the scene we are parsing for
  55422. * @param rootUrl Defines the rootUrl to load from
  55423. */
  55424. parse(source: any, scene: Scene, rootUrl: string): void;
  55425. }
  55426. }
  55427. declare module BABYLON {
  55428. /**
  55429. * @hidden
  55430. */
  55431. export interface IMaterialBRDFDefines {
  55432. BRDF_V_HEIGHT_CORRELATED: boolean;
  55433. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55434. SPHERICAL_HARMONICS: boolean;
  55435. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55436. /** @hidden */
  55437. _areMiscDirty: boolean;
  55438. }
  55439. /**
  55440. * Define the code related to the BRDF parameters of the pbr material.
  55441. */
  55442. export class PBRBRDFConfiguration {
  55443. /**
  55444. * Default value used for the energy conservation.
  55445. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55446. */
  55447. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55448. /**
  55449. * Default value used for the Smith Visibility Height Correlated mode.
  55450. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55451. */
  55452. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55453. /**
  55454. * Default value used for the IBL diffuse part.
  55455. * This can help switching back to the polynomials mode globally which is a tiny bit
  55456. * less GPU intensive at the drawback of a lower quality.
  55457. */
  55458. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55459. /**
  55460. * Default value used for activating energy conservation for the specular workflow.
  55461. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55462. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55463. */
  55464. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55465. private _useEnergyConservation;
  55466. /**
  55467. * Defines if the material uses energy conservation.
  55468. */
  55469. useEnergyConservation: boolean;
  55470. private _useSmithVisibilityHeightCorrelated;
  55471. /**
  55472. * LEGACY Mode set to false
  55473. * Defines if the material uses height smith correlated visibility term.
  55474. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55475. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55476. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55477. * Not relying on height correlated will also disable energy conservation.
  55478. */
  55479. useSmithVisibilityHeightCorrelated: boolean;
  55480. private _useSphericalHarmonics;
  55481. /**
  55482. * LEGACY Mode set to false
  55483. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55484. * diffuse part of the IBL.
  55485. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55486. * to the ground truth.
  55487. */
  55488. useSphericalHarmonics: boolean;
  55489. private _useSpecularGlossinessInputEnergyConservation;
  55490. /**
  55491. * Defines if the material uses energy conservation, when the specular workflow is active.
  55492. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55493. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55494. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55495. */
  55496. useSpecularGlossinessInputEnergyConservation: boolean;
  55497. /** @hidden */
  55498. private _internalMarkAllSubMeshesAsMiscDirty;
  55499. /** @hidden */
  55500. _markAllSubMeshesAsMiscDirty(): void;
  55501. /**
  55502. * Instantiate a new istance of clear coat configuration.
  55503. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55504. */
  55505. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55506. /**
  55507. * Checks to see if a texture is used in the material.
  55508. * @param defines the list of "defines" to update.
  55509. */
  55510. prepareDefines(defines: IMaterialBRDFDefines): void;
  55511. /**
  55512. * Get the current class name of the texture useful for serialization or dynamic coding.
  55513. * @returns "PBRClearCoatConfiguration"
  55514. */
  55515. getClassName(): string;
  55516. /**
  55517. * Makes a duplicate of the current configuration into another one.
  55518. * @param brdfConfiguration define the config where to copy the info
  55519. */
  55520. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55521. /**
  55522. * Serializes this BRDF configuration.
  55523. * @returns - An object with the serialized config.
  55524. */
  55525. serialize(): any;
  55526. /**
  55527. * Parses a anisotropy Configuration from a serialized object.
  55528. * @param source - Serialized object.
  55529. * @param scene Defines the scene we are parsing for
  55530. * @param rootUrl Defines the rootUrl to load from
  55531. */
  55532. parse(source: any, scene: Scene, rootUrl: string): void;
  55533. }
  55534. }
  55535. declare module BABYLON {
  55536. /**
  55537. * @hidden
  55538. */
  55539. export interface IMaterialSheenDefines {
  55540. SHEEN: boolean;
  55541. SHEEN_TEXTURE: boolean;
  55542. SHEEN_TEXTUREDIRECTUV: number;
  55543. SHEEN_LINKWITHALBEDO: boolean;
  55544. SHEEN_ROUGHNESS: boolean;
  55545. SHEEN_ALBEDOSCALING: boolean;
  55546. /** @hidden */
  55547. _areTexturesDirty: boolean;
  55548. }
  55549. /**
  55550. * Define the code related to the Sheen parameters of the pbr material.
  55551. */
  55552. export class PBRSheenConfiguration {
  55553. private _isEnabled;
  55554. /**
  55555. * Defines if the material uses sheen.
  55556. */
  55557. isEnabled: boolean;
  55558. private _linkSheenWithAlbedo;
  55559. /**
  55560. * Defines if the sheen is linked to the sheen color.
  55561. */
  55562. linkSheenWithAlbedo: boolean;
  55563. /**
  55564. * Defines the sheen intensity.
  55565. */
  55566. intensity: number;
  55567. /**
  55568. * Defines the sheen color.
  55569. */
  55570. color: Color3;
  55571. private _texture;
  55572. /**
  55573. * Stores the sheen tint values in a texture.
  55574. * rgb is tint
  55575. * a is a intensity or roughness if roughness has been defined
  55576. */
  55577. texture: Nullable<BaseTexture>;
  55578. private _roughness;
  55579. /**
  55580. * Defines the sheen roughness.
  55581. * It is not taken into account if linkSheenWithAlbedo is true.
  55582. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55583. */
  55584. roughness: Nullable<number>;
  55585. private _albedoScaling;
  55586. /**
  55587. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55588. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55589. * making it easier to setup and tweak the effect
  55590. */
  55591. albedoScaling: boolean;
  55592. /** @hidden */
  55593. private _internalMarkAllSubMeshesAsTexturesDirty;
  55594. /** @hidden */
  55595. _markAllSubMeshesAsTexturesDirty(): void;
  55596. /**
  55597. * Instantiate a new istance of clear coat configuration.
  55598. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55599. */
  55600. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55601. /**
  55602. * Specifies that the submesh is ready to be used.
  55603. * @param defines the list of "defines" to update.
  55604. * @param scene defines the scene the material belongs to.
  55605. * @returns - boolean indicating that the submesh is ready or not.
  55606. */
  55607. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55608. /**
  55609. * Checks to see if a texture is used in the material.
  55610. * @param defines the list of "defines" to update.
  55611. * @param scene defines the scene the material belongs to.
  55612. */
  55613. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55614. /**
  55615. * Binds the material data.
  55616. * @param uniformBuffer defines the Uniform buffer to fill in.
  55617. * @param scene defines the scene the material belongs to.
  55618. * @param isFrozen defines wether the material is frozen or not.
  55619. */
  55620. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55621. /**
  55622. * Checks to see if a texture is used in the material.
  55623. * @param texture - Base texture to use.
  55624. * @returns - Boolean specifying if a texture is used in the material.
  55625. */
  55626. hasTexture(texture: BaseTexture): boolean;
  55627. /**
  55628. * Returns an array of the actively used textures.
  55629. * @param activeTextures Array of BaseTextures
  55630. */
  55631. getActiveTextures(activeTextures: BaseTexture[]): void;
  55632. /**
  55633. * Returns the animatable textures.
  55634. * @param animatables Array of animatable textures.
  55635. */
  55636. getAnimatables(animatables: IAnimatable[]): void;
  55637. /**
  55638. * Disposes the resources of the material.
  55639. * @param forceDisposeTextures - Forces the disposal of all textures.
  55640. */
  55641. dispose(forceDisposeTextures?: boolean): void;
  55642. /**
  55643. * Get the current class name of the texture useful for serialization or dynamic coding.
  55644. * @returns "PBRSheenConfiguration"
  55645. */
  55646. getClassName(): string;
  55647. /**
  55648. * Add fallbacks to the effect fallbacks list.
  55649. * @param defines defines the Base texture to use.
  55650. * @param fallbacks defines the current fallback list.
  55651. * @param currentRank defines the current fallback rank.
  55652. * @returns the new fallback rank.
  55653. */
  55654. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55655. /**
  55656. * Add the required uniforms to the current list.
  55657. * @param uniforms defines the current uniform list.
  55658. */
  55659. static AddUniforms(uniforms: string[]): void;
  55660. /**
  55661. * Add the required uniforms to the current buffer.
  55662. * @param uniformBuffer defines the current uniform buffer.
  55663. */
  55664. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55665. /**
  55666. * Add the required samplers to the current list.
  55667. * @param samplers defines the current sampler list.
  55668. */
  55669. static AddSamplers(samplers: string[]): void;
  55670. /**
  55671. * Makes a duplicate of the current configuration into another one.
  55672. * @param sheenConfiguration define the config where to copy the info
  55673. */
  55674. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55675. /**
  55676. * Serializes this BRDF configuration.
  55677. * @returns - An object with the serialized config.
  55678. */
  55679. serialize(): any;
  55680. /**
  55681. * Parses a anisotropy Configuration from a serialized object.
  55682. * @param source - Serialized object.
  55683. * @param scene Defines the scene we are parsing for
  55684. * @param rootUrl Defines the rootUrl to load from
  55685. */
  55686. parse(source: any, scene: Scene, rootUrl: string): void;
  55687. }
  55688. }
  55689. declare module BABYLON {
  55690. /**
  55691. * @hidden
  55692. */
  55693. export interface IMaterialSubSurfaceDefines {
  55694. SUBSURFACE: boolean;
  55695. SS_REFRACTION: boolean;
  55696. SS_TRANSLUCENCY: boolean;
  55697. SS_SCATTERING: boolean;
  55698. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55699. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55700. SS_REFRACTIONMAP_3D: boolean;
  55701. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55702. SS_LODINREFRACTIONALPHA: boolean;
  55703. SS_GAMMAREFRACTION: boolean;
  55704. SS_RGBDREFRACTION: boolean;
  55705. SS_LINEARSPECULARREFRACTION: boolean;
  55706. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55707. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55708. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55709. /** @hidden */
  55710. _areTexturesDirty: boolean;
  55711. }
  55712. /**
  55713. * Define the code related to the sub surface parameters of the pbr material.
  55714. */
  55715. export class PBRSubSurfaceConfiguration {
  55716. private _isRefractionEnabled;
  55717. /**
  55718. * Defines if the refraction is enabled in the material.
  55719. */
  55720. isRefractionEnabled: boolean;
  55721. private _isTranslucencyEnabled;
  55722. /**
  55723. * Defines if the translucency is enabled in the material.
  55724. */
  55725. isTranslucencyEnabled: boolean;
  55726. private _isScatteringEnabled;
  55727. /**
  55728. * Defines if the sub surface scattering is enabled in the material.
  55729. */
  55730. isScatteringEnabled: boolean;
  55731. private _scatteringDiffusionProfileIndex;
  55732. /**
  55733. * Diffusion profile for subsurface scattering.
  55734. * Useful for better scattering in the skins or foliages.
  55735. */
  55736. get scatteringDiffusionProfile(): Nullable<Color3>;
  55737. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55738. /**
  55739. * Defines the refraction intensity of the material.
  55740. * The refraction when enabled replaces the Diffuse part of the material.
  55741. * The intensity helps transitionning between diffuse and refraction.
  55742. */
  55743. refractionIntensity: number;
  55744. /**
  55745. * Defines the translucency intensity of the material.
  55746. * When translucency has been enabled, this defines how much of the "translucency"
  55747. * is addded to the diffuse part of the material.
  55748. */
  55749. translucencyIntensity: number;
  55750. /**
  55751. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55752. */
  55753. useAlbedoToTintRefraction: boolean;
  55754. private _thicknessTexture;
  55755. /**
  55756. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55757. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55758. * 0 would mean minimumThickness
  55759. * 1 would mean maximumThickness
  55760. * The other channels might be use as a mask to vary the different effects intensity.
  55761. */
  55762. thicknessTexture: Nullable<BaseTexture>;
  55763. private _refractionTexture;
  55764. /**
  55765. * Defines the texture to use for refraction.
  55766. */
  55767. refractionTexture: Nullable<BaseTexture>;
  55768. private _indexOfRefraction;
  55769. /**
  55770. * Index of refraction of the material base layer.
  55771. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55772. *
  55773. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55774. *
  55775. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55776. */
  55777. indexOfRefraction: number;
  55778. private _volumeIndexOfRefraction;
  55779. /**
  55780. * Index of refraction of the material's volume.
  55781. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55782. *
  55783. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55784. * the volume will use the same IOR as the surface.
  55785. */
  55786. get volumeIndexOfRefraction(): number;
  55787. set volumeIndexOfRefraction(value: number);
  55788. private _invertRefractionY;
  55789. /**
  55790. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55791. */
  55792. invertRefractionY: boolean;
  55793. private _linkRefractionWithTransparency;
  55794. /**
  55795. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55796. * Materials half opaque for instance using refraction could benefit from this control.
  55797. */
  55798. linkRefractionWithTransparency: boolean;
  55799. /**
  55800. * Defines the minimum thickness stored in the thickness map.
  55801. * If no thickness map is defined, this value will be used to simulate thickness.
  55802. */
  55803. minimumThickness: number;
  55804. /**
  55805. * Defines the maximum thickness stored in the thickness map.
  55806. */
  55807. maximumThickness: number;
  55808. /**
  55809. * Defines the volume tint of the material.
  55810. * This is used for both translucency and scattering.
  55811. */
  55812. tintColor: Color3;
  55813. /**
  55814. * Defines the distance at which the tint color should be found in the media.
  55815. * This is used for refraction only.
  55816. */
  55817. tintColorAtDistance: number;
  55818. /**
  55819. * Defines how far each channel transmit through the media.
  55820. * It is defined as a color to simplify it selection.
  55821. */
  55822. diffusionDistance: Color3;
  55823. private _useMaskFromThicknessTexture;
  55824. /**
  55825. * Stores the intensity of the different subsurface effects in the thickness texture.
  55826. * * the green channel is the translucency intensity.
  55827. * * the blue channel is the scattering intensity.
  55828. * * the alpha channel is the refraction intensity.
  55829. */
  55830. useMaskFromThicknessTexture: boolean;
  55831. private _scene;
  55832. /** @hidden */
  55833. private _internalMarkAllSubMeshesAsTexturesDirty;
  55834. private _internalMarkScenePrePassDirty;
  55835. /** @hidden */
  55836. _markAllSubMeshesAsTexturesDirty(): void;
  55837. /** @hidden */
  55838. _markScenePrePassDirty(): void;
  55839. /**
  55840. * Instantiate a new istance of sub surface configuration.
  55841. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55842. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55843. * @param scene The scene
  55844. */
  55845. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55846. /**
  55847. * Gets wehter the submesh is ready to be used or not.
  55848. * @param defines the list of "defines" to update.
  55849. * @param scene defines the scene the material belongs to.
  55850. * @returns - boolean indicating that the submesh is ready or not.
  55851. */
  55852. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55853. /**
  55854. * Checks to see if a texture is used in the material.
  55855. * @param defines the list of "defines" to update.
  55856. * @param scene defines the scene to the material belongs to.
  55857. */
  55858. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55859. /**
  55860. * Binds the material data.
  55861. * @param uniformBuffer defines the Uniform buffer to fill in.
  55862. * @param scene defines the scene the material belongs to.
  55863. * @param engine defines the engine the material belongs to.
  55864. * @param isFrozen defines whether the material is frozen or not.
  55865. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55866. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55867. */
  55868. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55869. /**
  55870. * Unbinds the material from the mesh.
  55871. * @param activeEffect defines the effect that should be unbound from.
  55872. * @returns true if unbound, otherwise false
  55873. */
  55874. unbind(activeEffect: Effect): boolean;
  55875. /**
  55876. * Returns the texture used for refraction or null if none is used.
  55877. * @param scene defines the scene the material belongs to.
  55878. * @returns - Refraction texture if present. If no refraction texture and refraction
  55879. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55880. */
  55881. private _getRefractionTexture;
  55882. /**
  55883. * Returns true if alpha blending should be disabled.
  55884. */
  55885. get disableAlphaBlending(): boolean;
  55886. /**
  55887. * Fills the list of render target textures.
  55888. * @param renderTargets the list of render targets to update
  55889. */
  55890. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55891. /**
  55892. * Checks to see if a texture is used in the material.
  55893. * @param texture - Base texture to use.
  55894. * @returns - Boolean specifying if a texture is used in the material.
  55895. */
  55896. hasTexture(texture: BaseTexture): boolean;
  55897. /**
  55898. * Gets a boolean indicating that current material needs to register RTT
  55899. * @returns true if this uses a render target otherwise false.
  55900. */
  55901. hasRenderTargetTextures(): boolean;
  55902. /**
  55903. * Returns an array of the actively used textures.
  55904. * @param activeTextures Array of BaseTextures
  55905. */
  55906. getActiveTextures(activeTextures: BaseTexture[]): void;
  55907. /**
  55908. * Returns the animatable textures.
  55909. * @param animatables Array of animatable textures.
  55910. */
  55911. getAnimatables(animatables: IAnimatable[]): void;
  55912. /**
  55913. * Disposes the resources of the material.
  55914. * @param forceDisposeTextures - Forces the disposal of all textures.
  55915. */
  55916. dispose(forceDisposeTextures?: boolean): void;
  55917. /**
  55918. * Get the current class name of the texture useful for serialization or dynamic coding.
  55919. * @returns "PBRSubSurfaceConfiguration"
  55920. */
  55921. getClassName(): string;
  55922. /**
  55923. * Add fallbacks to the effect fallbacks list.
  55924. * @param defines defines the Base texture to use.
  55925. * @param fallbacks defines the current fallback list.
  55926. * @param currentRank defines the current fallback rank.
  55927. * @returns the new fallback rank.
  55928. */
  55929. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55930. /**
  55931. * Add the required uniforms to the current list.
  55932. * @param uniforms defines the current uniform list.
  55933. */
  55934. static AddUniforms(uniforms: string[]): void;
  55935. /**
  55936. * Add the required samplers to the current list.
  55937. * @param samplers defines the current sampler list.
  55938. */
  55939. static AddSamplers(samplers: string[]): void;
  55940. /**
  55941. * Add the required uniforms to the current buffer.
  55942. * @param uniformBuffer defines the current uniform buffer.
  55943. */
  55944. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55945. /**
  55946. * Makes a duplicate of the current configuration into another one.
  55947. * @param configuration define the config where to copy the info
  55948. */
  55949. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  55950. /**
  55951. * Serializes this Sub Surface configuration.
  55952. * @returns - An object with the serialized config.
  55953. */
  55954. serialize(): any;
  55955. /**
  55956. * Parses a anisotropy Configuration from a serialized object.
  55957. * @param source - Serialized object.
  55958. * @param scene Defines the scene we are parsing for
  55959. * @param rootUrl Defines the rootUrl to load from
  55960. */
  55961. parse(source: any, scene: Scene, rootUrl: string): void;
  55962. }
  55963. }
  55964. declare module BABYLON {
  55965. /** @hidden */
  55966. export var pbrFragmentDeclaration: {
  55967. name: string;
  55968. shader: string;
  55969. };
  55970. }
  55971. declare module BABYLON {
  55972. /** @hidden */
  55973. export var pbrUboDeclaration: {
  55974. name: string;
  55975. shader: string;
  55976. };
  55977. }
  55978. declare module BABYLON {
  55979. /** @hidden */
  55980. export var pbrFragmentExtraDeclaration: {
  55981. name: string;
  55982. shader: string;
  55983. };
  55984. }
  55985. declare module BABYLON {
  55986. /** @hidden */
  55987. export var pbrFragmentSamplersDeclaration: {
  55988. name: string;
  55989. shader: string;
  55990. };
  55991. }
  55992. declare module BABYLON {
  55993. /** @hidden */
  55994. export var importanceSampling: {
  55995. name: string;
  55996. shader: string;
  55997. };
  55998. }
  55999. declare module BABYLON {
  56000. /** @hidden */
  56001. export var pbrHelperFunctions: {
  56002. name: string;
  56003. shader: string;
  56004. };
  56005. }
  56006. declare module BABYLON {
  56007. /** @hidden */
  56008. export var harmonicsFunctions: {
  56009. name: string;
  56010. shader: string;
  56011. };
  56012. }
  56013. declare module BABYLON {
  56014. /** @hidden */
  56015. export var pbrDirectLightingSetupFunctions: {
  56016. name: string;
  56017. shader: string;
  56018. };
  56019. }
  56020. declare module BABYLON {
  56021. /** @hidden */
  56022. export var pbrDirectLightingFalloffFunctions: {
  56023. name: string;
  56024. shader: string;
  56025. };
  56026. }
  56027. declare module BABYLON {
  56028. /** @hidden */
  56029. export var pbrBRDFFunctions: {
  56030. name: string;
  56031. shader: string;
  56032. };
  56033. }
  56034. declare module BABYLON {
  56035. /** @hidden */
  56036. export var hdrFilteringFunctions: {
  56037. name: string;
  56038. shader: string;
  56039. };
  56040. }
  56041. declare module BABYLON {
  56042. /** @hidden */
  56043. export var pbrDirectLightingFunctions: {
  56044. name: string;
  56045. shader: string;
  56046. };
  56047. }
  56048. declare module BABYLON {
  56049. /** @hidden */
  56050. export var pbrIBLFunctions: {
  56051. name: string;
  56052. shader: string;
  56053. };
  56054. }
  56055. declare module BABYLON {
  56056. /** @hidden */
  56057. export var pbrBlockAlbedoOpacity: {
  56058. name: string;
  56059. shader: string;
  56060. };
  56061. }
  56062. declare module BABYLON {
  56063. /** @hidden */
  56064. export var pbrBlockReflectivity: {
  56065. name: string;
  56066. shader: string;
  56067. };
  56068. }
  56069. declare module BABYLON {
  56070. /** @hidden */
  56071. export var pbrBlockAmbientOcclusion: {
  56072. name: string;
  56073. shader: string;
  56074. };
  56075. }
  56076. declare module BABYLON {
  56077. /** @hidden */
  56078. export var pbrBlockAlphaFresnel: {
  56079. name: string;
  56080. shader: string;
  56081. };
  56082. }
  56083. declare module BABYLON {
  56084. /** @hidden */
  56085. export var pbrBlockAnisotropic: {
  56086. name: string;
  56087. shader: string;
  56088. };
  56089. }
  56090. declare module BABYLON {
  56091. /** @hidden */
  56092. export var pbrBlockReflection: {
  56093. name: string;
  56094. shader: string;
  56095. };
  56096. }
  56097. declare module BABYLON {
  56098. /** @hidden */
  56099. export var pbrBlockSheen: {
  56100. name: string;
  56101. shader: string;
  56102. };
  56103. }
  56104. declare module BABYLON {
  56105. /** @hidden */
  56106. export var pbrBlockClearcoat: {
  56107. name: string;
  56108. shader: string;
  56109. };
  56110. }
  56111. declare module BABYLON {
  56112. /** @hidden */
  56113. export var pbrBlockSubSurface: {
  56114. name: string;
  56115. shader: string;
  56116. };
  56117. }
  56118. declare module BABYLON {
  56119. /** @hidden */
  56120. export var pbrBlockNormalGeometric: {
  56121. name: string;
  56122. shader: string;
  56123. };
  56124. }
  56125. declare module BABYLON {
  56126. /** @hidden */
  56127. export var pbrBlockNormalFinal: {
  56128. name: string;
  56129. shader: string;
  56130. };
  56131. }
  56132. declare module BABYLON {
  56133. /** @hidden */
  56134. export var pbrBlockLightmapInit: {
  56135. name: string;
  56136. shader: string;
  56137. };
  56138. }
  56139. declare module BABYLON {
  56140. /** @hidden */
  56141. export var pbrBlockGeometryInfo: {
  56142. name: string;
  56143. shader: string;
  56144. };
  56145. }
  56146. declare module BABYLON {
  56147. /** @hidden */
  56148. export var pbrBlockReflectance0: {
  56149. name: string;
  56150. shader: string;
  56151. };
  56152. }
  56153. declare module BABYLON {
  56154. /** @hidden */
  56155. export var pbrBlockReflectance: {
  56156. name: string;
  56157. shader: string;
  56158. };
  56159. }
  56160. declare module BABYLON {
  56161. /** @hidden */
  56162. export var pbrBlockDirectLighting: {
  56163. name: string;
  56164. shader: string;
  56165. };
  56166. }
  56167. declare module BABYLON {
  56168. /** @hidden */
  56169. export var pbrBlockFinalLitComponents: {
  56170. name: string;
  56171. shader: string;
  56172. };
  56173. }
  56174. declare module BABYLON {
  56175. /** @hidden */
  56176. export var pbrBlockFinalUnlitComponents: {
  56177. name: string;
  56178. shader: string;
  56179. };
  56180. }
  56181. declare module BABYLON {
  56182. /** @hidden */
  56183. export var pbrBlockFinalColorComposition: {
  56184. name: string;
  56185. shader: string;
  56186. };
  56187. }
  56188. declare module BABYLON {
  56189. /** @hidden */
  56190. export var pbrBlockImageProcessing: {
  56191. name: string;
  56192. shader: string;
  56193. };
  56194. }
  56195. declare module BABYLON {
  56196. /** @hidden */
  56197. export var pbrDebug: {
  56198. name: string;
  56199. shader: string;
  56200. };
  56201. }
  56202. declare module BABYLON {
  56203. /** @hidden */
  56204. export var pbrPixelShader: {
  56205. name: string;
  56206. shader: string;
  56207. };
  56208. }
  56209. declare module BABYLON {
  56210. /** @hidden */
  56211. export var pbrVertexDeclaration: {
  56212. name: string;
  56213. shader: string;
  56214. };
  56215. }
  56216. declare module BABYLON {
  56217. /** @hidden */
  56218. export var pbrVertexShader: {
  56219. name: string;
  56220. shader: string;
  56221. };
  56222. }
  56223. declare module BABYLON {
  56224. /**
  56225. * Manages the defines for the PBR Material.
  56226. * @hidden
  56227. */
  56228. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56229. PBR: boolean;
  56230. NUM_SAMPLES: string;
  56231. REALTIME_FILTERING: boolean;
  56232. MAINUV1: boolean;
  56233. MAINUV2: boolean;
  56234. UV1: boolean;
  56235. UV2: boolean;
  56236. ALBEDO: boolean;
  56237. GAMMAALBEDO: boolean;
  56238. ALBEDODIRECTUV: number;
  56239. VERTEXCOLOR: boolean;
  56240. DETAIL: boolean;
  56241. DETAILDIRECTUV: number;
  56242. DETAIL_NORMALBLENDMETHOD: number;
  56243. AMBIENT: boolean;
  56244. AMBIENTDIRECTUV: number;
  56245. AMBIENTINGRAYSCALE: boolean;
  56246. OPACITY: boolean;
  56247. VERTEXALPHA: boolean;
  56248. OPACITYDIRECTUV: number;
  56249. OPACITYRGB: boolean;
  56250. ALPHATEST: boolean;
  56251. DEPTHPREPASS: boolean;
  56252. ALPHABLEND: boolean;
  56253. ALPHAFROMALBEDO: boolean;
  56254. ALPHATESTVALUE: string;
  56255. SPECULAROVERALPHA: boolean;
  56256. RADIANCEOVERALPHA: boolean;
  56257. ALPHAFRESNEL: boolean;
  56258. LINEARALPHAFRESNEL: boolean;
  56259. PREMULTIPLYALPHA: boolean;
  56260. EMISSIVE: boolean;
  56261. EMISSIVEDIRECTUV: number;
  56262. REFLECTIVITY: boolean;
  56263. REFLECTIVITYDIRECTUV: number;
  56264. SPECULARTERM: boolean;
  56265. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56266. MICROSURFACEAUTOMATIC: boolean;
  56267. LODBASEDMICROSFURACE: boolean;
  56268. MICROSURFACEMAP: boolean;
  56269. MICROSURFACEMAPDIRECTUV: number;
  56270. METALLICWORKFLOW: boolean;
  56271. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56272. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56273. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56274. AOSTOREINMETALMAPRED: boolean;
  56275. METALLIC_REFLECTANCE: boolean;
  56276. METALLIC_REFLECTANCEDIRECTUV: number;
  56277. ENVIRONMENTBRDF: boolean;
  56278. ENVIRONMENTBRDF_RGBD: boolean;
  56279. NORMAL: boolean;
  56280. TANGENT: boolean;
  56281. BUMP: boolean;
  56282. BUMPDIRECTUV: number;
  56283. OBJECTSPACE_NORMALMAP: boolean;
  56284. PARALLAX: boolean;
  56285. PARALLAXOCCLUSION: boolean;
  56286. NORMALXYSCALE: boolean;
  56287. LIGHTMAP: boolean;
  56288. LIGHTMAPDIRECTUV: number;
  56289. USELIGHTMAPASSHADOWMAP: boolean;
  56290. GAMMALIGHTMAP: boolean;
  56291. RGBDLIGHTMAP: boolean;
  56292. REFLECTION: boolean;
  56293. REFLECTIONMAP_3D: boolean;
  56294. REFLECTIONMAP_SPHERICAL: boolean;
  56295. REFLECTIONMAP_PLANAR: boolean;
  56296. REFLECTIONMAP_CUBIC: boolean;
  56297. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56298. REFLECTIONMAP_PROJECTION: boolean;
  56299. REFLECTIONMAP_SKYBOX: boolean;
  56300. REFLECTIONMAP_EXPLICIT: boolean;
  56301. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56302. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56303. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56304. INVERTCUBICMAP: boolean;
  56305. USESPHERICALFROMREFLECTIONMAP: boolean;
  56306. USEIRRADIANCEMAP: boolean;
  56307. SPHERICAL_HARMONICS: boolean;
  56308. USESPHERICALINVERTEX: boolean;
  56309. REFLECTIONMAP_OPPOSITEZ: boolean;
  56310. LODINREFLECTIONALPHA: boolean;
  56311. GAMMAREFLECTION: boolean;
  56312. RGBDREFLECTION: boolean;
  56313. LINEARSPECULARREFLECTION: boolean;
  56314. RADIANCEOCCLUSION: boolean;
  56315. HORIZONOCCLUSION: boolean;
  56316. INSTANCES: boolean;
  56317. THIN_INSTANCES: boolean;
  56318. PREPASS: boolean;
  56319. SCENE_MRT_COUNT: number;
  56320. NUM_BONE_INFLUENCERS: number;
  56321. BonesPerMesh: number;
  56322. BONETEXTURE: boolean;
  56323. NONUNIFORMSCALING: boolean;
  56324. MORPHTARGETS: boolean;
  56325. MORPHTARGETS_NORMAL: boolean;
  56326. MORPHTARGETS_TANGENT: boolean;
  56327. MORPHTARGETS_UV: boolean;
  56328. NUM_MORPH_INFLUENCERS: number;
  56329. IMAGEPROCESSING: boolean;
  56330. VIGNETTE: boolean;
  56331. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56332. VIGNETTEBLENDMODEOPAQUE: boolean;
  56333. TONEMAPPING: boolean;
  56334. TONEMAPPING_ACES: boolean;
  56335. CONTRAST: boolean;
  56336. COLORCURVES: boolean;
  56337. COLORGRADING: boolean;
  56338. COLORGRADING3D: boolean;
  56339. SAMPLER3DGREENDEPTH: boolean;
  56340. SAMPLER3DBGRMAP: boolean;
  56341. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56342. EXPOSURE: boolean;
  56343. MULTIVIEW: boolean;
  56344. USEPHYSICALLIGHTFALLOFF: boolean;
  56345. USEGLTFLIGHTFALLOFF: boolean;
  56346. TWOSIDEDLIGHTING: boolean;
  56347. SHADOWFLOAT: boolean;
  56348. CLIPPLANE: boolean;
  56349. CLIPPLANE2: boolean;
  56350. CLIPPLANE3: boolean;
  56351. CLIPPLANE4: boolean;
  56352. CLIPPLANE5: boolean;
  56353. CLIPPLANE6: boolean;
  56354. POINTSIZE: boolean;
  56355. FOG: boolean;
  56356. LOGARITHMICDEPTH: boolean;
  56357. FORCENORMALFORWARD: boolean;
  56358. SPECULARAA: boolean;
  56359. CLEARCOAT: boolean;
  56360. CLEARCOAT_DEFAULTIOR: boolean;
  56361. CLEARCOAT_TEXTURE: boolean;
  56362. CLEARCOAT_TEXTUREDIRECTUV: number;
  56363. CLEARCOAT_BUMP: boolean;
  56364. CLEARCOAT_BUMPDIRECTUV: number;
  56365. CLEARCOAT_TINT: boolean;
  56366. CLEARCOAT_TINT_TEXTURE: boolean;
  56367. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56368. ANISOTROPIC: boolean;
  56369. ANISOTROPIC_TEXTURE: boolean;
  56370. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56371. BRDF_V_HEIGHT_CORRELATED: boolean;
  56372. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56373. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56374. SHEEN: boolean;
  56375. SHEEN_TEXTURE: boolean;
  56376. SHEEN_TEXTUREDIRECTUV: number;
  56377. SHEEN_LINKWITHALBEDO: boolean;
  56378. SHEEN_ROUGHNESS: boolean;
  56379. SHEEN_ALBEDOSCALING: boolean;
  56380. SUBSURFACE: boolean;
  56381. SS_REFRACTION: boolean;
  56382. SS_TRANSLUCENCY: boolean;
  56383. SS_SCATTERING: boolean;
  56384. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56385. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56386. SS_REFRACTIONMAP_3D: boolean;
  56387. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56388. SS_LODINREFRACTIONALPHA: boolean;
  56389. SS_GAMMAREFRACTION: boolean;
  56390. SS_RGBDREFRACTION: boolean;
  56391. SS_LINEARSPECULARREFRACTION: boolean;
  56392. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56393. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56394. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56395. UNLIT: boolean;
  56396. DEBUGMODE: number;
  56397. /**
  56398. * Initializes the PBR Material defines.
  56399. */
  56400. constructor();
  56401. /**
  56402. * Resets the PBR Material defines.
  56403. */
  56404. reset(): void;
  56405. }
  56406. /**
  56407. * The Physically based material base class of BJS.
  56408. *
  56409. * This offers the main features of a standard PBR material.
  56410. * For more information, please refer to the documentation :
  56411. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56412. */
  56413. export abstract class PBRBaseMaterial extends PushMaterial {
  56414. /**
  56415. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56416. */
  56417. static readonly PBRMATERIAL_OPAQUE: number;
  56418. /**
  56419. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56420. */
  56421. static readonly PBRMATERIAL_ALPHATEST: number;
  56422. /**
  56423. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56424. */
  56425. static readonly PBRMATERIAL_ALPHABLEND: number;
  56426. /**
  56427. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56428. * They are also discarded below the alpha cutoff threshold to improve performances.
  56429. */
  56430. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56431. /**
  56432. * Defines the default value of how much AO map is occluding the analytical lights
  56433. * (point spot...).
  56434. */
  56435. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56436. /**
  56437. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56438. */
  56439. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56440. /**
  56441. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56442. * to enhance interoperability with other engines.
  56443. */
  56444. static readonly LIGHTFALLOFF_GLTF: number;
  56445. /**
  56446. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56447. * to enhance interoperability with other materials.
  56448. */
  56449. static readonly LIGHTFALLOFF_STANDARD: number;
  56450. /**
  56451. * Intensity of the direct lights e.g. the four lights available in your scene.
  56452. * This impacts both the direct diffuse and specular highlights.
  56453. */
  56454. protected _directIntensity: number;
  56455. /**
  56456. * Intensity of the emissive part of the material.
  56457. * This helps controlling the emissive effect without modifying the emissive color.
  56458. */
  56459. protected _emissiveIntensity: number;
  56460. /**
  56461. * Intensity of the environment e.g. how much the environment will light the object
  56462. * either through harmonics for rough material or through the refelction for shiny ones.
  56463. */
  56464. protected _environmentIntensity: number;
  56465. /**
  56466. * This is a special control allowing the reduction of the specular highlights coming from the
  56467. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56468. */
  56469. protected _specularIntensity: number;
  56470. /**
  56471. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56472. */
  56473. private _lightingInfos;
  56474. /**
  56475. * Debug Control allowing disabling the bump map on this material.
  56476. */
  56477. protected _disableBumpMap: boolean;
  56478. /**
  56479. * AKA Diffuse Texture in standard nomenclature.
  56480. */
  56481. protected _albedoTexture: Nullable<BaseTexture>;
  56482. /**
  56483. * AKA Occlusion Texture in other nomenclature.
  56484. */
  56485. protected _ambientTexture: Nullable<BaseTexture>;
  56486. /**
  56487. * AKA Occlusion Texture Intensity in other nomenclature.
  56488. */
  56489. protected _ambientTextureStrength: number;
  56490. /**
  56491. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56492. * 1 means it completely occludes it
  56493. * 0 mean it has no impact
  56494. */
  56495. protected _ambientTextureImpactOnAnalyticalLights: number;
  56496. /**
  56497. * Stores the alpha values in a texture.
  56498. */
  56499. protected _opacityTexture: Nullable<BaseTexture>;
  56500. /**
  56501. * Stores the reflection values in a texture.
  56502. */
  56503. protected _reflectionTexture: Nullable<BaseTexture>;
  56504. /**
  56505. * Stores the emissive values in a texture.
  56506. */
  56507. protected _emissiveTexture: Nullable<BaseTexture>;
  56508. /**
  56509. * AKA Specular texture in other nomenclature.
  56510. */
  56511. protected _reflectivityTexture: Nullable<BaseTexture>;
  56512. /**
  56513. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56514. */
  56515. protected _metallicTexture: Nullable<BaseTexture>;
  56516. /**
  56517. * Specifies the metallic scalar of the metallic/roughness workflow.
  56518. * Can also be used to scale the metalness values of the metallic texture.
  56519. */
  56520. protected _metallic: Nullable<number>;
  56521. /**
  56522. * Specifies the roughness scalar of the metallic/roughness workflow.
  56523. * Can also be used to scale the roughness values of the metallic texture.
  56524. */
  56525. protected _roughness: Nullable<number>;
  56526. /**
  56527. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56528. * By default the indexOfrefraction is used to compute F0;
  56529. *
  56530. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56531. *
  56532. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56533. * F90 = metallicReflectanceColor;
  56534. */
  56535. protected _metallicF0Factor: number;
  56536. /**
  56537. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56538. * By default the F90 is always 1;
  56539. *
  56540. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56541. *
  56542. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56543. * F90 = metallicReflectanceColor;
  56544. */
  56545. protected _metallicReflectanceColor: Color3;
  56546. /**
  56547. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56548. * This is multiply against the scalar values defined in the material.
  56549. */
  56550. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56551. /**
  56552. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56553. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56554. */
  56555. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56556. /**
  56557. * Stores surface normal data used to displace a mesh in a texture.
  56558. */
  56559. protected _bumpTexture: Nullable<BaseTexture>;
  56560. /**
  56561. * Stores the pre-calculated light information of a mesh in a texture.
  56562. */
  56563. protected _lightmapTexture: Nullable<BaseTexture>;
  56564. /**
  56565. * The color of a material in ambient lighting.
  56566. */
  56567. protected _ambientColor: Color3;
  56568. /**
  56569. * AKA Diffuse Color in other nomenclature.
  56570. */
  56571. protected _albedoColor: Color3;
  56572. /**
  56573. * AKA Specular Color in other nomenclature.
  56574. */
  56575. protected _reflectivityColor: Color3;
  56576. /**
  56577. * The color applied when light is reflected from a material.
  56578. */
  56579. protected _reflectionColor: Color3;
  56580. /**
  56581. * The color applied when light is emitted from a material.
  56582. */
  56583. protected _emissiveColor: Color3;
  56584. /**
  56585. * AKA Glossiness in other nomenclature.
  56586. */
  56587. protected _microSurface: number;
  56588. /**
  56589. * Specifies that the material will use the light map as a show map.
  56590. */
  56591. protected _useLightmapAsShadowmap: boolean;
  56592. /**
  56593. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56594. * makes the reflect vector face the model (under horizon).
  56595. */
  56596. protected _useHorizonOcclusion: boolean;
  56597. /**
  56598. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56599. * too much the area relying on ambient texture to define their ambient occlusion.
  56600. */
  56601. protected _useRadianceOcclusion: boolean;
  56602. /**
  56603. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56604. */
  56605. protected _useAlphaFromAlbedoTexture: boolean;
  56606. /**
  56607. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56608. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56609. */
  56610. protected _useSpecularOverAlpha: boolean;
  56611. /**
  56612. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56613. */
  56614. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56615. /**
  56616. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56617. */
  56618. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56619. /**
  56620. * Specifies if the metallic texture contains the roughness information in its green channel.
  56621. */
  56622. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56623. /**
  56624. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56625. */
  56626. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56627. /**
  56628. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56629. */
  56630. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56631. /**
  56632. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56633. */
  56634. protected _useAmbientInGrayScale: boolean;
  56635. /**
  56636. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56637. * The material will try to infer what glossiness each pixel should be.
  56638. */
  56639. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56640. /**
  56641. * Defines the falloff type used in this material.
  56642. * It by default is Physical.
  56643. */
  56644. protected _lightFalloff: number;
  56645. /**
  56646. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56647. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56648. */
  56649. protected _useRadianceOverAlpha: boolean;
  56650. /**
  56651. * Allows using an object space normal map (instead of tangent space).
  56652. */
  56653. protected _useObjectSpaceNormalMap: boolean;
  56654. /**
  56655. * Allows using the bump map in parallax mode.
  56656. */
  56657. protected _useParallax: boolean;
  56658. /**
  56659. * Allows using the bump map in parallax occlusion mode.
  56660. */
  56661. protected _useParallaxOcclusion: boolean;
  56662. /**
  56663. * Controls the scale bias of the parallax mode.
  56664. */
  56665. protected _parallaxScaleBias: number;
  56666. /**
  56667. * If sets to true, disables all the lights affecting the material.
  56668. */
  56669. protected _disableLighting: boolean;
  56670. /**
  56671. * Number of Simultaneous lights allowed on the material.
  56672. */
  56673. protected _maxSimultaneousLights: number;
  56674. /**
  56675. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56676. */
  56677. protected _invertNormalMapX: boolean;
  56678. /**
  56679. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56680. */
  56681. protected _invertNormalMapY: boolean;
  56682. /**
  56683. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56684. */
  56685. protected _twoSidedLighting: boolean;
  56686. /**
  56687. * Defines the alpha limits in alpha test mode.
  56688. */
  56689. protected _alphaCutOff: number;
  56690. /**
  56691. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56692. */
  56693. protected _forceAlphaTest: boolean;
  56694. /**
  56695. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56696. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56697. */
  56698. protected _useAlphaFresnel: boolean;
  56699. /**
  56700. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56701. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56702. */
  56703. protected _useLinearAlphaFresnel: boolean;
  56704. /**
  56705. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56706. * from cos thetav and roughness:
  56707. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56708. */
  56709. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56710. /**
  56711. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56712. */
  56713. protected _forceIrradianceInFragment: boolean;
  56714. private _realTimeFiltering;
  56715. /**
  56716. * Enables realtime filtering on the texture.
  56717. */
  56718. get realTimeFiltering(): boolean;
  56719. set realTimeFiltering(b: boolean);
  56720. private _realTimeFilteringQuality;
  56721. /**
  56722. * Quality switch for realtime filtering
  56723. */
  56724. get realTimeFilteringQuality(): number;
  56725. set realTimeFilteringQuality(n: number);
  56726. /**
  56727. * Can this material render to several textures at once
  56728. */
  56729. get canRenderToMRT(): boolean;
  56730. /**
  56731. * Force normal to face away from face.
  56732. */
  56733. protected _forceNormalForward: boolean;
  56734. /**
  56735. * Enables specular anti aliasing in the PBR shader.
  56736. * It will both interacts on the Geometry for analytical and IBL lighting.
  56737. * It also prefilter the roughness map based on the bump values.
  56738. */
  56739. protected _enableSpecularAntiAliasing: boolean;
  56740. /**
  56741. * Default configuration related to image processing available in the PBR Material.
  56742. */
  56743. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56744. /**
  56745. * Keep track of the image processing observer to allow dispose and replace.
  56746. */
  56747. private _imageProcessingObserver;
  56748. /**
  56749. * Attaches a new image processing configuration to the PBR Material.
  56750. * @param configuration
  56751. */
  56752. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56753. /**
  56754. * Stores the available render targets.
  56755. */
  56756. private _renderTargets;
  56757. /**
  56758. * Sets the global ambient color for the material used in lighting calculations.
  56759. */
  56760. private _globalAmbientColor;
  56761. /**
  56762. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56763. */
  56764. private _useLogarithmicDepth;
  56765. /**
  56766. * If set to true, no lighting calculations will be applied.
  56767. */
  56768. private _unlit;
  56769. private _debugMode;
  56770. /**
  56771. * @hidden
  56772. * This is reserved for the inspector.
  56773. * Defines the material debug mode.
  56774. * It helps seeing only some components of the material while troubleshooting.
  56775. */
  56776. debugMode: number;
  56777. /**
  56778. * @hidden
  56779. * This is reserved for the inspector.
  56780. * Specify from where on screen the debug mode should start.
  56781. * The value goes from -1 (full screen) to 1 (not visible)
  56782. * It helps with side by side comparison against the final render
  56783. * This defaults to -1
  56784. */
  56785. private debugLimit;
  56786. /**
  56787. * @hidden
  56788. * This is reserved for the inspector.
  56789. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56790. * You can use the factor to better multiply the final value.
  56791. */
  56792. private debugFactor;
  56793. /**
  56794. * Defines the clear coat layer parameters for the material.
  56795. */
  56796. readonly clearCoat: PBRClearCoatConfiguration;
  56797. /**
  56798. * Defines the anisotropic parameters for the material.
  56799. */
  56800. readonly anisotropy: PBRAnisotropicConfiguration;
  56801. /**
  56802. * Defines the BRDF parameters for the material.
  56803. */
  56804. readonly brdf: PBRBRDFConfiguration;
  56805. /**
  56806. * Defines the Sheen parameters for the material.
  56807. */
  56808. readonly sheen: PBRSheenConfiguration;
  56809. /**
  56810. * Defines the SubSurface parameters for the material.
  56811. */
  56812. readonly subSurface: PBRSubSurfaceConfiguration;
  56813. /**
  56814. * Defines the detail map parameters for the material.
  56815. */
  56816. readonly detailMap: DetailMapConfiguration;
  56817. protected _rebuildInParallel: boolean;
  56818. /**
  56819. * Instantiates a new PBRMaterial instance.
  56820. *
  56821. * @param name The material name
  56822. * @param scene The scene the material will be use in.
  56823. */
  56824. constructor(name: string, scene: Scene);
  56825. /**
  56826. * Gets a boolean indicating that current material needs to register RTT
  56827. */
  56828. get hasRenderTargetTextures(): boolean;
  56829. /**
  56830. * Gets the name of the material class.
  56831. */
  56832. getClassName(): string;
  56833. /**
  56834. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56835. */
  56836. get useLogarithmicDepth(): boolean;
  56837. /**
  56838. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56839. */
  56840. set useLogarithmicDepth(value: boolean);
  56841. /**
  56842. * Returns true if alpha blending should be disabled.
  56843. */
  56844. protected get _disableAlphaBlending(): boolean;
  56845. /**
  56846. * Specifies whether or not this material should be rendered in alpha blend mode.
  56847. */
  56848. needAlphaBlending(): boolean;
  56849. /**
  56850. * Specifies whether or not this material should be rendered in alpha test mode.
  56851. */
  56852. needAlphaTesting(): boolean;
  56853. /**
  56854. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56855. */
  56856. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56857. /**
  56858. * Gets the texture used for the alpha test.
  56859. */
  56860. getAlphaTestTexture(): Nullable<BaseTexture>;
  56861. /**
  56862. * Specifies that the submesh is ready to be used.
  56863. * @param mesh - BJS mesh.
  56864. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56865. * @param useInstances - Specifies that instances should be used.
  56866. * @returns - boolean indicating that the submesh is ready or not.
  56867. */
  56868. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56869. /**
  56870. * Specifies if the material uses metallic roughness workflow.
  56871. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56872. */
  56873. isMetallicWorkflow(): boolean;
  56874. private _prepareEffect;
  56875. private _prepareDefines;
  56876. /**
  56877. * Force shader compilation
  56878. */
  56879. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56880. /**
  56881. * Initializes the uniform buffer layout for the shader.
  56882. */
  56883. buildUniformLayout(): void;
  56884. /**
  56885. * Unbinds the material from the mesh
  56886. */
  56887. unbind(): void;
  56888. /**
  56889. * Binds the submesh data.
  56890. * @param world - The world matrix.
  56891. * @param mesh - The BJS mesh.
  56892. * @param subMesh - A submesh of the BJS mesh.
  56893. */
  56894. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56895. /**
  56896. * Returns the animatable textures.
  56897. * @returns - Array of animatable textures.
  56898. */
  56899. getAnimatables(): IAnimatable[];
  56900. /**
  56901. * Returns the texture used for reflections.
  56902. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56903. */
  56904. private _getReflectionTexture;
  56905. /**
  56906. * Returns an array of the actively used textures.
  56907. * @returns - Array of BaseTextures
  56908. */
  56909. getActiveTextures(): BaseTexture[];
  56910. /**
  56911. * Checks to see if a texture is used in the material.
  56912. * @param texture - Base texture to use.
  56913. * @returns - Boolean specifying if a texture is used in the material.
  56914. */
  56915. hasTexture(texture: BaseTexture): boolean;
  56916. /**
  56917. * Sets the required values to the prepass renderer.
  56918. * @param prePassRenderer defines the prepass renderer to setup
  56919. */
  56920. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  56921. /**
  56922. * Disposes the resources of the material.
  56923. * @param forceDisposeEffect - Forces the disposal of effects.
  56924. * @param forceDisposeTextures - Forces the disposal of all textures.
  56925. */
  56926. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56927. }
  56928. }
  56929. declare module BABYLON {
  56930. /**
  56931. * The Physically based material of BJS.
  56932. *
  56933. * This offers the main features of a standard PBR material.
  56934. * For more information, please refer to the documentation :
  56935. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56936. */
  56937. export class PBRMaterial extends PBRBaseMaterial {
  56938. /**
  56939. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56940. */
  56941. static readonly PBRMATERIAL_OPAQUE: number;
  56942. /**
  56943. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56944. */
  56945. static readonly PBRMATERIAL_ALPHATEST: number;
  56946. /**
  56947. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56948. */
  56949. static readonly PBRMATERIAL_ALPHABLEND: number;
  56950. /**
  56951. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56952. * They are also discarded below the alpha cutoff threshold to improve performances.
  56953. */
  56954. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56955. /**
  56956. * Defines the default value of how much AO map is occluding the analytical lights
  56957. * (point spot...).
  56958. */
  56959. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56960. /**
  56961. * Intensity of the direct lights e.g. the four lights available in your scene.
  56962. * This impacts both the direct diffuse and specular highlights.
  56963. */
  56964. directIntensity: number;
  56965. /**
  56966. * Intensity of the emissive part of the material.
  56967. * This helps controlling the emissive effect without modifying the emissive color.
  56968. */
  56969. emissiveIntensity: number;
  56970. /**
  56971. * Intensity of the environment e.g. how much the environment will light the object
  56972. * either through harmonics for rough material or through the refelction for shiny ones.
  56973. */
  56974. environmentIntensity: number;
  56975. /**
  56976. * This is a special control allowing the reduction of the specular highlights coming from the
  56977. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56978. */
  56979. specularIntensity: number;
  56980. /**
  56981. * Debug Control allowing disabling the bump map on this material.
  56982. */
  56983. disableBumpMap: boolean;
  56984. /**
  56985. * AKA Diffuse Texture in standard nomenclature.
  56986. */
  56987. albedoTexture: BaseTexture;
  56988. /**
  56989. * AKA Occlusion Texture in other nomenclature.
  56990. */
  56991. ambientTexture: BaseTexture;
  56992. /**
  56993. * AKA Occlusion Texture Intensity in other nomenclature.
  56994. */
  56995. ambientTextureStrength: number;
  56996. /**
  56997. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56998. * 1 means it completely occludes it
  56999. * 0 mean it has no impact
  57000. */
  57001. ambientTextureImpactOnAnalyticalLights: number;
  57002. /**
  57003. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57004. */
  57005. opacityTexture: BaseTexture;
  57006. /**
  57007. * Stores the reflection values in a texture.
  57008. */
  57009. reflectionTexture: Nullable<BaseTexture>;
  57010. /**
  57011. * Stores the emissive values in a texture.
  57012. */
  57013. emissiveTexture: BaseTexture;
  57014. /**
  57015. * AKA Specular texture in other nomenclature.
  57016. */
  57017. reflectivityTexture: BaseTexture;
  57018. /**
  57019. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57020. */
  57021. metallicTexture: BaseTexture;
  57022. /**
  57023. * Specifies the metallic scalar of the metallic/roughness workflow.
  57024. * Can also be used to scale the metalness values of the metallic texture.
  57025. */
  57026. metallic: Nullable<number>;
  57027. /**
  57028. * Specifies the roughness scalar of the metallic/roughness workflow.
  57029. * Can also be used to scale the roughness values of the metallic texture.
  57030. */
  57031. roughness: Nullable<number>;
  57032. /**
  57033. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57034. * By default the indexOfrefraction is used to compute F0;
  57035. *
  57036. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57037. *
  57038. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57039. * F90 = metallicReflectanceColor;
  57040. */
  57041. metallicF0Factor: number;
  57042. /**
  57043. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57044. * By default the F90 is always 1;
  57045. *
  57046. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57047. *
  57048. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57049. * F90 = metallicReflectanceColor;
  57050. */
  57051. metallicReflectanceColor: Color3;
  57052. /**
  57053. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57054. * This is multiply against the scalar values defined in the material.
  57055. */
  57056. metallicReflectanceTexture: Nullable<BaseTexture>;
  57057. /**
  57058. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57059. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57060. */
  57061. microSurfaceTexture: BaseTexture;
  57062. /**
  57063. * Stores surface normal data used to displace a mesh in a texture.
  57064. */
  57065. bumpTexture: BaseTexture;
  57066. /**
  57067. * Stores the pre-calculated light information of a mesh in a texture.
  57068. */
  57069. lightmapTexture: BaseTexture;
  57070. /**
  57071. * Stores the refracted light information in a texture.
  57072. */
  57073. get refractionTexture(): Nullable<BaseTexture>;
  57074. set refractionTexture(value: Nullable<BaseTexture>);
  57075. /**
  57076. * The color of a material in ambient lighting.
  57077. */
  57078. ambientColor: Color3;
  57079. /**
  57080. * AKA Diffuse Color in other nomenclature.
  57081. */
  57082. albedoColor: Color3;
  57083. /**
  57084. * AKA Specular Color in other nomenclature.
  57085. */
  57086. reflectivityColor: Color3;
  57087. /**
  57088. * The color reflected from the material.
  57089. */
  57090. reflectionColor: Color3;
  57091. /**
  57092. * The color emitted from the material.
  57093. */
  57094. emissiveColor: Color3;
  57095. /**
  57096. * AKA Glossiness in other nomenclature.
  57097. */
  57098. microSurface: number;
  57099. /**
  57100. * Index of refraction of the material base layer.
  57101. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57102. *
  57103. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57104. *
  57105. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57106. */
  57107. get indexOfRefraction(): number;
  57108. set indexOfRefraction(value: number);
  57109. /**
  57110. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57111. */
  57112. get invertRefractionY(): boolean;
  57113. set invertRefractionY(value: boolean);
  57114. /**
  57115. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57116. * Materials half opaque for instance using refraction could benefit from this control.
  57117. */
  57118. get linkRefractionWithTransparency(): boolean;
  57119. set linkRefractionWithTransparency(value: boolean);
  57120. /**
  57121. * If true, the light map contains occlusion information instead of lighting info.
  57122. */
  57123. useLightmapAsShadowmap: boolean;
  57124. /**
  57125. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57126. */
  57127. useAlphaFromAlbedoTexture: boolean;
  57128. /**
  57129. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57130. */
  57131. forceAlphaTest: boolean;
  57132. /**
  57133. * Defines the alpha limits in alpha test mode.
  57134. */
  57135. alphaCutOff: number;
  57136. /**
  57137. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57138. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57139. */
  57140. useSpecularOverAlpha: boolean;
  57141. /**
  57142. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57143. */
  57144. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57145. /**
  57146. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57147. */
  57148. useRoughnessFromMetallicTextureAlpha: boolean;
  57149. /**
  57150. * Specifies if the metallic texture contains the roughness information in its green channel.
  57151. */
  57152. useRoughnessFromMetallicTextureGreen: boolean;
  57153. /**
  57154. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57155. */
  57156. useMetallnessFromMetallicTextureBlue: boolean;
  57157. /**
  57158. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57159. */
  57160. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57161. /**
  57162. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57163. */
  57164. useAmbientInGrayScale: boolean;
  57165. /**
  57166. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57167. * The material will try to infer what glossiness each pixel should be.
  57168. */
  57169. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57170. /**
  57171. * BJS is using an harcoded light falloff based on a manually sets up range.
  57172. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57173. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57174. */
  57175. get usePhysicalLightFalloff(): boolean;
  57176. /**
  57177. * BJS is using an harcoded light falloff based on a manually sets up range.
  57178. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57179. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57180. */
  57181. set usePhysicalLightFalloff(value: boolean);
  57182. /**
  57183. * In order to support the falloff compatibility with gltf, a special mode has been added
  57184. * to reproduce the gltf light falloff.
  57185. */
  57186. get useGLTFLightFalloff(): boolean;
  57187. /**
  57188. * In order to support the falloff compatibility with gltf, a special mode has been added
  57189. * to reproduce the gltf light falloff.
  57190. */
  57191. set useGLTFLightFalloff(value: boolean);
  57192. /**
  57193. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57194. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57195. */
  57196. useRadianceOverAlpha: boolean;
  57197. /**
  57198. * Allows using an object space normal map (instead of tangent space).
  57199. */
  57200. useObjectSpaceNormalMap: boolean;
  57201. /**
  57202. * Allows using the bump map in parallax mode.
  57203. */
  57204. useParallax: boolean;
  57205. /**
  57206. * Allows using the bump map in parallax occlusion mode.
  57207. */
  57208. useParallaxOcclusion: boolean;
  57209. /**
  57210. * Controls the scale bias of the parallax mode.
  57211. */
  57212. parallaxScaleBias: number;
  57213. /**
  57214. * If sets to true, disables all the lights affecting the material.
  57215. */
  57216. disableLighting: boolean;
  57217. /**
  57218. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57219. */
  57220. forceIrradianceInFragment: boolean;
  57221. /**
  57222. * Number of Simultaneous lights allowed on the material.
  57223. */
  57224. maxSimultaneousLights: number;
  57225. /**
  57226. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57227. */
  57228. invertNormalMapX: boolean;
  57229. /**
  57230. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57231. */
  57232. invertNormalMapY: boolean;
  57233. /**
  57234. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57235. */
  57236. twoSidedLighting: boolean;
  57237. /**
  57238. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57239. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57240. */
  57241. useAlphaFresnel: boolean;
  57242. /**
  57243. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57244. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57245. */
  57246. useLinearAlphaFresnel: boolean;
  57247. /**
  57248. * Let user defines the brdf lookup texture used for IBL.
  57249. * A default 8bit version is embedded but you could point at :
  57250. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57251. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57252. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57253. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57254. */
  57255. environmentBRDFTexture: Nullable<BaseTexture>;
  57256. /**
  57257. * Force normal to face away from face.
  57258. */
  57259. forceNormalForward: boolean;
  57260. /**
  57261. * Enables specular anti aliasing in the PBR shader.
  57262. * It will both interacts on the Geometry for analytical and IBL lighting.
  57263. * It also prefilter the roughness map based on the bump values.
  57264. */
  57265. enableSpecularAntiAliasing: boolean;
  57266. /**
  57267. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57268. * makes the reflect vector face the model (under horizon).
  57269. */
  57270. useHorizonOcclusion: boolean;
  57271. /**
  57272. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57273. * too much the area relying on ambient texture to define their ambient occlusion.
  57274. */
  57275. useRadianceOcclusion: boolean;
  57276. /**
  57277. * If set to true, no lighting calculations will be applied.
  57278. */
  57279. unlit: boolean;
  57280. /**
  57281. * Gets the image processing configuration used either in this material.
  57282. */
  57283. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57284. /**
  57285. * Sets the Default image processing configuration used either in the this material.
  57286. *
  57287. * If sets to null, the scene one is in use.
  57288. */
  57289. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57290. /**
  57291. * Gets wether the color curves effect is enabled.
  57292. */
  57293. get cameraColorCurvesEnabled(): boolean;
  57294. /**
  57295. * Sets wether the color curves effect is enabled.
  57296. */
  57297. set cameraColorCurvesEnabled(value: boolean);
  57298. /**
  57299. * Gets wether the color grading effect is enabled.
  57300. */
  57301. get cameraColorGradingEnabled(): boolean;
  57302. /**
  57303. * Gets wether the color grading effect is enabled.
  57304. */
  57305. set cameraColorGradingEnabled(value: boolean);
  57306. /**
  57307. * Gets wether tonemapping is enabled or not.
  57308. */
  57309. get cameraToneMappingEnabled(): boolean;
  57310. /**
  57311. * Sets wether tonemapping is enabled or not
  57312. */
  57313. set cameraToneMappingEnabled(value: boolean);
  57314. /**
  57315. * The camera exposure used on this material.
  57316. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57317. * This corresponds to a photographic exposure.
  57318. */
  57319. get cameraExposure(): number;
  57320. /**
  57321. * The camera exposure used on this material.
  57322. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57323. * This corresponds to a photographic exposure.
  57324. */
  57325. set cameraExposure(value: number);
  57326. /**
  57327. * Gets The camera contrast used on this material.
  57328. */
  57329. get cameraContrast(): number;
  57330. /**
  57331. * Sets The camera contrast used on this material.
  57332. */
  57333. set cameraContrast(value: number);
  57334. /**
  57335. * Gets the Color Grading 2D Lookup Texture.
  57336. */
  57337. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57338. /**
  57339. * Sets the Color Grading 2D Lookup Texture.
  57340. */
  57341. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57342. /**
  57343. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57344. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57345. * 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;
  57346. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57347. */
  57348. get cameraColorCurves(): Nullable<ColorCurves>;
  57349. /**
  57350. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57351. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57352. * 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;
  57353. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57354. */
  57355. set cameraColorCurves(value: Nullable<ColorCurves>);
  57356. /**
  57357. * Instantiates a new PBRMaterial instance.
  57358. *
  57359. * @param name The material name
  57360. * @param scene The scene the material will be use in.
  57361. */
  57362. constructor(name: string, scene: Scene);
  57363. /**
  57364. * Returns the name of this material class.
  57365. */
  57366. getClassName(): string;
  57367. /**
  57368. * Makes a duplicate of the current material.
  57369. * @param name - name to use for the new material.
  57370. */
  57371. clone(name: string): PBRMaterial;
  57372. /**
  57373. * Serializes this PBR Material.
  57374. * @returns - An object with the serialized material.
  57375. */
  57376. serialize(): any;
  57377. /**
  57378. * Parses a PBR Material from a serialized object.
  57379. * @param source - Serialized object.
  57380. * @param scene - BJS scene instance.
  57381. * @param rootUrl - url for the scene object
  57382. * @returns - PBRMaterial
  57383. */
  57384. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57385. }
  57386. }
  57387. declare module BABYLON {
  57388. /**
  57389. * Direct draw surface info
  57390. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57391. */
  57392. export interface DDSInfo {
  57393. /**
  57394. * Width of the texture
  57395. */
  57396. width: number;
  57397. /**
  57398. * Width of the texture
  57399. */
  57400. height: number;
  57401. /**
  57402. * Number of Mipmaps for the texture
  57403. * @see https://en.wikipedia.org/wiki/Mipmap
  57404. */
  57405. mipmapCount: number;
  57406. /**
  57407. * If the textures format is a known fourCC format
  57408. * @see https://www.fourcc.org/
  57409. */
  57410. isFourCC: boolean;
  57411. /**
  57412. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57413. */
  57414. isRGB: boolean;
  57415. /**
  57416. * If the texture is a lumincance format
  57417. */
  57418. isLuminance: boolean;
  57419. /**
  57420. * If this is a cube texture
  57421. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57422. */
  57423. isCube: boolean;
  57424. /**
  57425. * If the texture is a compressed format eg. FOURCC_DXT1
  57426. */
  57427. isCompressed: boolean;
  57428. /**
  57429. * The dxgiFormat of the texture
  57430. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57431. */
  57432. dxgiFormat: number;
  57433. /**
  57434. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57435. */
  57436. textureType: number;
  57437. /**
  57438. * Sphericle polynomial created for the dds texture
  57439. */
  57440. sphericalPolynomial?: SphericalPolynomial;
  57441. }
  57442. /**
  57443. * Class used to provide DDS decompression tools
  57444. */
  57445. export class DDSTools {
  57446. /**
  57447. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57448. */
  57449. static StoreLODInAlphaChannel: boolean;
  57450. /**
  57451. * Gets DDS information from an array buffer
  57452. * @param data defines the array buffer view to read data from
  57453. * @returns the DDS information
  57454. */
  57455. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57456. private static _FloatView;
  57457. private static _Int32View;
  57458. private static _ToHalfFloat;
  57459. private static _FromHalfFloat;
  57460. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57461. private static _GetHalfFloatRGBAArrayBuffer;
  57462. private static _GetFloatRGBAArrayBuffer;
  57463. private static _GetFloatAsUIntRGBAArrayBuffer;
  57464. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57465. private static _GetRGBAArrayBuffer;
  57466. private static _ExtractLongWordOrder;
  57467. private static _GetRGBArrayBuffer;
  57468. private static _GetLuminanceArrayBuffer;
  57469. /**
  57470. * Uploads DDS Levels to a Babylon Texture
  57471. * @hidden
  57472. */
  57473. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57474. }
  57475. interface ThinEngine {
  57476. /**
  57477. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57478. * @param rootUrl defines the url where the file to load is located
  57479. * @param scene defines the current scene
  57480. * @param lodScale defines scale to apply to the mip map selection
  57481. * @param lodOffset defines offset to apply to the mip map selection
  57482. * @param onLoad defines an optional callback raised when the texture is loaded
  57483. * @param onError defines an optional callback raised if there is an issue to load the texture
  57484. * @param format defines the format of the data
  57485. * @param forcedExtension defines the extension to use to pick the right loader
  57486. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57487. * @returns the cube texture as an InternalTexture
  57488. */
  57489. 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;
  57490. }
  57491. }
  57492. declare module BABYLON {
  57493. /**
  57494. * Implementation of the DDS Texture Loader.
  57495. * @hidden
  57496. */
  57497. export class _DDSTextureLoader implements IInternalTextureLoader {
  57498. /**
  57499. * Defines wether the loader supports cascade loading the different faces.
  57500. */
  57501. readonly supportCascades: boolean;
  57502. /**
  57503. * This returns if the loader support the current file information.
  57504. * @param extension defines the file extension of the file being loaded
  57505. * @returns true if the loader can load the specified file
  57506. */
  57507. canLoad(extension: string): boolean;
  57508. /**
  57509. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57510. * @param data contains the texture data
  57511. * @param texture defines the BabylonJS internal texture
  57512. * @param createPolynomials will be true if polynomials have been requested
  57513. * @param onLoad defines the callback to trigger once the texture is ready
  57514. * @param onError defines the callback to trigger in case of error
  57515. */
  57516. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57517. /**
  57518. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57519. * @param data contains the texture data
  57520. * @param texture defines the BabylonJS internal texture
  57521. * @param callback defines the method to call once ready to upload
  57522. */
  57523. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57524. }
  57525. }
  57526. declare module BABYLON {
  57527. /**
  57528. * Implementation of the ENV Texture Loader.
  57529. * @hidden
  57530. */
  57531. export class _ENVTextureLoader implements IInternalTextureLoader {
  57532. /**
  57533. * Defines wether the loader supports cascade loading the different faces.
  57534. */
  57535. readonly supportCascades: boolean;
  57536. /**
  57537. * This returns if the loader support the current file information.
  57538. * @param extension defines the file extension of the file being loaded
  57539. * @returns true if the loader can load the specified file
  57540. */
  57541. canLoad(extension: string): boolean;
  57542. /**
  57543. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57544. * @param data contains the texture data
  57545. * @param texture defines the BabylonJS internal texture
  57546. * @param createPolynomials will be true if polynomials have been requested
  57547. * @param onLoad defines the callback to trigger once the texture is ready
  57548. * @param onError defines the callback to trigger in case of error
  57549. */
  57550. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57551. /**
  57552. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57553. * @param data contains the texture data
  57554. * @param texture defines the BabylonJS internal texture
  57555. * @param callback defines the method to call once ready to upload
  57556. */
  57557. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57558. }
  57559. }
  57560. declare module BABYLON {
  57561. /**
  57562. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57563. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57564. */
  57565. export class KhronosTextureContainer {
  57566. /** contents of the KTX container file */
  57567. data: ArrayBufferView;
  57568. private static HEADER_LEN;
  57569. private static COMPRESSED_2D;
  57570. private static COMPRESSED_3D;
  57571. private static TEX_2D;
  57572. private static TEX_3D;
  57573. /**
  57574. * Gets the openGL type
  57575. */
  57576. glType: number;
  57577. /**
  57578. * Gets the openGL type size
  57579. */
  57580. glTypeSize: number;
  57581. /**
  57582. * Gets the openGL format
  57583. */
  57584. glFormat: number;
  57585. /**
  57586. * Gets the openGL internal format
  57587. */
  57588. glInternalFormat: number;
  57589. /**
  57590. * Gets the base internal format
  57591. */
  57592. glBaseInternalFormat: number;
  57593. /**
  57594. * Gets image width in pixel
  57595. */
  57596. pixelWidth: number;
  57597. /**
  57598. * Gets image height in pixel
  57599. */
  57600. pixelHeight: number;
  57601. /**
  57602. * Gets image depth in pixels
  57603. */
  57604. pixelDepth: number;
  57605. /**
  57606. * Gets the number of array elements
  57607. */
  57608. numberOfArrayElements: number;
  57609. /**
  57610. * Gets the number of faces
  57611. */
  57612. numberOfFaces: number;
  57613. /**
  57614. * Gets the number of mipmap levels
  57615. */
  57616. numberOfMipmapLevels: number;
  57617. /**
  57618. * Gets the bytes of key value data
  57619. */
  57620. bytesOfKeyValueData: number;
  57621. /**
  57622. * Gets the load type
  57623. */
  57624. loadType: number;
  57625. /**
  57626. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57627. */
  57628. isInvalid: boolean;
  57629. /**
  57630. * Creates a new KhronosTextureContainer
  57631. * @param data contents of the KTX container file
  57632. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57633. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57634. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57635. */
  57636. constructor(
  57637. /** contents of the KTX container file */
  57638. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57639. /**
  57640. * Uploads KTX content to a Babylon Texture.
  57641. * It is assumed that the texture has already been created & is currently bound
  57642. * @hidden
  57643. */
  57644. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57645. private _upload2DCompressedLevels;
  57646. /**
  57647. * Checks if the given data starts with a KTX file identifier.
  57648. * @param data the data to check
  57649. * @returns true if the data is a KTX file or false otherwise
  57650. */
  57651. static IsValid(data: ArrayBufferView): boolean;
  57652. }
  57653. }
  57654. declare module BABYLON {
  57655. /**
  57656. * Class for loading KTX2 files
  57657. * !!! Experimental Extension Subject to Changes !!!
  57658. * @hidden
  57659. */
  57660. export class KhronosTextureContainer2 {
  57661. private static _ModulePromise;
  57662. private static _TranscodeFormat;
  57663. constructor(engine: ThinEngine);
  57664. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57665. private _determineTranscodeFormat;
  57666. /**
  57667. * Checks if the given data starts with a KTX2 file identifier.
  57668. * @param data the data to check
  57669. * @returns true if the data is a KTX2 file or false otherwise
  57670. */
  57671. static IsValid(data: ArrayBufferView): boolean;
  57672. }
  57673. }
  57674. declare module BABYLON {
  57675. /**
  57676. * Implementation of the KTX Texture Loader.
  57677. * @hidden
  57678. */
  57679. export class _KTXTextureLoader implements IInternalTextureLoader {
  57680. /**
  57681. * Defines wether the loader supports cascade loading the different faces.
  57682. */
  57683. readonly supportCascades: boolean;
  57684. /**
  57685. * This returns if the loader support the current file information.
  57686. * @param extension defines the file extension of the file being loaded
  57687. * @param mimeType defines the optional mime type of the file being loaded
  57688. * @returns true if the loader can load the specified file
  57689. */
  57690. canLoad(extension: string, mimeType?: string): boolean;
  57691. /**
  57692. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57693. * @param data contains the texture data
  57694. * @param texture defines the BabylonJS internal texture
  57695. * @param createPolynomials will be true if polynomials have been requested
  57696. * @param onLoad defines the callback to trigger once the texture is ready
  57697. * @param onError defines the callback to trigger in case of error
  57698. */
  57699. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57700. /**
  57701. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57702. * @param data contains the texture data
  57703. * @param texture defines the BabylonJS internal texture
  57704. * @param callback defines the method to call once ready to upload
  57705. */
  57706. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57707. }
  57708. }
  57709. declare module BABYLON {
  57710. /** @hidden */
  57711. export var _forceSceneHelpersToBundle: boolean;
  57712. interface Scene {
  57713. /**
  57714. * Creates a default light for the scene.
  57715. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57716. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57717. */
  57718. createDefaultLight(replace?: boolean): void;
  57719. /**
  57720. * Creates a default camera for the scene.
  57721. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57722. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57723. * @param replace has default false, when true replaces the active camera in the scene
  57724. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57725. */
  57726. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57727. /**
  57728. * Creates a default camera and a default light.
  57729. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57730. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57731. * @param replace has the default false, when true replaces the active camera/light in the scene
  57732. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57733. */
  57734. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57735. /**
  57736. * Creates a new sky box
  57737. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57738. * @param environmentTexture defines the texture to use as environment texture
  57739. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57740. * @param scale defines the overall scale of the skybox
  57741. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57742. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57743. * @returns a new mesh holding the sky box
  57744. */
  57745. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57746. /**
  57747. * Creates a new environment
  57748. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57749. * @param options defines the options you can use to configure the environment
  57750. * @returns the new EnvironmentHelper
  57751. */
  57752. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57753. /**
  57754. * Creates a new VREXperienceHelper
  57755. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57756. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57757. * @returns a new VREXperienceHelper
  57758. */
  57759. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57760. /**
  57761. * Creates a new WebXRDefaultExperience
  57762. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57763. * @param options experience options
  57764. * @returns a promise for a new WebXRDefaultExperience
  57765. */
  57766. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57767. }
  57768. }
  57769. declare module BABYLON {
  57770. /**
  57771. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57772. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57773. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57774. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57775. */
  57776. export class VideoDome extends TextureDome<VideoTexture> {
  57777. /**
  57778. * Define the video source as a Monoscopic panoramic 360 video.
  57779. */
  57780. static readonly MODE_MONOSCOPIC: number;
  57781. /**
  57782. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57783. */
  57784. static readonly MODE_TOPBOTTOM: number;
  57785. /**
  57786. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57787. */
  57788. static readonly MODE_SIDEBYSIDE: number;
  57789. /**
  57790. * Get the video texture associated with this video dome
  57791. */
  57792. get videoTexture(): VideoTexture;
  57793. /**
  57794. * Get the video mode of this dome
  57795. */
  57796. get videoMode(): number;
  57797. /**
  57798. * Set the video mode of this dome.
  57799. * @see textureMode
  57800. */
  57801. set videoMode(value: number);
  57802. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  57803. }
  57804. }
  57805. declare module BABYLON {
  57806. /**
  57807. * This class can be used to get instrumentation data from a Babylon engine
  57808. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57809. */
  57810. export class EngineInstrumentation implements IDisposable {
  57811. /**
  57812. * Define the instrumented engine.
  57813. */
  57814. engine: Engine;
  57815. private _captureGPUFrameTime;
  57816. private _gpuFrameTimeToken;
  57817. private _gpuFrameTime;
  57818. private _captureShaderCompilationTime;
  57819. private _shaderCompilationTime;
  57820. private _onBeginFrameObserver;
  57821. private _onEndFrameObserver;
  57822. private _onBeforeShaderCompilationObserver;
  57823. private _onAfterShaderCompilationObserver;
  57824. /**
  57825. * Gets the perf counter used for GPU frame time
  57826. */
  57827. get gpuFrameTimeCounter(): PerfCounter;
  57828. /**
  57829. * Gets the GPU frame time capture status
  57830. */
  57831. get captureGPUFrameTime(): boolean;
  57832. /**
  57833. * Enable or disable the GPU frame time capture
  57834. */
  57835. set captureGPUFrameTime(value: boolean);
  57836. /**
  57837. * Gets the perf counter used for shader compilation time
  57838. */
  57839. get shaderCompilationTimeCounter(): PerfCounter;
  57840. /**
  57841. * Gets the shader compilation time capture status
  57842. */
  57843. get captureShaderCompilationTime(): boolean;
  57844. /**
  57845. * Enable or disable the shader compilation time capture
  57846. */
  57847. set captureShaderCompilationTime(value: boolean);
  57848. /**
  57849. * Instantiates a new engine instrumentation.
  57850. * This class can be used to get instrumentation data from a Babylon engine
  57851. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57852. * @param engine Defines the engine to instrument
  57853. */
  57854. constructor(
  57855. /**
  57856. * Define the instrumented engine.
  57857. */
  57858. engine: Engine);
  57859. /**
  57860. * Dispose and release associated resources.
  57861. */
  57862. dispose(): void;
  57863. }
  57864. }
  57865. declare module BABYLON {
  57866. /**
  57867. * This class can be used to get instrumentation data from a Babylon engine
  57868. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57869. */
  57870. export class SceneInstrumentation implements IDisposable {
  57871. /**
  57872. * Defines the scene to instrument
  57873. */
  57874. scene: Scene;
  57875. private _captureActiveMeshesEvaluationTime;
  57876. private _activeMeshesEvaluationTime;
  57877. private _captureRenderTargetsRenderTime;
  57878. private _renderTargetsRenderTime;
  57879. private _captureFrameTime;
  57880. private _frameTime;
  57881. private _captureRenderTime;
  57882. private _renderTime;
  57883. private _captureInterFrameTime;
  57884. private _interFrameTime;
  57885. private _captureParticlesRenderTime;
  57886. private _particlesRenderTime;
  57887. private _captureSpritesRenderTime;
  57888. private _spritesRenderTime;
  57889. private _capturePhysicsTime;
  57890. private _physicsTime;
  57891. private _captureAnimationsTime;
  57892. private _animationsTime;
  57893. private _captureCameraRenderTime;
  57894. private _cameraRenderTime;
  57895. private _onBeforeActiveMeshesEvaluationObserver;
  57896. private _onAfterActiveMeshesEvaluationObserver;
  57897. private _onBeforeRenderTargetsRenderObserver;
  57898. private _onAfterRenderTargetsRenderObserver;
  57899. private _onAfterRenderObserver;
  57900. private _onBeforeDrawPhaseObserver;
  57901. private _onAfterDrawPhaseObserver;
  57902. private _onBeforeAnimationsObserver;
  57903. private _onBeforeParticlesRenderingObserver;
  57904. private _onAfterParticlesRenderingObserver;
  57905. private _onBeforeSpritesRenderingObserver;
  57906. private _onAfterSpritesRenderingObserver;
  57907. private _onBeforePhysicsObserver;
  57908. private _onAfterPhysicsObserver;
  57909. private _onAfterAnimationsObserver;
  57910. private _onBeforeCameraRenderObserver;
  57911. private _onAfterCameraRenderObserver;
  57912. /**
  57913. * Gets the perf counter used for active meshes evaluation time
  57914. */
  57915. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  57916. /**
  57917. * Gets the active meshes evaluation time capture status
  57918. */
  57919. get captureActiveMeshesEvaluationTime(): boolean;
  57920. /**
  57921. * Enable or disable the active meshes evaluation time capture
  57922. */
  57923. set captureActiveMeshesEvaluationTime(value: boolean);
  57924. /**
  57925. * Gets the perf counter used for render targets render time
  57926. */
  57927. get renderTargetsRenderTimeCounter(): PerfCounter;
  57928. /**
  57929. * Gets the render targets render time capture status
  57930. */
  57931. get captureRenderTargetsRenderTime(): boolean;
  57932. /**
  57933. * Enable or disable the render targets render time capture
  57934. */
  57935. set captureRenderTargetsRenderTime(value: boolean);
  57936. /**
  57937. * Gets the perf counter used for particles render time
  57938. */
  57939. get particlesRenderTimeCounter(): PerfCounter;
  57940. /**
  57941. * Gets the particles render time capture status
  57942. */
  57943. get captureParticlesRenderTime(): boolean;
  57944. /**
  57945. * Enable or disable the particles render time capture
  57946. */
  57947. set captureParticlesRenderTime(value: boolean);
  57948. /**
  57949. * Gets the perf counter used for sprites render time
  57950. */
  57951. get spritesRenderTimeCounter(): PerfCounter;
  57952. /**
  57953. * Gets the sprites render time capture status
  57954. */
  57955. get captureSpritesRenderTime(): boolean;
  57956. /**
  57957. * Enable or disable the sprites render time capture
  57958. */
  57959. set captureSpritesRenderTime(value: boolean);
  57960. /**
  57961. * Gets the perf counter used for physics time
  57962. */
  57963. get physicsTimeCounter(): PerfCounter;
  57964. /**
  57965. * Gets the physics time capture status
  57966. */
  57967. get capturePhysicsTime(): boolean;
  57968. /**
  57969. * Enable or disable the physics time capture
  57970. */
  57971. set capturePhysicsTime(value: boolean);
  57972. /**
  57973. * Gets the perf counter used for animations time
  57974. */
  57975. get animationsTimeCounter(): PerfCounter;
  57976. /**
  57977. * Gets the animations time capture status
  57978. */
  57979. get captureAnimationsTime(): boolean;
  57980. /**
  57981. * Enable or disable the animations time capture
  57982. */
  57983. set captureAnimationsTime(value: boolean);
  57984. /**
  57985. * Gets the perf counter used for frame time capture
  57986. */
  57987. get frameTimeCounter(): PerfCounter;
  57988. /**
  57989. * Gets the frame time capture status
  57990. */
  57991. get captureFrameTime(): boolean;
  57992. /**
  57993. * Enable or disable the frame time capture
  57994. */
  57995. set captureFrameTime(value: boolean);
  57996. /**
  57997. * Gets the perf counter used for inter-frames time capture
  57998. */
  57999. get interFrameTimeCounter(): PerfCounter;
  58000. /**
  58001. * Gets the inter-frames time capture status
  58002. */
  58003. get captureInterFrameTime(): boolean;
  58004. /**
  58005. * Enable or disable the inter-frames time capture
  58006. */
  58007. set captureInterFrameTime(value: boolean);
  58008. /**
  58009. * Gets the perf counter used for render time capture
  58010. */
  58011. get renderTimeCounter(): PerfCounter;
  58012. /**
  58013. * Gets the render time capture status
  58014. */
  58015. get captureRenderTime(): boolean;
  58016. /**
  58017. * Enable or disable the render time capture
  58018. */
  58019. set captureRenderTime(value: boolean);
  58020. /**
  58021. * Gets the perf counter used for camera render time capture
  58022. */
  58023. get cameraRenderTimeCounter(): PerfCounter;
  58024. /**
  58025. * Gets the camera render time capture status
  58026. */
  58027. get captureCameraRenderTime(): boolean;
  58028. /**
  58029. * Enable or disable the camera render time capture
  58030. */
  58031. set captureCameraRenderTime(value: boolean);
  58032. /**
  58033. * Gets the perf counter used for draw calls
  58034. */
  58035. get drawCallsCounter(): PerfCounter;
  58036. /**
  58037. * Instantiates a new scene instrumentation.
  58038. * This class can be used to get instrumentation data from a Babylon engine
  58039. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58040. * @param scene Defines the scene to instrument
  58041. */
  58042. constructor(
  58043. /**
  58044. * Defines the scene to instrument
  58045. */
  58046. scene: Scene);
  58047. /**
  58048. * Dispose and release associated resources.
  58049. */
  58050. dispose(): void;
  58051. }
  58052. }
  58053. declare module BABYLON {
  58054. /** @hidden */
  58055. export var glowMapGenerationPixelShader: {
  58056. name: string;
  58057. shader: string;
  58058. };
  58059. }
  58060. declare module BABYLON {
  58061. /** @hidden */
  58062. export var glowMapGenerationVertexShader: {
  58063. name: string;
  58064. shader: string;
  58065. };
  58066. }
  58067. declare module BABYLON {
  58068. /**
  58069. * Effect layer options. This helps customizing the behaviour
  58070. * of the effect layer.
  58071. */
  58072. export interface IEffectLayerOptions {
  58073. /**
  58074. * Multiplication factor apply to the canvas size to compute the render target size
  58075. * used to generated the objects (the smaller the faster).
  58076. */
  58077. mainTextureRatio: number;
  58078. /**
  58079. * Enforces a fixed size texture to ensure effect stability across devices.
  58080. */
  58081. mainTextureFixedSize?: number;
  58082. /**
  58083. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58084. */
  58085. alphaBlendingMode: number;
  58086. /**
  58087. * The camera attached to the layer.
  58088. */
  58089. camera: Nullable<Camera>;
  58090. /**
  58091. * The rendering group to draw the layer in.
  58092. */
  58093. renderingGroupId: number;
  58094. }
  58095. /**
  58096. * The effect layer Helps adding post process effect blended with the main pass.
  58097. *
  58098. * This can be for instance use to generate glow or higlight effects on the scene.
  58099. *
  58100. * The effect layer class can not be used directly and is intented to inherited from to be
  58101. * customized per effects.
  58102. */
  58103. export abstract class EffectLayer {
  58104. private _vertexBuffers;
  58105. private _indexBuffer;
  58106. private _cachedDefines;
  58107. private _effectLayerMapGenerationEffect;
  58108. private _effectLayerOptions;
  58109. private _mergeEffect;
  58110. protected _scene: Scene;
  58111. protected _engine: Engine;
  58112. protected _maxSize: number;
  58113. protected _mainTextureDesiredSize: ISize;
  58114. protected _mainTexture: RenderTargetTexture;
  58115. protected _shouldRender: boolean;
  58116. protected _postProcesses: PostProcess[];
  58117. protected _textures: BaseTexture[];
  58118. protected _emissiveTextureAndColor: {
  58119. texture: Nullable<BaseTexture>;
  58120. color: Color4;
  58121. };
  58122. /**
  58123. * The name of the layer
  58124. */
  58125. name: string;
  58126. /**
  58127. * The clear color of the texture used to generate the glow map.
  58128. */
  58129. neutralColor: Color4;
  58130. /**
  58131. * Specifies whether the highlight layer is enabled or not.
  58132. */
  58133. isEnabled: boolean;
  58134. /**
  58135. * Gets the camera attached to the layer.
  58136. */
  58137. get camera(): Nullable<Camera>;
  58138. /**
  58139. * Gets the rendering group id the layer should render in.
  58140. */
  58141. get renderingGroupId(): number;
  58142. set renderingGroupId(renderingGroupId: number);
  58143. /**
  58144. * An event triggered when the effect layer has been disposed.
  58145. */
  58146. onDisposeObservable: Observable<EffectLayer>;
  58147. /**
  58148. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58149. */
  58150. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58151. /**
  58152. * An event triggered when the generated texture is being merged in the scene.
  58153. */
  58154. onBeforeComposeObservable: Observable<EffectLayer>;
  58155. /**
  58156. * An event triggered when the mesh is rendered into the effect render target.
  58157. */
  58158. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58159. /**
  58160. * An event triggered after the mesh has been rendered into the effect render target.
  58161. */
  58162. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58163. /**
  58164. * An event triggered when the generated texture has been merged in the scene.
  58165. */
  58166. onAfterComposeObservable: Observable<EffectLayer>;
  58167. /**
  58168. * An event triggered when the efffect layer changes its size.
  58169. */
  58170. onSizeChangedObservable: Observable<EffectLayer>;
  58171. /** @hidden */
  58172. static _SceneComponentInitialization: (scene: Scene) => void;
  58173. /**
  58174. * Instantiates a new effect Layer and references it in the scene.
  58175. * @param name The name of the layer
  58176. * @param scene The scene to use the layer in
  58177. */
  58178. constructor(
  58179. /** The Friendly of the effect in the scene */
  58180. name: string, scene: Scene);
  58181. /**
  58182. * Get the effect name of the layer.
  58183. * @return The effect name
  58184. */
  58185. abstract getEffectName(): string;
  58186. /**
  58187. * Checks for the readiness of the element composing the layer.
  58188. * @param subMesh the mesh to check for
  58189. * @param useInstances specify whether or not to use instances to render the mesh
  58190. * @return true if ready otherwise, false
  58191. */
  58192. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58193. /**
  58194. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58195. * @returns true if the effect requires stencil during the main canvas render pass.
  58196. */
  58197. abstract needStencil(): boolean;
  58198. /**
  58199. * Create the merge effect. This is the shader use to blit the information back
  58200. * to the main canvas at the end of the scene rendering.
  58201. * @returns The effect containing the shader used to merge the effect on the main canvas
  58202. */
  58203. protected abstract _createMergeEffect(): Effect;
  58204. /**
  58205. * Creates the render target textures and post processes used in the effect layer.
  58206. */
  58207. protected abstract _createTextureAndPostProcesses(): void;
  58208. /**
  58209. * Implementation specific of rendering the generating effect on the main canvas.
  58210. * @param effect The effect used to render through
  58211. */
  58212. protected abstract _internalRender(effect: Effect): void;
  58213. /**
  58214. * Sets the required values for both the emissive texture and and the main color.
  58215. */
  58216. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58217. /**
  58218. * Free any resources and references associated to a mesh.
  58219. * Internal use
  58220. * @param mesh The mesh to free.
  58221. */
  58222. abstract _disposeMesh(mesh: Mesh): void;
  58223. /**
  58224. * Serializes this layer (Glow or Highlight for example)
  58225. * @returns a serialized layer object
  58226. */
  58227. abstract serialize?(): any;
  58228. /**
  58229. * Initializes the effect layer with the required options.
  58230. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58231. */
  58232. protected _init(options: Partial<IEffectLayerOptions>): void;
  58233. /**
  58234. * Generates the index buffer of the full screen quad blending to the main canvas.
  58235. */
  58236. private _generateIndexBuffer;
  58237. /**
  58238. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58239. */
  58240. private _generateVertexBuffer;
  58241. /**
  58242. * Sets the main texture desired size which is the closest power of two
  58243. * of the engine canvas size.
  58244. */
  58245. private _setMainTextureSize;
  58246. /**
  58247. * Creates the main texture for the effect layer.
  58248. */
  58249. protected _createMainTexture(): void;
  58250. /**
  58251. * Adds specific effects defines.
  58252. * @param defines The defines to add specifics to.
  58253. */
  58254. protected _addCustomEffectDefines(defines: string[]): void;
  58255. /**
  58256. * Checks for the readiness of the element composing the layer.
  58257. * @param subMesh the mesh to check for
  58258. * @param useInstances specify whether or not to use instances to render the mesh
  58259. * @param emissiveTexture the associated emissive texture used to generate the glow
  58260. * @return true if ready otherwise, false
  58261. */
  58262. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58263. /**
  58264. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58265. */
  58266. render(): void;
  58267. /**
  58268. * Determine if a given mesh will be used in the current effect.
  58269. * @param mesh mesh to test
  58270. * @returns true if the mesh will be used
  58271. */
  58272. hasMesh(mesh: AbstractMesh): boolean;
  58273. /**
  58274. * Returns true if the layer contains information to display, otherwise false.
  58275. * @returns true if the glow layer should be rendered
  58276. */
  58277. shouldRender(): boolean;
  58278. /**
  58279. * Returns true if the mesh should render, otherwise false.
  58280. * @param mesh The mesh to render
  58281. * @returns true if it should render otherwise false
  58282. */
  58283. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58284. /**
  58285. * Returns true if the mesh can be rendered, otherwise false.
  58286. * @param mesh The mesh to render
  58287. * @param material The material used on the mesh
  58288. * @returns true if it can be rendered otherwise false
  58289. */
  58290. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58291. /**
  58292. * Returns true if the mesh should render, otherwise false.
  58293. * @param mesh The mesh to render
  58294. * @returns true if it should render otherwise false
  58295. */
  58296. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58297. /**
  58298. * Renders the submesh passed in parameter to the generation map.
  58299. */
  58300. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58301. /**
  58302. * Defines whether the current material of the mesh should be use to render the effect.
  58303. * @param mesh defines the current mesh to render
  58304. */
  58305. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58306. /**
  58307. * Rebuild the required buffers.
  58308. * @hidden Internal use only.
  58309. */
  58310. _rebuild(): void;
  58311. /**
  58312. * Dispose only the render target textures and post process.
  58313. */
  58314. private _disposeTextureAndPostProcesses;
  58315. /**
  58316. * Dispose the highlight layer and free resources.
  58317. */
  58318. dispose(): void;
  58319. /**
  58320. * Gets the class name of the effect layer
  58321. * @returns the string with the class name of the effect layer
  58322. */
  58323. getClassName(): string;
  58324. /**
  58325. * Creates an effect layer from parsed effect layer data
  58326. * @param parsedEffectLayer defines effect layer data
  58327. * @param scene defines the current scene
  58328. * @param rootUrl defines the root URL containing the effect layer information
  58329. * @returns a parsed effect Layer
  58330. */
  58331. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58332. }
  58333. }
  58334. declare module BABYLON {
  58335. interface AbstractScene {
  58336. /**
  58337. * The list of effect layers (highlights/glow) added to the scene
  58338. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58339. * @see https://doc.babylonjs.com/how_to/glow_layer
  58340. */
  58341. effectLayers: Array<EffectLayer>;
  58342. /**
  58343. * Removes the given effect layer from this scene.
  58344. * @param toRemove defines the effect layer to remove
  58345. * @returns the index of the removed effect layer
  58346. */
  58347. removeEffectLayer(toRemove: EffectLayer): number;
  58348. /**
  58349. * Adds the given effect layer to this scene
  58350. * @param newEffectLayer defines the effect layer to add
  58351. */
  58352. addEffectLayer(newEffectLayer: EffectLayer): void;
  58353. }
  58354. /**
  58355. * Defines the layer scene component responsible to manage any effect layers
  58356. * in a given scene.
  58357. */
  58358. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58359. /**
  58360. * The component name helpfull to identify the component in the list of scene components.
  58361. */
  58362. readonly name: string;
  58363. /**
  58364. * The scene the component belongs to.
  58365. */
  58366. scene: Scene;
  58367. private _engine;
  58368. private _renderEffects;
  58369. private _needStencil;
  58370. private _previousStencilState;
  58371. /**
  58372. * Creates a new instance of the component for the given scene
  58373. * @param scene Defines the scene to register the component in
  58374. */
  58375. constructor(scene: Scene);
  58376. /**
  58377. * Registers the component in a given scene
  58378. */
  58379. register(): void;
  58380. /**
  58381. * Rebuilds the elements related to this component in case of
  58382. * context lost for instance.
  58383. */
  58384. rebuild(): void;
  58385. /**
  58386. * Serializes the component data to the specified json object
  58387. * @param serializationObject The object to serialize to
  58388. */
  58389. serialize(serializationObject: any): void;
  58390. /**
  58391. * Adds all the elements from the container to the scene
  58392. * @param container the container holding the elements
  58393. */
  58394. addFromContainer(container: AbstractScene): void;
  58395. /**
  58396. * Removes all the elements in the container from the scene
  58397. * @param container contains the elements to remove
  58398. * @param dispose if the removed element should be disposed (default: false)
  58399. */
  58400. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58401. /**
  58402. * Disposes the component and the associated ressources.
  58403. */
  58404. dispose(): void;
  58405. private _isReadyForMesh;
  58406. private _renderMainTexture;
  58407. private _setStencil;
  58408. private _setStencilBack;
  58409. private _draw;
  58410. private _drawCamera;
  58411. private _drawRenderingGroup;
  58412. }
  58413. }
  58414. declare module BABYLON {
  58415. /** @hidden */
  58416. export var glowMapMergePixelShader: {
  58417. name: string;
  58418. shader: string;
  58419. };
  58420. }
  58421. declare module BABYLON {
  58422. /** @hidden */
  58423. export var glowMapMergeVertexShader: {
  58424. name: string;
  58425. shader: string;
  58426. };
  58427. }
  58428. declare module BABYLON {
  58429. interface AbstractScene {
  58430. /**
  58431. * Return a the first highlight layer of the scene with a given name.
  58432. * @param name The name of the highlight layer to look for.
  58433. * @return The highlight layer if found otherwise null.
  58434. */
  58435. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58436. }
  58437. /**
  58438. * Glow layer options. This helps customizing the behaviour
  58439. * of the glow layer.
  58440. */
  58441. export interface IGlowLayerOptions {
  58442. /**
  58443. * Multiplication factor apply to the canvas size to compute the render target size
  58444. * used to generated the glowing objects (the smaller the faster).
  58445. */
  58446. mainTextureRatio: number;
  58447. /**
  58448. * Enforces a fixed size texture to ensure resize independant blur.
  58449. */
  58450. mainTextureFixedSize?: number;
  58451. /**
  58452. * How big is the kernel of the blur texture.
  58453. */
  58454. blurKernelSize: number;
  58455. /**
  58456. * The camera attached to the layer.
  58457. */
  58458. camera: Nullable<Camera>;
  58459. /**
  58460. * Enable MSAA by chosing the number of samples.
  58461. */
  58462. mainTextureSamples?: number;
  58463. /**
  58464. * The rendering group to draw the layer in.
  58465. */
  58466. renderingGroupId: number;
  58467. }
  58468. /**
  58469. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58470. *
  58471. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58472. *
  58473. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58474. */
  58475. export class GlowLayer extends EffectLayer {
  58476. /**
  58477. * Effect Name of the layer.
  58478. */
  58479. static readonly EffectName: string;
  58480. /**
  58481. * The default blur kernel size used for the glow.
  58482. */
  58483. static DefaultBlurKernelSize: number;
  58484. /**
  58485. * The default texture size ratio used for the glow.
  58486. */
  58487. static DefaultTextureRatio: number;
  58488. /**
  58489. * Sets the kernel size of the blur.
  58490. */
  58491. set blurKernelSize(value: number);
  58492. /**
  58493. * Gets the kernel size of the blur.
  58494. */
  58495. get blurKernelSize(): number;
  58496. /**
  58497. * Sets the glow intensity.
  58498. */
  58499. set intensity(value: number);
  58500. /**
  58501. * Gets the glow intensity.
  58502. */
  58503. get intensity(): number;
  58504. private _options;
  58505. private _intensity;
  58506. private _horizontalBlurPostprocess1;
  58507. private _verticalBlurPostprocess1;
  58508. private _horizontalBlurPostprocess2;
  58509. private _verticalBlurPostprocess2;
  58510. private _blurTexture1;
  58511. private _blurTexture2;
  58512. private _postProcesses1;
  58513. private _postProcesses2;
  58514. private _includedOnlyMeshes;
  58515. private _excludedMeshes;
  58516. private _meshesUsingTheirOwnMaterials;
  58517. /**
  58518. * Callback used to let the user override the color selection on a per mesh basis
  58519. */
  58520. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58521. /**
  58522. * Callback used to let the user override the texture selection on a per mesh basis
  58523. */
  58524. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58525. /**
  58526. * Instantiates a new glow Layer and references it to the scene.
  58527. * @param name The name of the layer
  58528. * @param scene The scene to use the layer in
  58529. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58530. */
  58531. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58532. /**
  58533. * Get the effect name of the layer.
  58534. * @return The effect name
  58535. */
  58536. getEffectName(): string;
  58537. /**
  58538. * Create the merge effect. This is the shader use to blit the information back
  58539. * to the main canvas at the end of the scene rendering.
  58540. */
  58541. protected _createMergeEffect(): Effect;
  58542. /**
  58543. * Creates the render target textures and post processes used in the glow layer.
  58544. */
  58545. protected _createTextureAndPostProcesses(): void;
  58546. /**
  58547. * Checks for the readiness of the element composing the layer.
  58548. * @param subMesh the mesh to check for
  58549. * @param useInstances specify wether or not to use instances to render the mesh
  58550. * @param emissiveTexture the associated emissive texture used to generate the glow
  58551. * @return true if ready otherwise, false
  58552. */
  58553. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58554. /**
  58555. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58556. */
  58557. needStencil(): boolean;
  58558. /**
  58559. * Returns true if the mesh can be rendered, otherwise false.
  58560. * @param mesh The mesh to render
  58561. * @param material The material used on the mesh
  58562. * @returns true if it can be rendered otherwise false
  58563. */
  58564. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58565. /**
  58566. * Implementation specific of rendering the generating effect on the main canvas.
  58567. * @param effect The effect used to render through
  58568. */
  58569. protected _internalRender(effect: Effect): void;
  58570. /**
  58571. * Sets the required values for both the emissive texture and and the main color.
  58572. */
  58573. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  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: Mesh): boolean;
  58580. /**
  58581. * Adds specific effects defines.
  58582. * @param defines The defines to add specifics to.
  58583. */
  58584. protected _addCustomEffectDefines(defines: string[]): void;
  58585. /**
  58586. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58587. * @param mesh The mesh to exclude from the glow layer
  58588. */
  58589. addExcludedMesh(mesh: Mesh): void;
  58590. /**
  58591. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58592. * @param mesh The mesh to remove
  58593. */
  58594. removeExcludedMesh(mesh: Mesh): void;
  58595. /**
  58596. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58597. * @param mesh The mesh to include in the glow layer
  58598. */
  58599. addIncludedOnlyMesh(mesh: Mesh): void;
  58600. /**
  58601. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58602. * @param mesh The mesh to remove
  58603. */
  58604. removeIncludedOnlyMesh(mesh: Mesh): void;
  58605. /**
  58606. * Determine if a given mesh will be used in the glow layer
  58607. * @param mesh The mesh to test
  58608. * @returns true if the mesh will be highlighted by the current glow layer
  58609. */
  58610. hasMesh(mesh: AbstractMesh): boolean;
  58611. /**
  58612. * Defines whether the current material of the mesh should be use to render the effect.
  58613. * @param mesh defines the current mesh to render
  58614. */
  58615. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58616. /**
  58617. * Add a mesh to be rendered through its own material and not with emissive only.
  58618. * @param mesh The mesh for which we need to use its material
  58619. */
  58620. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58621. /**
  58622. * Remove a mesh from being rendered through its own material and not with emissive only.
  58623. * @param mesh The mesh for which we need to not use its material
  58624. */
  58625. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58626. /**
  58627. * Free any resources and references associated to a mesh.
  58628. * Internal use
  58629. * @param mesh The mesh to free.
  58630. * @hidden
  58631. */
  58632. _disposeMesh(mesh: Mesh): void;
  58633. /**
  58634. * Gets the class name of the effect layer
  58635. * @returns the string with the class name of the effect layer
  58636. */
  58637. getClassName(): string;
  58638. /**
  58639. * Serializes this glow layer
  58640. * @returns a serialized glow layer object
  58641. */
  58642. serialize(): any;
  58643. /**
  58644. * Creates a Glow Layer from parsed glow layer data
  58645. * @param parsedGlowLayer defines glow layer data
  58646. * @param scene defines the current scene
  58647. * @param rootUrl defines the root URL containing the glow layer information
  58648. * @returns a parsed Glow Layer
  58649. */
  58650. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58651. }
  58652. }
  58653. declare module BABYLON {
  58654. /** @hidden */
  58655. export var glowBlurPostProcessPixelShader: {
  58656. name: string;
  58657. shader: string;
  58658. };
  58659. }
  58660. declare module BABYLON {
  58661. interface AbstractScene {
  58662. /**
  58663. * Return a the first highlight layer of the scene with a given name.
  58664. * @param name The name of the highlight layer to look for.
  58665. * @return The highlight layer if found otherwise null.
  58666. */
  58667. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58668. }
  58669. /**
  58670. * Highlight layer options. This helps customizing the behaviour
  58671. * of the highlight layer.
  58672. */
  58673. export interface IHighlightLayerOptions {
  58674. /**
  58675. * Multiplication factor apply to the canvas size to compute the render target size
  58676. * used to generated the glowing objects (the smaller the faster).
  58677. */
  58678. mainTextureRatio: number;
  58679. /**
  58680. * Enforces a fixed size texture to ensure resize independant blur.
  58681. */
  58682. mainTextureFixedSize?: number;
  58683. /**
  58684. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58685. * of the picture to blur (the smaller the faster).
  58686. */
  58687. blurTextureSizeRatio: number;
  58688. /**
  58689. * How big in texel of the blur texture is the vertical blur.
  58690. */
  58691. blurVerticalSize: number;
  58692. /**
  58693. * How big in texel of the blur texture is the horizontal blur.
  58694. */
  58695. blurHorizontalSize: number;
  58696. /**
  58697. * Alpha blending mode used to apply the blur. Default is combine.
  58698. */
  58699. alphaBlendingMode: number;
  58700. /**
  58701. * The camera attached to the layer.
  58702. */
  58703. camera: Nullable<Camera>;
  58704. /**
  58705. * Should we display highlight as a solid stroke?
  58706. */
  58707. isStroke?: boolean;
  58708. /**
  58709. * The rendering group to draw the layer in.
  58710. */
  58711. renderingGroupId: number;
  58712. }
  58713. /**
  58714. * The highlight layer Helps adding a glow effect around a mesh.
  58715. *
  58716. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58717. * glowy meshes to your scene.
  58718. *
  58719. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58720. */
  58721. export class HighlightLayer extends EffectLayer {
  58722. name: string;
  58723. /**
  58724. * Effect Name of the highlight layer.
  58725. */
  58726. static readonly EffectName: string;
  58727. /**
  58728. * The neutral color used during the preparation of the glow effect.
  58729. * This is black by default as the blend operation is a blend operation.
  58730. */
  58731. static NeutralColor: Color4;
  58732. /**
  58733. * Stencil value used for glowing meshes.
  58734. */
  58735. static GlowingMeshStencilReference: number;
  58736. /**
  58737. * Stencil value used for the other meshes in the scene.
  58738. */
  58739. static NormalMeshStencilReference: number;
  58740. /**
  58741. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58742. */
  58743. innerGlow: boolean;
  58744. /**
  58745. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58746. */
  58747. outerGlow: boolean;
  58748. /**
  58749. * Specifies the horizontal size of the blur.
  58750. */
  58751. set blurHorizontalSize(value: number);
  58752. /**
  58753. * Specifies the vertical size of the blur.
  58754. */
  58755. set blurVerticalSize(value: number);
  58756. /**
  58757. * Gets the horizontal size of the blur.
  58758. */
  58759. get blurHorizontalSize(): number;
  58760. /**
  58761. * Gets the vertical size of the blur.
  58762. */
  58763. get blurVerticalSize(): number;
  58764. /**
  58765. * An event triggered when the highlight layer is being blurred.
  58766. */
  58767. onBeforeBlurObservable: Observable<HighlightLayer>;
  58768. /**
  58769. * An event triggered when the highlight layer has been blurred.
  58770. */
  58771. onAfterBlurObservable: Observable<HighlightLayer>;
  58772. private _instanceGlowingMeshStencilReference;
  58773. private _options;
  58774. private _downSamplePostprocess;
  58775. private _horizontalBlurPostprocess;
  58776. private _verticalBlurPostprocess;
  58777. private _blurTexture;
  58778. private _meshes;
  58779. private _excludedMeshes;
  58780. /**
  58781. * Instantiates a new highlight Layer and references it to the scene..
  58782. * @param name The name of the layer
  58783. * @param scene The scene to use the layer in
  58784. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58785. */
  58786. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58787. /**
  58788. * Get the effect name of the layer.
  58789. * @return The effect name
  58790. */
  58791. getEffectName(): string;
  58792. /**
  58793. * Create the merge effect. This is the shader use to blit the information back
  58794. * to the main canvas at the end of the scene rendering.
  58795. */
  58796. protected _createMergeEffect(): Effect;
  58797. /**
  58798. * Creates the render target textures and post processes used in the highlight layer.
  58799. */
  58800. protected _createTextureAndPostProcesses(): void;
  58801. /**
  58802. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58803. */
  58804. needStencil(): boolean;
  58805. /**
  58806. * Checks for the readiness of the element composing the layer.
  58807. * @param subMesh the mesh to check for
  58808. * @param useInstances specify wether or not to use instances to render the mesh
  58809. * @param emissiveTexture the associated emissive texture used to generate the glow
  58810. * @return true if ready otherwise, false
  58811. */
  58812. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58813. /**
  58814. * Implementation specific of rendering the generating effect on the main canvas.
  58815. * @param effect The effect used to render through
  58816. */
  58817. protected _internalRender(effect: Effect): void;
  58818. /**
  58819. * Returns true if the layer contains information to display, otherwise false.
  58820. */
  58821. shouldRender(): boolean;
  58822. /**
  58823. * Returns true if the mesh should render, otherwise false.
  58824. * @param mesh The mesh to render
  58825. * @returns true if it should render otherwise false
  58826. */
  58827. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58828. /**
  58829. * Returns true if the mesh can be rendered, otherwise false.
  58830. * @param mesh The mesh to render
  58831. * @param material The material used on the mesh
  58832. * @returns true if it can be rendered otherwise false
  58833. */
  58834. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58835. /**
  58836. * Adds specific effects defines.
  58837. * @param defines The defines to add specifics to.
  58838. */
  58839. protected _addCustomEffectDefines(defines: string[]): void;
  58840. /**
  58841. * Sets the required values for both the emissive texture and and the main color.
  58842. */
  58843. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58844. /**
  58845. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58846. * @param mesh The mesh to exclude from the highlight layer
  58847. */
  58848. addExcludedMesh(mesh: Mesh): void;
  58849. /**
  58850. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58851. * @param mesh The mesh to highlight
  58852. */
  58853. removeExcludedMesh(mesh: Mesh): void;
  58854. /**
  58855. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58856. * @param mesh mesh to test
  58857. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58858. */
  58859. hasMesh(mesh: AbstractMesh): boolean;
  58860. /**
  58861. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  58862. * @param mesh The mesh to highlight
  58863. * @param color The color of the highlight
  58864. * @param glowEmissiveOnly Extract the glow from the emissive texture
  58865. */
  58866. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  58867. /**
  58868. * Remove a mesh from the highlight layer in order to make it stop glowing.
  58869. * @param mesh The mesh to highlight
  58870. */
  58871. removeMesh(mesh: Mesh): void;
  58872. /**
  58873. * Remove all the meshes currently referenced in the highlight layer
  58874. */
  58875. removeAllMeshes(): void;
  58876. /**
  58877. * Force the stencil to the normal expected value for none glowing parts
  58878. */
  58879. private _defaultStencilReference;
  58880. /**
  58881. * Free any resources and references associated to a mesh.
  58882. * Internal use
  58883. * @param mesh The mesh to free.
  58884. * @hidden
  58885. */
  58886. _disposeMesh(mesh: Mesh): void;
  58887. /**
  58888. * Dispose the highlight layer and free resources.
  58889. */
  58890. dispose(): void;
  58891. /**
  58892. * Gets the class name of the effect layer
  58893. * @returns the string with the class name of the effect layer
  58894. */
  58895. getClassName(): string;
  58896. /**
  58897. * Serializes this Highlight layer
  58898. * @returns a serialized Highlight layer object
  58899. */
  58900. serialize(): any;
  58901. /**
  58902. * Creates a Highlight layer from parsed Highlight layer data
  58903. * @param parsedHightlightLayer defines the Highlight layer data
  58904. * @param scene defines the current scene
  58905. * @param rootUrl defines the root URL containing the Highlight layer information
  58906. * @returns a parsed Highlight layer
  58907. */
  58908. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  58909. }
  58910. }
  58911. declare module BABYLON {
  58912. interface AbstractScene {
  58913. /**
  58914. * The list of layers (background and foreground) of the scene
  58915. */
  58916. layers: Array<Layer>;
  58917. }
  58918. /**
  58919. * Defines the layer scene component responsible to manage any layers
  58920. * in a given scene.
  58921. */
  58922. export class LayerSceneComponent implements ISceneComponent {
  58923. /**
  58924. * The component name helpfull to identify the component in the list of scene components.
  58925. */
  58926. readonly name: string;
  58927. /**
  58928. * The scene the component belongs to.
  58929. */
  58930. scene: Scene;
  58931. private _engine;
  58932. /**
  58933. * Creates a new instance of the component for the given scene
  58934. * @param scene Defines the scene to register the component in
  58935. */
  58936. constructor(scene: Scene);
  58937. /**
  58938. * Registers the component in a given scene
  58939. */
  58940. register(): void;
  58941. /**
  58942. * Rebuilds the elements related to this component in case of
  58943. * context lost for instance.
  58944. */
  58945. rebuild(): void;
  58946. /**
  58947. * Disposes the component and the associated ressources.
  58948. */
  58949. dispose(): void;
  58950. private _draw;
  58951. private _drawCameraPredicate;
  58952. private _drawCameraBackground;
  58953. private _drawCameraForeground;
  58954. private _drawRenderTargetPredicate;
  58955. private _drawRenderTargetBackground;
  58956. private _drawRenderTargetForeground;
  58957. /**
  58958. * Adds all the elements from the container to the scene
  58959. * @param container the container holding the elements
  58960. */
  58961. addFromContainer(container: AbstractScene): void;
  58962. /**
  58963. * Removes all the elements in the container from the scene
  58964. * @param container contains the elements to remove
  58965. * @param dispose if the removed element should be disposed (default: false)
  58966. */
  58967. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58968. }
  58969. }
  58970. declare module BABYLON {
  58971. /** @hidden */
  58972. export var layerPixelShader: {
  58973. name: string;
  58974. shader: string;
  58975. };
  58976. }
  58977. declare module BABYLON {
  58978. /** @hidden */
  58979. export var layerVertexShader: {
  58980. name: string;
  58981. shader: string;
  58982. };
  58983. }
  58984. declare module BABYLON {
  58985. /**
  58986. * This represents a full screen 2d layer.
  58987. * This can be useful to display a picture in the background of your scene for instance.
  58988. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58989. */
  58990. export class Layer {
  58991. /**
  58992. * Define the name of the layer.
  58993. */
  58994. name: string;
  58995. /**
  58996. * Define the texture the layer should display.
  58997. */
  58998. texture: Nullable<Texture>;
  58999. /**
  59000. * Is the layer in background or foreground.
  59001. */
  59002. isBackground: boolean;
  59003. /**
  59004. * Define the color of the layer (instead of texture).
  59005. */
  59006. color: Color4;
  59007. /**
  59008. * Define the scale of the layer in order to zoom in out of the texture.
  59009. */
  59010. scale: Vector2;
  59011. /**
  59012. * Define an offset for the layer in order to shift the texture.
  59013. */
  59014. offset: Vector2;
  59015. /**
  59016. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59017. */
  59018. alphaBlendingMode: number;
  59019. /**
  59020. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59021. * Alpha test will not mix with the background color in case of transparency.
  59022. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59023. */
  59024. alphaTest: boolean;
  59025. /**
  59026. * Define a mask to restrict the layer to only some of the scene cameras.
  59027. */
  59028. layerMask: number;
  59029. /**
  59030. * Define the list of render target the layer is visible into.
  59031. */
  59032. renderTargetTextures: RenderTargetTexture[];
  59033. /**
  59034. * Define if the layer is only used in renderTarget or if it also
  59035. * renders in the main frame buffer of the canvas.
  59036. */
  59037. renderOnlyInRenderTargetTextures: boolean;
  59038. private _scene;
  59039. private _vertexBuffers;
  59040. private _indexBuffer;
  59041. private _effect;
  59042. private _previousDefines;
  59043. /**
  59044. * An event triggered when the layer is disposed.
  59045. */
  59046. onDisposeObservable: Observable<Layer>;
  59047. private _onDisposeObserver;
  59048. /**
  59049. * Back compatibility with callback before the onDisposeObservable existed.
  59050. * The set callback will be triggered when the layer has been disposed.
  59051. */
  59052. set onDispose(callback: () => void);
  59053. /**
  59054. * An event triggered before rendering the scene
  59055. */
  59056. onBeforeRenderObservable: Observable<Layer>;
  59057. private _onBeforeRenderObserver;
  59058. /**
  59059. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59060. * The set callback will be triggered just before rendering the layer.
  59061. */
  59062. set onBeforeRender(callback: () => void);
  59063. /**
  59064. * An event triggered after rendering the scene
  59065. */
  59066. onAfterRenderObservable: Observable<Layer>;
  59067. private _onAfterRenderObserver;
  59068. /**
  59069. * Back compatibility with callback before the onAfterRenderObservable existed.
  59070. * The set callback will be triggered just after rendering the layer.
  59071. */
  59072. set onAfterRender(callback: () => void);
  59073. /**
  59074. * Instantiates a new layer.
  59075. * This represents a full screen 2d layer.
  59076. * This can be useful to display a picture in the background of your scene for instance.
  59077. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59078. * @param name Define the name of the layer in the scene
  59079. * @param imgUrl Define the url of the texture to display in the layer
  59080. * @param scene Define the scene the layer belongs to
  59081. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59082. * @param color Defines a color for the layer
  59083. */
  59084. constructor(
  59085. /**
  59086. * Define the name of the layer.
  59087. */
  59088. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59089. private _createIndexBuffer;
  59090. /** @hidden */
  59091. _rebuild(): void;
  59092. /**
  59093. * Renders the layer in the scene.
  59094. */
  59095. render(): void;
  59096. /**
  59097. * Disposes and releases the associated ressources.
  59098. */
  59099. dispose(): void;
  59100. }
  59101. }
  59102. declare module BABYLON {
  59103. /** @hidden */
  59104. export var lensFlarePixelShader: {
  59105. name: string;
  59106. shader: string;
  59107. };
  59108. }
  59109. declare module BABYLON {
  59110. /** @hidden */
  59111. export var lensFlareVertexShader: {
  59112. name: string;
  59113. shader: string;
  59114. };
  59115. }
  59116. declare module BABYLON {
  59117. /**
  59118. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59119. * It is usually composed of several `lensFlare`.
  59120. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59121. */
  59122. export class LensFlareSystem {
  59123. /**
  59124. * Define the name of the lens flare system
  59125. */
  59126. name: string;
  59127. /**
  59128. * List of lens flares used in this system.
  59129. */
  59130. lensFlares: LensFlare[];
  59131. /**
  59132. * Define a limit from the border the lens flare can be visible.
  59133. */
  59134. borderLimit: number;
  59135. /**
  59136. * Define a viewport border we do not want to see the lens flare in.
  59137. */
  59138. viewportBorder: number;
  59139. /**
  59140. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59141. */
  59142. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59143. /**
  59144. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59145. */
  59146. layerMask: number;
  59147. /**
  59148. * Define the id of the lens flare system in the scene.
  59149. * (equal to name by default)
  59150. */
  59151. id: string;
  59152. private _scene;
  59153. private _emitter;
  59154. private _vertexBuffers;
  59155. private _indexBuffer;
  59156. private _effect;
  59157. private _positionX;
  59158. private _positionY;
  59159. private _isEnabled;
  59160. /** @hidden */
  59161. static _SceneComponentInitialization: (scene: Scene) => void;
  59162. /**
  59163. * Instantiates a lens flare system.
  59164. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59165. * It is usually composed of several `lensFlare`.
  59166. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59167. * @param name Define the name of the lens flare system in the scene
  59168. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59169. * @param scene Define the scene the lens flare system belongs to
  59170. */
  59171. constructor(
  59172. /**
  59173. * Define the name of the lens flare system
  59174. */
  59175. name: string, emitter: any, scene: Scene);
  59176. /**
  59177. * Define if the lens flare system is enabled.
  59178. */
  59179. get isEnabled(): boolean;
  59180. set isEnabled(value: boolean);
  59181. /**
  59182. * Get the scene the effects belongs to.
  59183. * @returns the scene holding the lens flare system
  59184. */
  59185. getScene(): Scene;
  59186. /**
  59187. * Get the emitter of the lens flare system.
  59188. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59189. * @returns the emitter of the lens flare system
  59190. */
  59191. getEmitter(): any;
  59192. /**
  59193. * Set the emitter of the lens flare system.
  59194. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59195. * @param newEmitter Define the new emitter of the system
  59196. */
  59197. setEmitter(newEmitter: any): void;
  59198. /**
  59199. * Get the lens flare system emitter position.
  59200. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59201. * @returns the position
  59202. */
  59203. getEmitterPosition(): Vector3;
  59204. /**
  59205. * @hidden
  59206. */
  59207. computeEffectivePosition(globalViewport: Viewport): boolean;
  59208. /** @hidden */
  59209. _isVisible(): boolean;
  59210. /**
  59211. * @hidden
  59212. */
  59213. render(): boolean;
  59214. /**
  59215. * Dispose and release the lens flare with its associated resources.
  59216. */
  59217. dispose(): void;
  59218. /**
  59219. * Parse a lens flare system from a JSON repressentation
  59220. * @param parsedLensFlareSystem Define the JSON to parse
  59221. * @param scene Define the scene the parsed system should be instantiated in
  59222. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59223. * @returns the parsed system
  59224. */
  59225. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59226. /**
  59227. * Serialize the current Lens Flare System into a JSON representation.
  59228. * @returns the serialized JSON
  59229. */
  59230. serialize(): any;
  59231. }
  59232. }
  59233. declare module BABYLON {
  59234. /**
  59235. * This represents one of the lens effect in a `lensFlareSystem`.
  59236. * It controls one of the indiviual texture used in the effect.
  59237. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59238. */
  59239. export class LensFlare {
  59240. /**
  59241. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59242. */
  59243. size: number;
  59244. /**
  59245. * 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.
  59246. */
  59247. position: number;
  59248. /**
  59249. * Define the lens color.
  59250. */
  59251. color: Color3;
  59252. /**
  59253. * Define the lens texture.
  59254. */
  59255. texture: Nullable<Texture>;
  59256. /**
  59257. * Define the alpha mode to render this particular lens.
  59258. */
  59259. alphaMode: number;
  59260. private _system;
  59261. /**
  59262. * Creates a new Lens Flare.
  59263. * This represents one of the lens effect in a `lensFlareSystem`.
  59264. * It controls one of the indiviual texture used in the effect.
  59265. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59266. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59267. * @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.
  59268. * @param color Define the lens color
  59269. * @param imgUrl Define the lens texture url
  59270. * @param system Define the `lensFlareSystem` this flare is part of
  59271. * @returns The newly created Lens Flare
  59272. */
  59273. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59274. /**
  59275. * Instantiates a new Lens Flare.
  59276. * This represents one of the lens effect in a `lensFlareSystem`.
  59277. * It controls one of the indiviual texture used in the effect.
  59278. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59279. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59280. * @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.
  59281. * @param color Define the lens color
  59282. * @param imgUrl Define the lens texture url
  59283. * @param system Define the `lensFlareSystem` this flare is part of
  59284. */
  59285. constructor(
  59286. /**
  59287. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59288. */
  59289. size: number,
  59290. /**
  59291. * 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.
  59292. */
  59293. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59294. /**
  59295. * Dispose and release the lens flare with its associated resources.
  59296. */
  59297. dispose(): void;
  59298. }
  59299. }
  59300. declare module BABYLON {
  59301. interface AbstractScene {
  59302. /**
  59303. * The list of lens flare system added to the scene
  59304. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59305. */
  59306. lensFlareSystems: Array<LensFlareSystem>;
  59307. /**
  59308. * Removes the given lens flare system from this scene.
  59309. * @param toRemove The lens flare system to remove
  59310. * @returns The index of the removed lens flare system
  59311. */
  59312. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59313. /**
  59314. * Adds the given lens flare system to this scene
  59315. * @param newLensFlareSystem The lens flare system to add
  59316. */
  59317. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59318. /**
  59319. * Gets a lens flare system using its name
  59320. * @param name defines the name to look for
  59321. * @returns the lens flare system or null if not found
  59322. */
  59323. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59324. /**
  59325. * Gets a lens flare system using its id
  59326. * @param id defines the id to look for
  59327. * @returns the lens flare system or null if not found
  59328. */
  59329. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59330. }
  59331. /**
  59332. * Defines the lens flare scene component responsible to manage any lens flares
  59333. * in a given scene.
  59334. */
  59335. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59336. /**
  59337. * The component name helpfull to identify the component in the list of scene components.
  59338. */
  59339. readonly name: string;
  59340. /**
  59341. * The scene the component belongs to.
  59342. */
  59343. scene: Scene;
  59344. /**
  59345. * Creates a new instance of the component for the given scene
  59346. * @param scene Defines the scene to register the component in
  59347. */
  59348. constructor(scene: Scene);
  59349. /**
  59350. * Registers the component in a given scene
  59351. */
  59352. register(): void;
  59353. /**
  59354. * Rebuilds the elements related to this component in case of
  59355. * context lost for instance.
  59356. */
  59357. rebuild(): void;
  59358. /**
  59359. * Adds all the elements from the container to the scene
  59360. * @param container the container holding the elements
  59361. */
  59362. addFromContainer(container: AbstractScene): void;
  59363. /**
  59364. * Removes all the elements in the container from the scene
  59365. * @param container contains the elements to remove
  59366. * @param dispose if the removed element should be disposed (default: false)
  59367. */
  59368. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59369. /**
  59370. * Serializes the component data to the specified json object
  59371. * @param serializationObject The object to serialize to
  59372. */
  59373. serialize(serializationObject: any): void;
  59374. /**
  59375. * Disposes the component and the associated ressources.
  59376. */
  59377. dispose(): void;
  59378. private _draw;
  59379. }
  59380. }
  59381. declare module BABYLON {
  59382. /** @hidden */
  59383. export var depthPixelShader: {
  59384. name: string;
  59385. shader: string;
  59386. };
  59387. }
  59388. declare module BABYLON {
  59389. /** @hidden */
  59390. export var depthVertexShader: {
  59391. name: string;
  59392. shader: string;
  59393. };
  59394. }
  59395. declare module BABYLON {
  59396. /**
  59397. * This represents a depth renderer in Babylon.
  59398. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59399. */
  59400. export class DepthRenderer {
  59401. private _scene;
  59402. private _depthMap;
  59403. private _effect;
  59404. private readonly _storeNonLinearDepth;
  59405. private readonly _clearColor;
  59406. /** Get if the depth renderer is using packed depth or not */
  59407. readonly isPacked: boolean;
  59408. private _cachedDefines;
  59409. private _camera;
  59410. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59411. enabled: boolean;
  59412. /**
  59413. * Specifiess that the depth renderer will only be used within
  59414. * the camera it is created for.
  59415. * This can help forcing its rendering during the camera processing.
  59416. */
  59417. useOnlyInActiveCamera: boolean;
  59418. /** @hidden */
  59419. static _SceneComponentInitialization: (scene: Scene) => void;
  59420. /**
  59421. * Instantiates a depth renderer
  59422. * @param scene The scene the renderer belongs to
  59423. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59424. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59425. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59426. */
  59427. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59428. /**
  59429. * Creates the depth rendering effect and checks if the effect is ready.
  59430. * @param subMesh The submesh to be used to render the depth map of
  59431. * @param useInstances If multiple world instances should be used
  59432. * @returns if the depth renderer is ready to render the depth map
  59433. */
  59434. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59435. /**
  59436. * Gets the texture which the depth map will be written to.
  59437. * @returns The depth map texture
  59438. */
  59439. getDepthMap(): RenderTargetTexture;
  59440. /**
  59441. * Disposes of the depth renderer.
  59442. */
  59443. dispose(): void;
  59444. }
  59445. }
  59446. declare module BABYLON {
  59447. /** @hidden */
  59448. export var minmaxReduxPixelShader: {
  59449. name: string;
  59450. shader: string;
  59451. };
  59452. }
  59453. declare module BABYLON {
  59454. /**
  59455. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59456. * and maximum values from all values of the texture.
  59457. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59458. * The source values are read from the red channel of the texture.
  59459. */
  59460. export class MinMaxReducer {
  59461. /**
  59462. * Observable triggered when the computation has been performed
  59463. */
  59464. onAfterReductionPerformed: Observable<{
  59465. min: number;
  59466. max: number;
  59467. }>;
  59468. protected _camera: Camera;
  59469. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59470. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59471. protected _postProcessManager: PostProcessManager;
  59472. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59473. protected _forceFullscreenViewport: boolean;
  59474. /**
  59475. * Creates a min/max reducer
  59476. * @param camera The camera to use for the post processes
  59477. */
  59478. constructor(camera: Camera);
  59479. /**
  59480. * Gets the texture used to read the values from.
  59481. */
  59482. get sourceTexture(): Nullable<RenderTargetTexture>;
  59483. /**
  59484. * Sets the source texture to read the values from.
  59485. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59486. * because in such textures '1' value must not be taken into account to compute the maximum
  59487. * as this value is used to clear the texture.
  59488. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59489. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59490. * @param depthRedux Indicates if the texture is a depth texture or not
  59491. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59492. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59493. */
  59494. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59495. /**
  59496. * Defines the refresh rate of the computation.
  59497. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59498. */
  59499. get refreshRate(): number;
  59500. set refreshRate(value: number);
  59501. protected _activated: boolean;
  59502. /**
  59503. * Gets the activation status of the reducer
  59504. */
  59505. get activated(): boolean;
  59506. /**
  59507. * Activates the reduction computation.
  59508. * When activated, the observers registered in onAfterReductionPerformed are
  59509. * called after the compuation is performed
  59510. */
  59511. activate(): void;
  59512. /**
  59513. * Deactivates the reduction computation.
  59514. */
  59515. deactivate(): void;
  59516. /**
  59517. * Disposes the min/max reducer
  59518. * @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.
  59519. */
  59520. dispose(disposeAll?: boolean): void;
  59521. }
  59522. }
  59523. declare module BABYLON {
  59524. /**
  59525. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59526. */
  59527. export class DepthReducer extends MinMaxReducer {
  59528. private _depthRenderer;
  59529. private _depthRendererId;
  59530. /**
  59531. * Gets the depth renderer used for the computation.
  59532. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59533. */
  59534. get depthRenderer(): Nullable<DepthRenderer>;
  59535. /**
  59536. * Creates a depth reducer
  59537. * @param camera The camera used to render the depth texture
  59538. */
  59539. constructor(camera: Camera);
  59540. /**
  59541. * Sets the depth renderer to use to generate the depth map
  59542. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59543. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59544. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59545. */
  59546. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59547. /** @hidden */
  59548. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59549. /**
  59550. * Activates the reduction computation.
  59551. * When activated, the observers registered in onAfterReductionPerformed are
  59552. * called after the compuation is performed
  59553. */
  59554. activate(): void;
  59555. /**
  59556. * Deactivates the reduction computation.
  59557. */
  59558. deactivate(): void;
  59559. /**
  59560. * Disposes the depth reducer
  59561. * @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.
  59562. */
  59563. dispose(disposeAll?: boolean): void;
  59564. }
  59565. }
  59566. declare module BABYLON {
  59567. /**
  59568. * A CSM implementation allowing casting shadows on large scenes.
  59569. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59570. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59571. */
  59572. export class CascadedShadowGenerator extends ShadowGenerator {
  59573. private static readonly frustumCornersNDCSpace;
  59574. /**
  59575. * Name of the CSM class
  59576. */
  59577. static CLASSNAME: string;
  59578. /**
  59579. * Defines the default number of cascades used by the CSM.
  59580. */
  59581. static readonly DEFAULT_CASCADES_COUNT: number;
  59582. /**
  59583. * Defines the minimum number of cascades used by the CSM.
  59584. */
  59585. static readonly MIN_CASCADES_COUNT: number;
  59586. /**
  59587. * Defines the maximum number of cascades used by the CSM.
  59588. */
  59589. static readonly MAX_CASCADES_COUNT: number;
  59590. protected _validateFilter(filter: number): number;
  59591. /**
  59592. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59593. */
  59594. penumbraDarkness: number;
  59595. private _numCascades;
  59596. /**
  59597. * Gets or set the number of cascades used by the CSM.
  59598. */
  59599. get numCascades(): number;
  59600. set numCascades(value: number);
  59601. /**
  59602. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59603. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59604. */
  59605. stabilizeCascades: boolean;
  59606. private _freezeShadowCastersBoundingInfo;
  59607. private _freezeShadowCastersBoundingInfoObservable;
  59608. /**
  59609. * Enables or disables the shadow casters bounding info computation.
  59610. * If your shadow casters don't move, you can disable this feature.
  59611. * If it is enabled, the bounding box computation is done every frame.
  59612. */
  59613. get freezeShadowCastersBoundingInfo(): boolean;
  59614. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59615. private _scbiMin;
  59616. private _scbiMax;
  59617. protected _computeShadowCastersBoundingInfo(): void;
  59618. protected _shadowCastersBoundingInfo: BoundingInfo;
  59619. /**
  59620. * Gets or sets the shadow casters bounding info.
  59621. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59622. * so that the system won't overwrite the bounds you provide
  59623. */
  59624. get shadowCastersBoundingInfo(): BoundingInfo;
  59625. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59626. protected _breaksAreDirty: boolean;
  59627. protected _minDistance: number;
  59628. protected _maxDistance: number;
  59629. /**
  59630. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59631. *
  59632. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59633. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59634. * @param min minimal distance for the breaks (default to 0.)
  59635. * @param max maximal distance for the breaks (default to 1.)
  59636. */
  59637. setMinMaxDistance(min: number, max: number): void;
  59638. /** Gets the minimal distance used in the cascade break computation */
  59639. get minDistance(): number;
  59640. /** Gets the maximal distance used in the cascade break computation */
  59641. get maxDistance(): number;
  59642. /**
  59643. * Gets the class name of that object
  59644. * @returns "CascadedShadowGenerator"
  59645. */
  59646. getClassName(): string;
  59647. private _cascadeMinExtents;
  59648. private _cascadeMaxExtents;
  59649. /**
  59650. * Gets a cascade minimum extents
  59651. * @param cascadeIndex index of the cascade
  59652. * @returns the minimum cascade extents
  59653. */
  59654. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59655. /**
  59656. * Gets a cascade maximum extents
  59657. * @param cascadeIndex index of the cascade
  59658. * @returns the maximum cascade extents
  59659. */
  59660. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59661. private _cascades;
  59662. private _currentLayer;
  59663. private _viewSpaceFrustumsZ;
  59664. private _viewMatrices;
  59665. private _projectionMatrices;
  59666. private _transformMatrices;
  59667. private _transformMatricesAsArray;
  59668. private _frustumLengths;
  59669. private _lightSizeUVCorrection;
  59670. private _depthCorrection;
  59671. private _frustumCornersWorldSpace;
  59672. private _frustumCenter;
  59673. private _shadowCameraPos;
  59674. private _shadowMaxZ;
  59675. /**
  59676. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59677. * It defaults to camera.maxZ
  59678. */
  59679. get shadowMaxZ(): number;
  59680. /**
  59681. * Sets the shadow max z distance.
  59682. */
  59683. set shadowMaxZ(value: number);
  59684. protected _debug: boolean;
  59685. /**
  59686. * Gets or sets the debug flag.
  59687. * When enabled, the cascades are materialized by different colors on the screen.
  59688. */
  59689. get debug(): boolean;
  59690. set debug(dbg: boolean);
  59691. private _depthClamp;
  59692. /**
  59693. * Gets or sets the depth clamping value.
  59694. *
  59695. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59696. * to account for the shadow casters far away.
  59697. *
  59698. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59699. */
  59700. get depthClamp(): boolean;
  59701. set depthClamp(value: boolean);
  59702. private _cascadeBlendPercentage;
  59703. /**
  59704. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59705. * It defaults to 0.1 (10% blending).
  59706. */
  59707. get cascadeBlendPercentage(): number;
  59708. set cascadeBlendPercentage(value: number);
  59709. private _lambda;
  59710. /**
  59711. * Gets or set the lambda parameter.
  59712. * This parameter is used to split the camera frustum and create the cascades.
  59713. * 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.
  59714. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59715. */
  59716. get lambda(): number;
  59717. set lambda(value: number);
  59718. /**
  59719. * Gets the view matrix corresponding to a given cascade
  59720. * @param cascadeNum cascade to retrieve the view matrix from
  59721. * @returns the cascade view matrix
  59722. */
  59723. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59724. /**
  59725. * Gets the projection matrix corresponding to a given cascade
  59726. * @param cascadeNum cascade to retrieve the projection matrix from
  59727. * @returns the cascade projection matrix
  59728. */
  59729. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59730. /**
  59731. * Gets the transformation matrix corresponding to a given cascade
  59732. * @param cascadeNum cascade to retrieve the transformation matrix from
  59733. * @returns the cascade transformation matrix
  59734. */
  59735. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59736. private _depthRenderer;
  59737. /**
  59738. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59739. *
  59740. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59741. *
  59742. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59743. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59744. * @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
  59745. */
  59746. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59747. private _depthReducer;
  59748. private _autoCalcDepthBounds;
  59749. /**
  59750. * Gets or sets the autoCalcDepthBounds property.
  59751. *
  59752. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59753. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59754. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59755. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59756. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59757. */
  59758. get autoCalcDepthBounds(): boolean;
  59759. set autoCalcDepthBounds(value: boolean);
  59760. /**
  59761. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59762. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59763. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59764. * for setting the refresh rate on the renderer yourself!
  59765. */
  59766. get autoCalcDepthBoundsRefreshRate(): number;
  59767. set autoCalcDepthBoundsRefreshRate(value: number);
  59768. /**
  59769. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59770. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59771. * you change the camera near/far planes!
  59772. */
  59773. splitFrustum(): void;
  59774. private _splitFrustum;
  59775. private _computeMatrices;
  59776. private _computeFrustumInWorldSpace;
  59777. private _computeCascadeFrustum;
  59778. /**
  59779. * Support test.
  59780. */
  59781. static get IsSupported(): boolean;
  59782. /** @hidden */
  59783. static _SceneComponentInitialization: (scene: Scene) => void;
  59784. /**
  59785. * Creates a Cascaded Shadow Generator object.
  59786. * A ShadowGenerator is the required tool to use the shadows.
  59787. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59788. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59789. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59790. * @param light The directional light object generating the shadows.
  59791. * @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.
  59792. */
  59793. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59794. protected _initializeGenerator(): void;
  59795. protected _createTargetRenderTexture(): void;
  59796. protected _initializeShadowMap(): void;
  59797. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59798. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59799. /**
  59800. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59801. * @param defines Defines of the material we want to update
  59802. * @param lightIndex Index of the light in the enabled light list of the material
  59803. */
  59804. prepareDefines(defines: any, lightIndex: number): void;
  59805. /**
  59806. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59807. * defined in the generator but impacting the effect).
  59808. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59809. * @param effect The effect we are binfing the information for
  59810. */
  59811. bindShadowLight(lightIndex: string, effect: Effect): void;
  59812. /**
  59813. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59814. * (eq to view projection * shadow projection matrices)
  59815. * @returns The transform matrix used to create the shadow map
  59816. */
  59817. getTransformMatrix(): Matrix;
  59818. /**
  59819. * Disposes the ShadowGenerator.
  59820. * Returns nothing.
  59821. */
  59822. dispose(): void;
  59823. /**
  59824. * Serializes the shadow generator setup to a json object.
  59825. * @returns The serialized JSON object
  59826. */
  59827. serialize(): any;
  59828. /**
  59829. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59830. * @param parsedShadowGenerator The JSON object to parse
  59831. * @param scene The scene to create the shadow map for
  59832. * @returns The parsed shadow generator
  59833. */
  59834. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59835. }
  59836. }
  59837. declare module BABYLON {
  59838. /**
  59839. * Defines the shadow generator component responsible to manage any shadow generators
  59840. * in a given scene.
  59841. */
  59842. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59843. /**
  59844. * The component name helpfull to identify the component in the list of scene components.
  59845. */
  59846. readonly name: string;
  59847. /**
  59848. * The scene the component belongs to.
  59849. */
  59850. scene: Scene;
  59851. /**
  59852. * Creates a new instance of the component for the given scene
  59853. * @param scene Defines the scene to register the component in
  59854. */
  59855. constructor(scene: Scene);
  59856. /**
  59857. * Registers the component in a given scene
  59858. */
  59859. register(): void;
  59860. /**
  59861. * Rebuilds the elements related to this component in case of
  59862. * context lost for instance.
  59863. */
  59864. rebuild(): void;
  59865. /**
  59866. * Serializes the component data to the specified json object
  59867. * @param serializationObject The object to serialize to
  59868. */
  59869. serialize(serializationObject: any): void;
  59870. /**
  59871. * Adds all the elements from the container to the scene
  59872. * @param container the container holding the elements
  59873. */
  59874. addFromContainer(container: AbstractScene): void;
  59875. /**
  59876. * Removes all the elements in the container from the scene
  59877. * @param container contains the elements to remove
  59878. * @param dispose if the removed element should be disposed (default: false)
  59879. */
  59880. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59881. /**
  59882. * Rebuilds the elements related to this component in case of
  59883. * context lost for instance.
  59884. */
  59885. dispose(): void;
  59886. private _gatherRenderTargets;
  59887. }
  59888. }
  59889. declare module BABYLON {
  59890. /**
  59891. * A point light is a light defined by an unique point in world space.
  59892. * The light is emitted in every direction from this point.
  59893. * A good example of a point light is a standard light bulb.
  59894. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59895. */
  59896. export class PointLight extends ShadowLight {
  59897. private _shadowAngle;
  59898. /**
  59899. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59900. * This specifies what angle the shadow will use to be created.
  59901. *
  59902. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59903. */
  59904. get shadowAngle(): number;
  59905. /**
  59906. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59907. * This specifies what angle the shadow will use to be created.
  59908. *
  59909. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59910. */
  59911. set shadowAngle(value: number);
  59912. /**
  59913. * Gets the direction if it has been set.
  59914. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59915. */
  59916. get direction(): Vector3;
  59917. /**
  59918. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59919. */
  59920. set direction(value: Vector3);
  59921. /**
  59922. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  59923. * A PointLight emits the light in every direction.
  59924. * It can cast shadows.
  59925. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  59926. * ```javascript
  59927. * var pointLight = new PointLight("pl", camera.position, scene);
  59928. * ```
  59929. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59930. * @param name The light friendly name
  59931. * @param position The position of the point light in the scene
  59932. * @param scene The scene the lights belongs to
  59933. */
  59934. constructor(name: string, position: Vector3, scene: Scene);
  59935. /**
  59936. * Returns the string "PointLight"
  59937. * @returns the class name
  59938. */
  59939. getClassName(): string;
  59940. /**
  59941. * Returns the integer 0.
  59942. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59943. */
  59944. getTypeID(): number;
  59945. /**
  59946. * Specifies wether or not the shadowmap should be a cube texture.
  59947. * @returns true if the shadowmap needs to be a cube texture.
  59948. */
  59949. needCube(): boolean;
  59950. /**
  59951. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  59952. * @param faceIndex The index of the face we are computed the direction to generate shadow
  59953. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  59954. */
  59955. getShadowDirection(faceIndex?: number): Vector3;
  59956. /**
  59957. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  59958. * - fov = PI / 2
  59959. * - aspect ratio : 1.0
  59960. * - z-near and far equal to the active camera minZ and maxZ.
  59961. * Returns the PointLight.
  59962. */
  59963. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59964. protected _buildUniformLayout(): void;
  59965. /**
  59966. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  59967. * @param effect The effect to update
  59968. * @param lightIndex The index of the light in the effect to update
  59969. * @returns The point light
  59970. */
  59971. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  59972. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59973. /**
  59974. * Prepares the list of defines specific to the light type.
  59975. * @param defines the list of defines
  59976. * @param lightIndex defines the index of the light for the effect
  59977. */
  59978. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59979. }
  59980. }
  59981. declare module BABYLON {
  59982. /**
  59983. * Header information of HDR texture files.
  59984. */
  59985. export interface HDRInfo {
  59986. /**
  59987. * The height of the texture in pixels.
  59988. */
  59989. height: number;
  59990. /**
  59991. * The width of the texture in pixels.
  59992. */
  59993. width: number;
  59994. /**
  59995. * The index of the beginning of the data in the binary file.
  59996. */
  59997. dataPosition: number;
  59998. }
  59999. /**
  60000. * This groups tools to convert HDR texture to native colors array.
  60001. */
  60002. export class HDRTools {
  60003. private static Ldexp;
  60004. private static Rgbe2float;
  60005. private static readStringLine;
  60006. /**
  60007. * Reads header information from an RGBE texture stored in a native array.
  60008. * More information on this format are available here:
  60009. * https://en.wikipedia.org/wiki/RGBE_image_format
  60010. *
  60011. * @param uint8array The binary file stored in native array.
  60012. * @return The header information.
  60013. */
  60014. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60015. /**
  60016. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60017. * This RGBE texture needs to store the information as a panorama.
  60018. *
  60019. * More information on this format are available here:
  60020. * https://en.wikipedia.org/wiki/RGBE_image_format
  60021. *
  60022. * @param buffer The binary file stored in an array buffer.
  60023. * @param size The expected size of the extracted cubemap.
  60024. * @return The Cube Map information.
  60025. */
  60026. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60027. /**
  60028. * Returns the pixels data extracted from an RGBE texture.
  60029. * This pixels will be stored left to right up to down in the R G B order in one array.
  60030. *
  60031. * More information on this format are available here:
  60032. * https://en.wikipedia.org/wiki/RGBE_image_format
  60033. *
  60034. * @param uint8array The binary file stored in an array buffer.
  60035. * @param hdrInfo The header information of the file.
  60036. * @return The pixels data in RGB right to left up to down order.
  60037. */
  60038. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60039. private static RGBE_ReadPixels_RLE;
  60040. private static RGBE_ReadPixels_NOT_RLE;
  60041. }
  60042. }
  60043. declare module BABYLON {
  60044. /**
  60045. * Effect Render Options
  60046. */
  60047. export interface IEffectRendererOptions {
  60048. /**
  60049. * Defines the vertices positions.
  60050. */
  60051. positions?: number[];
  60052. /**
  60053. * Defines the indices.
  60054. */
  60055. indices?: number[];
  60056. }
  60057. /**
  60058. * Helper class to render one or more effects.
  60059. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60060. */
  60061. export class EffectRenderer {
  60062. private engine;
  60063. private static _DefaultOptions;
  60064. private _vertexBuffers;
  60065. private _indexBuffer;
  60066. private _fullscreenViewport;
  60067. /**
  60068. * Creates an effect renderer
  60069. * @param engine the engine to use for rendering
  60070. * @param options defines the options of the effect renderer
  60071. */
  60072. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60073. /**
  60074. * Sets the current viewport in normalized coordinates 0-1
  60075. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60076. */
  60077. setViewport(viewport?: Viewport): void;
  60078. /**
  60079. * Binds the embedded attributes buffer to the effect.
  60080. * @param effect Defines the effect to bind the attributes for
  60081. */
  60082. bindBuffers(effect: Effect): void;
  60083. /**
  60084. * Sets the current effect wrapper to use during draw.
  60085. * The effect needs to be ready before calling this api.
  60086. * This also sets the default full screen position attribute.
  60087. * @param effectWrapper Defines the effect to draw with
  60088. */
  60089. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60090. /**
  60091. * Restores engine states
  60092. */
  60093. restoreStates(): void;
  60094. /**
  60095. * Draws a full screen quad.
  60096. */
  60097. draw(): void;
  60098. private isRenderTargetTexture;
  60099. /**
  60100. * renders one or more effects to a specified texture
  60101. * @param effectWrapper the effect to renderer
  60102. * @param outputTexture texture to draw to, if null it will render to the screen.
  60103. */
  60104. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60105. /**
  60106. * Disposes of the effect renderer
  60107. */
  60108. dispose(): void;
  60109. }
  60110. /**
  60111. * Options to create an EffectWrapper
  60112. */
  60113. interface EffectWrapperCreationOptions {
  60114. /**
  60115. * Engine to use to create the effect
  60116. */
  60117. engine: ThinEngine;
  60118. /**
  60119. * Fragment shader for the effect
  60120. */
  60121. fragmentShader: string;
  60122. /**
  60123. * Use the shader store instead of direct source code
  60124. */
  60125. useShaderStore?: boolean;
  60126. /**
  60127. * Vertex shader for the effect
  60128. */
  60129. vertexShader?: string;
  60130. /**
  60131. * Attributes to use in the shader
  60132. */
  60133. attributeNames?: Array<string>;
  60134. /**
  60135. * Uniforms to use in the shader
  60136. */
  60137. uniformNames?: Array<string>;
  60138. /**
  60139. * Texture sampler names to use in the shader
  60140. */
  60141. samplerNames?: Array<string>;
  60142. /**
  60143. * Defines to use in the shader
  60144. */
  60145. defines?: Array<string>;
  60146. /**
  60147. * Callback when effect is compiled
  60148. */
  60149. onCompiled?: Nullable<(effect: Effect) => void>;
  60150. /**
  60151. * The friendly name of the effect displayed in Spector.
  60152. */
  60153. name?: string;
  60154. }
  60155. /**
  60156. * Wraps an effect to be used for rendering
  60157. */
  60158. export class EffectWrapper {
  60159. /**
  60160. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60161. */
  60162. onApplyObservable: Observable<{}>;
  60163. /**
  60164. * The underlying effect
  60165. */
  60166. effect: Effect;
  60167. /**
  60168. * Creates an effect to be renderer
  60169. * @param creationOptions options to create the effect
  60170. */
  60171. constructor(creationOptions: EffectWrapperCreationOptions);
  60172. /**
  60173. * Disposes of the effect wrapper
  60174. */
  60175. dispose(): void;
  60176. }
  60177. }
  60178. declare module BABYLON {
  60179. /** @hidden */
  60180. export var hdrFilteringVertexShader: {
  60181. name: string;
  60182. shader: string;
  60183. };
  60184. }
  60185. declare module BABYLON {
  60186. /** @hidden */
  60187. export var hdrFilteringPixelShader: {
  60188. name: string;
  60189. shader: string;
  60190. };
  60191. }
  60192. declare module BABYLON {
  60193. /**
  60194. * Options for texture filtering
  60195. */
  60196. interface IHDRFilteringOptions {
  60197. /**
  60198. * Scales pixel intensity for the input HDR map.
  60199. */
  60200. hdrScale?: number;
  60201. /**
  60202. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60203. */
  60204. quality?: number;
  60205. }
  60206. /**
  60207. * Filters HDR maps to get correct renderings of PBR reflections
  60208. */
  60209. export class HDRFiltering {
  60210. private _engine;
  60211. private _effectRenderer;
  60212. private _effectWrapper;
  60213. private _lodGenerationOffset;
  60214. private _lodGenerationScale;
  60215. /**
  60216. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60217. * you care about baking speed.
  60218. */
  60219. quality: number;
  60220. /**
  60221. * Scales pixel intensity for the input HDR map.
  60222. */
  60223. hdrScale: number;
  60224. /**
  60225. * Instantiates HDR filter for reflection maps
  60226. *
  60227. * @param engine Thin engine
  60228. * @param options Options
  60229. */
  60230. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60231. private _createRenderTarget;
  60232. private _prefilterInternal;
  60233. private _createEffect;
  60234. /**
  60235. * Get a value indicating if the filter is ready to be used
  60236. * @param texture Texture to filter
  60237. * @returns true if the filter is ready
  60238. */
  60239. isReady(texture: BaseTexture): boolean;
  60240. /**
  60241. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60242. * Prefiltering will be invoked at the end of next rendering pass.
  60243. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60244. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60245. * @param texture Texture to filter
  60246. * @param onFinished Callback when filtering is done
  60247. * @return Promise called when prefiltering is done
  60248. */
  60249. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60250. }
  60251. }
  60252. declare module BABYLON {
  60253. /**
  60254. * This represents a texture coming from an HDR input.
  60255. *
  60256. * The only supported format is currently panorama picture stored in RGBE format.
  60257. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60258. */
  60259. export class HDRCubeTexture extends BaseTexture {
  60260. private static _facesMapping;
  60261. private _generateHarmonics;
  60262. private _noMipmap;
  60263. private _prefilterOnLoad;
  60264. private _textureMatrix;
  60265. private _size;
  60266. private _onLoad;
  60267. private _onError;
  60268. /**
  60269. * The texture URL.
  60270. */
  60271. url: string;
  60272. protected _isBlocking: boolean;
  60273. /**
  60274. * Sets wether or not the texture is blocking during loading.
  60275. */
  60276. set isBlocking(value: boolean);
  60277. /**
  60278. * Gets wether or not the texture is blocking during loading.
  60279. */
  60280. get isBlocking(): boolean;
  60281. protected _rotationY: number;
  60282. /**
  60283. * Sets texture matrix rotation angle around Y axis in radians.
  60284. */
  60285. set rotationY(value: number);
  60286. /**
  60287. * Gets texture matrix rotation angle around Y axis radians.
  60288. */
  60289. get rotationY(): number;
  60290. /**
  60291. * Gets or sets the center of the bounding box associated with the cube texture
  60292. * It must define where the camera used to render the texture was set
  60293. */
  60294. boundingBoxPosition: Vector3;
  60295. private _boundingBoxSize;
  60296. /**
  60297. * Gets or sets the size of the bounding box associated with the cube texture
  60298. * When defined, the cubemap will switch to local mode
  60299. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60300. * @example https://www.babylonjs-playground.com/#RNASML
  60301. */
  60302. set boundingBoxSize(value: Vector3);
  60303. get boundingBoxSize(): Vector3;
  60304. /**
  60305. * Instantiates an HDRTexture from the following parameters.
  60306. *
  60307. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60308. * @param sceneOrEngine The scene or engine the texture will be used in
  60309. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60310. * @param noMipmap Forces to not generate the mipmap if true
  60311. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60312. * @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)
  60313. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60314. */
  60315. 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>);
  60316. /**
  60317. * Get the current class name of the texture useful for serialization or dynamic coding.
  60318. * @returns "HDRCubeTexture"
  60319. */
  60320. getClassName(): string;
  60321. /**
  60322. * Occurs when the file is raw .hdr file.
  60323. */
  60324. private loadTexture;
  60325. clone(): HDRCubeTexture;
  60326. delayLoad(): void;
  60327. /**
  60328. * Get the texture reflection matrix used to rotate/transform the reflection.
  60329. * @returns the reflection matrix
  60330. */
  60331. getReflectionTextureMatrix(): Matrix;
  60332. /**
  60333. * Set the texture reflection matrix used to rotate/transform the reflection.
  60334. * @param value Define the reflection matrix to set
  60335. */
  60336. setReflectionTextureMatrix(value: Matrix): void;
  60337. /**
  60338. * Parses a JSON representation of an HDR Texture in order to create the texture
  60339. * @param parsedTexture Define the JSON representation
  60340. * @param scene Define the scene the texture should be created in
  60341. * @param rootUrl Define the root url in case we need to load relative dependencies
  60342. * @returns the newly created texture after parsing
  60343. */
  60344. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60345. serialize(): any;
  60346. }
  60347. }
  60348. declare module BABYLON {
  60349. /**
  60350. * Class used to control physics engine
  60351. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60352. */
  60353. export class PhysicsEngine implements IPhysicsEngine {
  60354. private _physicsPlugin;
  60355. /**
  60356. * Global value used to control the smallest number supported by the simulation
  60357. */
  60358. static Epsilon: number;
  60359. private _impostors;
  60360. private _joints;
  60361. private _subTimeStep;
  60362. /**
  60363. * Gets the gravity vector used by the simulation
  60364. */
  60365. gravity: Vector3;
  60366. /**
  60367. * Factory used to create the default physics plugin.
  60368. * @returns The default physics plugin
  60369. */
  60370. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60371. /**
  60372. * Creates a new Physics Engine
  60373. * @param gravity defines the gravity vector used by the simulation
  60374. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60375. */
  60376. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60377. /**
  60378. * Sets the gravity vector used by the simulation
  60379. * @param gravity defines the gravity vector to use
  60380. */
  60381. setGravity(gravity: Vector3): void;
  60382. /**
  60383. * Set the time step of the physics engine.
  60384. * Default is 1/60.
  60385. * To slow it down, enter 1/600 for example.
  60386. * To speed it up, 1/30
  60387. * @param newTimeStep defines the new timestep to apply to this world.
  60388. */
  60389. setTimeStep(newTimeStep?: number): void;
  60390. /**
  60391. * Get the time step of the physics engine.
  60392. * @returns the current time step
  60393. */
  60394. getTimeStep(): number;
  60395. /**
  60396. * Set the sub time step of the physics engine.
  60397. * Default is 0 meaning there is no sub steps
  60398. * To increase physics resolution precision, set a small value (like 1 ms)
  60399. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60400. */
  60401. setSubTimeStep(subTimeStep?: number): void;
  60402. /**
  60403. * Get the sub time step of the physics engine.
  60404. * @returns the current sub time step
  60405. */
  60406. getSubTimeStep(): number;
  60407. /**
  60408. * Release all resources
  60409. */
  60410. dispose(): void;
  60411. /**
  60412. * Gets the name of the current physics plugin
  60413. * @returns the name of the plugin
  60414. */
  60415. getPhysicsPluginName(): string;
  60416. /**
  60417. * Adding a new impostor for the impostor tracking.
  60418. * This will be done by the impostor itself.
  60419. * @param impostor the impostor to add
  60420. */
  60421. addImpostor(impostor: PhysicsImpostor): void;
  60422. /**
  60423. * Remove an impostor from the engine.
  60424. * This impostor and its mesh will not longer be updated by the physics engine.
  60425. * @param impostor the impostor to remove
  60426. */
  60427. removeImpostor(impostor: PhysicsImpostor): void;
  60428. /**
  60429. * Add a joint to the physics engine
  60430. * @param mainImpostor defines the main impostor to which the joint is added.
  60431. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60432. * @param joint defines the joint that will connect both impostors.
  60433. */
  60434. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60435. /**
  60436. * Removes a joint from the simulation
  60437. * @param mainImpostor defines the impostor used with the joint
  60438. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60439. * @param joint defines the joint to remove
  60440. */
  60441. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60442. /**
  60443. * Called by the scene. No need to call it.
  60444. * @param delta defines the timespam between frames
  60445. */
  60446. _step(delta: number): void;
  60447. /**
  60448. * Gets the current plugin used to run the simulation
  60449. * @returns current plugin
  60450. */
  60451. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60452. /**
  60453. * Gets the list of physic impostors
  60454. * @returns an array of PhysicsImpostor
  60455. */
  60456. getImpostors(): Array<PhysicsImpostor>;
  60457. /**
  60458. * Gets the impostor for a physics enabled object
  60459. * @param object defines the object impersonated by the impostor
  60460. * @returns the PhysicsImpostor or null if not found
  60461. */
  60462. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60463. /**
  60464. * Gets the impostor for a physics body object
  60465. * @param body defines physics body used by the impostor
  60466. * @returns the PhysicsImpostor or null if not found
  60467. */
  60468. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60469. /**
  60470. * Does a raycast in the physics world
  60471. * @param from when should the ray start?
  60472. * @param to when should the ray end?
  60473. * @returns PhysicsRaycastResult
  60474. */
  60475. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60476. }
  60477. }
  60478. declare module BABYLON {
  60479. /** @hidden */
  60480. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60481. private _useDeltaForWorldStep;
  60482. world: any;
  60483. name: string;
  60484. private _physicsMaterials;
  60485. private _fixedTimeStep;
  60486. private _cannonRaycastResult;
  60487. private _raycastResult;
  60488. private _physicsBodysToRemoveAfterStep;
  60489. private _firstFrame;
  60490. BJSCANNON: any;
  60491. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60492. setGravity(gravity: Vector3): void;
  60493. setTimeStep(timeStep: number): void;
  60494. getTimeStep(): number;
  60495. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60496. private _removeMarkedPhysicsBodiesFromWorld;
  60497. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60498. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60499. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60500. private _processChildMeshes;
  60501. removePhysicsBody(impostor: PhysicsImpostor): void;
  60502. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60503. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60504. private _addMaterial;
  60505. private _checkWithEpsilon;
  60506. private _createShape;
  60507. private _createHeightmap;
  60508. private _minus90X;
  60509. private _plus90X;
  60510. private _tmpPosition;
  60511. private _tmpDeltaPosition;
  60512. private _tmpUnityRotation;
  60513. private _updatePhysicsBodyTransformation;
  60514. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60515. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60516. isSupported(): boolean;
  60517. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60518. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60519. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60520. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60521. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60522. getBodyMass(impostor: PhysicsImpostor): number;
  60523. getBodyFriction(impostor: PhysicsImpostor): number;
  60524. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60525. getBodyRestitution(impostor: PhysicsImpostor): number;
  60526. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60527. sleepBody(impostor: PhysicsImpostor): void;
  60528. wakeUpBody(impostor: PhysicsImpostor): void;
  60529. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60530. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60531. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60532. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60533. getRadius(impostor: PhysicsImpostor): number;
  60534. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60535. dispose(): void;
  60536. private _extendNamespace;
  60537. /**
  60538. * Does a raycast in the physics world
  60539. * @param from when should the ray start?
  60540. * @param to when should the ray end?
  60541. * @returns PhysicsRaycastResult
  60542. */
  60543. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60544. }
  60545. }
  60546. declare module BABYLON {
  60547. /** @hidden */
  60548. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60549. private _useDeltaForWorldStep;
  60550. world: any;
  60551. name: string;
  60552. BJSOIMO: any;
  60553. private _raycastResult;
  60554. private _fixedTimeStep;
  60555. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60556. setGravity(gravity: Vector3): void;
  60557. setTimeStep(timeStep: number): void;
  60558. getTimeStep(): number;
  60559. private _tmpImpostorsArray;
  60560. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60561. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60562. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60563. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60564. private _tmpPositionVector;
  60565. removePhysicsBody(impostor: PhysicsImpostor): void;
  60566. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60567. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60568. isSupported(): boolean;
  60569. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60570. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60571. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60572. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60573. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60574. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60575. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60576. getBodyMass(impostor: PhysicsImpostor): number;
  60577. getBodyFriction(impostor: PhysicsImpostor): number;
  60578. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60579. getBodyRestitution(impostor: PhysicsImpostor): number;
  60580. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60581. sleepBody(impostor: PhysicsImpostor): void;
  60582. wakeUpBody(impostor: PhysicsImpostor): void;
  60583. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60584. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60585. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60586. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60587. getRadius(impostor: PhysicsImpostor): number;
  60588. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60589. dispose(): void;
  60590. /**
  60591. * Does a raycast in the physics world
  60592. * @param from when should the ray start?
  60593. * @param to when should the ray end?
  60594. * @returns PhysicsRaycastResult
  60595. */
  60596. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60597. }
  60598. }
  60599. declare module BABYLON {
  60600. /**
  60601. * AmmoJS Physics plugin
  60602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60603. * @see https://github.com/kripken/ammo.js/
  60604. */
  60605. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60606. private _useDeltaForWorldStep;
  60607. /**
  60608. * Reference to the Ammo library
  60609. */
  60610. bjsAMMO: any;
  60611. /**
  60612. * Created ammoJS world which physics bodies are added to
  60613. */
  60614. world: any;
  60615. /**
  60616. * Name of the plugin
  60617. */
  60618. name: string;
  60619. private _timeStep;
  60620. private _fixedTimeStep;
  60621. private _maxSteps;
  60622. private _tmpQuaternion;
  60623. private _tmpAmmoTransform;
  60624. private _tmpAmmoQuaternion;
  60625. private _tmpAmmoConcreteContactResultCallback;
  60626. private _collisionConfiguration;
  60627. private _dispatcher;
  60628. private _overlappingPairCache;
  60629. private _solver;
  60630. private _softBodySolver;
  60631. private _tmpAmmoVectorA;
  60632. private _tmpAmmoVectorB;
  60633. private _tmpAmmoVectorC;
  60634. private _tmpAmmoVectorD;
  60635. private _tmpContactCallbackResult;
  60636. private _tmpAmmoVectorRCA;
  60637. private _tmpAmmoVectorRCB;
  60638. private _raycastResult;
  60639. private static readonly DISABLE_COLLISION_FLAG;
  60640. private static readonly KINEMATIC_FLAG;
  60641. private static readonly DISABLE_DEACTIVATION_FLAG;
  60642. /**
  60643. * Initializes the ammoJS plugin
  60644. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60645. * @param ammoInjection can be used to inject your own ammo reference
  60646. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60647. */
  60648. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60649. /**
  60650. * Sets the gravity of the physics world (m/(s^2))
  60651. * @param gravity Gravity to set
  60652. */
  60653. setGravity(gravity: Vector3): void;
  60654. /**
  60655. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60656. * @param timeStep timestep to use in seconds
  60657. */
  60658. setTimeStep(timeStep: number): void;
  60659. /**
  60660. * 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)
  60661. * @param fixedTimeStep fixedTimeStep to use in seconds
  60662. */
  60663. setFixedTimeStep(fixedTimeStep: number): void;
  60664. /**
  60665. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60666. * @param maxSteps the maximum number of steps by the physics engine per frame
  60667. */
  60668. setMaxSteps(maxSteps: number): void;
  60669. /**
  60670. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60671. * @returns the current timestep in seconds
  60672. */
  60673. getTimeStep(): number;
  60674. /**
  60675. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60676. */
  60677. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60678. private _isImpostorInContact;
  60679. private _isImpostorPairInContact;
  60680. private _stepSimulation;
  60681. /**
  60682. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60683. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60684. * After the step the babylon meshes are set to the position of the physics imposters
  60685. * @param delta amount of time to step forward
  60686. * @param impostors array of imposters to update before/after the step
  60687. */
  60688. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60689. /**
  60690. * Update babylon mesh to match physics world object
  60691. * @param impostor imposter to match
  60692. */
  60693. private _afterSoftStep;
  60694. /**
  60695. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60696. * @param impostor imposter to match
  60697. */
  60698. private _ropeStep;
  60699. /**
  60700. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60701. * @param impostor imposter to match
  60702. */
  60703. private _softbodyOrClothStep;
  60704. private _tmpMatrix;
  60705. /**
  60706. * Applies an impulse on the imposter
  60707. * @param impostor imposter to apply impulse to
  60708. * @param force amount of force to be applied to the imposter
  60709. * @param contactPoint the location to apply the impulse on the imposter
  60710. */
  60711. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60712. /**
  60713. * Applies a force on the imposter
  60714. * @param impostor imposter to apply force
  60715. * @param force amount of force to be applied to the imposter
  60716. * @param contactPoint the location to apply the force on the imposter
  60717. */
  60718. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60719. /**
  60720. * Creates a physics body using the plugin
  60721. * @param impostor the imposter to create the physics body on
  60722. */
  60723. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60724. /**
  60725. * Removes the physics body from the imposter and disposes of the body's memory
  60726. * @param impostor imposter to remove the physics body from
  60727. */
  60728. removePhysicsBody(impostor: PhysicsImpostor): void;
  60729. /**
  60730. * Generates a joint
  60731. * @param impostorJoint the imposter joint to create the joint with
  60732. */
  60733. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60734. /**
  60735. * Removes a joint
  60736. * @param impostorJoint the imposter joint to remove the joint from
  60737. */
  60738. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60739. private _addMeshVerts;
  60740. /**
  60741. * Initialise the soft body vertices to match its object's (mesh) vertices
  60742. * Softbody vertices (nodes) are in world space and to match this
  60743. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60744. * @param impostor to create the softbody for
  60745. */
  60746. private _softVertexData;
  60747. /**
  60748. * Create an impostor's soft body
  60749. * @param impostor to create the softbody for
  60750. */
  60751. private _createSoftbody;
  60752. /**
  60753. * Create cloth for an impostor
  60754. * @param impostor to create the softbody for
  60755. */
  60756. private _createCloth;
  60757. /**
  60758. * Create rope for an impostor
  60759. * @param impostor to create the softbody for
  60760. */
  60761. private _createRope;
  60762. /**
  60763. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60764. * @param impostor to create the custom physics shape for
  60765. */
  60766. private _createCustom;
  60767. private _addHullVerts;
  60768. private _createShape;
  60769. /**
  60770. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60771. * @param impostor imposter containing the physics body and babylon object
  60772. */
  60773. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60774. /**
  60775. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60776. * @param impostor imposter containing the physics body and babylon object
  60777. * @param newPosition new position
  60778. * @param newRotation new rotation
  60779. */
  60780. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60781. /**
  60782. * If this plugin is supported
  60783. * @returns true if its supported
  60784. */
  60785. isSupported(): boolean;
  60786. /**
  60787. * Sets the linear velocity of the physics body
  60788. * @param impostor imposter to set the velocity on
  60789. * @param velocity velocity to set
  60790. */
  60791. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60792. /**
  60793. * Sets the angular velocity of the physics body
  60794. * @param impostor imposter to set the velocity on
  60795. * @param velocity velocity to set
  60796. */
  60797. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60798. /**
  60799. * gets the linear velocity
  60800. * @param impostor imposter to get linear velocity from
  60801. * @returns linear velocity
  60802. */
  60803. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60804. /**
  60805. * gets the angular velocity
  60806. * @param impostor imposter to get angular velocity from
  60807. * @returns angular velocity
  60808. */
  60809. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60810. /**
  60811. * Sets the mass of physics body
  60812. * @param impostor imposter to set the mass on
  60813. * @param mass mass to set
  60814. */
  60815. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60816. /**
  60817. * Gets the mass of the physics body
  60818. * @param impostor imposter to get the mass from
  60819. * @returns mass
  60820. */
  60821. getBodyMass(impostor: PhysicsImpostor): number;
  60822. /**
  60823. * Gets friction of the impostor
  60824. * @param impostor impostor to get friction from
  60825. * @returns friction value
  60826. */
  60827. getBodyFriction(impostor: PhysicsImpostor): number;
  60828. /**
  60829. * Sets friction of the impostor
  60830. * @param impostor impostor to set friction on
  60831. * @param friction friction value
  60832. */
  60833. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60834. /**
  60835. * Gets restitution of the impostor
  60836. * @param impostor impostor to get restitution from
  60837. * @returns restitution value
  60838. */
  60839. getBodyRestitution(impostor: PhysicsImpostor): number;
  60840. /**
  60841. * Sets resitution of the impostor
  60842. * @param impostor impostor to set resitution on
  60843. * @param restitution resitution value
  60844. */
  60845. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60846. /**
  60847. * Gets pressure inside the impostor
  60848. * @param impostor impostor to get pressure from
  60849. * @returns pressure value
  60850. */
  60851. getBodyPressure(impostor: PhysicsImpostor): number;
  60852. /**
  60853. * Sets pressure inside a soft body impostor
  60854. * Cloth and rope must remain 0 pressure
  60855. * @param impostor impostor to set pressure on
  60856. * @param pressure pressure value
  60857. */
  60858. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60859. /**
  60860. * Gets stiffness of the impostor
  60861. * @param impostor impostor to get stiffness from
  60862. * @returns pressure value
  60863. */
  60864. getBodyStiffness(impostor: PhysicsImpostor): number;
  60865. /**
  60866. * Sets stiffness of the impostor
  60867. * @param impostor impostor to set stiffness on
  60868. * @param stiffness stiffness value from 0 to 1
  60869. */
  60870. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  60871. /**
  60872. * Gets velocityIterations of the impostor
  60873. * @param impostor impostor to get velocity iterations from
  60874. * @returns velocityIterations value
  60875. */
  60876. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  60877. /**
  60878. * Sets velocityIterations of the impostor
  60879. * @param impostor impostor to set velocity iterations on
  60880. * @param velocityIterations velocityIterations value
  60881. */
  60882. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  60883. /**
  60884. * Gets positionIterations of the impostor
  60885. * @param impostor impostor to get position iterations from
  60886. * @returns positionIterations value
  60887. */
  60888. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  60889. /**
  60890. * Sets positionIterations of the impostor
  60891. * @param impostor impostor to set position on
  60892. * @param positionIterations positionIterations value
  60893. */
  60894. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60895. /**
  60896. * Append an anchor to a cloth object
  60897. * @param impostor is the cloth impostor to add anchor to
  60898. * @param otherImpostor is the rigid impostor to anchor to
  60899. * @param width ratio across width from 0 to 1
  60900. * @param height ratio up height from 0 to 1
  60901. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60902. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60903. */
  60904. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60905. /**
  60906. * Append an hook to a rope object
  60907. * @param impostor is the rope impostor to add hook to
  60908. * @param otherImpostor is the rigid impostor to hook to
  60909. * @param length ratio along the rope from 0 to 1
  60910. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60911. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60912. */
  60913. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60914. /**
  60915. * Sleeps the physics body and stops it from being active
  60916. * @param impostor impostor to sleep
  60917. */
  60918. sleepBody(impostor: PhysicsImpostor): void;
  60919. /**
  60920. * Activates the physics body
  60921. * @param impostor impostor to activate
  60922. */
  60923. wakeUpBody(impostor: PhysicsImpostor): void;
  60924. /**
  60925. * Updates the distance parameters of the joint
  60926. * @param joint joint to update
  60927. * @param maxDistance maximum distance of the joint
  60928. * @param minDistance minimum distance of the joint
  60929. */
  60930. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60931. /**
  60932. * Sets a motor on the joint
  60933. * @param joint joint to set motor on
  60934. * @param speed speed of the motor
  60935. * @param maxForce maximum force of the motor
  60936. * @param motorIndex index of the motor
  60937. */
  60938. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60939. /**
  60940. * Sets the motors limit
  60941. * @param joint joint to set limit on
  60942. * @param upperLimit upper limit
  60943. * @param lowerLimit lower limit
  60944. */
  60945. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60946. /**
  60947. * Syncs the position and rotation of a mesh with the impostor
  60948. * @param mesh mesh to sync
  60949. * @param impostor impostor to update the mesh with
  60950. */
  60951. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60952. /**
  60953. * Gets the radius of the impostor
  60954. * @param impostor impostor to get radius from
  60955. * @returns the radius
  60956. */
  60957. getRadius(impostor: PhysicsImpostor): number;
  60958. /**
  60959. * Gets the box size of the impostor
  60960. * @param impostor impostor to get box size from
  60961. * @param result the resulting box size
  60962. */
  60963. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60964. /**
  60965. * Disposes of the impostor
  60966. */
  60967. dispose(): void;
  60968. /**
  60969. * Does a raycast in the physics world
  60970. * @param from when should the ray start?
  60971. * @param to when should the ray end?
  60972. * @returns PhysicsRaycastResult
  60973. */
  60974. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60975. }
  60976. }
  60977. declare module BABYLON {
  60978. interface AbstractScene {
  60979. /**
  60980. * The list of reflection probes added to the scene
  60981. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60982. */
  60983. reflectionProbes: Array<ReflectionProbe>;
  60984. /**
  60985. * Removes the given reflection probe from this scene.
  60986. * @param toRemove The reflection probe to remove
  60987. * @returns The index of the removed reflection probe
  60988. */
  60989. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60990. /**
  60991. * Adds the given reflection probe to this scene.
  60992. * @param newReflectionProbe The reflection probe to add
  60993. */
  60994. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60995. }
  60996. /**
  60997. * Class used to generate realtime reflection / refraction cube textures
  60998. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60999. */
  61000. export class ReflectionProbe {
  61001. /** defines the name of the probe */
  61002. name: string;
  61003. private _scene;
  61004. private _renderTargetTexture;
  61005. private _projectionMatrix;
  61006. private _viewMatrix;
  61007. private _target;
  61008. private _add;
  61009. private _attachedMesh;
  61010. private _invertYAxis;
  61011. /** Gets or sets probe position (center of the cube map) */
  61012. position: Vector3;
  61013. /**
  61014. * Creates a new reflection probe
  61015. * @param name defines the name of the probe
  61016. * @param size defines the texture resolution (for each face)
  61017. * @param scene defines the hosting scene
  61018. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61019. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61020. */
  61021. constructor(
  61022. /** defines the name of the probe */
  61023. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61024. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61025. get samples(): number;
  61026. set samples(value: number);
  61027. /** Gets or sets the refresh rate to use (on every frame by default) */
  61028. get refreshRate(): number;
  61029. set refreshRate(value: number);
  61030. /**
  61031. * Gets the hosting scene
  61032. * @returns a Scene
  61033. */
  61034. getScene(): Scene;
  61035. /** Gets the internal CubeTexture used to render to */
  61036. get cubeTexture(): RenderTargetTexture;
  61037. /** Gets the list of meshes to render */
  61038. get renderList(): Nullable<AbstractMesh[]>;
  61039. /**
  61040. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61041. * @param mesh defines the mesh to attach to
  61042. */
  61043. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61044. /**
  61045. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61046. * @param renderingGroupId The rendering group id corresponding to its index
  61047. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61048. */
  61049. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61050. /**
  61051. * Clean all associated resources
  61052. */
  61053. dispose(): void;
  61054. /**
  61055. * Converts the reflection probe information to a readable string for debug purpose.
  61056. * @param fullDetails Supports for multiple levels of logging within scene loading
  61057. * @returns the human readable reflection probe info
  61058. */
  61059. toString(fullDetails?: boolean): string;
  61060. /**
  61061. * Get the class name of the relfection probe.
  61062. * @returns "ReflectionProbe"
  61063. */
  61064. getClassName(): string;
  61065. /**
  61066. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61067. * @returns The JSON representation of the texture
  61068. */
  61069. serialize(): any;
  61070. /**
  61071. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61072. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61073. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61074. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61075. * @returns The parsed reflection probe if successful
  61076. */
  61077. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61078. }
  61079. }
  61080. declare module BABYLON {
  61081. /** @hidden */
  61082. export var _BabylonLoaderRegistered: boolean;
  61083. /**
  61084. * Helps setting up some configuration for the babylon file loader.
  61085. */
  61086. export class BabylonFileLoaderConfiguration {
  61087. /**
  61088. * The loader does not allow injecting custom physix engine into the plugins.
  61089. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61090. * So you could set this variable to your engine import to make it work.
  61091. */
  61092. static LoaderInjectedPhysicsEngine: any;
  61093. }
  61094. }
  61095. declare module BABYLON {
  61096. /**
  61097. * The Physically based simple base material of BJS.
  61098. *
  61099. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61100. * It is used as the base class for both the specGloss and metalRough conventions.
  61101. */
  61102. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61103. /**
  61104. * Number of Simultaneous lights allowed on the material.
  61105. */
  61106. maxSimultaneousLights: number;
  61107. /**
  61108. * If sets to true, disables all the lights affecting the material.
  61109. */
  61110. disableLighting: boolean;
  61111. /**
  61112. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61113. */
  61114. environmentTexture: BaseTexture;
  61115. /**
  61116. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61117. */
  61118. invertNormalMapX: boolean;
  61119. /**
  61120. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61121. */
  61122. invertNormalMapY: boolean;
  61123. /**
  61124. * Normal map used in the model.
  61125. */
  61126. normalTexture: BaseTexture;
  61127. /**
  61128. * Emissivie color used to self-illuminate the model.
  61129. */
  61130. emissiveColor: Color3;
  61131. /**
  61132. * Emissivie texture used to self-illuminate the model.
  61133. */
  61134. emissiveTexture: BaseTexture;
  61135. /**
  61136. * Occlusion Channel Strenght.
  61137. */
  61138. occlusionStrength: number;
  61139. /**
  61140. * Occlusion Texture of the material (adding extra occlusion effects).
  61141. */
  61142. occlusionTexture: BaseTexture;
  61143. /**
  61144. * Defines the alpha limits in alpha test mode.
  61145. */
  61146. alphaCutOff: number;
  61147. /**
  61148. * Gets the current double sided mode.
  61149. */
  61150. get doubleSided(): boolean;
  61151. /**
  61152. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61153. */
  61154. set doubleSided(value: boolean);
  61155. /**
  61156. * Stores the pre-calculated light information of a mesh in a texture.
  61157. */
  61158. lightmapTexture: BaseTexture;
  61159. /**
  61160. * If true, the light map contains occlusion information instead of lighting info.
  61161. */
  61162. useLightmapAsShadowmap: boolean;
  61163. /**
  61164. * Instantiates a new PBRMaterial instance.
  61165. *
  61166. * @param name The material name
  61167. * @param scene The scene the material will be use in.
  61168. */
  61169. constructor(name: string, scene: Scene);
  61170. getClassName(): string;
  61171. }
  61172. }
  61173. declare module BABYLON {
  61174. /**
  61175. * The PBR material of BJS following the metal roughness convention.
  61176. *
  61177. * This fits to the PBR convention in the GLTF definition:
  61178. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61179. */
  61180. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61181. /**
  61182. * The base color has two different interpretations depending on the value of metalness.
  61183. * When the material is a metal, the base color is the specific measured reflectance value
  61184. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61185. * of the material.
  61186. */
  61187. baseColor: Color3;
  61188. /**
  61189. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61190. * well as opacity information in the alpha channel.
  61191. */
  61192. baseTexture: BaseTexture;
  61193. /**
  61194. * Specifies the metallic scalar value of the material.
  61195. * Can also be used to scale the metalness values of the metallic texture.
  61196. */
  61197. metallic: number;
  61198. /**
  61199. * Specifies the roughness scalar value of the material.
  61200. * Can also be used to scale the roughness values of the metallic texture.
  61201. */
  61202. roughness: number;
  61203. /**
  61204. * Texture containing both the metallic value in the B channel and the
  61205. * roughness value in the G channel to keep better precision.
  61206. */
  61207. metallicRoughnessTexture: BaseTexture;
  61208. /**
  61209. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61210. *
  61211. * @param name The material name
  61212. * @param scene The scene the material will be use in.
  61213. */
  61214. constructor(name: string, scene: Scene);
  61215. /**
  61216. * Return the currrent class name of the material.
  61217. */
  61218. getClassName(): string;
  61219. /**
  61220. * Makes a duplicate of the current material.
  61221. * @param name - name to use for the new material.
  61222. */
  61223. clone(name: string): PBRMetallicRoughnessMaterial;
  61224. /**
  61225. * Serialize the material to a parsable JSON object.
  61226. */
  61227. serialize(): any;
  61228. /**
  61229. * Parses a JSON object correponding to the serialize function.
  61230. */
  61231. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61232. }
  61233. }
  61234. declare module BABYLON {
  61235. /**
  61236. * The PBR material of BJS following the specular glossiness convention.
  61237. *
  61238. * This fits to the PBR convention in the GLTF definition:
  61239. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61240. */
  61241. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61242. /**
  61243. * Specifies the diffuse color of the material.
  61244. */
  61245. diffuseColor: Color3;
  61246. /**
  61247. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61248. * channel.
  61249. */
  61250. diffuseTexture: BaseTexture;
  61251. /**
  61252. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61253. */
  61254. specularColor: Color3;
  61255. /**
  61256. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61257. */
  61258. glossiness: number;
  61259. /**
  61260. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61261. */
  61262. specularGlossinessTexture: BaseTexture;
  61263. /**
  61264. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61265. *
  61266. * @param name The material name
  61267. * @param scene The scene the material will be use in.
  61268. */
  61269. constructor(name: string, scene: Scene);
  61270. /**
  61271. * Return the currrent class name of the material.
  61272. */
  61273. getClassName(): string;
  61274. /**
  61275. * Makes a duplicate of the current material.
  61276. * @param name - name to use for the new material.
  61277. */
  61278. clone(name: string): PBRSpecularGlossinessMaterial;
  61279. /**
  61280. * Serialize the material to a parsable JSON object.
  61281. */
  61282. serialize(): any;
  61283. /**
  61284. * Parses a JSON object correponding to the serialize function.
  61285. */
  61286. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61287. }
  61288. }
  61289. declare module BABYLON {
  61290. /**
  61291. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61292. * It can help converting any input color in a desired output one. This can then be used to create effects
  61293. * from sepia, black and white to sixties or futuristic rendering...
  61294. *
  61295. * The only supported format is currently 3dl.
  61296. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61297. */
  61298. export class ColorGradingTexture extends BaseTexture {
  61299. /**
  61300. * The texture URL.
  61301. */
  61302. url: string;
  61303. /**
  61304. * Empty line regex stored for GC.
  61305. */
  61306. private static _noneEmptyLineRegex;
  61307. private _textureMatrix;
  61308. private _onLoad;
  61309. /**
  61310. * Instantiates a ColorGradingTexture from the following parameters.
  61311. *
  61312. * @param url The location of the color gradind data (currently only supporting 3dl)
  61313. * @param sceneOrEngine The scene or engine the texture will be used in
  61314. * @param onLoad defines a callback triggered when the texture has been loaded
  61315. */
  61316. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61317. /**
  61318. * Fires the onload event from the constructor if requested.
  61319. */
  61320. private _triggerOnLoad;
  61321. /**
  61322. * Returns the texture matrix used in most of the material.
  61323. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61324. */
  61325. getTextureMatrix(): Matrix;
  61326. /**
  61327. * Occurs when the file being loaded is a .3dl LUT file.
  61328. */
  61329. private load3dlTexture;
  61330. /**
  61331. * Starts the loading process of the texture.
  61332. */
  61333. private loadTexture;
  61334. /**
  61335. * Clones the color gradind texture.
  61336. */
  61337. clone(): ColorGradingTexture;
  61338. /**
  61339. * Called during delayed load for textures.
  61340. */
  61341. delayLoad(): void;
  61342. /**
  61343. * Parses a color grading texture serialized by Babylon.
  61344. * @param parsedTexture The texture information being parsedTexture
  61345. * @param scene The scene to load the texture in
  61346. * @param rootUrl The root url of the data assets to load
  61347. * @return A color gradind texture
  61348. */
  61349. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61350. /**
  61351. * Serializes the LUT texture to json format.
  61352. */
  61353. serialize(): any;
  61354. }
  61355. }
  61356. declare module BABYLON {
  61357. /**
  61358. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61359. */
  61360. export class EquiRectangularCubeTexture extends BaseTexture {
  61361. /** The six faces of the cube. */
  61362. private static _FacesMapping;
  61363. private _noMipmap;
  61364. private _onLoad;
  61365. private _onError;
  61366. /** The size of the cubemap. */
  61367. private _size;
  61368. /** The buffer of the image. */
  61369. private _buffer;
  61370. /** The width of the input image. */
  61371. private _width;
  61372. /** The height of the input image. */
  61373. private _height;
  61374. /** The URL to the image. */
  61375. url: string;
  61376. /**
  61377. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61378. * @param url The location of the image
  61379. * @param scene The scene the texture will be used in
  61380. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61381. * @param noMipmap Forces to not generate the mipmap if true
  61382. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61383. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61384. * @param onLoad — defines a callback called when texture is loaded
  61385. * @param onError — defines a callback called if there is an error
  61386. */
  61387. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61388. /**
  61389. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61390. */
  61391. private loadImage;
  61392. /**
  61393. * Convert the image buffer into a cubemap and create a CubeTexture.
  61394. */
  61395. private loadTexture;
  61396. /**
  61397. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61398. * @param buffer The ArrayBuffer that should be converted.
  61399. * @returns The buffer as Float32Array.
  61400. */
  61401. private getFloat32ArrayFromArrayBuffer;
  61402. /**
  61403. * Get the current class name of the texture useful for serialization or dynamic coding.
  61404. * @returns "EquiRectangularCubeTexture"
  61405. */
  61406. getClassName(): string;
  61407. /**
  61408. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61409. * @returns A clone of the current EquiRectangularCubeTexture.
  61410. */
  61411. clone(): EquiRectangularCubeTexture;
  61412. }
  61413. }
  61414. declare module BABYLON {
  61415. /**
  61416. * Defines the options related to the creation of an HtmlElementTexture
  61417. */
  61418. export interface IHtmlElementTextureOptions {
  61419. /**
  61420. * Defines wether mip maps should be created or not.
  61421. */
  61422. generateMipMaps?: boolean;
  61423. /**
  61424. * Defines the sampling mode of the texture.
  61425. */
  61426. samplingMode?: number;
  61427. /**
  61428. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61429. */
  61430. engine: Nullable<ThinEngine>;
  61431. /**
  61432. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61433. */
  61434. scene: Nullable<Scene>;
  61435. }
  61436. /**
  61437. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61438. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61439. * is automatically managed.
  61440. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61441. * in your application.
  61442. *
  61443. * As the update is not automatic, you need to call them manually.
  61444. */
  61445. export class HtmlElementTexture extends BaseTexture {
  61446. /**
  61447. * The texture URL.
  61448. */
  61449. element: HTMLVideoElement | HTMLCanvasElement;
  61450. private static readonly DefaultOptions;
  61451. private _textureMatrix;
  61452. private _isVideo;
  61453. private _generateMipMaps;
  61454. private _samplingMode;
  61455. /**
  61456. * Instantiates a HtmlElementTexture from the following parameters.
  61457. *
  61458. * @param name Defines the name of the texture
  61459. * @param element Defines the video or canvas the texture is filled with
  61460. * @param options Defines the other none mandatory texture creation options
  61461. */
  61462. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61463. private _createInternalTexture;
  61464. /**
  61465. * Returns the texture matrix used in most of the material.
  61466. */
  61467. getTextureMatrix(): Matrix;
  61468. /**
  61469. * Updates the content of the texture.
  61470. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61471. */
  61472. update(invertY?: Nullable<boolean>): void;
  61473. }
  61474. }
  61475. declare module BABYLON {
  61476. /**
  61477. * Based on jsTGALoader - Javascript loader for TGA file
  61478. * By Vincent Thibault
  61479. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61480. */
  61481. export class TGATools {
  61482. private static _TYPE_INDEXED;
  61483. private static _TYPE_RGB;
  61484. private static _TYPE_GREY;
  61485. private static _TYPE_RLE_INDEXED;
  61486. private static _TYPE_RLE_RGB;
  61487. private static _TYPE_RLE_GREY;
  61488. private static _ORIGIN_MASK;
  61489. private static _ORIGIN_SHIFT;
  61490. private static _ORIGIN_BL;
  61491. private static _ORIGIN_BR;
  61492. private static _ORIGIN_UL;
  61493. private static _ORIGIN_UR;
  61494. /**
  61495. * Gets the header of a TGA file
  61496. * @param data defines the TGA data
  61497. * @returns the header
  61498. */
  61499. static GetTGAHeader(data: Uint8Array): any;
  61500. /**
  61501. * Uploads TGA content to a Babylon Texture
  61502. * @hidden
  61503. */
  61504. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61505. /** @hidden */
  61506. 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;
  61507. /** @hidden */
  61508. 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;
  61509. /** @hidden */
  61510. 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;
  61511. /** @hidden */
  61512. 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;
  61513. /** @hidden */
  61514. 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;
  61515. /** @hidden */
  61516. 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;
  61517. }
  61518. }
  61519. declare module BABYLON {
  61520. /**
  61521. * Implementation of the TGA Texture Loader.
  61522. * @hidden
  61523. */
  61524. export class _TGATextureLoader implements IInternalTextureLoader {
  61525. /**
  61526. * Defines wether the loader supports cascade loading the different faces.
  61527. */
  61528. readonly supportCascades: boolean;
  61529. /**
  61530. * This returns if the loader support the current file information.
  61531. * @param extension defines the file extension of the file being loaded
  61532. * @returns true if the loader can load the specified file
  61533. */
  61534. canLoad(extension: string): boolean;
  61535. /**
  61536. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61537. * @param data contains the texture data
  61538. * @param texture defines the BabylonJS internal texture
  61539. * @param createPolynomials will be true if polynomials have been requested
  61540. * @param onLoad defines the callback to trigger once the texture is ready
  61541. * @param onError defines the callback to trigger in case of error
  61542. */
  61543. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61544. /**
  61545. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61546. * @param data contains the texture data
  61547. * @param texture defines the BabylonJS internal texture
  61548. * @param callback defines the method to call once ready to upload
  61549. */
  61550. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61551. }
  61552. }
  61553. declare module BABYLON {
  61554. /**
  61555. * Info about the .basis files
  61556. */
  61557. class BasisFileInfo {
  61558. /**
  61559. * If the file has alpha
  61560. */
  61561. hasAlpha: boolean;
  61562. /**
  61563. * Info about each image of the basis file
  61564. */
  61565. images: Array<{
  61566. levels: Array<{
  61567. width: number;
  61568. height: number;
  61569. transcodedPixels: ArrayBufferView;
  61570. }>;
  61571. }>;
  61572. }
  61573. /**
  61574. * Result of transcoding a basis file
  61575. */
  61576. class TranscodeResult {
  61577. /**
  61578. * Info about the .basis file
  61579. */
  61580. fileInfo: BasisFileInfo;
  61581. /**
  61582. * Format to use when loading the file
  61583. */
  61584. format: number;
  61585. }
  61586. /**
  61587. * Configuration options for the Basis transcoder
  61588. */
  61589. export class BasisTranscodeConfiguration {
  61590. /**
  61591. * Supported compression formats used to determine the supported output format of the transcoder
  61592. */
  61593. supportedCompressionFormats?: {
  61594. /**
  61595. * etc1 compression format
  61596. */
  61597. etc1?: boolean;
  61598. /**
  61599. * s3tc compression format
  61600. */
  61601. s3tc?: boolean;
  61602. /**
  61603. * pvrtc compression format
  61604. */
  61605. pvrtc?: boolean;
  61606. /**
  61607. * etc2 compression format
  61608. */
  61609. etc2?: boolean;
  61610. };
  61611. /**
  61612. * If mipmap levels should be loaded for transcoded images (Default: true)
  61613. */
  61614. loadMipmapLevels?: boolean;
  61615. /**
  61616. * Index of a single image to load (Default: all images)
  61617. */
  61618. loadSingleImage?: number;
  61619. }
  61620. /**
  61621. * Used to load .Basis files
  61622. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61623. */
  61624. export class BasisTools {
  61625. private static _IgnoreSupportedFormats;
  61626. /**
  61627. * URL to use when loading the basis transcoder
  61628. */
  61629. static JSModuleURL: string;
  61630. /**
  61631. * URL to use when loading the wasm module for the transcoder
  61632. */
  61633. static WasmModuleURL: string;
  61634. /**
  61635. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61636. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61637. * @returns internal format corresponding to the Basis format
  61638. */
  61639. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61640. private static _WorkerPromise;
  61641. private static _Worker;
  61642. private static _actionId;
  61643. private static _CreateWorkerAsync;
  61644. /**
  61645. * Transcodes a loaded image file to compressed pixel data
  61646. * @param data image data to transcode
  61647. * @param config configuration options for the transcoding
  61648. * @returns a promise resulting in the transcoded image
  61649. */
  61650. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61651. /**
  61652. * Loads a texture from the transcode result
  61653. * @param texture texture load to
  61654. * @param transcodeResult the result of transcoding the basis file to load from
  61655. */
  61656. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61657. }
  61658. }
  61659. declare module BABYLON {
  61660. /**
  61661. * Loader for .basis file format
  61662. */
  61663. export class _BasisTextureLoader implements IInternalTextureLoader {
  61664. /**
  61665. * Defines whether the loader supports cascade loading the different faces.
  61666. */
  61667. readonly supportCascades: boolean;
  61668. /**
  61669. * This returns if the loader support the current file information.
  61670. * @param extension defines the file extension of the file being loaded
  61671. * @returns true if the loader can load the specified file
  61672. */
  61673. canLoad(extension: string): boolean;
  61674. /**
  61675. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61676. * @param data contains the texture data
  61677. * @param texture defines the BabylonJS internal texture
  61678. * @param createPolynomials will be true if polynomials have been requested
  61679. * @param onLoad defines the callback to trigger once the texture is ready
  61680. * @param onError defines the callback to trigger in case of error
  61681. */
  61682. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61683. /**
  61684. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61685. * @param data contains the texture data
  61686. * @param texture defines the BabylonJS internal texture
  61687. * @param callback defines the method to call once ready to upload
  61688. */
  61689. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61690. }
  61691. }
  61692. declare module BABYLON {
  61693. /**
  61694. * Defines the basic options interface of a TexturePacker Frame
  61695. */
  61696. export interface ITexturePackerFrame {
  61697. /**
  61698. * The frame ID
  61699. */
  61700. id: number;
  61701. /**
  61702. * The frames Scale
  61703. */
  61704. scale: Vector2;
  61705. /**
  61706. * The Frames offset
  61707. */
  61708. offset: Vector2;
  61709. }
  61710. /**
  61711. * This is a support class for frame Data on texture packer sets.
  61712. */
  61713. export class TexturePackerFrame implements ITexturePackerFrame {
  61714. /**
  61715. * The frame ID
  61716. */
  61717. id: number;
  61718. /**
  61719. * The frames Scale
  61720. */
  61721. scale: Vector2;
  61722. /**
  61723. * The Frames offset
  61724. */
  61725. offset: Vector2;
  61726. /**
  61727. * Initializes a texture package frame.
  61728. * @param id The numerical frame identifier
  61729. * @param scale Scalar Vector2 for UV frame
  61730. * @param offset Vector2 for the frame position in UV units.
  61731. * @returns TexturePackerFrame
  61732. */
  61733. constructor(id: number, scale: Vector2, offset: Vector2);
  61734. }
  61735. }
  61736. declare module BABYLON {
  61737. /**
  61738. * Defines the basic options interface of a TexturePacker
  61739. */
  61740. export interface ITexturePackerOptions {
  61741. /**
  61742. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61743. */
  61744. map?: string[];
  61745. /**
  61746. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61747. */
  61748. uvsIn?: string;
  61749. /**
  61750. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61751. */
  61752. uvsOut?: string;
  61753. /**
  61754. * number representing the layout style. Defaults to LAYOUT_STRIP
  61755. */
  61756. layout?: number;
  61757. /**
  61758. * number of columns if using custom column count layout(2). This defaults to 4.
  61759. */
  61760. colnum?: number;
  61761. /**
  61762. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61763. */
  61764. updateInputMeshes?: boolean;
  61765. /**
  61766. * boolean flag to dispose all the source textures. Defaults to true.
  61767. */
  61768. disposeSources?: boolean;
  61769. /**
  61770. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61771. */
  61772. fillBlanks?: boolean;
  61773. /**
  61774. * string value representing the context fill style color. Defaults to 'black'.
  61775. */
  61776. customFillColor?: string;
  61777. /**
  61778. * Width and Height Value of each Frame in the TexturePacker Sets
  61779. */
  61780. frameSize?: number;
  61781. /**
  61782. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61783. */
  61784. paddingRatio?: number;
  61785. /**
  61786. * Number that declares the fill method for the padding gutter.
  61787. */
  61788. paddingMode?: number;
  61789. /**
  61790. * If in SUBUV_COLOR padding mode what color to use.
  61791. */
  61792. paddingColor?: Color3 | Color4;
  61793. }
  61794. /**
  61795. * Defines the basic interface of a TexturePacker JSON File
  61796. */
  61797. export interface ITexturePackerJSON {
  61798. /**
  61799. * The frame ID
  61800. */
  61801. name: string;
  61802. /**
  61803. * The base64 channel data
  61804. */
  61805. sets: any;
  61806. /**
  61807. * The options of the Packer
  61808. */
  61809. options: ITexturePackerOptions;
  61810. /**
  61811. * The frame data of the Packer
  61812. */
  61813. frames: Array<number>;
  61814. }
  61815. /**
  61816. * This is a support class that generates a series of packed texture sets.
  61817. * @see https://doc.babylonjs.com/babylon101/materials
  61818. */
  61819. export class TexturePacker {
  61820. /** Packer Layout Constant 0 */
  61821. static readonly LAYOUT_STRIP: number;
  61822. /** Packer Layout Constant 1 */
  61823. static readonly LAYOUT_POWER2: number;
  61824. /** Packer Layout Constant 2 */
  61825. static readonly LAYOUT_COLNUM: number;
  61826. /** Packer Layout Constant 0 */
  61827. static readonly SUBUV_WRAP: number;
  61828. /** Packer Layout Constant 1 */
  61829. static readonly SUBUV_EXTEND: number;
  61830. /** Packer Layout Constant 2 */
  61831. static readonly SUBUV_COLOR: number;
  61832. /** The Name of the Texture Package */
  61833. name: string;
  61834. /** The scene scope of the TexturePacker */
  61835. scene: Scene;
  61836. /** The Meshes to target */
  61837. meshes: AbstractMesh[];
  61838. /** Arguments passed with the Constructor */
  61839. options: ITexturePackerOptions;
  61840. /** The promise that is started upon initialization */
  61841. promise: Nullable<Promise<TexturePacker | string>>;
  61842. /** The Container object for the channel sets that are generated */
  61843. sets: object;
  61844. /** The Container array for the frames that are generated */
  61845. frames: TexturePackerFrame[];
  61846. /** The expected number of textures the system is parsing. */
  61847. private _expecting;
  61848. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61849. private _paddingValue;
  61850. /**
  61851. * Initializes a texture package series from an array of meshes or a single mesh.
  61852. * @param name The name of the package
  61853. * @param meshes The target meshes to compose the package from
  61854. * @param options The arguments that texture packer should follow while building.
  61855. * @param scene The scene which the textures are scoped to.
  61856. * @returns TexturePacker
  61857. */
  61858. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61859. /**
  61860. * Starts the package process
  61861. * @param resolve The promises resolution function
  61862. * @returns TexturePacker
  61863. */
  61864. private _createFrames;
  61865. /**
  61866. * Calculates the Size of the Channel Sets
  61867. * @returns Vector2
  61868. */
  61869. private _calculateSize;
  61870. /**
  61871. * Calculates the UV data for the frames.
  61872. * @param baseSize the base frameSize
  61873. * @param padding the base frame padding
  61874. * @param dtSize size of the Dynamic Texture for that channel
  61875. * @param dtUnits is 1/dtSize
  61876. * @param update flag to update the input meshes
  61877. */
  61878. private _calculateMeshUVFrames;
  61879. /**
  61880. * Calculates the frames Offset.
  61881. * @param index of the frame
  61882. * @returns Vector2
  61883. */
  61884. private _getFrameOffset;
  61885. /**
  61886. * Updates a Mesh to the frame data
  61887. * @param mesh that is the target
  61888. * @param frameID or the frame index
  61889. */
  61890. private _updateMeshUV;
  61891. /**
  61892. * Updates a Meshes materials to use the texture packer channels
  61893. * @param m is the mesh to target
  61894. * @param force all channels on the packer to be set.
  61895. */
  61896. private _updateTextureReferences;
  61897. /**
  61898. * Public method to set a Mesh to a frame
  61899. * @param m that is the target
  61900. * @param frameID or the frame index
  61901. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61902. */
  61903. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61904. /**
  61905. * Starts the async promise to compile the texture packer.
  61906. * @returns Promise<void>
  61907. */
  61908. processAsync(): Promise<void>;
  61909. /**
  61910. * Disposes all textures associated with this packer
  61911. */
  61912. dispose(): void;
  61913. /**
  61914. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61915. * @param imageType is the image type to use.
  61916. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61917. */
  61918. download(imageType?: string, quality?: number): void;
  61919. /**
  61920. * Public method to load a texturePacker JSON file.
  61921. * @param data of the JSON file in string format.
  61922. */
  61923. updateFromJSON(data: string): void;
  61924. }
  61925. }
  61926. declare module BABYLON {
  61927. /**
  61928. * 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.
  61929. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61930. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61931. */
  61932. export class CustomProceduralTexture extends ProceduralTexture {
  61933. private _animate;
  61934. private _time;
  61935. private _config;
  61936. private _texturePath;
  61937. /**
  61938. * Instantiates a new Custom Procedural Texture.
  61939. * 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.
  61940. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61941. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61942. * @param name Define the name of the texture
  61943. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61944. * @param size Define the size of the texture to create
  61945. * @param scene Define the scene the texture belongs to
  61946. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61947. * @param generateMipMaps Define if the texture should creates mip maps or not
  61948. */
  61949. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61950. private _loadJson;
  61951. /**
  61952. * Is the texture ready to be used ? (rendered at least once)
  61953. * @returns true if ready, otherwise, false.
  61954. */
  61955. isReady(): boolean;
  61956. /**
  61957. * Render the texture to its associated render target.
  61958. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61959. */
  61960. render(useCameraPostProcess?: boolean): void;
  61961. /**
  61962. * Update the list of dependant textures samplers in the shader.
  61963. */
  61964. updateTextures(): void;
  61965. /**
  61966. * Update the uniform values of the procedural texture in the shader.
  61967. */
  61968. updateShaderUniforms(): void;
  61969. /**
  61970. * Define if the texture animates or not.
  61971. */
  61972. get animate(): boolean;
  61973. set animate(value: boolean);
  61974. }
  61975. }
  61976. declare module BABYLON {
  61977. /** @hidden */
  61978. export var noisePixelShader: {
  61979. name: string;
  61980. shader: string;
  61981. };
  61982. }
  61983. declare module BABYLON {
  61984. /**
  61985. * Class used to generate noise procedural textures
  61986. */
  61987. export class NoiseProceduralTexture extends ProceduralTexture {
  61988. private _time;
  61989. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61990. brightness: number;
  61991. /** Defines the number of octaves to process */
  61992. octaves: number;
  61993. /** Defines the level of persistence (0.8 by default) */
  61994. persistence: number;
  61995. /** Gets or sets animation speed factor (default is 1) */
  61996. animationSpeedFactor: number;
  61997. /**
  61998. * Creates a new NoiseProceduralTexture
  61999. * @param name defines the name fo the texture
  62000. * @param size defines the size of the texture (default is 256)
  62001. * @param scene defines the hosting scene
  62002. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62003. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62004. */
  62005. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62006. private _updateShaderUniforms;
  62007. protected _getDefines(): string;
  62008. /** Generate the current state of the procedural texture */
  62009. render(useCameraPostProcess?: boolean): void;
  62010. /**
  62011. * Serializes this noise procedural texture
  62012. * @returns a serialized noise procedural texture object
  62013. */
  62014. serialize(): any;
  62015. /**
  62016. * Clone the texture.
  62017. * @returns the cloned texture
  62018. */
  62019. clone(): NoiseProceduralTexture;
  62020. /**
  62021. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62022. * @param parsedTexture defines parsed texture data
  62023. * @param scene defines the current scene
  62024. * @param rootUrl defines the root URL containing noise procedural texture information
  62025. * @returns a parsed NoiseProceduralTexture
  62026. */
  62027. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62028. }
  62029. }
  62030. declare module BABYLON {
  62031. /**
  62032. * Raw cube texture where the raw buffers are passed in
  62033. */
  62034. export class RawCubeTexture extends CubeTexture {
  62035. /**
  62036. * Creates a cube texture where the raw buffers are passed in.
  62037. * @param scene defines the scene the texture is attached to
  62038. * @param data defines the array of data to use to create each face
  62039. * @param size defines the size of the textures
  62040. * @param format defines the format of the data
  62041. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62042. * @param generateMipMaps defines if the engine should generate the mip levels
  62043. * @param invertY defines if data must be stored with Y axis inverted
  62044. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62045. * @param compression defines the compression used (null by default)
  62046. */
  62047. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62048. /**
  62049. * Updates the raw cube texture.
  62050. * @param data defines the data to store
  62051. * @param format defines the data format
  62052. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62053. * @param invertY defines if data must be stored with Y axis inverted
  62054. * @param compression defines the compression used (null by default)
  62055. * @param level defines which level of the texture to update
  62056. */
  62057. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62058. /**
  62059. * Updates a raw cube texture with RGBD encoded data.
  62060. * @param data defines the array of data [mipmap][face] to use to create each face
  62061. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62062. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62063. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62064. * @returns a promsie that resolves when the operation is complete
  62065. */
  62066. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62067. /**
  62068. * Clones the raw cube texture.
  62069. * @return a new cube texture
  62070. */
  62071. clone(): CubeTexture;
  62072. /** @hidden */
  62073. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62074. }
  62075. }
  62076. declare module BABYLON {
  62077. /**
  62078. * Class used to store 2D array textures containing user data
  62079. */
  62080. export class RawTexture2DArray extends Texture {
  62081. /** Gets or sets the texture format to use */
  62082. format: number;
  62083. /**
  62084. * Create a new RawTexture2DArray
  62085. * @param data defines the data of the texture
  62086. * @param width defines the width of the texture
  62087. * @param height defines the height of the texture
  62088. * @param depth defines the number of layers of the texture
  62089. * @param format defines the texture format to use
  62090. * @param scene defines the hosting scene
  62091. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62092. * @param invertY defines if texture must be stored with Y axis inverted
  62093. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62094. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62095. */
  62096. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62097. /** Gets or sets the texture format to use */
  62098. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62099. /**
  62100. * Update the texture with new data
  62101. * @param data defines the data to store in the texture
  62102. */
  62103. update(data: ArrayBufferView): void;
  62104. }
  62105. }
  62106. declare module BABYLON {
  62107. /**
  62108. * Class used to store 3D textures containing user data
  62109. */
  62110. export class RawTexture3D extends Texture {
  62111. /** Gets or sets the texture format to use */
  62112. format: number;
  62113. /**
  62114. * Create a new RawTexture3D
  62115. * @param data defines the data of the texture
  62116. * @param width defines the width of the texture
  62117. * @param height defines the height of the texture
  62118. * @param depth defines the depth of the texture
  62119. * @param format defines the texture format to use
  62120. * @param scene defines the hosting scene
  62121. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62122. * @param invertY defines if texture must be stored with Y axis inverted
  62123. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62124. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62125. */
  62126. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62127. /** Gets or sets the texture format to use */
  62128. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62129. /**
  62130. * Update the texture with new data
  62131. * @param data defines the data to store in the texture
  62132. */
  62133. update(data: ArrayBufferView): void;
  62134. }
  62135. }
  62136. declare module BABYLON {
  62137. /**
  62138. * Creates a refraction texture used by refraction channel of the standard material.
  62139. * It is like a mirror but to see through a material.
  62140. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62141. */
  62142. export class RefractionTexture extends RenderTargetTexture {
  62143. /**
  62144. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62145. * 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.
  62146. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62147. */
  62148. refractionPlane: Plane;
  62149. /**
  62150. * Define how deep under the surface we should see.
  62151. */
  62152. depth: number;
  62153. /**
  62154. * Creates a refraction texture used by refraction channel of the standard material.
  62155. * It is like a mirror but to see through a material.
  62156. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62157. * @param name Define the texture name
  62158. * @param size Define the size of the underlying texture
  62159. * @param scene Define the scene the refraction belongs to
  62160. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62161. */
  62162. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62163. /**
  62164. * Clone the refraction texture.
  62165. * @returns the cloned texture
  62166. */
  62167. clone(): RefractionTexture;
  62168. /**
  62169. * Serialize the texture to a JSON representation you could use in Parse later on
  62170. * @returns the serialized JSON representation
  62171. */
  62172. serialize(): any;
  62173. }
  62174. }
  62175. declare module BABYLON {
  62176. /**
  62177. * Block used to add support for vertex skinning (bones)
  62178. */
  62179. export class BonesBlock extends NodeMaterialBlock {
  62180. /**
  62181. * Creates a new BonesBlock
  62182. * @param name defines the block name
  62183. */
  62184. constructor(name: string);
  62185. /**
  62186. * Initialize the block and prepare the context for build
  62187. * @param state defines the state that will be used for the build
  62188. */
  62189. initialize(state: NodeMaterialBuildState): void;
  62190. /**
  62191. * Gets the current class name
  62192. * @returns the class name
  62193. */
  62194. getClassName(): string;
  62195. /**
  62196. * Gets the matrix indices input component
  62197. */
  62198. get matricesIndices(): NodeMaterialConnectionPoint;
  62199. /**
  62200. * Gets the matrix weights input component
  62201. */
  62202. get matricesWeights(): NodeMaterialConnectionPoint;
  62203. /**
  62204. * Gets the extra matrix indices input component
  62205. */
  62206. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62207. /**
  62208. * Gets the extra matrix weights input component
  62209. */
  62210. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62211. /**
  62212. * Gets the world input component
  62213. */
  62214. get world(): NodeMaterialConnectionPoint;
  62215. /**
  62216. * Gets the output component
  62217. */
  62218. get output(): NodeMaterialConnectionPoint;
  62219. autoConfigure(material: NodeMaterial): void;
  62220. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62221. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62222. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62223. protected _buildBlock(state: NodeMaterialBuildState): this;
  62224. }
  62225. }
  62226. declare module BABYLON {
  62227. /**
  62228. * Block used to add support for instances
  62229. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62230. */
  62231. export class InstancesBlock extends NodeMaterialBlock {
  62232. /**
  62233. * Creates a new InstancesBlock
  62234. * @param name defines the block name
  62235. */
  62236. constructor(name: string);
  62237. /**
  62238. * Gets the current class name
  62239. * @returns the class name
  62240. */
  62241. getClassName(): string;
  62242. /**
  62243. * Gets the first world row input component
  62244. */
  62245. get world0(): NodeMaterialConnectionPoint;
  62246. /**
  62247. * Gets the second world row input component
  62248. */
  62249. get world1(): NodeMaterialConnectionPoint;
  62250. /**
  62251. * Gets the third world row input component
  62252. */
  62253. get world2(): NodeMaterialConnectionPoint;
  62254. /**
  62255. * Gets the forth world row input component
  62256. */
  62257. get world3(): NodeMaterialConnectionPoint;
  62258. /**
  62259. * Gets the world input component
  62260. */
  62261. get world(): NodeMaterialConnectionPoint;
  62262. /**
  62263. * Gets the output component
  62264. */
  62265. get output(): NodeMaterialConnectionPoint;
  62266. /**
  62267. * Gets the isntanceID component
  62268. */
  62269. get instanceID(): NodeMaterialConnectionPoint;
  62270. autoConfigure(material: NodeMaterial): void;
  62271. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62272. protected _buildBlock(state: NodeMaterialBuildState): this;
  62273. }
  62274. }
  62275. declare module BABYLON {
  62276. /**
  62277. * Block used to add morph targets support to vertex shader
  62278. */
  62279. export class MorphTargetsBlock extends NodeMaterialBlock {
  62280. private _repeatableContentAnchor;
  62281. /**
  62282. * Create a new MorphTargetsBlock
  62283. * @param name defines the block name
  62284. */
  62285. constructor(name: string);
  62286. /**
  62287. * Gets the current class name
  62288. * @returns the class name
  62289. */
  62290. getClassName(): string;
  62291. /**
  62292. * Gets the position input component
  62293. */
  62294. get position(): NodeMaterialConnectionPoint;
  62295. /**
  62296. * Gets the normal input component
  62297. */
  62298. get normal(): NodeMaterialConnectionPoint;
  62299. /**
  62300. * Gets the tangent input component
  62301. */
  62302. get tangent(): NodeMaterialConnectionPoint;
  62303. /**
  62304. * Gets the tangent input component
  62305. */
  62306. get uv(): NodeMaterialConnectionPoint;
  62307. /**
  62308. * Gets the position output component
  62309. */
  62310. get positionOutput(): NodeMaterialConnectionPoint;
  62311. /**
  62312. * Gets the normal output component
  62313. */
  62314. get normalOutput(): NodeMaterialConnectionPoint;
  62315. /**
  62316. * Gets the tangent output component
  62317. */
  62318. get tangentOutput(): NodeMaterialConnectionPoint;
  62319. /**
  62320. * Gets the tangent output component
  62321. */
  62322. get uvOutput(): NodeMaterialConnectionPoint;
  62323. initialize(state: NodeMaterialBuildState): void;
  62324. autoConfigure(material: NodeMaterial): void;
  62325. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62326. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62327. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62328. protected _buildBlock(state: NodeMaterialBuildState): this;
  62329. }
  62330. }
  62331. declare module BABYLON {
  62332. /**
  62333. * Block used to get data information from a light
  62334. */
  62335. export class LightInformationBlock extends NodeMaterialBlock {
  62336. private _lightDataUniformName;
  62337. private _lightColorUniformName;
  62338. private _lightTypeDefineName;
  62339. /**
  62340. * Gets or sets the light associated with this block
  62341. */
  62342. light: Nullable<Light>;
  62343. /**
  62344. * Creates a new LightInformationBlock
  62345. * @param name defines the block name
  62346. */
  62347. constructor(name: string);
  62348. /**
  62349. * Gets the current class name
  62350. * @returns the class name
  62351. */
  62352. getClassName(): string;
  62353. /**
  62354. * Gets the world position input component
  62355. */
  62356. get worldPosition(): NodeMaterialConnectionPoint;
  62357. /**
  62358. * Gets the direction output component
  62359. */
  62360. get direction(): NodeMaterialConnectionPoint;
  62361. /**
  62362. * Gets the direction output component
  62363. */
  62364. get color(): NodeMaterialConnectionPoint;
  62365. /**
  62366. * Gets the direction output component
  62367. */
  62368. get intensity(): NodeMaterialConnectionPoint;
  62369. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62370. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62371. protected _buildBlock(state: NodeMaterialBuildState): this;
  62372. serialize(): any;
  62373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62374. }
  62375. }
  62376. declare module BABYLON {
  62377. /**
  62378. * Block used to add image processing support to fragment shader
  62379. */
  62380. export class ImageProcessingBlock extends NodeMaterialBlock {
  62381. /**
  62382. * Create a new ImageProcessingBlock
  62383. * @param name defines the block name
  62384. */
  62385. constructor(name: string);
  62386. /**
  62387. * Gets the current class name
  62388. * @returns the class name
  62389. */
  62390. getClassName(): string;
  62391. /**
  62392. * Gets the color input component
  62393. */
  62394. get color(): NodeMaterialConnectionPoint;
  62395. /**
  62396. * Gets the output component
  62397. */
  62398. get output(): NodeMaterialConnectionPoint;
  62399. /**
  62400. * Initialize the block and prepare the context for build
  62401. * @param state defines the state that will be used for the build
  62402. */
  62403. initialize(state: NodeMaterialBuildState): void;
  62404. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62405. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62406. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62407. protected _buildBlock(state: NodeMaterialBuildState): this;
  62408. }
  62409. }
  62410. declare module BABYLON {
  62411. /**
  62412. * Block used to pertub normals based on a normal map
  62413. */
  62414. export class PerturbNormalBlock extends NodeMaterialBlock {
  62415. private _tangentSpaceParameterName;
  62416. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62417. invertX: boolean;
  62418. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62419. invertY: boolean;
  62420. /**
  62421. * Create a new PerturbNormalBlock
  62422. * @param name defines the block name
  62423. */
  62424. constructor(name: string);
  62425. /**
  62426. * Gets the current class name
  62427. * @returns the class name
  62428. */
  62429. getClassName(): string;
  62430. /**
  62431. * Gets the world position input component
  62432. */
  62433. get worldPosition(): NodeMaterialConnectionPoint;
  62434. /**
  62435. * Gets the world normal input component
  62436. */
  62437. get worldNormal(): NodeMaterialConnectionPoint;
  62438. /**
  62439. * Gets the world tangent input component
  62440. */
  62441. get worldTangent(): NodeMaterialConnectionPoint;
  62442. /**
  62443. * Gets the uv input component
  62444. */
  62445. get uv(): NodeMaterialConnectionPoint;
  62446. /**
  62447. * Gets the normal map color input component
  62448. */
  62449. get normalMapColor(): NodeMaterialConnectionPoint;
  62450. /**
  62451. * Gets the strength input component
  62452. */
  62453. get strength(): NodeMaterialConnectionPoint;
  62454. /**
  62455. * Gets the output component
  62456. */
  62457. get output(): NodeMaterialConnectionPoint;
  62458. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62459. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62460. autoConfigure(material: NodeMaterial): void;
  62461. protected _buildBlock(state: NodeMaterialBuildState): this;
  62462. protected _dumpPropertiesCode(): string;
  62463. serialize(): any;
  62464. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62465. }
  62466. }
  62467. declare module BABYLON {
  62468. /**
  62469. * Block used to discard a pixel if a value is smaller than a cutoff
  62470. */
  62471. export class DiscardBlock extends NodeMaterialBlock {
  62472. /**
  62473. * Create a new DiscardBlock
  62474. * @param name defines the block name
  62475. */
  62476. constructor(name: string);
  62477. /**
  62478. * Gets the current class name
  62479. * @returns the class name
  62480. */
  62481. getClassName(): string;
  62482. /**
  62483. * Gets the color input component
  62484. */
  62485. get value(): NodeMaterialConnectionPoint;
  62486. /**
  62487. * Gets the cutoff input component
  62488. */
  62489. get cutoff(): NodeMaterialConnectionPoint;
  62490. protected _buildBlock(state: NodeMaterialBuildState): this;
  62491. }
  62492. }
  62493. declare module BABYLON {
  62494. /**
  62495. * Block used to test if the fragment shader is front facing
  62496. */
  62497. export class FrontFacingBlock extends NodeMaterialBlock {
  62498. /**
  62499. * Creates a new FrontFacingBlock
  62500. * @param name defines the block name
  62501. */
  62502. constructor(name: string);
  62503. /**
  62504. * Gets the current class name
  62505. * @returns the class name
  62506. */
  62507. getClassName(): string;
  62508. /**
  62509. * Gets the output component
  62510. */
  62511. get output(): NodeMaterialConnectionPoint;
  62512. protected _buildBlock(state: NodeMaterialBuildState): this;
  62513. }
  62514. }
  62515. declare module BABYLON {
  62516. /**
  62517. * Block used to get the derivative value on x and y of a given input
  62518. */
  62519. export class DerivativeBlock extends NodeMaterialBlock {
  62520. /**
  62521. * Create a new DerivativeBlock
  62522. * @param name defines the block name
  62523. */
  62524. constructor(name: string);
  62525. /**
  62526. * Gets the current class name
  62527. * @returns the class name
  62528. */
  62529. getClassName(): string;
  62530. /**
  62531. * Gets the input component
  62532. */
  62533. get input(): NodeMaterialConnectionPoint;
  62534. /**
  62535. * Gets the derivative output on x
  62536. */
  62537. get dx(): NodeMaterialConnectionPoint;
  62538. /**
  62539. * Gets the derivative output on y
  62540. */
  62541. get dy(): NodeMaterialConnectionPoint;
  62542. protected _buildBlock(state: NodeMaterialBuildState): this;
  62543. }
  62544. }
  62545. declare module BABYLON {
  62546. /**
  62547. * Block used to make gl_FragCoord available
  62548. */
  62549. export class FragCoordBlock extends NodeMaterialBlock {
  62550. /**
  62551. * Creates a new FragCoordBlock
  62552. * @param name defines the block name
  62553. */
  62554. constructor(name: string);
  62555. /**
  62556. * Gets the current class name
  62557. * @returns the class name
  62558. */
  62559. getClassName(): string;
  62560. /**
  62561. * Gets the xy component
  62562. */
  62563. get xy(): NodeMaterialConnectionPoint;
  62564. /**
  62565. * Gets the xyz component
  62566. */
  62567. get xyz(): NodeMaterialConnectionPoint;
  62568. /**
  62569. * Gets the xyzw component
  62570. */
  62571. get xyzw(): NodeMaterialConnectionPoint;
  62572. /**
  62573. * Gets the x component
  62574. */
  62575. get x(): NodeMaterialConnectionPoint;
  62576. /**
  62577. * Gets the y component
  62578. */
  62579. get y(): NodeMaterialConnectionPoint;
  62580. /**
  62581. * Gets the z component
  62582. */
  62583. get z(): NodeMaterialConnectionPoint;
  62584. /**
  62585. * Gets the w component
  62586. */
  62587. get output(): NodeMaterialConnectionPoint;
  62588. protected writeOutputs(state: NodeMaterialBuildState): string;
  62589. protected _buildBlock(state: NodeMaterialBuildState): this;
  62590. }
  62591. }
  62592. declare module BABYLON {
  62593. /**
  62594. * Block used to get the screen sizes
  62595. */
  62596. export class ScreenSizeBlock extends NodeMaterialBlock {
  62597. private _varName;
  62598. private _scene;
  62599. /**
  62600. * Creates a new ScreenSizeBlock
  62601. * @param name defines the block name
  62602. */
  62603. constructor(name: string);
  62604. /**
  62605. * Gets the current class name
  62606. * @returns the class name
  62607. */
  62608. getClassName(): string;
  62609. /**
  62610. * Gets the xy component
  62611. */
  62612. get xy(): NodeMaterialConnectionPoint;
  62613. /**
  62614. * Gets the x component
  62615. */
  62616. get x(): NodeMaterialConnectionPoint;
  62617. /**
  62618. * Gets the y component
  62619. */
  62620. get y(): NodeMaterialConnectionPoint;
  62621. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62622. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62623. protected _buildBlock(state: NodeMaterialBuildState): this;
  62624. }
  62625. }
  62626. declare module BABYLON {
  62627. /**
  62628. * Block used to add support for scene fog
  62629. */
  62630. export class FogBlock extends NodeMaterialBlock {
  62631. private _fogDistanceName;
  62632. private _fogParameters;
  62633. /**
  62634. * Create a new FogBlock
  62635. * @param name defines the block name
  62636. */
  62637. constructor(name: string);
  62638. /**
  62639. * Gets the current class name
  62640. * @returns the class name
  62641. */
  62642. getClassName(): string;
  62643. /**
  62644. * Gets the world position input component
  62645. */
  62646. get worldPosition(): NodeMaterialConnectionPoint;
  62647. /**
  62648. * Gets the view input component
  62649. */
  62650. get view(): NodeMaterialConnectionPoint;
  62651. /**
  62652. * Gets the color input component
  62653. */
  62654. get input(): NodeMaterialConnectionPoint;
  62655. /**
  62656. * Gets the fog color input component
  62657. */
  62658. get fogColor(): NodeMaterialConnectionPoint;
  62659. /**
  62660. * Gets the output component
  62661. */
  62662. get output(): NodeMaterialConnectionPoint;
  62663. autoConfigure(material: NodeMaterial): void;
  62664. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62665. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62666. protected _buildBlock(state: NodeMaterialBuildState): this;
  62667. }
  62668. }
  62669. declare module BABYLON {
  62670. /**
  62671. * Block used to add light in the fragment shader
  62672. */
  62673. export class LightBlock extends NodeMaterialBlock {
  62674. private _lightId;
  62675. /**
  62676. * Gets or sets the light associated with this block
  62677. */
  62678. light: Nullable<Light>;
  62679. /**
  62680. * Create a new LightBlock
  62681. * @param name defines the block name
  62682. */
  62683. constructor(name: string);
  62684. /**
  62685. * Gets the current class name
  62686. * @returns the class name
  62687. */
  62688. getClassName(): string;
  62689. /**
  62690. * Gets the world position input component
  62691. */
  62692. get worldPosition(): NodeMaterialConnectionPoint;
  62693. /**
  62694. * Gets the world normal input component
  62695. */
  62696. get worldNormal(): NodeMaterialConnectionPoint;
  62697. /**
  62698. * Gets the camera (or eye) position component
  62699. */
  62700. get cameraPosition(): NodeMaterialConnectionPoint;
  62701. /**
  62702. * Gets the glossiness component
  62703. */
  62704. get glossiness(): NodeMaterialConnectionPoint;
  62705. /**
  62706. * Gets the glossinness power component
  62707. */
  62708. get glossPower(): NodeMaterialConnectionPoint;
  62709. /**
  62710. * Gets the diffuse color component
  62711. */
  62712. get diffuseColor(): NodeMaterialConnectionPoint;
  62713. /**
  62714. * Gets the specular color component
  62715. */
  62716. get specularColor(): NodeMaterialConnectionPoint;
  62717. /**
  62718. * Gets the diffuse output component
  62719. */
  62720. get diffuseOutput(): NodeMaterialConnectionPoint;
  62721. /**
  62722. * Gets the specular output component
  62723. */
  62724. get specularOutput(): NodeMaterialConnectionPoint;
  62725. /**
  62726. * Gets the shadow output component
  62727. */
  62728. get shadow(): NodeMaterialConnectionPoint;
  62729. autoConfigure(material: NodeMaterial): void;
  62730. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62731. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62732. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62733. private _injectVertexCode;
  62734. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62735. serialize(): any;
  62736. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62737. }
  62738. }
  62739. declare module BABYLON {
  62740. /**
  62741. * Block used to read a reflection texture from a sampler
  62742. */
  62743. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62744. /**
  62745. * Create a new ReflectionTextureBlock
  62746. * @param name defines the block name
  62747. */
  62748. constructor(name: string);
  62749. /**
  62750. * Gets the current class name
  62751. * @returns the class name
  62752. */
  62753. getClassName(): string;
  62754. /**
  62755. * Gets the world position input component
  62756. */
  62757. get position(): NodeMaterialConnectionPoint;
  62758. /**
  62759. * Gets the world position input component
  62760. */
  62761. get worldPosition(): NodeMaterialConnectionPoint;
  62762. /**
  62763. * Gets the world normal input component
  62764. */
  62765. get worldNormal(): NodeMaterialConnectionPoint;
  62766. /**
  62767. * Gets the world input component
  62768. */
  62769. get world(): NodeMaterialConnectionPoint;
  62770. /**
  62771. * Gets the camera (or eye) position component
  62772. */
  62773. get cameraPosition(): NodeMaterialConnectionPoint;
  62774. /**
  62775. * Gets the view input component
  62776. */
  62777. get view(): NodeMaterialConnectionPoint;
  62778. /**
  62779. * Gets the rgb output component
  62780. */
  62781. get rgb(): NodeMaterialConnectionPoint;
  62782. /**
  62783. * Gets the rgba output component
  62784. */
  62785. get rgba(): NodeMaterialConnectionPoint;
  62786. /**
  62787. * Gets the r output component
  62788. */
  62789. get r(): NodeMaterialConnectionPoint;
  62790. /**
  62791. * Gets the g output component
  62792. */
  62793. get g(): NodeMaterialConnectionPoint;
  62794. /**
  62795. * Gets the b output component
  62796. */
  62797. get b(): NodeMaterialConnectionPoint;
  62798. /**
  62799. * Gets the a output component
  62800. */
  62801. get a(): NodeMaterialConnectionPoint;
  62802. autoConfigure(material: NodeMaterial): void;
  62803. protected _buildBlock(state: NodeMaterialBuildState): this;
  62804. }
  62805. }
  62806. declare module BABYLON {
  62807. /**
  62808. * Block used to add 2 vectors
  62809. */
  62810. export class AddBlock extends NodeMaterialBlock {
  62811. /**
  62812. * Creates a new AddBlock
  62813. * @param name defines the block name
  62814. */
  62815. constructor(name: string);
  62816. /**
  62817. * Gets the current class name
  62818. * @returns the class name
  62819. */
  62820. getClassName(): string;
  62821. /**
  62822. * Gets the left operand input component
  62823. */
  62824. get left(): NodeMaterialConnectionPoint;
  62825. /**
  62826. * Gets the right operand input component
  62827. */
  62828. get right(): NodeMaterialConnectionPoint;
  62829. /**
  62830. * Gets the output component
  62831. */
  62832. get output(): NodeMaterialConnectionPoint;
  62833. protected _buildBlock(state: NodeMaterialBuildState): this;
  62834. }
  62835. }
  62836. declare module BABYLON {
  62837. /**
  62838. * Block used to scale a vector by a float
  62839. */
  62840. export class ScaleBlock extends NodeMaterialBlock {
  62841. /**
  62842. * Creates a new ScaleBlock
  62843. * @param name defines the block name
  62844. */
  62845. constructor(name: string);
  62846. /**
  62847. * Gets the current class name
  62848. * @returns the class name
  62849. */
  62850. getClassName(): string;
  62851. /**
  62852. * Gets the input component
  62853. */
  62854. get input(): NodeMaterialConnectionPoint;
  62855. /**
  62856. * Gets the factor input component
  62857. */
  62858. get factor(): NodeMaterialConnectionPoint;
  62859. /**
  62860. * Gets the output component
  62861. */
  62862. get output(): NodeMaterialConnectionPoint;
  62863. protected _buildBlock(state: NodeMaterialBuildState): this;
  62864. }
  62865. }
  62866. declare module BABYLON {
  62867. /**
  62868. * Block used to clamp a float
  62869. */
  62870. export class ClampBlock extends NodeMaterialBlock {
  62871. /** Gets or sets the minimum range */
  62872. minimum: number;
  62873. /** Gets or sets the maximum range */
  62874. maximum: number;
  62875. /**
  62876. * Creates a new ClampBlock
  62877. * @param name defines the block name
  62878. */
  62879. constructor(name: string);
  62880. /**
  62881. * Gets the current class name
  62882. * @returns the class name
  62883. */
  62884. getClassName(): string;
  62885. /**
  62886. * Gets the value input component
  62887. */
  62888. get value(): NodeMaterialConnectionPoint;
  62889. /**
  62890. * Gets the output component
  62891. */
  62892. get output(): NodeMaterialConnectionPoint;
  62893. protected _buildBlock(state: NodeMaterialBuildState): this;
  62894. protected _dumpPropertiesCode(): string;
  62895. serialize(): any;
  62896. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62897. }
  62898. }
  62899. declare module BABYLON {
  62900. /**
  62901. * Block used to apply a cross product between 2 vectors
  62902. */
  62903. export class CrossBlock extends NodeMaterialBlock {
  62904. /**
  62905. * Creates a new CrossBlock
  62906. * @param name defines the block name
  62907. */
  62908. constructor(name: string);
  62909. /**
  62910. * Gets the current class name
  62911. * @returns the class name
  62912. */
  62913. getClassName(): string;
  62914. /**
  62915. * Gets the left operand input component
  62916. */
  62917. get left(): NodeMaterialConnectionPoint;
  62918. /**
  62919. * Gets the right operand input component
  62920. */
  62921. get right(): NodeMaterialConnectionPoint;
  62922. /**
  62923. * Gets the output component
  62924. */
  62925. get output(): NodeMaterialConnectionPoint;
  62926. protected _buildBlock(state: NodeMaterialBuildState): this;
  62927. }
  62928. }
  62929. declare module BABYLON {
  62930. /**
  62931. * Block used to apply a dot product between 2 vectors
  62932. */
  62933. export class DotBlock extends NodeMaterialBlock {
  62934. /**
  62935. * Creates a new DotBlock
  62936. * @param name defines the block name
  62937. */
  62938. constructor(name: string);
  62939. /**
  62940. * Gets the current class name
  62941. * @returns the class name
  62942. */
  62943. getClassName(): string;
  62944. /**
  62945. * Gets the left operand input component
  62946. */
  62947. get left(): NodeMaterialConnectionPoint;
  62948. /**
  62949. * Gets the right operand input component
  62950. */
  62951. get right(): NodeMaterialConnectionPoint;
  62952. /**
  62953. * Gets the output component
  62954. */
  62955. get output(): NodeMaterialConnectionPoint;
  62956. protected _buildBlock(state: NodeMaterialBuildState): this;
  62957. }
  62958. }
  62959. declare module BABYLON {
  62960. /**
  62961. * Block used to normalize a vector
  62962. */
  62963. export class NormalizeBlock extends NodeMaterialBlock {
  62964. /**
  62965. * Creates a new NormalizeBlock
  62966. * @param name defines the block name
  62967. */
  62968. constructor(name: string);
  62969. /**
  62970. * Gets the current class name
  62971. * @returns the class name
  62972. */
  62973. getClassName(): string;
  62974. /**
  62975. * Gets the input component
  62976. */
  62977. get input(): NodeMaterialConnectionPoint;
  62978. /**
  62979. * Gets the output component
  62980. */
  62981. get output(): NodeMaterialConnectionPoint;
  62982. protected _buildBlock(state: NodeMaterialBuildState): this;
  62983. }
  62984. }
  62985. declare module BABYLON {
  62986. /**
  62987. * Operations supported by the Trigonometry block
  62988. */
  62989. export enum TrigonometryBlockOperations {
  62990. /** Cos */
  62991. Cos = 0,
  62992. /** Sin */
  62993. Sin = 1,
  62994. /** Abs */
  62995. Abs = 2,
  62996. /** Exp */
  62997. Exp = 3,
  62998. /** Exp2 */
  62999. Exp2 = 4,
  63000. /** Round */
  63001. Round = 5,
  63002. /** Floor */
  63003. Floor = 6,
  63004. /** Ceiling */
  63005. Ceiling = 7,
  63006. /** Square root */
  63007. Sqrt = 8,
  63008. /** Log */
  63009. Log = 9,
  63010. /** Tangent */
  63011. Tan = 10,
  63012. /** Arc tangent */
  63013. ArcTan = 11,
  63014. /** Arc cosinus */
  63015. ArcCos = 12,
  63016. /** Arc sinus */
  63017. ArcSin = 13,
  63018. /** Fraction */
  63019. Fract = 14,
  63020. /** Sign */
  63021. Sign = 15,
  63022. /** To radians (from degrees) */
  63023. Radians = 16,
  63024. /** To degrees (from radians) */
  63025. Degrees = 17
  63026. }
  63027. /**
  63028. * Block used to apply trigonometry operation to floats
  63029. */
  63030. export class TrigonometryBlock extends NodeMaterialBlock {
  63031. /**
  63032. * Gets or sets the operation applied by the block
  63033. */
  63034. operation: TrigonometryBlockOperations;
  63035. /**
  63036. * Creates a new TrigonometryBlock
  63037. * @param name defines the block name
  63038. */
  63039. constructor(name: string);
  63040. /**
  63041. * Gets the current class name
  63042. * @returns the class name
  63043. */
  63044. getClassName(): string;
  63045. /**
  63046. * Gets the input component
  63047. */
  63048. get input(): NodeMaterialConnectionPoint;
  63049. /**
  63050. * Gets the output component
  63051. */
  63052. get output(): NodeMaterialConnectionPoint;
  63053. protected _buildBlock(state: NodeMaterialBuildState): this;
  63054. serialize(): any;
  63055. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63056. protected _dumpPropertiesCode(): string;
  63057. }
  63058. }
  63059. declare module BABYLON {
  63060. /**
  63061. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63062. */
  63063. export class ColorMergerBlock extends NodeMaterialBlock {
  63064. /**
  63065. * Create a new ColorMergerBlock
  63066. * @param name defines the block name
  63067. */
  63068. constructor(name: string);
  63069. /**
  63070. * Gets the current class name
  63071. * @returns the class name
  63072. */
  63073. getClassName(): string;
  63074. /**
  63075. * Gets the rgb component (input)
  63076. */
  63077. get rgbIn(): NodeMaterialConnectionPoint;
  63078. /**
  63079. * Gets the r component (input)
  63080. */
  63081. get r(): NodeMaterialConnectionPoint;
  63082. /**
  63083. * Gets the g component (input)
  63084. */
  63085. get g(): NodeMaterialConnectionPoint;
  63086. /**
  63087. * Gets the b component (input)
  63088. */
  63089. get b(): NodeMaterialConnectionPoint;
  63090. /**
  63091. * Gets the a component (input)
  63092. */
  63093. get a(): NodeMaterialConnectionPoint;
  63094. /**
  63095. * Gets the rgba component (output)
  63096. */
  63097. get rgba(): NodeMaterialConnectionPoint;
  63098. /**
  63099. * Gets the rgb component (output)
  63100. */
  63101. get rgbOut(): NodeMaterialConnectionPoint;
  63102. /**
  63103. * Gets the rgb component (output)
  63104. * @deprecated Please use rgbOut instead.
  63105. */
  63106. get rgb(): NodeMaterialConnectionPoint;
  63107. protected _buildBlock(state: NodeMaterialBuildState): this;
  63108. }
  63109. }
  63110. declare module BABYLON {
  63111. /**
  63112. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63113. */
  63114. export class VectorSplitterBlock extends NodeMaterialBlock {
  63115. /**
  63116. * Create a new VectorSplitterBlock
  63117. * @param name defines the block name
  63118. */
  63119. constructor(name: string);
  63120. /**
  63121. * Gets the current class name
  63122. * @returns the class name
  63123. */
  63124. getClassName(): string;
  63125. /**
  63126. * Gets the xyzw component (input)
  63127. */
  63128. get xyzw(): NodeMaterialConnectionPoint;
  63129. /**
  63130. * Gets the xyz component (input)
  63131. */
  63132. get xyzIn(): NodeMaterialConnectionPoint;
  63133. /**
  63134. * Gets the xy component (input)
  63135. */
  63136. get xyIn(): NodeMaterialConnectionPoint;
  63137. /**
  63138. * Gets the xyz component (output)
  63139. */
  63140. get xyzOut(): NodeMaterialConnectionPoint;
  63141. /**
  63142. * Gets the xy component (output)
  63143. */
  63144. get xyOut(): NodeMaterialConnectionPoint;
  63145. /**
  63146. * Gets the x component (output)
  63147. */
  63148. get x(): NodeMaterialConnectionPoint;
  63149. /**
  63150. * Gets the y component (output)
  63151. */
  63152. get y(): NodeMaterialConnectionPoint;
  63153. /**
  63154. * Gets the z component (output)
  63155. */
  63156. get z(): NodeMaterialConnectionPoint;
  63157. /**
  63158. * Gets the w component (output)
  63159. */
  63160. get w(): NodeMaterialConnectionPoint;
  63161. protected _inputRename(name: string): string;
  63162. protected _outputRename(name: string): string;
  63163. protected _buildBlock(state: NodeMaterialBuildState): this;
  63164. }
  63165. }
  63166. declare module BABYLON {
  63167. /**
  63168. * Block used to lerp between 2 values
  63169. */
  63170. export class LerpBlock extends NodeMaterialBlock {
  63171. /**
  63172. * Creates a new LerpBlock
  63173. * @param name defines the block name
  63174. */
  63175. constructor(name: string);
  63176. /**
  63177. * Gets the current class name
  63178. * @returns the class name
  63179. */
  63180. getClassName(): string;
  63181. /**
  63182. * Gets the left operand input component
  63183. */
  63184. get left(): NodeMaterialConnectionPoint;
  63185. /**
  63186. * Gets the right operand input component
  63187. */
  63188. get right(): NodeMaterialConnectionPoint;
  63189. /**
  63190. * Gets the gradient operand input component
  63191. */
  63192. get gradient(): NodeMaterialConnectionPoint;
  63193. /**
  63194. * Gets the output component
  63195. */
  63196. get output(): NodeMaterialConnectionPoint;
  63197. protected _buildBlock(state: NodeMaterialBuildState): this;
  63198. }
  63199. }
  63200. declare module BABYLON {
  63201. /**
  63202. * Block used to divide 2 vectors
  63203. */
  63204. export class DivideBlock extends NodeMaterialBlock {
  63205. /**
  63206. * Creates a new DivideBlock
  63207. * @param name defines the block name
  63208. */
  63209. constructor(name: string);
  63210. /**
  63211. * Gets the current class name
  63212. * @returns the class name
  63213. */
  63214. getClassName(): string;
  63215. /**
  63216. * Gets the left operand input component
  63217. */
  63218. get left(): NodeMaterialConnectionPoint;
  63219. /**
  63220. * Gets the right operand input component
  63221. */
  63222. get right(): NodeMaterialConnectionPoint;
  63223. /**
  63224. * Gets the output component
  63225. */
  63226. get output(): NodeMaterialConnectionPoint;
  63227. protected _buildBlock(state: NodeMaterialBuildState): this;
  63228. }
  63229. }
  63230. declare module BABYLON {
  63231. /**
  63232. * Block used to subtract 2 vectors
  63233. */
  63234. export class SubtractBlock extends NodeMaterialBlock {
  63235. /**
  63236. * Creates a new SubtractBlock
  63237. * @param name defines the block name
  63238. */
  63239. constructor(name: string);
  63240. /**
  63241. * Gets the current class name
  63242. * @returns the class name
  63243. */
  63244. getClassName(): string;
  63245. /**
  63246. * Gets the left operand input component
  63247. */
  63248. get left(): NodeMaterialConnectionPoint;
  63249. /**
  63250. * Gets the right operand input component
  63251. */
  63252. get right(): NodeMaterialConnectionPoint;
  63253. /**
  63254. * Gets the output component
  63255. */
  63256. get output(): NodeMaterialConnectionPoint;
  63257. protected _buildBlock(state: NodeMaterialBuildState): this;
  63258. }
  63259. }
  63260. declare module BABYLON {
  63261. /**
  63262. * Block used to step a value
  63263. */
  63264. export class StepBlock extends NodeMaterialBlock {
  63265. /**
  63266. * Creates a new StepBlock
  63267. * @param name defines the block name
  63268. */
  63269. constructor(name: string);
  63270. /**
  63271. * Gets the current class name
  63272. * @returns the class name
  63273. */
  63274. getClassName(): string;
  63275. /**
  63276. * Gets the value operand input component
  63277. */
  63278. get value(): NodeMaterialConnectionPoint;
  63279. /**
  63280. * Gets the edge operand input component
  63281. */
  63282. get edge(): NodeMaterialConnectionPoint;
  63283. /**
  63284. * Gets the output component
  63285. */
  63286. get output(): NodeMaterialConnectionPoint;
  63287. protected _buildBlock(state: NodeMaterialBuildState): this;
  63288. }
  63289. }
  63290. declare module BABYLON {
  63291. /**
  63292. * Block used to get the opposite (1 - x) of a value
  63293. */
  63294. export class OneMinusBlock extends NodeMaterialBlock {
  63295. /**
  63296. * Creates a new OneMinusBlock
  63297. * @param name defines the block name
  63298. */
  63299. constructor(name: string);
  63300. /**
  63301. * Gets the current class name
  63302. * @returns the class name
  63303. */
  63304. getClassName(): string;
  63305. /**
  63306. * Gets the input component
  63307. */
  63308. get input(): NodeMaterialConnectionPoint;
  63309. /**
  63310. * Gets the output component
  63311. */
  63312. get output(): NodeMaterialConnectionPoint;
  63313. protected _buildBlock(state: NodeMaterialBuildState): this;
  63314. }
  63315. }
  63316. declare module BABYLON {
  63317. /**
  63318. * Block used to get the view direction
  63319. */
  63320. export class ViewDirectionBlock extends NodeMaterialBlock {
  63321. /**
  63322. * Creates a new ViewDirectionBlock
  63323. * @param name defines the block name
  63324. */
  63325. constructor(name: string);
  63326. /**
  63327. * Gets the current class name
  63328. * @returns the class name
  63329. */
  63330. getClassName(): string;
  63331. /**
  63332. * Gets the world position component
  63333. */
  63334. get worldPosition(): NodeMaterialConnectionPoint;
  63335. /**
  63336. * Gets the camera position component
  63337. */
  63338. get cameraPosition(): NodeMaterialConnectionPoint;
  63339. /**
  63340. * Gets the output component
  63341. */
  63342. get output(): NodeMaterialConnectionPoint;
  63343. autoConfigure(material: NodeMaterial): void;
  63344. protected _buildBlock(state: NodeMaterialBuildState): this;
  63345. }
  63346. }
  63347. declare module BABYLON {
  63348. /**
  63349. * Block used to compute fresnel value
  63350. */
  63351. export class FresnelBlock extends NodeMaterialBlock {
  63352. /**
  63353. * Create a new FresnelBlock
  63354. * @param name defines the block name
  63355. */
  63356. constructor(name: string);
  63357. /**
  63358. * Gets the current class name
  63359. * @returns the class name
  63360. */
  63361. getClassName(): string;
  63362. /**
  63363. * Gets the world normal input component
  63364. */
  63365. get worldNormal(): NodeMaterialConnectionPoint;
  63366. /**
  63367. * Gets the view direction input component
  63368. */
  63369. get viewDirection(): NodeMaterialConnectionPoint;
  63370. /**
  63371. * Gets the bias input component
  63372. */
  63373. get bias(): NodeMaterialConnectionPoint;
  63374. /**
  63375. * Gets the camera (or eye) position component
  63376. */
  63377. get power(): NodeMaterialConnectionPoint;
  63378. /**
  63379. * Gets the fresnel output component
  63380. */
  63381. get fresnel(): NodeMaterialConnectionPoint;
  63382. autoConfigure(material: NodeMaterial): void;
  63383. protected _buildBlock(state: NodeMaterialBuildState): this;
  63384. }
  63385. }
  63386. declare module BABYLON {
  63387. /**
  63388. * Block used to get the max of 2 values
  63389. */
  63390. export class MaxBlock extends NodeMaterialBlock {
  63391. /**
  63392. * Creates a new MaxBlock
  63393. * @param name defines the block name
  63394. */
  63395. constructor(name: string);
  63396. /**
  63397. * Gets the current class name
  63398. * @returns the class name
  63399. */
  63400. getClassName(): string;
  63401. /**
  63402. * Gets the left operand input component
  63403. */
  63404. get left(): NodeMaterialConnectionPoint;
  63405. /**
  63406. * Gets the right operand input component
  63407. */
  63408. get right(): NodeMaterialConnectionPoint;
  63409. /**
  63410. * Gets the output component
  63411. */
  63412. get output(): NodeMaterialConnectionPoint;
  63413. protected _buildBlock(state: NodeMaterialBuildState): this;
  63414. }
  63415. }
  63416. declare module BABYLON {
  63417. /**
  63418. * Block used to get the min of 2 values
  63419. */
  63420. export class MinBlock extends NodeMaterialBlock {
  63421. /**
  63422. * Creates a new MinBlock
  63423. * @param name defines the block name
  63424. */
  63425. constructor(name: string);
  63426. /**
  63427. * Gets the current class name
  63428. * @returns the class name
  63429. */
  63430. getClassName(): string;
  63431. /**
  63432. * Gets the left operand input component
  63433. */
  63434. get left(): NodeMaterialConnectionPoint;
  63435. /**
  63436. * Gets the right operand input component
  63437. */
  63438. get right(): NodeMaterialConnectionPoint;
  63439. /**
  63440. * Gets the output component
  63441. */
  63442. get output(): NodeMaterialConnectionPoint;
  63443. protected _buildBlock(state: NodeMaterialBuildState): this;
  63444. }
  63445. }
  63446. declare module BABYLON {
  63447. /**
  63448. * Block used to get the distance between 2 values
  63449. */
  63450. export class DistanceBlock extends NodeMaterialBlock {
  63451. /**
  63452. * Creates a new DistanceBlock
  63453. * @param name defines the block name
  63454. */
  63455. constructor(name: string);
  63456. /**
  63457. * Gets the current class name
  63458. * @returns the class name
  63459. */
  63460. getClassName(): string;
  63461. /**
  63462. * Gets the left operand input component
  63463. */
  63464. get left(): NodeMaterialConnectionPoint;
  63465. /**
  63466. * Gets the right operand input component
  63467. */
  63468. get right(): NodeMaterialConnectionPoint;
  63469. /**
  63470. * Gets the output component
  63471. */
  63472. get output(): NodeMaterialConnectionPoint;
  63473. protected _buildBlock(state: NodeMaterialBuildState): this;
  63474. }
  63475. }
  63476. declare module BABYLON {
  63477. /**
  63478. * Block used to get the length of a vector
  63479. */
  63480. export class LengthBlock extends NodeMaterialBlock {
  63481. /**
  63482. * Creates a new LengthBlock
  63483. * @param name defines the block name
  63484. */
  63485. constructor(name: string);
  63486. /**
  63487. * Gets the current class name
  63488. * @returns the class name
  63489. */
  63490. getClassName(): string;
  63491. /**
  63492. * Gets the value input component
  63493. */
  63494. get value(): NodeMaterialConnectionPoint;
  63495. /**
  63496. * Gets the output component
  63497. */
  63498. get output(): NodeMaterialConnectionPoint;
  63499. protected _buildBlock(state: NodeMaterialBuildState): this;
  63500. }
  63501. }
  63502. declare module BABYLON {
  63503. /**
  63504. * Block used to get negative version of a value (i.e. x * -1)
  63505. */
  63506. export class NegateBlock extends NodeMaterialBlock {
  63507. /**
  63508. * Creates a new NegateBlock
  63509. * @param name defines the block name
  63510. */
  63511. constructor(name: string);
  63512. /**
  63513. * Gets the current class name
  63514. * @returns the class name
  63515. */
  63516. getClassName(): string;
  63517. /**
  63518. * Gets the value input component
  63519. */
  63520. get value(): NodeMaterialConnectionPoint;
  63521. /**
  63522. * Gets the output component
  63523. */
  63524. get output(): NodeMaterialConnectionPoint;
  63525. protected _buildBlock(state: NodeMaterialBuildState): this;
  63526. }
  63527. }
  63528. declare module BABYLON {
  63529. /**
  63530. * Block used to get the value of the first parameter raised to the power of the second
  63531. */
  63532. export class PowBlock extends NodeMaterialBlock {
  63533. /**
  63534. * Creates a new PowBlock
  63535. * @param name defines the block name
  63536. */
  63537. constructor(name: string);
  63538. /**
  63539. * Gets the current class name
  63540. * @returns the class name
  63541. */
  63542. getClassName(): string;
  63543. /**
  63544. * Gets the value operand input component
  63545. */
  63546. get value(): NodeMaterialConnectionPoint;
  63547. /**
  63548. * Gets the power operand input component
  63549. */
  63550. get power(): NodeMaterialConnectionPoint;
  63551. /**
  63552. * Gets the output component
  63553. */
  63554. get output(): NodeMaterialConnectionPoint;
  63555. protected _buildBlock(state: NodeMaterialBuildState): this;
  63556. }
  63557. }
  63558. declare module BABYLON {
  63559. /**
  63560. * Block used to get a random number
  63561. */
  63562. export class RandomNumberBlock extends NodeMaterialBlock {
  63563. /**
  63564. * Creates a new RandomNumberBlock
  63565. * @param name defines the block name
  63566. */
  63567. constructor(name: string);
  63568. /**
  63569. * Gets the current class name
  63570. * @returns the class name
  63571. */
  63572. getClassName(): string;
  63573. /**
  63574. * Gets the seed input component
  63575. */
  63576. get seed(): NodeMaterialConnectionPoint;
  63577. /**
  63578. * Gets the output component
  63579. */
  63580. get output(): NodeMaterialConnectionPoint;
  63581. protected _buildBlock(state: NodeMaterialBuildState): this;
  63582. }
  63583. }
  63584. declare module BABYLON {
  63585. /**
  63586. * Block used to compute arc tangent of 2 values
  63587. */
  63588. export class ArcTan2Block extends NodeMaterialBlock {
  63589. /**
  63590. * Creates a new ArcTan2Block
  63591. * @param name defines the block name
  63592. */
  63593. constructor(name: string);
  63594. /**
  63595. * Gets the current class name
  63596. * @returns the class name
  63597. */
  63598. getClassName(): string;
  63599. /**
  63600. * Gets the x operand input component
  63601. */
  63602. get x(): NodeMaterialConnectionPoint;
  63603. /**
  63604. * Gets the y operand input component
  63605. */
  63606. get y(): NodeMaterialConnectionPoint;
  63607. /**
  63608. * Gets the output component
  63609. */
  63610. get output(): NodeMaterialConnectionPoint;
  63611. protected _buildBlock(state: NodeMaterialBuildState): this;
  63612. }
  63613. }
  63614. declare module BABYLON {
  63615. /**
  63616. * Block used to smooth step a value
  63617. */
  63618. export class SmoothStepBlock extends NodeMaterialBlock {
  63619. /**
  63620. * Creates a new SmoothStepBlock
  63621. * @param name defines the block name
  63622. */
  63623. constructor(name: string);
  63624. /**
  63625. * Gets the current class name
  63626. * @returns the class name
  63627. */
  63628. getClassName(): string;
  63629. /**
  63630. * Gets the value operand input component
  63631. */
  63632. get value(): NodeMaterialConnectionPoint;
  63633. /**
  63634. * Gets the first edge operand input component
  63635. */
  63636. get edge0(): NodeMaterialConnectionPoint;
  63637. /**
  63638. * Gets the second edge operand input component
  63639. */
  63640. get edge1(): NodeMaterialConnectionPoint;
  63641. /**
  63642. * Gets the output component
  63643. */
  63644. get output(): NodeMaterialConnectionPoint;
  63645. protected _buildBlock(state: NodeMaterialBuildState): this;
  63646. }
  63647. }
  63648. declare module BABYLON {
  63649. /**
  63650. * Block used to get the reciprocal (1 / x) of a value
  63651. */
  63652. export class ReciprocalBlock extends NodeMaterialBlock {
  63653. /**
  63654. * Creates a new ReciprocalBlock
  63655. * @param name defines the block name
  63656. */
  63657. constructor(name: string);
  63658. /**
  63659. * Gets the current class name
  63660. * @returns the class name
  63661. */
  63662. getClassName(): string;
  63663. /**
  63664. * Gets the input component
  63665. */
  63666. get input(): NodeMaterialConnectionPoint;
  63667. /**
  63668. * Gets the output component
  63669. */
  63670. get output(): NodeMaterialConnectionPoint;
  63671. protected _buildBlock(state: NodeMaterialBuildState): this;
  63672. }
  63673. }
  63674. declare module BABYLON {
  63675. /**
  63676. * Block used to replace a color by another one
  63677. */
  63678. export class ReplaceColorBlock extends NodeMaterialBlock {
  63679. /**
  63680. * Creates a new ReplaceColorBlock
  63681. * @param name defines the block name
  63682. */
  63683. constructor(name: string);
  63684. /**
  63685. * Gets the current class name
  63686. * @returns the class name
  63687. */
  63688. getClassName(): string;
  63689. /**
  63690. * Gets the value input component
  63691. */
  63692. get value(): NodeMaterialConnectionPoint;
  63693. /**
  63694. * Gets the reference input component
  63695. */
  63696. get reference(): NodeMaterialConnectionPoint;
  63697. /**
  63698. * Gets the distance input component
  63699. */
  63700. get distance(): NodeMaterialConnectionPoint;
  63701. /**
  63702. * Gets the replacement input component
  63703. */
  63704. get replacement(): NodeMaterialConnectionPoint;
  63705. /**
  63706. * Gets the output component
  63707. */
  63708. get output(): NodeMaterialConnectionPoint;
  63709. protected _buildBlock(state: NodeMaterialBuildState): this;
  63710. }
  63711. }
  63712. declare module BABYLON {
  63713. /**
  63714. * Block used to posterize a value
  63715. * @see https://en.wikipedia.org/wiki/Posterization
  63716. */
  63717. export class PosterizeBlock extends NodeMaterialBlock {
  63718. /**
  63719. * Creates a new PosterizeBlock
  63720. * @param name defines the block name
  63721. */
  63722. constructor(name: string);
  63723. /**
  63724. * Gets the current class name
  63725. * @returns the class name
  63726. */
  63727. getClassName(): string;
  63728. /**
  63729. * Gets the value input component
  63730. */
  63731. get value(): NodeMaterialConnectionPoint;
  63732. /**
  63733. * Gets the steps input component
  63734. */
  63735. get steps(): NodeMaterialConnectionPoint;
  63736. /**
  63737. * Gets the output component
  63738. */
  63739. get output(): NodeMaterialConnectionPoint;
  63740. protected _buildBlock(state: NodeMaterialBuildState): this;
  63741. }
  63742. }
  63743. declare module BABYLON {
  63744. /**
  63745. * Operations supported by the Wave block
  63746. */
  63747. export enum WaveBlockKind {
  63748. /** SawTooth */
  63749. SawTooth = 0,
  63750. /** Square */
  63751. Square = 1,
  63752. /** Triangle */
  63753. Triangle = 2
  63754. }
  63755. /**
  63756. * Block used to apply wave operation to floats
  63757. */
  63758. export class WaveBlock extends NodeMaterialBlock {
  63759. /**
  63760. * Gets or sets the kibnd of wave to be applied by the block
  63761. */
  63762. kind: WaveBlockKind;
  63763. /**
  63764. * Creates a new WaveBlock
  63765. * @param name defines the block name
  63766. */
  63767. constructor(name: string);
  63768. /**
  63769. * Gets the current class name
  63770. * @returns the class name
  63771. */
  63772. getClassName(): string;
  63773. /**
  63774. * Gets the input component
  63775. */
  63776. get input(): NodeMaterialConnectionPoint;
  63777. /**
  63778. * Gets the output component
  63779. */
  63780. get output(): NodeMaterialConnectionPoint;
  63781. protected _buildBlock(state: NodeMaterialBuildState): this;
  63782. serialize(): any;
  63783. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63784. }
  63785. }
  63786. declare module BABYLON {
  63787. /**
  63788. * Class used to store a color step for the GradientBlock
  63789. */
  63790. export class GradientBlockColorStep {
  63791. /**
  63792. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63793. */
  63794. step: number;
  63795. /**
  63796. * Gets or sets the color associated with this step
  63797. */
  63798. color: Color3;
  63799. /**
  63800. * Creates a new GradientBlockColorStep
  63801. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63802. * @param color defines the color associated with this step
  63803. */
  63804. constructor(
  63805. /**
  63806. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63807. */
  63808. step: number,
  63809. /**
  63810. * Gets or sets the color associated with this step
  63811. */
  63812. color: Color3);
  63813. }
  63814. /**
  63815. * Block used to return a color from a gradient based on an input value between 0 and 1
  63816. */
  63817. export class GradientBlock extends NodeMaterialBlock {
  63818. /**
  63819. * Gets or sets the list of color steps
  63820. */
  63821. colorSteps: GradientBlockColorStep[];
  63822. /**
  63823. * Creates a new GradientBlock
  63824. * @param name defines the block name
  63825. */
  63826. constructor(name: string);
  63827. /**
  63828. * Gets the current class name
  63829. * @returns the class name
  63830. */
  63831. getClassName(): string;
  63832. /**
  63833. * Gets the gradient input component
  63834. */
  63835. get gradient(): NodeMaterialConnectionPoint;
  63836. /**
  63837. * Gets the output component
  63838. */
  63839. get output(): NodeMaterialConnectionPoint;
  63840. private _writeColorConstant;
  63841. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63842. serialize(): any;
  63843. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63844. protected _dumpPropertiesCode(): string;
  63845. }
  63846. }
  63847. declare module BABYLON {
  63848. /**
  63849. * Block used to normalize lerp between 2 values
  63850. */
  63851. export class NLerpBlock extends NodeMaterialBlock {
  63852. /**
  63853. * Creates a new NLerpBlock
  63854. * @param name defines the block name
  63855. */
  63856. constructor(name: string);
  63857. /**
  63858. * Gets the current class name
  63859. * @returns the class name
  63860. */
  63861. getClassName(): string;
  63862. /**
  63863. * Gets the left operand input component
  63864. */
  63865. get left(): NodeMaterialConnectionPoint;
  63866. /**
  63867. * Gets the right operand input component
  63868. */
  63869. get right(): NodeMaterialConnectionPoint;
  63870. /**
  63871. * Gets the gradient operand input component
  63872. */
  63873. get gradient(): NodeMaterialConnectionPoint;
  63874. /**
  63875. * Gets the output component
  63876. */
  63877. get output(): NodeMaterialConnectionPoint;
  63878. protected _buildBlock(state: NodeMaterialBuildState): this;
  63879. }
  63880. }
  63881. declare module BABYLON {
  63882. /**
  63883. * block used to Generate a Worley Noise 3D Noise Pattern
  63884. */
  63885. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63886. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63887. manhattanDistance: boolean;
  63888. /**
  63889. * Creates a new WorleyNoise3DBlock
  63890. * @param name defines the block name
  63891. */
  63892. constructor(name: string);
  63893. /**
  63894. * Gets the current class name
  63895. * @returns the class name
  63896. */
  63897. getClassName(): string;
  63898. /**
  63899. * Gets the seed input component
  63900. */
  63901. get seed(): NodeMaterialConnectionPoint;
  63902. /**
  63903. * Gets the jitter input component
  63904. */
  63905. get jitter(): NodeMaterialConnectionPoint;
  63906. /**
  63907. * Gets the output component
  63908. */
  63909. get output(): NodeMaterialConnectionPoint;
  63910. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63911. /**
  63912. * Exposes the properties to the UI?
  63913. */
  63914. protected _dumpPropertiesCode(): string;
  63915. /**
  63916. * Exposes the properties to the Seralize?
  63917. */
  63918. serialize(): any;
  63919. /**
  63920. * Exposes the properties to the deseralize?
  63921. */
  63922. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63923. }
  63924. }
  63925. declare module BABYLON {
  63926. /**
  63927. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63928. */
  63929. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63930. /**
  63931. * Creates a new SimplexPerlin3DBlock
  63932. * @param name defines the block name
  63933. */
  63934. constructor(name: string);
  63935. /**
  63936. * Gets the current class name
  63937. * @returns the class name
  63938. */
  63939. getClassName(): string;
  63940. /**
  63941. * Gets the seed operand input component
  63942. */
  63943. get seed(): NodeMaterialConnectionPoint;
  63944. /**
  63945. * Gets the output component
  63946. */
  63947. get output(): NodeMaterialConnectionPoint;
  63948. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63949. }
  63950. }
  63951. declare module BABYLON {
  63952. /**
  63953. * Block used to blend normals
  63954. */
  63955. export class NormalBlendBlock extends NodeMaterialBlock {
  63956. /**
  63957. * Creates a new NormalBlendBlock
  63958. * @param name defines the block name
  63959. */
  63960. constructor(name: string);
  63961. /**
  63962. * Gets the current class name
  63963. * @returns the class name
  63964. */
  63965. getClassName(): string;
  63966. /**
  63967. * Gets the first input component
  63968. */
  63969. get normalMap0(): NodeMaterialConnectionPoint;
  63970. /**
  63971. * Gets the second input component
  63972. */
  63973. get normalMap1(): NodeMaterialConnectionPoint;
  63974. /**
  63975. * Gets the output component
  63976. */
  63977. get output(): NodeMaterialConnectionPoint;
  63978. protected _buildBlock(state: NodeMaterialBuildState): this;
  63979. }
  63980. }
  63981. declare module BABYLON {
  63982. /**
  63983. * Block used to rotate a 2d vector by a given angle
  63984. */
  63985. export class Rotate2dBlock extends NodeMaterialBlock {
  63986. /**
  63987. * Creates a new Rotate2dBlock
  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 vector
  63998. */
  63999. get input(): NodeMaterialConnectionPoint;
  64000. /**
  64001. * Gets the input angle
  64002. */
  64003. get angle(): NodeMaterialConnectionPoint;
  64004. /**
  64005. * Gets the output component
  64006. */
  64007. get output(): NodeMaterialConnectionPoint;
  64008. autoConfigure(material: NodeMaterial): void;
  64009. protected _buildBlock(state: NodeMaterialBuildState): this;
  64010. }
  64011. }
  64012. declare module BABYLON {
  64013. /**
  64014. * Block used to get the reflected vector from a direction and a normal
  64015. */
  64016. export class ReflectBlock extends NodeMaterialBlock {
  64017. /**
  64018. * Creates a new ReflectBlock
  64019. * @param name defines the block name
  64020. */
  64021. constructor(name: string);
  64022. /**
  64023. * Gets the current class name
  64024. * @returns the class name
  64025. */
  64026. getClassName(): string;
  64027. /**
  64028. * Gets the incident component
  64029. */
  64030. get incident(): NodeMaterialConnectionPoint;
  64031. /**
  64032. * Gets the normal component
  64033. */
  64034. get normal(): NodeMaterialConnectionPoint;
  64035. /**
  64036. * Gets the output component
  64037. */
  64038. get output(): NodeMaterialConnectionPoint;
  64039. protected _buildBlock(state: NodeMaterialBuildState): this;
  64040. }
  64041. }
  64042. declare module BABYLON {
  64043. /**
  64044. * Block used to get the refracted vector from a direction and a normal
  64045. */
  64046. export class RefractBlock extends NodeMaterialBlock {
  64047. /**
  64048. * Creates a new RefractBlock
  64049. * @param name defines the block name
  64050. */
  64051. constructor(name: string);
  64052. /**
  64053. * Gets the current class name
  64054. * @returns the class name
  64055. */
  64056. getClassName(): string;
  64057. /**
  64058. * Gets the incident component
  64059. */
  64060. get incident(): NodeMaterialConnectionPoint;
  64061. /**
  64062. * Gets the normal component
  64063. */
  64064. get normal(): NodeMaterialConnectionPoint;
  64065. /**
  64066. * Gets the index of refraction component
  64067. */
  64068. get ior(): NodeMaterialConnectionPoint;
  64069. /**
  64070. * Gets the output component
  64071. */
  64072. get output(): NodeMaterialConnectionPoint;
  64073. protected _buildBlock(state: NodeMaterialBuildState): this;
  64074. }
  64075. }
  64076. declare module BABYLON {
  64077. /**
  64078. * Block used to desaturate a color
  64079. */
  64080. export class DesaturateBlock extends NodeMaterialBlock {
  64081. /**
  64082. * Creates a new DesaturateBlock
  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 color operand input component
  64093. */
  64094. get color(): NodeMaterialConnectionPoint;
  64095. /**
  64096. * Gets the level operand input component
  64097. */
  64098. get level(): NodeMaterialConnectionPoint;
  64099. /**
  64100. * Gets the output component
  64101. */
  64102. get output(): NodeMaterialConnectionPoint;
  64103. protected _buildBlock(state: NodeMaterialBuildState): this;
  64104. }
  64105. }
  64106. declare module BABYLON {
  64107. /**
  64108. * Block used to implement the ambient occlusion module of the PBR material
  64109. */
  64110. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64111. /**
  64112. * Create a new AmbientOcclusionBlock
  64113. * @param name defines the block name
  64114. */
  64115. constructor(name: string);
  64116. /**
  64117. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64118. */
  64119. useAmbientInGrayScale: boolean;
  64120. /**
  64121. * Initialize the block and prepare the context for build
  64122. * @param state defines the state that will be used for the build
  64123. */
  64124. initialize(state: NodeMaterialBuildState): void;
  64125. /**
  64126. * Gets the current class name
  64127. * @returns the class name
  64128. */
  64129. getClassName(): string;
  64130. /**
  64131. * Gets the texture input component
  64132. */
  64133. get texture(): NodeMaterialConnectionPoint;
  64134. /**
  64135. * Gets the texture intensity component
  64136. */
  64137. get intensity(): NodeMaterialConnectionPoint;
  64138. /**
  64139. * Gets the direct light intensity input component
  64140. */
  64141. get directLightIntensity(): NodeMaterialConnectionPoint;
  64142. /**
  64143. * Gets the ambient occlusion object output component
  64144. */
  64145. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64146. /**
  64147. * Gets the main code of the block (fragment side)
  64148. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64149. * @returns the shader code
  64150. */
  64151. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64152. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64153. protected _buildBlock(state: NodeMaterialBuildState): this;
  64154. protected _dumpPropertiesCode(): string;
  64155. serialize(): any;
  64156. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64157. }
  64158. }
  64159. declare module BABYLON {
  64160. /**
  64161. * Block used to implement the reflection module of the PBR material
  64162. */
  64163. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64164. /** @hidden */
  64165. _defineLODReflectionAlpha: string;
  64166. /** @hidden */
  64167. _defineLinearSpecularReflection: string;
  64168. private _vEnvironmentIrradianceName;
  64169. /** @hidden */
  64170. _vReflectionMicrosurfaceInfosName: string;
  64171. /** @hidden */
  64172. _vReflectionInfosName: string;
  64173. /** @hidden */
  64174. _vReflectionFilteringInfoName: string;
  64175. private _scene;
  64176. /**
  64177. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64178. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64179. * It's less burden on the user side in the editor part.
  64180. */
  64181. /** @hidden */
  64182. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64183. /** @hidden */
  64184. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64185. /** @hidden */
  64186. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64187. /**
  64188. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64189. * diffuse part of the IBL.
  64190. */
  64191. useSphericalHarmonics: boolean;
  64192. /**
  64193. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64194. */
  64195. forceIrradianceInFragment: boolean;
  64196. /**
  64197. * Create a new ReflectionBlock
  64198. * @param name defines the block name
  64199. */
  64200. constructor(name: string);
  64201. /**
  64202. * Gets the current class name
  64203. * @returns the class name
  64204. */
  64205. getClassName(): string;
  64206. /**
  64207. * Gets the position input component
  64208. */
  64209. get position(): NodeMaterialConnectionPoint;
  64210. /**
  64211. * Gets the world position input component
  64212. */
  64213. get worldPosition(): NodeMaterialConnectionPoint;
  64214. /**
  64215. * Gets the world normal input component
  64216. */
  64217. get worldNormal(): NodeMaterialConnectionPoint;
  64218. /**
  64219. * Gets the world input component
  64220. */
  64221. get world(): NodeMaterialConnectionPoint;
  64222. /**
  64223. * Gets the camera (or eye) position component
  64224. */
  64225. get cameraPosition(): NodeMaterialConnectionPoint;
  64226. /**
  64227. * Gets the view input component
  64228. */
  64229. get view(): NodeMaterialConnectionPoint;
  64230. /**
  64231. * Gets the color input component
  64232. */
  64233. get color(): NodeMaterialConnectionPoint;
  64234. /**
  64235. * Gets the reflection object output component
  64236. */
  64237. get reflection(): NodeMaterialConnectionPoint;
  64238. /**
  64239. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64240. */
  64241. get hasTexture(): boolean;
  64242. /**
  64243. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64244. */
  64245. get reflectionColor(): string;
  64246. protected _getTexture(): Nullable<BaseTexture>;
  64247. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64248. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64249. /**
  64250. * Gets the code to inject in the vertex shader
  64251. * @param state current state of the node material building
  64252. * @returns the shader code
  64253. */
  64254. handleVertexSide(state: NodeMaterialBuildState): string;
  64255. /**
  64256. * Gets the main code of the block (fragment side)
  64257. * @param state current state of the node material building
  64258. * @param normalVarName name of the existing variable corresponding to the normal
  64259. * @returns the shader code
  64260. */
  64261. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64262. protected _buildBlock(state: NodeMaterialBuildState): this;
  64263. protected _dumpPropertiesCode(): string;
  64264. serialize(): any;
  64265. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64266. }
  64267. }
  64268. declare module BABYLON {
  64269. /**
  64270. * Block used to implement the sheen module of the PBR material
  64271. */
  64272. export class SheenBlock extends NodeMaterialBlock {
  64273. /**
  64274. * Create a new SheenBlock
  64275. * @param name defines the block name
  64276. */
  64277. constructor(name: string);
  64278. /**
  64279. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64280. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64281. * making it easier to setup and tweak the effect
  64282. */
  64283. albedoScaling: boolean;
  64284. /**
  64285. * Defines if the sheen is linked to the sheen color.
  64286. */
  64287. linkSheenWithAlbedo: boolean;
  64288. /**
  64289. * Initialize the block and prepare the context for build
  64290. * @param state defines the state that will be used for the build
  64291. */
  64292. initialize(state: NodeMaterialBuildState): void;
  64293. /**
  64294. * Gets the current class name
  64295. * @returns the class name
  64296. */
  64297. getClassName(): string;
  64298. /**
  64299. * Gets the intensity input component
  64300. */
  64301. get intensity(): NodeMaterialConnectionPoint;
  64302. /**
  64303. * Gets the color input component
  64304. */
  64305. get color(): NodeMaterialConnectionPoint;
  64306. /**
  64307. * Gets the roughness input component
  64308. */
  64309. get roughness(): NodeMaterialConnectionPoint;
  64310. /**
  64311. * Gets the sheen object output component
  64312. */
  64313. get sheen(): NodeMaterialConnectionPoint;
  64314. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64315. /**
  64316. * Gets the main code of the block (fragment side)
  64317. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64318. * @returns the shader code
  64319. */
  64320. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64321. protected _buildBlock(state: NodeMaterialBuildState): this;
  64322. protected _dumpPropertiesCode(): string;
  64323. serialize(): any;
  64324. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64325. }
  64326. }
  64327. declare module BABYLON {
  64328. /**
  64329. * Block used to implement the reflectivity module of the PBR material
  64330. */
  64331. export class ReflectivityBlock extends NodeMaterialBlock {
  64332. private _metallicReflectanceColor;
  64333. private _metallicF0Factor;
  64334. /** @hidden */
  64335. _vMetallicReflectanceFactorsName: string;
  64336. /**
  64337. * The property below is set by the main PBR block prior to calling methods of this class.
  64338. */
  64339. /** @hidden */
  64340. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64341. /**
  64342. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64343. */
  64344. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64345. /**
  64346. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64347. */
  64348. useMetallnessFromMetallicTextureBlue: boolean;
  64349. /**
  64350. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64351. */
  64352. useRoughnessFromMetallicTextureAlpha: boolean;
  64353. /**
  64354. * Specifies if the metallic texture contains the roughness information in its green channel.
  64355. */
  64356. useRoughnessFromMetallicTextureGreen: boolean;
  64357. /**
  64358. * Create a new ReflectivityBlock
  64359. * @param name defines the block name
  64360. */
  64361. constructor(name: string);
  64362. /**
  64363. * Initialize the block and prepare the context for build
  64364. * @param state defines the state that will be used for the build
  64365. */
  64366. initialize(state: NodeMaterialBuildState): void;
  64367. /**
  64368. * Gets the current class name
  64369. * @returns the class name
  64370. */
  64371. getClassName(): string;
  64372. /**
  64373. * Gets the metallic input component
  64374. */
  64375. get metallic(): NodeMaterialConnectionPoint;
  64376. /**
  64377. * Gets the roughness input component
  64378. */
  64379. get roughness(): NodeMaterialConnectionPoint;
  64380. /**
  64381. * Gets the texture input component
  64382. */
  64383. get texture(): NodeMaterialConnectionPoint;
  64384. /**
  64385. * Gets the reflectivity object output component
  64386. */
  64387. get reflectivity(): NodeMaterialConnectionPoint;
  64388. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64389. /**
  64390. * Gets the main code of the block (fragment side)
  64391. * @param state current state of the node material building
  64392. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64393. * @returns the shader code
  64394. */
  64395. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64396. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64397. protected _buildBlock(state: NodeMaterialBuildState): this;
  64398. protected _dumpPropertiesCode(): string;
  64399. serialize(): any;
  64400. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64401. }
  64402. }
  64403. declare module BABYLON {
  64404. /**
  64405. * Block used to implement the anisotropy module of the PBR material
  64406. */
  64407. export class AnisotropyBlock extends NodeMaterialBlock {
  64408. /**
  64409. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64410. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64411. * It's less burden on the user side in the editor part.
  64412. */
  64413. /** @hidden */
  64414. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64415. /** @hidden */
  64416. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64417. /**
  64418. * Create a new AnisotropyBlock
  64419. * @param name defines the block name
  64420. */
  64421. constructor(name: string);
  64422. /**
  64423. * Initialize the block and prepare the context for build
  64424. * @param state defines the state that will be used for the build
  64425. */
  64426. initialize(state: NodeMaterialBuildState): void;
  64427. /**
  64428. * Gets the current class name
  64429. * @returns the class name
  64430. */
  64431. getClassName(): string;
  64432. /**
  64433. * Gets the intensity input component
  64434. */
  64435. get intensity(): NodeMaterialConnectionPoint;
  64436. /**
  64437. * Gets the direction input component
  64438. */
  64439. get direction(): NodeMaterialConnectionPoint;
  64440. /**
  64441. * Gets the texture input component
  64442. */
  64443. get texture(): NodeMaterialConnectionPoint;
  64444. /**
  64445. * Gets the uv input component
  64446. */
  64447. get uv(): NodeMaterialConnectionPoint;
  64448. /**
  64449. * Gets the worldTangent input component
  64450. */
  64451. get worldTangent(): NodeMaterialConnectionPoint;
  64452. /**
  64453. * Gets the anisotropy object output component
  64454. */
  64455. get anisotropy(): NodeMaterialConnectionPoint;
  64456. private _generateTBNSpace;
  64457. /**
  64458. * Gets the main code of the block (fragment side)
  64459. * @param state current state of the node material building
  64460. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64461. * @returns the shader code
  64462. */
  64463. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64464. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64465. protected _buildBlock(state: NodeMaterialBuildState): this;
  64466. }
  64467. }
  64468. declare module BABYLON {
  64469. /**
  64470. * Block used to implement the clear coat module of the PBR material
  64471. */
  64472. export class ClearCoatBlock extends NodeMaterialBlock {
  64473. private _scene;
  64474. /**
  64475. * Create a new ClearCoatBlock
  64476. * @param name defines the block name
  64477. */
  64478. constructor(name: string);
  64479. /**
  64480. * Initialize the block and prepare the context for build
  64481. * @param state defines the state that will be used for the build
  64482. */
  64483. initialize(state: NodeMaterialBuildState): void;
  64484. /**
  64485. * Gets the current class name
  64486. * @returns the class name
  64487. */
  64488. getClassName(): string;
  64489. /**
  64490. * Gets the intensity input component
  64491. */
  64492. get intensity(): NodeMaterialConnectionPoint;
  64493. /**
  64494. * Gets the roughness input component
  64495. */
  64496. get roughness(): NodeMaterialConnectionPoint;
  64497. /**
  64498. * Gets the ior input component
  64499. */
  64500. get ior(): NodeMaterialConnectionPoint;
  64501. /**
  64502. * Gets the texture input component
  64503. */
  64504. get texture(): NodeMaterialConnectionPoint;
  64505. /**
  64506. * Gets the bump texture input component
  64507. */
  64508. get bumpTexture(): NodeMaterialConnectionPoint;
  64509. /**
  64510. * Gets the uv input component
  64511. */
  64512. get uv(): NodeMaterialConnectionPoint;
  64513. /**
  64514. * Gets the tint color input component
  64515. */
  64516. get tintColor(): NodeMaterialConnectionPoint;
  64517. /**
  64518. * Gets the tint "at distance" input component
  64519. */
  64520. get tintAtDistance(): NodeMaterialConnectionPoint;
  64521. /**
  64522. * Gets the tint thickness input component
  64523. */
  64524. get tintThickness(): NodeMaterialConnectionPoint;
  64525. /**
  64526. * Gets the world tangent input component
  64527. */
  64528. get worldTangent(): NodeMaterialConnectionPoint;
  64529. /**
  64530. * Gets the clear coat object output component
  64531. */
  64532. get clearcoat(): NodeMaterialConnectionPoint;
  64533. autoConfigure(material: NodeMaterial): void;
  64534. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64535. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64536. private _generateTBNSpace;
  64537. /**
  64538. * Gets the main code of the block (fragment side)
  64539. * @param state current state of the node material building
  64540. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64541. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64542. * @param worldPosVarName name of the variable holding the world position
  64543. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64544. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64545. * @param worldNormalVarName name of the variable holding the world normal
  64546. * @returns the shader code
  64547. */
  64548. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64549. protected _buildBlock(state: NodeMaterialBuildState): this;
  64550. }
  64551. }
  64552. declare module BABYLON {
  64553. /**
  64554. * Block used to implement the sub surface module of the PBR material
  64555. */
  64556. export class SubSurfaceBlock extends NodeMaterialBlock {
  64557. /**
  64558. * Create a new SubSurfaceBlock
  64559. * @param name defines the block name
  64560. */
  64561. constructor(name: string);
  64562. /**
  64563. * Stores the intensity of the different subsurface effects in the thickness texture.
  64564. * * the green channel is the translucency intensity.
  64565. * * the blue channel is the scattering intensity.
  64566. * * the alpha channel is the refraction intensity.
  64567. */
  64568. useMaskFromThicknessTexture: boolean;
  64569. /**
  64570. * Initialize the block and prepare the context for build
  64571. * @param state defines the state that will be used for the build
  64572. */
  64573. initialize(state: NodeMaterialBuildState): void;
  64574. /**
  64575. * Gets the current class name
  64576. * @returns the class name
  64577. */
  64578. getClassName(): string;
  64579. /**
  64580. * Gets the min thickness input component
  64581. */
  64582. get minThickness(): NodeMaterialConnectionPoint;
  64583. /**
  64584. * Gets the max thickness input component
  64585. */
  64586. get maxThickness(): NodeMaterialConnectionPoint;
  64587. /**
  64588. * Gets the thickness texture component
  64589. */
  64590. get thicknessTexture(): NodeMaterialConnectionPoint;
  64591. /**
  64592. * Gets the tint color input component
  64593. */
  64594. get tintColor(): NodeMaterialConnectionPoint;
  64595. /**
  64596. * Gets the translucency intensity input component
  64597. */
  64598. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64599. /**
  64600. * Gets the translucency diffusion distance input component
  64601. */
  64602. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64603. /**
  64604. * Gets the refraction object parameters
  64605. */
  64606. get refraction(): NodeMaterialConnectionPoint;
  64607. /**
  64608. * Gets the sub surface object output component
  64609. */
  64610. get subsurface(): NodeMaterialConnectionPoint;
  64611. autoConfigure(material: NodeMaterial): void;
  64612. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64613. /**
  64614. * Gets the main code of the block (fragment side)
  64615. * @param state current state of the node material building
  64616. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64617. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64618. * @param worldPosVarName name of the variable holding the world position
  64619. * @returns the shader code
  64620. */
  64621. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64622. protected _buildBlock(state: NodeMaterialBuildState): this;
  64623. }
  64624. }
  64625. declare module BABYLON {
  64626. /**
  64627. * Block used to implement the PBR metallic/roughness model
  64628. */
  64629. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64630. /**
  64631. * Gets or sets the light associated with this block
  64632. */
  64633. light: Nullable<Light>;
  64634. private _lightId;
  64635. private _scene;
  64636. private _environmentBRDFTexture;
  64637. private _environmentBrdfSamplerName;
  64638. private _vNormalWName;
  64639. private _invertNormalName;
  64640. /**
  64641. * Create a new ReflectionBlock
  64642. * @param name defines the block name
  64643. */
  64644. constructor(name: string);
  64645. /**
  64646. * Intensity of the direct lights e.g. the four lights available in your scene.
  64647. * This impacts both the direct diffuse and specular highlights.
  64648. */
  64649. directIntensity: number;
  64650. /**
  64651. * Intensity of the environment e.g. how much the environment will light the object
  64652. * either through harmonics for rough material or through the refelction for shiny ones.
  64653. */
  64654. environmentIntensity: number;
  64655. /**
  64656. * This is a special control allowing the reduction of the specular highlights coming from the
  64657. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64658. */
  64659. specularIntensity: number;
  64660. /**
  64661. * Defines the falloff type used in this material.
  64662. * It by default is Physical.
  64663. */
  64664. lightFalloff: number;
  64665. /**
  64666. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64667. */
  64668. useAlphaFromAlbedoTexture: boolean;
  64669. /**
  64670. * Specifies that alpha test should be used
  64671. */
  64672. useAlphaTest: boolean;
  64673. /**
  64674. * Defines the alpha limits in alpha test mode.
  64675. */
  64676. alphaTestCutoff: number;
  64677. /**
  64678. * Specifies that alpha blending should be used
  64679. */
  64680. useAlphaBlending: boolean;
  64681. /**
  64682. * Defines if the alpha value should be determined via the rgb values.
  64683. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64684. */
  64685. opacityRGB: boolean;
  64686. /**
  64687. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64688. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64689. */
  64690. useRadianceOverAlpha: boolean;
  64691. /**
  64692. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64693. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64694. */
  64695. useSpecularOverAlpha: boolean;
  64696. /**
  64697. * Enables specular anti aliasing in the PBR shader.
  64698. * It will both interacts on the Geometry for analytical and IBL lighting.
  64699. * It also prefilter the roughness map based on the bump values.
  64700. */
  64701. enableSpecularAntiAliasing: boolean;
  64702. /**
  64703. * Enables realtime filtering on the texture.
  64704. */
  64705. realTimeFiltering: boolean;
  64706. /**
  64707. * Quality switch for realtime filtering
  64708. */
  64709. realTimeFilteringQuality: number;
  64710. /**
  64711. * Defines if the material uses energy conservation.
  64712. */
  64713. useEnergyConservation: boolean;
  64714. /**
  64715. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64716. * too much the area relying on ambient texture to define their ambient occlusion.
  64717. */
  64718. useRadianceOcclusion: boolean;
  64719. /**
  64720. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64721. * makes the reflect vector face the model (under horizon).
  64722. */
  64723. useHorizonOcclusion: boolean;
  64724. /**
  64725. * If set to true, no lighting calculations will be applied.
  64726. */
  64727. unlit: boolean;
  64728. /**
  64729. * Force normal to face away from face.
  64730. */
  64731. forceNormalForward: boolean;
  64732. /**
  64733. * Defines the material debug mode.
  64734. * It helps seeing only some components of the material while troubleshooting.
  64735. */
  64736. debugMode: number;
  64737. /**
  64738. * Specify from where on screen the debug mode should start.
  64739. * The value goes from -1 (full screen) to 1 (not visible)
  64740. * It helps with side by side comparison against the final render
  64741. * This defaults to 0
  64742. */
  64743. debugLimit: number;
  64744. /**
  64745. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64746. * You can use the factor to better multiply the final value.
  64747. */
  64748. debugFactor: number;
  64749. /**
  64750. * Initialize the block and prepare the context for build
  64751. * @param state defines the state that will be used for the build
  64752. */
  64753. initialize(state: NodeMaterialBuildState): void;
  64754. /**
  64755. * Gets the current class name
  64756. * @returns the class name
  64757. */
  64758. getClassName(): string;
  64759. /**
  64760. * Gets the world position input component
  64761. */
  64762. get worldPosition(): NodeMaterialConnectionPoint;
  64763. /**
  64764. * Gets the world normal input component
  64765. */
  64766. get worldNormal(): NodeMaterialConnectionPoint;
  64767. /**
  64768. * Gets the perturbed normal input component
  64769. */
  64770. get perturbedNormal(): NodeMaterialConnectionPoint;
  64771. /**
  64772. * Gets the camera position input component
  64773. */
  64774. get cameraPosition(): NodeMaterialConnectionPoint;
  64775. /**
  64776. * Gets the base color input component
  64777. */
  64778. get baseColor(): NodeMaterialConnectionPoint;
  64779. /**
  64780. * Gets the opacity texture input component
  64781. */
  64782. get opacityTexture(): NodeMaterialConnectionPoint;
  64783. /**
  64784. * Gets the ambient color input component
  64785. */
  64786. get ambientColor(): NodeMaterialConnectionPoint;
  64787. /**
  64788. * Gets the reflectivity object parameters
  64789. */
  64790. get reflectivity(): NodeMaterialConnectionPoint;
  64791. /**
  64792. * Gets the ambient occlusion object parameters
  64793. */
  64794. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64795. /**
  64796. * Gets the reflection object parameters
  64797. */
  64798. get reflection(): NodeMaterialConnectionPoint;
  64799. /**
  64800. * Gets the sheen object parameters
  64801. */
  64802. get sheen(): NodeMaterialConnectionPoint;
  64803. /**
  64804. * Gets the clear coat object parameters
  64805. */
  64806. get clearcoat(): NodeMaterialConnectionPoint;
  64807. /**
  64808. * Gets the sub surface object parameters
  64809. */
  64810. get subsurface(): NodeMaterialConnectionPoint;
  64811. /**
  64812. * Gets the anisotropy object parameters
  64813. */
  64814. get anisotropy(): NodeMaterialConnectionPoint;
  64815. /**
  64816. * Gets the ambient output component
  64817. */
  64818. get ambient(): NodeMaterialConnectionPoint;
  64819. /**
  64820. * Gets the diffuse output component
  64821. */
  64822. get diffuse(): NodeMaterialConnectionPoint;
  64823. /**
  64824. * Gets the specular output component
  64825. */
  64826. get specular(): NodeMaterialConnectionPoint;
  64827. /**
  64828. * Gets the sheen output component
  64829. */
  64830. get sheenDir(): NodeMaterialConnectionPoint;
  64831. /**
  64832. * Gets the clear coat output component
  64833. */
  64834. get clearcoatDir(): NodeMaterialConnectionPoint;
  64835. /**
  64836. * Gets the indirect diffuse output component
  64837. */
  64838. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64839. /**
  64840. * Gets the indirect specular output component
  64841. */
  64842. get specularIndirect(): NodeMaterialConnectionPoint;
  64843. /**
  64844. * Gets the indirect sheen output component
  64845. */
  64846. get sheenIndirect(): NodeMaterialConnectionPoint;
  64847. /**
  64848. * Gets the indirect clear coat output component
  64849. */
  64850. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64851. /**
  64852. * Gets the refraction output component
  64853. */
  64854. get refraction(): NodeMaterialConnectionPoint;
  64855. /**
  64856. * Gets the global lighting output component
  64857. */
  64858. get lighting(): NodeMaterialConnectionPoint;
  64859. /**
  64860. * Gets the shadow output component
  64861. */
  64862. get shadow(): NodeMaterialConnectionPoint;
  64863. /**
  64864. * Gets the alpha output component
  64865. */
  64866. get alpha(): NodeMaterialConnectionPoint;
  64867. autoConfigure(material: NodeMaterial): void;
  64868. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64869. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64870. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64871. private _injectVertexCode;
  64872. /**
  64873. * Gets the code corresponding to the albedo/opacity module
  64874. * @returns the shader code
  64875. */
  64876. getAlbedoOpacityCode(): string;
  64877. protected _buildBlock(state: NodeMaterialBuildState): this;
  64878. protected _dumpPropertiesCode(): string;
  64879. serialize(): any;
  64880. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64881. }
  64882. }
  64883. declare module BABYLON {
  64884. /**
  64885. * Block used to compute value of one parameter modulo another
  64886. */
  64887. export class ModBlock extends NodeMaterialBlock {
  64888. /**
  64889. * Creates a new ModBlock
  64890. * @param name defines the block name
  64891. */
  64892. constructor(name: string);
  64893. /**
  64894. * Gets the current class name
  64895. * @returns the class name
  64896. */
  64897. getClassName(): string;
  64898. /**
  64899. * Gets the left operand input component
  64900. */
  64901. get left(): NodeMaterialConnectionPoint;
  64902. /**
  64903. * Gets the right operand input component
  64904. */
  64905. get right(): NodeMaterialConnectionPoint;
  64906. /**
  64907. * Gets the output component
  64908. */
  64909. get output(): NodeMaterialConnectionPoint;
  64910. protected _buildBlock(state: NodeMaterialBuildState): this;
  64911. }
  64912. }
  64913. declare module BABYLON {
  64914. /**
  64915. * Helper class to push actions to a pool of workers.
  64916. */
  64917. export class WorkerPool implements IDisposable {
  64918. private _workerInfos;
  64919. private _pendingActions;
  64920. /**
  64921. * Constructor
  64922. * @param workers Array of workers to use for actions
  64923. */
  64924. constructor(workers: Array<Worker>);
  64925. /**
  64926. * Terminates all workers and clears any pending actions.
  64927. */
  64928. dispose(): void;
  64929. /**
  64930. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64931. * pended until a worker has completed its action.
  64932. * @param action The action to perform. Call onComplete when the action is complete.
  64933. */
  64934. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64935. private _execute;
  64936. }
  64937. }
  64938. declare module BABYLON {
  64939. /**
  64940. * Configuration for Draco compression
  64941. */
  64942. export interface IDracoCompressionConfiguration {
  64943. /**
  64944. * Configuration for the decoder.
  64945. */
  64946. decoder: {
  64947. /**
  64948. * The url to the WebAssembly module.
  64949. */
  64950. wasmUrl?: string;
  64951. /**
  64952. * The url to the WebAssembly binary.
  64953. */
  64954. wasmBinaryUrl?: string;
  64955. /**
  64956. * The url to the fallback JavaScript module.
  64957. */
  64958. fallbackUrl?: string;
  64959. };
  64960. }
  64961. /**
  64962. * Draco compression (https://google.github.io/draco/)
  64963. *
  64964. * This class wraps the Draco module.
  64965. *
  64966. * **Encoder**
  64967. *
  64968. * The encoder is not currently implemented.
  64969. *
  64970. * **Decoder**
  64971. *
  64972. * 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.
  64973. *
  64974. * To update the configuration, use the following code:
  64975. * ```javascript
  64976. * DracoCompression.Configuration = {
  64977. * decoder: {
  64978. * wasmUrl: "<url to the WebAssembly library>",
  64979. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64980. * fallbackUrl: "<url to the fallback JavaScript library>",
  64981. * }
  64982. * };
  64983. * ```
  64984. *
  64985. * 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.
  64986. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64987. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64988. *
  64989. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64990. * ```javascript
  64991. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64992. * ```
  64993. *
  64994. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64995. */
  64996. export class DracoCompression implements IDisposable {
  64997. private _workerPoolPromise?;
  64998. private _decoderModulePromise?;
  64999. /**
  65000. * The configuration. Defaults to the following urls:
  65001. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65002. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65003. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65004. */
  65005. static Configuration: IDracoCompressionConfiguration;
  65006. /**
  65007. * Returns true if the decoder configuration is available.
  65008. */
  65009. static get DecoderAvailable(): boolean;
  65010. /**
  65011. * Default number of workers to create when creating the draco compression object.
  65012. */
  65013. static DefaultNumWorkers: number;
  65014. private static GetDefaultNumWorkers;
  65015. private static _Default;
  65016. /**
  65017. * Default instance for the draco compression object.
  65018. */
  65019. static get Default(): DracoCompression;
  65020. /**
  65021. * Constructor
  65022. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65023. */
  65024. constructor(numWorkers?: number);
  65025. /**
  65026. * Stop all async operations and release resources.
  65027. */
  65028. dispose(): void;
  65029. /**
  65030. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65031. * @returns a promise that resolves when ready
  65032. */
  65033. whenReadyAsync(): Promise<void>;
  65034. /**
  65035. * Decode Draco compressed mesh data to vertex data.
  65036. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65037. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65038. * @returns A promise that resolves with the decoded vertex data
  65039. */
  65040. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65041. [kind: string]: number;
  65042. }): Promise<VertexData>;
  65043. }
  65044. }
  65045. declare module BABYLON {
  65046. /**
  65047. * Class for building Constructive Solid Geometry
  65048. */
  65049. export class CSG {
  65050. private polygons;
  65051. /**
  65052. * The world matrix
  65053. */
  65054. matrix: Matrix;
  65055. /**
  65056. * Stores the position
  65057. */
  65058. position: Vector3;
  65059. /**
  65060. * Stores the rotation
  65061. */
  65062. rotation: Vector3;
  65063. /**
  65064. * Stores the rotation quaternion
  65065. */
  65066. rotationQuaternion: Nullable<Quaternion>;
  65067. /**
  65068. * Stores the scaling vector
  65069. */
  65070. scaling: Vector3;
  65071. /**
  65072. * Convert the Mesh to CSG
  65073. * @param mesh The Mesh to convert to CSG
  65074. * @returns A new CSG from the Mesh
  65075. */
  65076. static FromMesh(mesh: Mesh): CSG;
  65077. /**
  65078. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65079. * @param polygons Polygons used to construct a CSG solid
  65080. */
  65081. private static FromPolygons;
  65082. /**
  65083. * Clones, or makes a deep copy, of the CSG
  65084. * @returns A new CSG
  65085. */
  65086. clone(): CSG;
  65087. /**
  65088. * Unions this CSG with another CSG
  65089. * @param csg The CSG to union against this CSG
  65090. * @returns The unioned CSG
  65091. */
  65092. union(csg: CSG): CSG;
  65093. /**
  65094. * Unions this CSG with another CSG in place
  65095. * @param csg The CSG to union against this CSG
  65096. */
  65097. unionInPlace(csg: CSG): void;
  65098. /**
  65099. * Subtracts this CSG with another CSG
  65100. * @param csg The CSG to subtract against this CSG
  65101. * @returns A new CSG
  65102. */
  65103. subtract(csg: CSG): CSG;
  65104. /**
  65105. * Subtracts this CSG with another CSG in place
  65106. * @param csg The CSG to subtact against this CSG
  65107. */
  65108. subtractInPlace(csg: CSG): void;
  65109. /**
  65110. * Intersect this CSG with another CSG
  65111. * @param csg The CSG to intersect against this CSG
  65112. * @returns A new CSG
  65113. */
  65114. intersect(csg: CSG): CSG;
  65115. /**
  65116. * Intersects this CSG with another CSG in place
  65117. * @param csg The CSG to intersect against this CSG
  65118. */
  65119. intersectInPlace(csg: CSG): void;
  65120. /**
  65121. * Return a new CSG solid with solid and empty space switched. This solid is
  65122. * not modified.
  65123. * @returns A new CSG solid with solid and empty space switched
  65124. */
  65125. inverse(): CSG;
  65126. /**
  65127. * Inverses the CSG in place
  65128. */
  65129. inverseInPlace(): void;
  65130. /**
  65131. * This is used to keep meshes transformations so they can be restored
  65132. * when we build back a Babylon Mesh
  65133. * NB : All CSG operations are performed in world coordinates
  65134. * @param csg The CSG to copy the transform attributes from
  65135. * @returns This CSG
  65136. */
  65137. copyTransformAttributes(csg: CSG): CSG;
  65138. /**
  65139. * Build Raw mesh from CSG
  65140. * Coordinates here are in world space
  65141. * @param name The name of the mesh geometry
  65142. * @param scene The Scene
  65143. * @param keepSubMeshes Specifies if the submeshes should be kept
  65144. * @returns A new Mesh
  65145. */
  65146. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65147. /**
  65148. * Build Mesh from CSG taking material and transforms into account
  65149. * @param name The name of the Mesh
  65150. * @param material The material of the Mesh
  65151. * @param scene The Scene
  65152. * @param keepSubMeshes Specifies if submeshes should be kept
  65153. * @returns The new Mesh
  65154. */
  65155. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65156. }
  65157. }
  65158. declare module BABYLON {
  65159. /**
  65160. * Class used to create a trail following a mesh
  65161. */
  65162. export class TrailMesh extends Mesh {
  65163. private _generator;
  65164. private _autoStart;
  65165. private _running;
  65166. private _diameter;
  65167. private _length;
  65168. private _sectionPolygonPointsCount;
  65169. private _sectionVectors;
  65170. private _sectionNormalVectors;
  65171. private _beforeRenderObserver;
  65172. /**
  65173. * @constructor
  65174. * @param name The value used by scene.getMeshByName() to do a lookup.
  65175. * @param generator The mesh or transform node to generate a trail.
  65176. * @param scene The scene to add this mesh to.
  65177. * @param diameter Diameter of trailing mesh. Default is 1.
  65178. * @param length Length of trailing mesh. Default is 60.
  65179. * @param autoStart Automatically start trailing mesh. Default true.
  65180. */
  65181. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65182. /**
  65183. * "TrailMesh"
  65184. * @returns "TrailMesh"
  65185. */
  65186. getClassName(): string;
  65187. private _createMesh;
  65188. /**
  65189. * Start trailing mesh.
  65190. */
  65191. start(): void;
  65192. /**
  65193. * Stop trailing mesh.
  65194. */
  65195. stop(): void;
  65196. /**
  65197. * Update trailing mesh geometry.
  65198. */
  65199. update(): void;
  65200. /**
  65201. * Returns a new TrailMesh object.
  65202. * @param name is a string, the name given to the new mesh
  65203. * @param newGenerator use new generator object for cloned trail mesh
  65204. * @returns a new mesh
  65205. */
  65206. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65207. /**
  65208. * Serializes this trail mesh
  65209. * @param serializationObject object to write serialization to
  65210. */
  65211. serialize(serializationObject: any): void;
  65212. /**
  65213. * Parses a serialized trail mesh
  65214. * @param parsedMesh the serialized mesh
  65215. * @param scene the scene to create the trail mesh in
  65216. * @returns the created trail mesh
  65217. */
  65218. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65219. }
  65220. }
  65221. declare module BABYLON {
  65222. /**
  65223. * Class containing static functions to help procedurally build meshes
  65224. */
  65225. export class TiledBoxBuilder {
  65226. /**
  65227. * Creates a box mesh
  65228. * 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)
  65229. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65231. * * 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
  65232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65233. * @param name defines the name of the mesh
  65234. * @param options defines the options used to create the mesh
  65235. * @param scene defines the hosting scene
  65236. * @returns the box mesh
  65237. */
  65238. static CreateTiledBox(name: string, options: {
  65239. pattern?: number;
  65240. width?: number;
  65241. height?: number;
  65242. depth?: number;
  65243. tileSize?: number;
  65244. tileWidth?: number;
  65245. tileHeight?: number;
  65246. alignHorizontal?: number;
  65247. alignVertical?: number;
  65248. faceUV?: Vector4[];
  65249. faceColors?: Color4[];
  65250. sideOrientation?: number;
  65251. updatable?: boolean;
  65252. }, scene?: Nullable<Scene>): Mesh;
  65253. }
  65254. }
  65255. declare module BABYLON {
  65256. /**
  65257. * Class containing static functions to help procedurally build meshes
  65258. */
  65259. export class TorusKnotBuilder {
  65260. /**
  65261. * Creates a torus knot mesh
  65262. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65263. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65264. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65265. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65267. * * 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
  65268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65269. * @param name defines the name of the mesh
  65270. * @param options defines the options used to create the mesh
  65271. * @param scene defines the hosting scene
  65272. * @returns the torus knot mesh
  65273. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65274. */
  65275. static CreateTorusKnot(name: string, options: {
  65276. radius?: number;
  65277. tube?: number;
  65278. radialSegments?: number;
  65279. tubularSegments?: number;
  65280. p?: number;
  65281. q?: number;
  65282. updatable?: boolean;
  65283. sideOrientation?: number;
  65284. frontUVs?: Vector4;
  65285. backUVs?: Vector4;
  65286. }, scene: any): Mesh;
  65287. }
  65288. }
  65289. declare module BABYLON {
  65290. /**
  65291. * Polygon
  65292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65293. */
  65294. export class Polygon {
  65295. /**
  65296. * Creates a rectangle
  65297. * @param xmin bottom X coord
  65298. * @param ymin bottom Y coord
  65299. * @param xmax top X coord
  65300. * @param ymax top Y coord
  65301. * @returns points that make the resulting rectation
  65302. */
  65303. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65304. /**
  65305. * Creates a circle
  65306. * @param radius radius of circle
  65307. * @param cx scale in x
  65308. * @param cy scale in y
  65309. * @param numberOfSides number of sides that make up the circle
  65310. * @returns points that make the resulting circle
  65311. */
  65312. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65313. /**
  65314. * Creates a polygon from input string
  65315. * @param input Input polygon data
  65316. * @returns the parsed points
  65317. */
  65318. static Parse(input: string): Vector2[];
  65319. /**
  65320. * Starts building a polygon from x and y coordinates
  65321. * @param x x coordinate
  65322. * @param y y coordinate
  65323. * @returns the started path2
  65324. */
  65325. static StartingAt(x: number, y: number): Path2;
  65326. }
  65327. /**
  65328. * Builds a polygon
  65329. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65330. */
  65331. export class PolygonMeshBuilder {
  65332. private _points;
  65333. private _outlinepoints;
  65334. private _holes;
  65335. private _name;
  65336. private _scene;
  65337. private _epoints;
  65338. private _eholes;
  65339. private _addToepoint;
  65340. /**
  65341. * Babylon reference to the earcut plugin.
  65342. */
  65343. bjsEarcut: any;
  65344. /**
  65345. * Creates a PolygonMeshBuilder
  65346. * @param name name of the builder
  65347. * @param contours Path of the polygon
  65348. * @param scene scene to add to when creating the mesh
  65349. * @param earcutInjection can be used to inject your own earcut reference
  65350. */
  65351. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65352. /**
  65353. * Adds a whole within the polygon
  65354. * @param hole Array of points defining the hole
  65355. * @returns this
  65356. */
  65357. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65358. /**
  65359. * Creates the polygon
  65360. * @param updatable If the mesh should be updatable
  65361. * @param depth The depth of the mesh created
  65362. * @returns the created mesh
  65363. */
  65364. build(updatable?: boolean, depth?: number): Mesh;
  65365. /**
  65366. * Creates the polygon
  65367. * @param depth The depth of the mesh created
  65368. * @returns the created VertexData
  65369. */
  65370. buildVertexData(depth?: number): VertexData;
  65371. /**
  65372. * Adds a side to the polygon
  65373. * @param positions points that make the polygon
  65374. * @param normals normals of the polygon
  65375. * @param uvs uvs of the polygon
  65376. * @param indices indices of the polygon
  65377. * @param bounds bounds of the polygon
  65378. * @param points points of the polygon
  65379. * @param depth depth of the polygon
  65380. * @param flip flip of the polygon
  65381. */
  65382. private addSide;
  65383. }
  65384. }
  65385. declare module BABYLON {
  65386. /**
  65387. * Class containing static functions to help procedurally build meshes
  65388. */
  65389. export class PolygonBuilder {
  65390. /**
  65391. * Creates a polygon mesh
  65392. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65393. * * 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
  65394. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65396. * * 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)
  65397. * * Remember you can only change the shape positions, not their number when updating a polygon
  65398. * @param name defines the name of the mesh
  65399. * @param options defines the options used to create the mesh
  65400. * @param scene defines the hosting scene
  65401. * @param earcutInjection can be used to inject your own earcut reference
  65402. * @returns the polygon mesh
  65403. */
  65404. static CreatePolygon(name: string, options: {
  65405. shape: Vector3[];
  65406. holes?: Vector3[][];
  65407. depth?: number;
  65408. faceUV?: Vector4[];
  65409. faceColors?: Color4[];
  65410. updatable?: boolean;
  65411. sideOrientation?: number;
  65412. frontUVs?: Vector4;
  65413. backUVs?: Vector4;
  65414. wrap?: boolean;
  65415. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65416. /**
  65417. * Creates an extruded polygon mesh, with depth in the Y direction.
  65418. * * 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)
  65419. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65420. * @param name defines the name of the mesh
  65421. * @param options defines the options used to create the mesh
  65422. * @param scene defines the hosting scene
  65423. * @param earcutInjection can be used to inject your own earcut reference
  65424. * @returns the polygon mesh
  65425. */
  65426. static ExtrudePolygon(name: string, options: {
  65427. shape: Vector3[];
  65428. holes?: Vector3[][];
  65429. depth?: number;
  65430. faceUV?: Vector4[];
  65431. faceColors?: Color4[];
  65432. updatable?: boolean;
  65433. sideOrientation?: number;
  65434. frontUVs?: Vector4;
  65435. backUVs?: Vector4;
  65436. wrap?: boolean;
  65437. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65438. }
  65439. }
  65440. declare module BABYLON {
  65441. /**
  65442. * Class containing static functions to help procedurally build meshes
  65443. */
  65444. export class LatheBuilder {
  65445. /**
  65446. * Creates lathe mesh.
  65447. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65448. * * 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
  65449. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65450. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65451. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65452. * * 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
  65453. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65454. * * 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
  65455. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65456. * * 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
  65457. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65459. * @param name defines the name of the mesh
  65460. * @param options defines the options used to create the mesh
  65461. * @param scene defines the hosting scene
  65462. * @returns the lathe mesh
  65463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65464. */
  65465. static CreateLathe(name: string, options: {
  65466. shape: Vector3[];
  65467. radius?: number;
  65468. tessellation?: number;
  65469. clip?: number;
  65470. arc?: number;
  65471. closed?: boolean;
  65472. updatable?: boolean;
  65473. sideOrientation?: number;
  65474. frontUVs?: Vector4;
  65475. backUVs?: Vector4;
  65476. cap?: number;
  65477. invertUV?: boolean;
  65478. }, scene?: Nullable<Scene>): Mesh;
  65479. }
  65480. }
  65481. declare module BABYLON {
  65482. /**
  65483. * Class containing static functions to help procedurally build meshes
  65484. */
  65485. export class TiledPlaneBuilder {
  65486. /**
  65487. * Creates a tiled plane mesh
  65488. * * The parameter `pattern` will, depending on value, do nothing or
  65489. * * * flip (reflect about central vertical) alternate tiles across and up
  65490. * * * flip every tile on alternate rows
  65491. * * * rotate (180 degs) alternate tiles across and up
  65492. * * * rotate every tile on alternate rows
  65493. * * * flip and rotate alternate tiles across and up
  65494. * * * flip and rotate every tile on alternate rows
  65495. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65496. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65497. * * 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
  65498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65499. * * 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)
  65500. * * 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)
  65501. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65502. * @param name defines the name of the mesh
  65503. * @param options defines the options used to create the mesh
  65504. * @param scene defines the hosting scene
  65505. * @returns the box mesh
  65506. */
  65507. static CreateTiledPlane(name: string, options: {
  65508. pattern?: number;
  65509. tileSize?: number;
  65510. tileWidth?: number;
  65511. tileHeight?: number;
  65512. size?: number;
  65513. width?: number;
  65514. height?: number;
  65515. alignHorizontal?: number;
  65516. alignVertical?: number;
  65517. sideOrientation?: number;
  65518. frontUVs?: Vector4;
  65519. backUVs?: Vector4;
  65520. updatable?: boolean;
  65521. }, scene?: Nullable<Scene>): Mesh;
  65522. }
  65523. }
  65524. declare module BABYLON {
  65525. /**
  65526. * Class containing static functions to help procedurally build meshes
  65527. */
  65528. export class TubeBuilder {
  65529. /**
  65530. * Creates a tube mesh.
  65531. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65532. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65533. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65534. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65535. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65536. * * 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)
  65537. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65538. * * 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
  65539. * * 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
  65540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65541. * * 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
  65542. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65544. * @param name defines the name of the mesh
  65545. * @param options defines the options used to create the mesh
  65546. * @param scene defines the hosting scene
  65547. * @returns the tube mesh
  65548. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65549. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65550. */
  65551. static CreateTube(name: string, options: {
  65552. path: Vector3[];
  65553. radius?: number;
  65554. tessellation?: number;
  65555. radiusFunction?: {
  65556. (i: number, distance: number): number;
  65557. };
  65558. cap?: number;
  65559. arc?: number;
  65560. updatable?: boolean;
  65561. sideOrientation?: number;
  65562. frontUVs?: Vector4;
  65563. backUVs?: Vector4;
  65564. instance?: Mesh;
  65565. invertUV?: boolean;
  65566. }, scene?: Nullable<Scene>): Mesh;
  65567. }
  65568. }
  65569. declare module BABYLON {
  65570. /**
  65571. * Class containing static functions to help procedurally build meshes
  65572. */
  65573. export class IcoSphereBuilder {
  65574. /**
  65575. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65576. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65577. * * 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`)
  65578. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65579. * * 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
  65580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65581. * * 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
  65582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65583. * @param name defines the name of the mesh
  65584. * @param options defines the options used to create the mesh
  65585. * @param scene defines the hosting scene
  65586. * @returns the icosahedron mesh
  65587. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65588. */
  65589. static CreateIcoSphere(name: string, options: {
  65590. radius?: number;
  65591. radiusX?: number;
  65592. radiusY?: number;
  65593. radiusZ?: number;
  65594. flat?: boolean;
  65595. subdivisions?: number;
  65596. sideOrientation?: number;
  65597. frontUVs?: Vector4;
  65598. backUVs?: Vector4;
  65599. updatable?: boolean;
  65600. }, scene?: Nullable<Scene>): Mesh;
  65601. }
  65602. }
  65603. declare module BABYLON {
  65604. /**
  65605. * Class containing static functions to help procedurally build meshes
  65606. */
  65607. export class DecalBuilder {
  65608. /**
  65609. * Creates a decal mesh.
  65610. * 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
  65611. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65612. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65613. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65614. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65615. * @param name defines the name of the mesh
  65616. * @param sourceMesh defines the mesh where the decal must be applied
  65617. * @param options defines the options used to create the mesh
  65618. * @param scene defines the hosting scene
  65619. * @returns the decal mesh
  65620. * @see https://doc.babylonjs.com/how_to/decals
  65621. */
  65622. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65623. position?: Vector3;
  65624. normal?: Vector3;
  65625. size?: Vector3;
  65626. angle?: number;
  65627. }): Mesh;
  65628. }
  65629. }
  65630. declare module BABYLON {
  65631. /**
  65632. * Class containing static functions to help procedurally build meshes
  65633. */
  65634. export class MeshBuilder {
  65635. /**
  65636. * Creates a box mesh
  65637. * * The parameter `size` sets the size (float) of each box side (default 1)
  65638. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65639. * * 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)
  65640. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65642. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65644. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65645. * @param name defines the name of the mesh
  65646. * @param options defines the options used to create the mesh
  65647. * @param scene defines the hosting scene
  65648. * @returns the box mesh
  65649. */
  65650. static CreateBox(name: string, options: {
  65651. size?: number;
  65652. width?: number;
  65653. height?: number;
  65654. depth?: number;
  65655. faceUV?: Vector4[];
  65656. faceColors?: Color4[];
  65657. sideOrientation?: number;
  65658. frontUVs?: Vector4;
  65659. backUVs?: Vector4;
  65660. wrap?: boolean;
  65661. topBaseAt?: number;
  65662. bottomBaseAt?: number;
  65663. updatable?: boolean;
  65664. }, scene?: Nullable<Scene>): Mesh;
  65665. /**
  65666. * Creates a tiled box mesh
  65667. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65669. * @param name defines the name of the mesh
  65670. * @param options defines the options used to create the mesh
  65671. * @param scene defines the hosting scene
  65672. * @returns the tiled box mesh
  65673. */
  65674. static CreateTiledBox(name: string, options: {
  65675. pattern?: number;
  65676. size?: number;
  65677. width?: number;
  65678. height?: number;
  65679. depth: number;
  65680. tileSize?: number;
  65681. tileWidth?: number;
  65682. tileHeight?: number;
  65683. faceUV?: Vector4[];
  65684. faceColors?: Color4[];
  65685. alignHorizontal?: number;
  65686. alignVertical?: number;
  65687. sideOrientation?: number;
  65688. updatable?: boolean;
  65689. }, scene?: Nullable<Scene>): Mesh;
  65690. /**
  65691. * Creates a sphere mesh
  65692. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65693. * * 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`)
  65694. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65695. * * 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
  65696. * * 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)
  65697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65700. * @param name defines the name of the mesh
  65701. * @param options defines the options used to create the mesh
  65702. * @param scene defines the hosting scene
  65703. * @returns the sphere mesh
  65704. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65705. */
  65706. static CreateSphere(name: string, options: {
  65707. segments?: number;
  65708. diameter?: number;
  65709. diameterX?: number;
  65710. diameterY?: number;
  65711. diameterZ?: number;
  65712. arc?: number;
  65713. slice?: number;
  65714. sideOrientation?: number;
  65715. frontUVs?: Vector4;
  65716. backUVs?: Vector4;
  65717. updatable?: boolean;
  65718. }, scene?: Nullable<Scene>): Mesh;
  65719. /**
  65720. * Creates a plane polygonal mesh. By default, this is a disc
  65721. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65722. * * 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
  65723. * * 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
  65724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65725. * * 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
  65726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65727. * @param name defines the name of the mesh
  65728. * @param options defines the options used to create the mesh
  65729. * @param scene defines the hosting scene
  65730. * @returns the plane polygonal mesh
  65731. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65732. */
  65733. static CreateDisc(name: string, options: {
  65734. radius?: number;
  65735. tessellation?: number;
  65736. arc?: number;
  65737. updatable?: boolean;
  65738. sideOrientation?: number;
  65739. frontUVs?: Vector4;
  65740. backUVs?: Vector4;
  65741. }, scene?: Nullable<Scene>): Mesh;
  65742. /**
  65743. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65744. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65745. * * 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`)
  65746. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65747. * * 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
  65748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65749. * * 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
  65750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65751. * @param name defines the name of the mesh
  65752. * @param options defines the options used to create the mesh
  65753. * @param scene defines the hosting scene
  65754. * @returns the icosahedron mesh
  65755. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65756. */
  65757. static CreateIcoSphere(name: string, options: {
  65758. radius?: number;
  65759. radiusX?: number;
  65760. radiusY?: number;
  65761. radiusZ?: number;
  65762. flat?: boolean;
  65763. subdivisions?: number;
  65764. sideOrientation?: number;
  65765. frontUVs?: Vector4;
  65766. backUVs?: Vector4;
  65767. updatable?: boolean;
  65768. }, scene?: Nullable<Scene>): Mesh;
  65769. /**
  65770. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65771. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65772. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65773. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65774. * * 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
  65775. * * 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
  65776. * * 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
  65777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65778. * * 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
  65779. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65780. * * 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
  65781. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65782. * * 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
  65783. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65785. * @param name defines the name of the mesh
  65786. * @param options defines the options used to create the mesh
  65787. * @param scene defines the hosting scene
  65788. * @returns the ribbon mesh
  65789. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65790. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65791. */
  65792. static CreateRibbon(name: string, options: {
  65793. pathArray: Vector3[][];
  65794. closeArray?: boolean;
  65795. closePath?: boolean;
  65796. offset?: number;
  65797. updatable?: boolean;
  65798. sideOrientation?: number;
  65799. frontUVs?: Vector4;
  65800. backUVs?: Vector4;
  65801. instance?: Mesh;
  65802. invertUV?: boolean;
  65803. uvs?: Vector2[];
  65804. colors?: Color4[];
  65805. }, scene?: Nullable<Scene>): Mesh;
  65806. /**
  65807. * Creates a cylinder or a cone mesh
  65808. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65809. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65810. * * 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.
  65811. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65812. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65813. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65814. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65815. * * 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).
  65816. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65817. * * 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).
  65818. * * 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
  65819. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65820. * * 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
  65821. * * 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.
  65822. * * If `enclose` is false, a ring surface is one element.
  65823. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65824. * * 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
  65825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65826. * * 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
  65827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65828. * @param name defines the name of the mesh
  65829. * @param options defines the options used to create the mesh
  65830. * @param scene defines the hosting scene
  65831. * @returns the cylinder mesh
  65832. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65833. */
  65834. static CreateCylinder(name: string, options: {
  65835. height?: number;
  65836. diameterTop?: number;
  65837. diameterBottom?: number;
  65838. diameter?: number;
  65839. tessellation?: number;
  65840. subdivisions?: number;
  65841. arc?: number;
  65842. faceColors?: Color4[];
  65843. faceUV?: Vector4[];
  65844. updatable?: boolean;
  65845. hasRings?: boolean;
  65846. enclose?: boolean;
  65847. cap?: number;
  65848. sideOrientation?: number;
  65849. frontUVs?: Vector4;
  65850. backUVs?: Vector4;
  65851. }, scene?: Nullable<Scene>): Mesh;
  65852. /**
  65853. * Creates a torus mesh
  65854. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65855. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65856. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65858. * * 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
  65859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65860. * @param name defines the name of the mesh
  65861. * @param options defines the options used to create the mesh
  65862. * @param scene defines the hosting scene
  65863. * @returns the torus mesh
  65864. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65865. */
  65866. static CreateTorus(name: string, options: {
  65867. diameter?: number;
  65868. thickness?: number;
  65869. tessellation?: number;
  65870. updatable?: boolean;
  65871. sideOrientation?: number;
  65872. frontUVs?: Vector4;
  65873. backUVs?: Vector4;
  65874. }, scene?: Nullable<Scene>): Mesh;
  65875. /**
  65876. * Creates a torus knot mesh
  65877. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65878. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65879. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65880. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65881. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65882. * * 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
  65883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65884. * @param name defines the name of the mesh
  65885. * @param options defines the options used to create the mesh
  65886. * @param scene defines the hosting scene
  65887. * @returns the torus knot mesh
  65888. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65889. */
  65890. static CreateTorusKnot(name: string, options: {
  65891. radius?: number;
  65892. tube?: number;
  65893. radialSegments?: number;
  65894. tubularSegments?: number;
  65895. p?: number;
  65896. q?: number;
  65897. updatable?: boolean;
  65898. sideOrientation?: number;
  65899. frontUVs?: Vector4;
  65900. backUVs?: Vector4;
  65901. }, scene?: Nullable<Scene>): Mesh;
  65902. /**
  65903. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65904. * * 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
  65905. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65906. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65907. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65908. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65909. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65910. * * 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
  65911. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65913. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65914. * @param name defines the name of the new line system
  65915. * @param options defines the options used to create the line system
  65916. * @param scene defines the hosting scene
  65917. * @returns a new line system mesh
  65918. */
  65919. static CreateLineSystem(name: string, options: {
  65920. lines: Vector3[][];
  65921. updatable?: boolean;
  65922. instance?: Nullable<LinesMesh>;
  65923. colors?: Nullable<Color4[][]>;
  65924. useVertexAlpha?: boolean;
  65925. }, scene: Nullable<Scene>): LinesMesh;
  65926. /**
  65927. * Creates a line mesh
  65928. * 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
  65929. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65930. * * The parameter `points` is an array successive Vector3
  65931. * * 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
  65932. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65933. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65934. * * When updating an instance, remember that only point positions can change, not the number of points
  65935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65937. * @param name defines the name of the new line system
  65938. * @param options defines the options used to create the line system
  65939. * @param scene defines the hosting scene
  65940. * @returns a new line mesh
  65941. */
  65942. static CreateLines(name: string, options: {
  65943. points: Vector3[];
  65944. updatable?: boolean;
  65945. instance?: Nullable<LinesMesh>;
  65946. colors?: Color4[];
  65947. useVertexAlpha?: boolean;
  65948. }, scene?: Nullable<Scene>): LinesMesh;
  65949. /**
  65950. * Creates a dashed line mesh
  65951. * * 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
  65952. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65953. * * The parameter `points` is an array successive Vector3
  65954. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65955. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65956. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65957. * * 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
  65958. * * When updating an instance, remember that only point positions can change, not the number of points
  65959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65960. * @param name defines the name of the mesh
  65961. * @param options defines the options used to create the mesh
  65962. * @param scene defines the hosting scene
  65963. * @returns the dashed line mesh
  65964. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65965. */
  65966. static CreateDashedLines(name: string, options: {
  65967. points: Vector3[];
  65968. dashSize?: number;
  65969. gapSize?: number;
  65970. dashNb?: number;
  65971. updatable?: boolean;
  65972. instance?: LinesMesh;
  65973. }, scene?: Nullable<Scene>): LinesMesh;
  65974. /**
  65975. * 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.
  65976. * * 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.
  65977. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65978. * * 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.
  65979. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65980. * * 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
  65981. * * 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
  65982. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65984. * * 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
  65985. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65987. * @param name defines the name of the mesh
  65988. * @param options defines the options used to create the mesh
  65989. * @param scene defines the hosting scene
  65990. * @returns the extruded shape mesh
  65991. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65992. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65993. */
  65994. static ExtrudeShape(name: string, options: {
  65995. shape: Vector3[];
  65996. path: Vector3[];
  65997. scale?: number;
  65998. rotation?: number;
  65999. cap?: number;
  66000. updatable?: boolean;
  66001. sideOrientation?: number;
  66002. frontUVs?: Vector4;
  66003. backUVs?: Vector4;
  66004. instance?: Mesh;
  66005. invertUV?: boolean;
  66006. }, scene?: Nullable<Scene>): Mesh;
  66007. /**
  66008. * Creates an custom extruded shape mesh.
  66009. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66010. * * 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.
  66011. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66012. * * 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
  66013. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66014. * * 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
  66015. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66016. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66017. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66018. * * 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
  66019. * * 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
  66020. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66022. * * 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
  66023. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66025. * @param name defines the name of the mesh
  66026. * @param options defines the options used to create the mesh
  66027. * @param scene defines the hosting scene
  66028. * @returns the custom extruded shape mesh
  66029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66030. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66031. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66032. */
  66033. static ExtrudeShapeCustom(name: string, options: {
  66034. shape: Vector3[];
  66035. path: Vector3[];
  66036. scaleFunction?: any;
  66037. rotationFunction?: any;
  66038. ribbonCloseArray?: boolean;
  66039. ribbonClosePath?: boolean;
  66040. cap?: number;
  66041. updatable?: boolean;
  66042. sideOrientation?: number;
  66043. frontUVs?: Vector4;
  66044. backUVs?: Vector4;
  66045. instance?: Mesh;
  66046. invertUV?: boolean;
  66047. }, scene?: Nullable<Scene>): Mesh;
  66048. /**
  66049. * Creates lathe mesh.
  66050. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66051. * * 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
  66052. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66053. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66054. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66055. * * 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
  66056. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66057. * * 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
  66058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66059. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66060. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66062. * @param name defines the name of the mesh
  66063. * @param options defines the options used to create the mesh
  66064. * @param scene defines the hosting scene
  66065. * @returns the lathe mesh
  66066. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66067. */
  66068. static CreateLathe(name: string, options: {
  66069. shape: Vector3[];
  66070. radius?: number;
  66071. tessellation?: number;
  66072. clip?: number;
  66073. arc?: number;
  66074. closed?: boolean;
  66075. updatable?: boolean;
  66076. sideOrientation?: number;
  66077. frontUVs?: Vector4;
  66078. backUVs?: Vector4;
  66079. cap?: number;
  66080. invertUV?: boolean;
  66081. }, scene?: Nullable<Scene>): Mesh;
  66082. /**
  66083. * Creates a tiled plane mesh
  66084. * * You can set a limited pattern arrangement with the tiles
  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 plane mesh
  66092. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66093. */
  66094. static CreateTiledPlane(name: string, options: {
  66095. pattern?: number;
  66096. tileSize?: number;
  66097. tileWidth?: number;
  66098. tileHeight?: number;
  66099. size?: number;
  66100. width?: number;
  66101. height?: number;
  66102. alignHorizontal?: number;
  66103. alignVertical?: number;
  66104. sideOrientation?: number;
  66105. frontUVs?: Vector4;
  66106. backUVs?: Vector4;
  66107. updatable?: boolean;
  66108. }, scene?: Nullable<Scene>): Mesh;
  66109. /**
  66110. * Creates a plane mesh
  66111. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66112. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66113. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66117. * @param name defines the name of the mesh
  66118. * @param options defines the options used to create the mesh
  66119. * @param scene defines the hosting scene
  66120. * @returns the plane mesh
  66121. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66122. */
  66123. static CreatePlane(name: string, options: {
  66124. size?: number;
  66125. width?: number;
  66126. height?: number;
  66127. sideOrientation?: number;
  66128. frontUVs?: Vector4;
  66129. backUVs?: Vector4;
  66130. updatable?: boolean;
  66131. sourcePlane?: Plane;
  66132. }, scene?: Nullable<Scene>): Mesh;
  66133. /**
  66134. * Creates a ground mesh
  66135. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66136. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66138. * @param name defines the name of the mesh
  66139. * @param options defines the options used to create the mesh
  66140. * @param scene defines the hosting scene
  66141. * @returns the ground mesh
  66142. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66143. */
  66144. static CreateGround(name: string, options: {
  66145. width?: number;
  66146. height?: number;
  66147. subdivisions?: number;
  66148. subdivisionsX?: number;
  66149. subdivisionsY?: number;
  66150. updatable?: boolean;
  66151. }, scene?: Nullable<Scene>): Mesh;
  66152. /**
  66153. * Creates a tiled ground mesh
  66154. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66155. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66156. * * 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
  66157. * * 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
  66158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66159. * @param name defines the name of the mesh
  66160. * @param options defines the options used to create the mesh
  66161. * @param scene defines the hosting scene
  66162. * @returns the tiled ground mesh
  66163. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66164. */
  66165. static CreateTiledGround(name: string, options: {
  66166. xmin: number;
  66167. zmin: number;
  66168. xmax: number;
  66169. zmax: number;
  66170. subdivisions?: {
  66171. w: number;
  66172. h: number;
  66173. };
  66174. precision?: {
  66175. w: number;
  66176. h: number;
  66177. };
  66178. updatable?: boolean;
  66179. }, scene?: Nullable<Scene>): Mesh;
  66180. /**
  66181. * Creates a ground mesh from a height map
  66182. * * The parameter `url` sets the URL of the height map image resource.
  66183. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66184. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66185. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66186. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66187. * * 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.
  66188. * * 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).
  66189. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  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 url defines the url to the height map
  66193. * @param options defines the options used to create the mesh
  66194. * @param scene defines the hosting scene
  66195. * @returns the ground mesh
  66196. * @see https://doc.babylonjs.com/babylon101/height_map
  66197. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66198. */
  66199. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66200. width?: number;
  66201. height?: number;
  66202. subdivisions?: number;
  66203. minHeight?: number;
  66204. maxHeight?: number;
  66205. colorFilter?: Color3;
  66206. alphaFilter?: number;
  66207. updatable?: boolean;
  66208. onReady?: (mesh: GroundMesh) => void;
  66209. }, scene?: Nullable<Scene>): GroundMesh;
  66210. /**
  66211. * Creates a polygon mesh
  66212. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66213. * * 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
  66214. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66216. * * 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)
  66217. * * Remember you can only change the shape positions, not their number when updating a polygon
  66218. * @param name defines the name of the mesh
  66219. * @param options defines the options used to create the mesh
  66220. * @param scene defines the hosting scene
  66221. * @param earcutInjection can be used to inject your own earcut reference
  66222. * @returns the polygon mesh
  66223. */
  66224. static CreatePolygon(name: string, options: {
  66225. shape: Vector3[];
  66226. holes?: Vector3[][];
  66227. depth?: number;
  66228. faceUV?: Vector4[];
  66229. faceColors?: Color4[];
  66230. updatable?: boolean;
  66231. sideOrientation?: number;
  66232. frontUVs?: Vector4;
  66233. backUVs?: Vector4;
  66234. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66235. /**
  66236. * Creates an extruded polygon mesh, with depth in the Y direction.
  66237. * * 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)
  66238. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66239. * @param name defines the name of the mesh
  66240. * @param options defines the options used to create the mesh
  66241. * @param scene defines the hosting scene
  66242. * @param earcutInjection can be used to inject your own earcut reference
  66243. * @returns the polygon mesh
  66244. */
  66245. static ExtrudePolygon(name: string, options: {
  66246. shape: Vector3[];
  66247. holes?: Vector3[][];
  66248. depth?: number;
  66249. faceUV?: Vector4[];
  66250. faceColors?: Color4[];
  66251. updatable?: boolean;
  66252. sideOrientation?: number;
  66253. frontUVs?: Vector4;
  66254. backUVs?: Vector4;
  66255. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66256. /**
  66257. * Creates a tube mesh.
  66258. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66259. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66260. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66261. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66262. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66263. * * 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)
  66264. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66265. * * 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
  66266. * * 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
  66267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66268. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66269. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66271. * @param name defines the name of the mesh
  66272. * @param options defines the options used to create the mesh
  66273. * @param scene defines the hosting scene
  66274. * @returns the tube mesh
  66275. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66276. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66277. */
  66278. static CreateTube(name: string, options: {
  66279. path: Vector3[];
  66280. radius?: number;
  66281. tessellation?: number;
  66282. radiusFunction?: {
  66283. (i: number, distance: number): number;
  66284. };
  66285. cap?: number;
  66286. arc?: number;
  66287. updatable?: boolean;
  66288. sideOrientation?: number;
  66289. frontUVs?: Vector4;
  66290. backUVs?: Vector4;
  66291. instance?: Mesh;
  66292. invertUV?: boolean;
  66293. }, scene?: Nullable<Scene>): Mesh;
  66294. /**
  66295. * Creates a polyhedron mesh
  66296. * * 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
  66297. * * The parameter `size` (positive float, default 1) sets the polygon size
  66298. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66299. * * 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`
  66300. * * 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
  66301. * * 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)`)
  66302. * * 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
  66303. * * 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
  66304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  66306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66307. * @param name defines the name of the mesh
  66308. * @param options defines the options used to create the mesh
  66309. * @param scene defines the hosting scene
  66310. * @returns the polyhedron mesh
  66311. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66312. */
  66313. static CreatePolyhedron(name: string, options: {
  66314. type?: number;
  66315. size?: number;
  66316. sizeX?: number;
  66317. sizeY?: number;
  66318. sizeZ?: number;
  66319. custom?: any;
  66320. faceUV?: Vector4[];
  66321. faceColors?: Color4[];
  66322. flat?: boolean;
  66323. updatable?: boolean;
  66324. sideOrientation?: number;
  66325. frontUVs?: Vector4;
  66326. backUVs?: Vector4;
  66327. }, scene?: Nullable<Scene>): Mesh;
  66328. /**
  66329. * Creates a decal mesh.
  66330. * 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
  66331. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66332. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66333. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66334. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66335. * @param name defines the name of the mesh
  66336. * @param sourceMesh defines the mesh where the decal must be applied
  66337. * @param options defines the options used to create the mesh
  66338. * @param scene defines the hosting scene
  66339. * @returns the decal mesh
  66340. * @see https://doc.babylonjs.com/how_to/decals
  66341. */
  66342. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66343. position?: Vector3;
  66344. normal?: Vector3;
  66345. size?: Vector3;
  66346. angle?: number;
  66347. }): Mesh;
  66348. }
  66349. }
  66350. declare module BABYLON {
  66351. /**
  66352. * A simplifier interface for future simplification implementations
  66353. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66354. */
  66355. export interface ISimplifier {
  66356. /**
  66357. * Simplification of a given mesh according to the given settings.
  66358. * Since this requires computation, it is assumed that the function runs async.
  66359. * @param settings The settings of the simplification, including quality and distance
  66360. * @param successCallback A callback that will be called after the mesh was simplified.
  66361. * @param errorCallback in case of an error, this callback will be called. optional.
  66362. */
  66363. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66364. }
  66365. /**
  66366. * Expected simplification settings.
  66367. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66368. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66369. */
  66370. export interface ISimplificationSettings {
  66371. /**
  66372. * Gets or sets the expected quality
  66373. */
  66374. quality: number;
  66375. /**
  66376. * Gets or sets the distance when this optimized version should be used
  66377. */
  66378. distance: number;
  66379. /**
  66380. * Gets an already optimized mesh
  66381. */
  66382. optimizeMesh?: boolean;
  66383. }
  66384. /**
  66385. * Class used to specify simplification options
  66386. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66387. */
  66388. export class SimplificationSettings implements ISimplificationSettings {
  66389. /** expected quality */
  66390. quality: number;
  66391. /** distance when this optimized version should be used */
  66392. distance: number;
  66393. /** already optimized mesh */
  66394. optimizeMesh?: boolean | undefined;
  66395. /**
  66396. * Creates a SimplificationSettings
  66397. * @param quality expected quality
  66398. * @param distance distance when this optimized version should be used
  66399. * @param optimizeMesh already optimized mesh
  66400. */
  66401. constructor(
  66402. /** expected quality */
  66403. quality: number,
  66404. /** distance when this optimized version should be used */
  66405. distance: number,
  66406. /** already optimized mesh */
  66407. optimizeMesh?: boolean | undefined);
  66408. }
  66409. /**
  66410. * Interface used to define a simplification task
  66411. */
  66412. export interface ISimplificationTask {
  66413. /**
  66414. * Array of settings
  66415. */
  66416. settings: Array<ISimplificationSettings>;
  66417. /**
  66418. * Simplification type
  66419. */
  66420. simplificationType: SimplificationType;
  66421. /**
  66422. * Mesh to simplify
  66423. */
  66424. mesh: Mesh;
  66425. /**
  66426. * Callback called on success
  66427. */
  66428. successCallback?: () => void;
  66429. /**
  66430. * Defines if parallel processing can be used
  66431. */
  66432. parallelProcessing: boolean;
  66433. }
  66434. /**
  66435. * Queue used to order the simplification tasks
  66436. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66437. */
  66438. export class SimplificationQueue {
  66439. private _simplificationArray;
  66440. /**
  66441. * Gets a boolean indicating that the process is still running
  66442. */
  66443. running: boolean;
  66444. /**
  66445. * Creates a new queue
  66446. */
  66447. constructor();
  66448. /**
  66449. * Adds a new simplification task
  66450. * @param task defines a task to add
  66451. */
  66452. addTask(task: ISimplificationTask): void;
  66453. /**
  66454. * Execute next task
  66455. */
  66456. executeNext(): void;
  66457. /**
  66458. * Execute a simplification task
  66459. * @param task defines the task to run
  66460. */
  66461. runSimplification(task: ISimplificationTask): void;
  66462. private getSimplifier;
  66463. }
  66464. /**
  66465. * The implemented types of simplification
  66466. * At the moment only Quadratic Error Decimation is implemented
  66467. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66468. */
  66469. export enum SimplificationType {
  66470. /** Quadratic error decimation */
  66471. QUADRATIC = 0
  66472. }
  66473. /**
  66474. * An implementation of the Quadratic Error simplification algorithm.
  66475. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66476. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66477. * @author RaananW
  66478. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66479. */
  66480. export class QuadraticErrorSimplification implements ISimplifier {
  66481. private _mesh;
  66482. private triangles;
  66483. private vertices;
  66484. private references;
  66485. private _reconstructedMesh;
  66486. /** Gets or sets the number pf sync interations */
  66487. syncIterations: number;
  66488. /** Gets or sets the aggressiveness of the simplifier */
  66489. aggressiveness: number;
  66490. /** Gets or sets the number of allowed iterations for decimation */
  66491. decimationIterations: number;
  66492. /** Gets or sets the espilon to use for bounding box computation */
  66493. boundingBoxEpsilon: number;
  66494. /**
  66495. * Creates a new QuadraticErrorSimplification
  66496. * @param _mesh defines the target mesh
  66497. */
  66498. constructor(_mesh: Mesh);
  66499. /**
  66500. * Simplification of a given mesh according to the given settings.
  66501. * Since this requires computation, it is assumed that the function runs async.
  66502. * @param settings The settings of the simplification, including quality and distance
  66503. * @param successCallback A callback that will be called after the mesh was simplified.
  66504. */
  66505. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66506. private runDecimation;
  66507. private initWithMesh;
  66508. private init;
  66509. private reconstructMesh;
  66510. private initDecimatedMesh;
  66511. private isFlipped;
  66512. private updateTriangles;
  66513. private identifyBorder;
  66514. private updateMesh;
  66515. private vertexError;
  66516. private calculateError;
  66517. }
  66518. }
  66519. declare module BABYLON {
  66520. interface Scene {
  66521. /** @hidden (Backing field) */
  66522. _simplificationQueue: SimplificationQueue;
  66523. /**
  66524. * Gets or sets the simplification queue attached to the scene
  66525. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66526. */
  66527. simplificationQueue: SimplificationQueue;
  66528. }
  66529. interface Mesh {
  66530. /**
  66531. * Simplify the mesh according to the given array of settings.
  66532. * Function will return immediately and will simplify async
  66533. * @param settings a collection of simplification settings
  66534. * @param parallelProcessing should all levels calculate parallel or one after the other
  66535. * @param simplificationType the type of simplification to run
  66536. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66537. * @returns the current mesh
  66538. */
  66539. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66540. }
  66541. /**
  66542. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66543. * created in a scene
  66544. */
  66545. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66546. /**
  66547. * The component name helpfull to identify the component in the list of scene components.
  66548. */
  66549. readonly name: string;
  66550. /**
  66551. * The scene the component belongs to.
  66552. */
  66553. scene: Scene;
  66554. /**
  66555. * Creates a new instance of the component for the given scene
  66556. * @param scene Defines the scene to register the component in
  66557. */
  66558. constructor(scene: Scene);
  66559. /**
  66560. * Registers the component in a given scene
  66561. */
  66562. register(): void;
  66563. /**
  66564. * Rebuilds the elements related to this component in case of
  66565. * context lost for instance.
  66566. */
  66567. rebuild(): void;
  66568. /**
  66569. * Disposes the component and the associated ressources
  66570. */
  66571. dispose(): void;
  66572. private _beforeCameraUpdate;
  66573. }
  66574. }
  66575. declare module BABYLON {
  66576. interface Mesh {
  66577. /**
  66578. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66579. */
  66580. thinInstanceEnablePicking: boolean;
  66581. /**
  66582. * Creates a new thin instance
  66583. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66584. * @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
  66585. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66586. */
  66587. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66588. /**
  66589. * Adds the transformation (matrix) of the current mesh as a thin instance
  66590. * @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
  66591. * @returns the thin instance index number
  66592. */
  66593. thinInstanceAddSelf(refresh: boolean): number;
  66594. /**
  66595. * Registers a custom attribute to be used with thin instances
  66596. * @param kind name of the attribute
  66597. * @param stride size in floats of the attribute
  66598. */
  66599. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66600. /**
  66601. * Sets the matrix of a thin instance
  66602. * @param index index of the thin instance
  66603. * @param matrix matrix to set
  66604. * @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
  66605. */
  66606. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66607. /**
  66608. * Sets the value of a custom attribute for a thin instance
  66609. * @param kind name of the attribute
  66610. * @param index index of the thin instance
  66611. * @param value value to set
  66612. * @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
  66613. */
  66614. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66615. /**
  66616. * 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.
  66617. */
  66618. thinInstanceCount: number;
  66619. /**
  66620. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66621. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66622. * @param buffer buffer to set
  66623. * @param stride size in floats of each value of the buffer
  66624. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66625. */
  66626. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66627. /**
  66628. * Gets the list of world matrices
  66629. * @return an array containing all the world matrices from the thin instances
  66630. */
  66631. thinInstanceGetWorldMatrices(): Matrix[];
  66632. /**
  66633. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66634. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66635. */
  66636. thinInstanceBufferUpdated(kind: string): void;
  66637. /**
  66638. * Refreshes the bounding info, taking into account all the thin instances defined
  66639. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66640. */
  66641. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66642. /** @hidden */
  66643. _thinInstanceInitializeUserStorage(): void;
  66644. /** @hidden */
  66645. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66646. /** @hidden */
  66647. _userThinInstanceBuffersStorage: {
  66648. data: {
  66649. [key: string]: Float32Array;
  66650. };
  66651. sizes: {
  66652. [key: string]: number;
  66653. };
  66654. vertexBuffers: {
  66655. [key: string]: Nullable<VertexBuffer>;
  66656. };
  66657. strides: {
  66658. [key: string]: number;
  66659. };
  66660. };
  66661. }
  66662. }
  66663. declare module BABYLON {
  66664. /**
  66665. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66666. */
  66667. export interface INavigationEnginePlugin {
  66668. /**
  66669. * plugin name
  66670. */
  66671. name: string;
  66672. /**
  66673. * Creates a navigation mesh
  66674. * @param meshes array of all the geometry used to compute the navigatio mesh
  66675. * @param parameters bunch of parameters used to filter geometry
  66676. */
  66677. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66678. /**
  66679. * Create a navigation mesh debug mesh
  66680. * @param scene is where the mesh will be added
  66681. * @returns debug display mesh
  66682. */
  66683. createDebugNavMesh(scene: Scene): Mesh;
  66684. /**
  66685. * Get a navigation mesh constrained position, closest to the parameter position
  66686. * @param position world position
  66687. * @returns the closest point to position constrained by the navigation mesh
  66688. */
  66689. getClosestPoint(position: Vector3): Vector3;
  66690. /**
  66691. * Get a navigation mesh constrained position, closest to the parameter position
  66692. * @param position world position
  66693. * @param result output the closest point to position constrained by the navigation mesh
  66694. */
  66695. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66696. /**
  66697. * Get a navigation mesh constrained position, within a particular radius
  66698. * @param position world position
  66699. * @param maxRadius the maximum distance to the constrained world position
  66700. * @returns the closest point to position constrained by the navigation mesh
  66701. */
  66702. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66703. /**
  66704. * Get a navigation mesh constrained position, within a particular radius
  66705. * @param position world position
  66706. * @param maxRadius the maximum distance to the constrained world position
  66707. * @param result output the closest point to position constrained by the navigation mesh
  66708. */
  66709. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66710. /**
  66711. * Compute the final position from a segment made of destination-position
  66712. * @param position world position
  66713. * @param destination world position
  66714. * @returns the resulting point along the navmesh
  66715. */
  66716. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66717. /**
  66718. * Compute the final position from a segment made of destination-position
  66719. * @param position world position
  66720. * @param destination world position
  66721. * @param result output the resulting point along the navmesh
  66722. */
  66723. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66724. /**
  66725. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66726. * @param start world position
  66727. * @param end world position
  66728. * @returns array containing world position composing the path
  66729. */
  66730. computePath(start: Vector3, end: Vector3): Vector3[];
  66731. /**
  66732. * If this plugin is supported
  66733. * @returns true if plugin is supported
  66734. */
  66735. isSupported(): boolean;
  66736. /**
  66737. * Create a new Crowd so you can add agents
  66738. * @param maxAgents the maximum agent count in the crowd
  66739. * @param maxAgentRadius the maximum radius an agent can have
  66740. * @param scene to attach the crowd to
  66741. * @returns the crowd you can add agents to
  66742. */
  66743. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66744. /**
  66745. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66746. * The queries will try to find a solution within those bounds
  66747. * default is (1,1,1)
  66748. * @param extent x,y,z value that define the extent around the queries point of reference
  66749. */
  66750. setDefaultQueryExtent(extent: Vector3): void;
  66751. /**
  66752. * Get the Bounding box extent specified by setDefaultQueryExtent
  66753. * @returns the box extent values
  66754. */
  66755. getDefaultQueryExtent(): Vector3;
  66756. /**
  66757. * build the navmesh from a previously saved state using getNavmeshData
  66758. * @param data the Uint8Array returned by getNavmeshData
  66759. */
  66760. buildFromNavmeshData(data: Uint8Array): void;
  66761. /**
  66762. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66763. * @returns data the Uint8Array that can be saved and reused
  66764. */
  66765. getNavmeshData(): Uint8Array;
  66766. /**
  66767. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66768. * @param result output the box extent values
  66769. */
  66770. getDefaultQueryExtentToRef(result: Vector3): void;
  66771. /**
  66772. * Release all resources
  66773. */
  66774. dispose(): void;
  66775. }
  66776. /**
  66777. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66778. */
  66779. export interface ICrowd {
  66780. /**
  66781. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66782. * You can attach anything to that node. The node position is updated in the scene update tick.
  66783. * @param pos world position that will be constrained by the navigation mesh
  66784. * @param parameters agent parameters
  66785. * @param transform hooked to the agent that will be update by the scene
  66786. * @returns agent index
  66787. */
  66788. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66789. /**
  66790. * Returns the agent position in world space
  66791. * @param index agent index returned by addAgent
  66792. * @returns world space position
  66793. */
  66794. getAgentPosition(index: number): Vector3;
  66795. /**
  66796. * Gets the agent position result in world space
  66797. * @param index agent index returned by addAgent
  66798. * @param result output world space position
  66799. */
  66800. getAgentPositionToRef(index: number, result: Vector3): void;
  66801. /**
  66802. * Gets the agent velocity in world space
  66803. * @param index agent index returned by addAgent
  66804. * @returns world space velocity
  66805. */
  66806. getAgentVelocity(index: number): Vector3;
  66807. /**
  66808. * Gets the agent velocity result in world space
  66809. * @param index agent index returned by addAgent
  66810. * @param result output world space velocity
  66811. */
  66812. getAgentVelocityToRef(index: number, result: Vector3): void;
  66813. /**
  66814. * remove a particular agent previously created
  66815. * @param index agent index returned by addAgent
  66816. */
  66817. removeAgent(index: number): void;
  66818. /**
  66819. * get the list of all agents attached to this crowd
  66820. * @returns list of agent indices
  66821. */
  66822. getAgents(): number[];
  66823. /**
  66824. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66825. * @param deltaTime in seconds
  66826. */
  66827. update(deltaTime: number): void;
  66828. /**
  66829. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66830. * @param index agent index returned by addAgent
  66831. * @param destination targeted world position
  66832. */
  66833. agentGoto(index: number, destination: Vector3): void;
  66834. /**
  66835. * Teleport the agent to a new position
  66836. * @param index agent index returned by addAgent
  66837. * @param destination targeted world position
  66838. */
  66839. agentTeleport(index: number, destination: Vector3): void;
  66840. /**
  66841. * Update agent parameters
  66842. * @param index agent index returned by addAgent
  66843. * @param parameters agent parameters
  66844. */
  66845. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66846. /**
  66847. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66848. * The queries will try to find a solution within those bounds
  66849. * default is (1,1,1)
  66850. * @param extent x,y,z value that define the extent around the queries point of reference
  66851. */
  66852. setDefaultQueryExtent(extent: Vector3): void;
  66853. /**
  66854. * Get the Bounding box extent specified by setDefaultQueryExtent
  66855. * @returns the box extent values
  66856. */
  66857. getDefaultQueryExtent(): Vector3;
  66858. /**
  66859. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66860. * @param result output the box extent values
  66861. */
  66862. getDefaultQueryExtentToRef(result: Vector3): void;
  66863. /**
  66864. * Release all resources
  66865. */
  66866. dispose(): void;
  66867. }
  66868. /**
  66869. * Configures an agent
  66870. */
  66871. export interface IAgentParameters {
  66872. /**
  66873. * Agent radius. [Limit: >= 0]
  66874. */
  66875. radius: number;
  66876. /**
  66877. * Agent height. [Limit: > 0]
  66878. */
  66879. height: number;
  66880. /**
  66881. * Maximum allowed acceleration. [Limit: >= 0]
  66882. */
  66883. maxAcceleration: number;
  66884. /**
  66885. * Maximum allowed speed. [Limit: >= 0]
  66886. */
  66887. maxSpeed: number;
  66888. /**
  66889. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66890. */
  66891. collisionQueryRange: number;
  66892. /**
  66893. * The path visibility optimization range. [Limit: > 0]
  66894. */
  66895. pathOptimizationRange: number;
  66896. /**
  66897. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66898. */
  66899. separationWeight: number;
  66900. }
  66901. /**
  66902. * Configures the navigation mesh creation
  66903. */
  66904. export interface INavMeshParameters {
  66905. /**
  66906. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66907. */
  66908. cs: number;
  66909. /**
  66910. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66911. */
  66912. ch: number;
  66913. /**
  66914. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66915. */
  66916. walkableSlopeAngle: number;
  66917. /**
  66918. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66919. * be considered walkable. [Limit: >= 3] [Units: vx]
  66920. */
  66921. walkableHeight: number;
  66922. /**
  66923. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66924. */
  66925. walkableClimb: number;
  66926. /**
  66927. * The distance to erode/shrink the walkable area of the heightfield away from
  66928. * obstructions. [Limit: >=0] [Units: vx]
  66929. */
  66930. walkableRadius: number;
  66931. /**
  66932. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66933. */
  66934. maxEdgeLen: number;
  66935. /**
  66936. * The maximum distance a simplfied contour's border edges should deviate
  66937. * the original raw contour. [Limit: >=0] [Units: vx]
  66938. */
  66939. maxSimplificationError: number;
  66940. /**
  66941. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66942. */
  66943. minRegionArea: number;
  66944. /**
  66945. * Any regions with a span count smaller than this value will, if possible,
  66946. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66947. */
  66948. mergeRegionArea: number;
  66949. /**
  66950. * The maximum number of vertices allowed for polygons generated during the
  66951. * contour to polygon conversion process. [Limit: >= 3]
  66952. */
  66953. maxVertsPerPoly: number;
  66954. /**
  66955. * Sets the sampling distance to use when generating the detail mesh.
  66956. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66957. */
  66958. detailSampleDist: number;
  66959. /**
  66960. * The maximum distance the detail mesh surface should deviate from heightfield
  66961. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66962. */
  66963. detailSampleMaxError: number;
  66964. }
  66965. }
  66966. declare module BABYLON {
  66967. /**
  66968. * RecastJS navigation plugin
  66969. */
  66970. export class RecastJSPlugin implements INavigationEnginePlugin {
  66971. /**
  66972. * Reference to the Recast library
  66973. */
  66974. bjsRECAST: any;
  66975. /**
  66976. * plugin name
  66977. */
  66978. name: string;
  66979. /**
  66980. * the first navmesh created. We might extend this to support multiple navmeshes
  66981. */
  66982. navMesh: any;
  66983. /**
  66984. * Initializes the recastJS plugin
  66985. * @param recastInjection can be used to inject your own recast reference
  66986. */
  66987. constructor(recastInjection?: any);
  66988. /**
  66989. * Creates a navigation mesh
  66990. * @param meshes array of all the geometry used to compute the navigatio mesh
  66991. * @param parameters bunch of parameters used to filter geometry
  66992. */
  66993. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66994. /**
  66995. * Create a navigation mesh debug mesh
  66996. * @param scene is where the mesh will be added
  66997. * @returns debug display mesh
  66998. */
  66999. createDebugNavMesh(scene: Scene): Mesh;
  67000. /**
  67001. * Get a navigation mesh constrained position, closest to the parameter position
  67002. * @param position world position
  67003. * @returns the closest point to position constrained by the navigation mesh
  67004. */
  67005. getClosestPoint(position: Vector3): Vector3;
  67006. /**
  67007. * Get a navigation mesh constrained position, closest to the parameter position
  67008. * @param position world position
  67009. * @param result output the closest point to position constrained by the navigation mesh
  67010. */
  67011. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67012. /**
  67013. * Get a navigation mesh constrained position, within a particular radius
  67014. * @param position world position
  67015. * @param maxRadius the maximum distance to the constrained world position
  67016. * @returns the closest point to position constrained by the navigation mesh
  67017. */
  67018. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67019. /**
  67020. * Get a navigation mesh constrained position, within a particular radius
  67021. * @param position world position
  67022. * @param maxRadius the maximum distance to the constrained world position
  67023. * @param result output the closest point to position constrained by the navigation mesh
  67024. */
  67025. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67026. /**
  67027. * Compute the final position from a segment made of destination-position
  67028. * @param position world position
  67029. * @param destination world position
  67030. * @returns the resulting point along the navmesh
  67031. */
  67032. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67033. /**
  67034. * Compute the final position from a segment made of destination-position
  67035. * @param position world position
  67036. * @param destination world position
  67037. * @param result output the resulting point along the navmesh
  67038. */
  67039. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67040. /**
  67041. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67042. * @param start world position
  67043. * @param end world position
  67044. * @returns array containing world position composing the path
  67045. */
  67046. computePath(start: Vector3, end: Vector3): Vector3[];
  67047. /**
  67048. * Create a new Crowd so you can add agents
  67049. * @param maxAgents the maximum agent count in the crowd
  67050. * @param maxAgentRadius the maximum radius an agent can have
  67051. * @param scene to attach the crowd to
  67052. * @returns the crowd you can add agents to
  67053. */
  67054. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67055. /**
  67056. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67057. * The queries will try to find a solution within those bounds
  67058. * default is (1,1,1)
  67059. * @param extent x,y,z value that define the extent around the queries point of reference
  67060. */
  67061. setDefaultQueryExtent(extent: Vector3): void;
  67062. /**
  67063. * Get the Bounding box extent specified by setDefaultQueryExtent
  67064. * @returns the box extent values
  67065. */
  67066. getDefaultQueryExtent(): Vector3;
  67067. /**
  67068. * build the navmesh from a previously saved state using getNavmeshData
  67069. * @param data the Uint8Array returned by getNavmeshData
  67070. */
  67071. buildFromNavmeshData(data: Uint8Array): void;
  67072. /**
  67073. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67074. * @returns data the Uint8Array that can be saved and reused
  67075. */
  67076. getNavmeshData(): Uint8Array;
  67077. /**
  67078. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67079. * @param result output the box extent values
  67080. */
  67081. getDefaultQueryExtentToRef(result: Vector3): void;
  67082. /**
  67083. * Disposes
  67084. */
  67085. dispose(): void;
  67086. /**
  67087. * If this plugin is supported
  67088. * @returns true if plugin is supported
  67089. */
  67090. isSupported(): boolean;
  67091. }
  67092. /**
  67093. * Recast detour crowd implementation
  67094. */
  67095. export class RecastJSCrowd implements ICrowd {
  67096. /**
  67097. * Recast/detour plugin
  67098. */
  67099. bjsRECASTPlugin: RecastJSPlugin;
  67100. /**
  67101. * Link to the detour crowd
  67102. */
  67103. recastCrowd: any;
  67104. /**
  67105. * One transform per agent
  67106. */
  67107. transforms: TransformNode[];
  67108. /**
  67109. * All agents created
  67110. */
  67111. agents: number[];
  67112. /**
  67113. * Link to the scene is kept to unregister the crowd from the scene
  67114. */
  67115. private _scene;
  67116. /**
  67117. * Observer for crowd updates
  67118. */
  67119. private _onBeforeAnimationsObserver;
  67120. /**
  67121. * Constructor
  67122. * @param plugin recastJS plugin
  67123. * @param maxAgents the maximum agent count in the crowd
  67124. * @param maxAgentRadius the maximum radius an agent can have
  67125. * @param scene to attach the crowd to
  67126. * @returns the crowd you can add agents to
  67127. */
  67128. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67129. /**
  67130. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67131. * You can attach anything to that node. The node position is updated in the scene update tick.
  67132. * @param pos world position that will be constrained by the navigation mesh
  67133. * @param parameters agent parameters
  67134. * @param transform hooked to the agent that will be update by the scene
  67135. * @returns agent index
  67136. */
  67137. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67138. /**
  67139. * Returns the agent position in world space
  67140. * @param index agent index returned by addAgent
  67141. * @returns world space position
  67142. */
  67143. getAgentPosition(index: number): Vector3;
  67144. /**
  67145. * Returns the agent position result in world space
  67146. * @param index agent index returned by addAgent
  67147. * @param result output world space position
  67148. */
  67149. getAgentPositionToRef(index: number, result: Vector3): void;
  67150. /**
  67151. * Returns the agent velocity in world space
  67152. * @param index agent index returned by addAgent
  67153. * @returns world space velocity
  67154. */
  67155. getAgentVelocity(index: number): Vector3;
  67156. /**
  67157. * Returns the agent velocity result in world space
  67158. * @param index agent index returned by addAgent
  67159. * @param result output world space velocity
  67160. */
  67161. getAgentVelocityToRef(index: number, result: Vector3): void;
  67162. /**
  67163. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67164. * @param index agent index returned by addAgent
  67165. * @param destination targeted world position
  67166. */
  67167. agentGoto(index: number, destination: Vector3): void;
  67168. /**
  67169. * Teleport the agent to a new position
  67170. * @param index agent index returned by addAgent
  67171. * @param destination targeted world position
  67172. */
  67173. agentTeleport(index: number, destination: Vector3): void;
  67174. /**
  67175. * Update agent parameters
  67176. * @param index agent index returned by addAgent
  67177. * @param parameters agent parameters
  67178. */
  67179. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67180. /**
  67181. * remove a particular agent previously created
  67182. * @param index agent index returned by addAgent
  67183. */
  67184. removeAgent(index: number): void;
  67185. /**
  67186. * get the list of all agents attached to this crowd
  67187. * @returns list of agent indices
  67188. */
  67189. getAgents(): number[];
  67190. /**
  67191. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67192. * @param deltaTime in seconds
  67193. */
  67194. update(deltaTime: number): void;
  67195. /**
  67196. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67197. * The queries will try to find a solution within those bounds
  67198. * default is (1,1,1)
  67199. * @param extent x,y,z value that define the extent around the queries point of reference
  67200. */
  67201. setDefaultQueryExtent(extent: Vector3): void;
  67202. /**
  67203. * Get the Bounding box extent specified by setDefaultQueryExtent
  67204. * @returns the box extent values
  67205. */
  67206. getDefaultQueryExtent(): Vector3;
  67207. /**
  67208. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67209. * @param result output the box extent values
  67210. */
  67211. getDefaultQueryExtentToRef(result: Vector3): void;
  67212. /**
  67213. * Release all resources
  67214. */
  67215. dispose(): void;
  67216. }
  67217. }
  67218. declare module BABYLON {
  67219. /**
  67220. * Class used to enable access to IndexedDB
  67221. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67222. */
  67223. export class Database implements IOfflineProvider {
  67224. private _callbackManifestChecked;
  67225. private _currentSceneUrl;
  67226. private _db;
  67227. private _enableSceneOffline;
  67228. private _enableTexturesOffline;
  67229. private _manifestVersionFound;
  67230. private _mustUpdateRessources;
  67231. private _hasReachedQuota;
  67232. private _isSupported;
  67233. private _idbFactory;
  67234. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67235. private static IsUASupportingBlobStorage;
  67236. /**
  67237. * Gets a boolean indicating if Database storate is enabled (off by default)
  67238. */
  67239. static IDBStorageEnabled: boolean;
  67240. /**
  67241. * Gets a boolean indicating if scene must be saved in the database
  67242. */
  67243. get enableSceneOffline(): boolean;
  67244. /**
  67245. * Gets a boolean indicating if textures must be saved in the database
  67246. */
  67247. get enableTexturesOffline(): boolean;
  67248. /**
  67249. * Creates a new Database
  67250. * @param urlToScene defines the url to load the scene
  67251. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67252. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67253. */
  67254. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67255. private static _ParseURL;
  67256. private static _ReturnFullUrlLocation;
  67257. private _checkManifestFile;
  67258. /**
  67259. * Open the database and make it available
  67260. * @param successCallback defines the callback to call on success
  67261. * @param errorCallback defines the callback to call on error
  67262. */
  67263. open(successCallback: () => void, errorCallback: () => void): void;
  67264. /**
  67265. * Loads an image from the database
  67266. * @param url defines the url to load from
  67267. * @param image defines the target DOM image
  67268. */
  67269. loadImage(url: string, image: HTMLImageElement): void;
  67270. private _loadImageFromDBAsync;
  67271. private _saveImageIntoDBAsync;
  67272. private _checkVersionFromDB;
  67273. private _loadVersionFromDBAsync;
  67274. private _saveVersionIntoDBAsync;
  67275. /**
  67276. * Loads a file from database
  67277. * @param url defines the URL to load from
  67278. * @param sceneLoaded defines a callback to call on success
  67279. * @param progressCallBack defines a callback to call when progress changed
  67280. * @param errorCallback defines a callback to call on error
  67281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67282. */
  67283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67284. private _loadFileAsync;
  67285. private _saveFileAsync;
  67286. /**
  67287. * Validates if xhr data is correct
  67288. * @param xhr defines the request to validate
  67289. * @param dataType defines the expected data type
  67290. * @returns true if data is correct
  67291. */
  67292. private static _ValidateXHRData;
  67293. }
  67294. }
  67295. declare module BABYLON {
  67296. /** @hidden */
  67297. export var gpuUpdateParticlesPixelShader: {
  67298. name: string;
  67299. shader: string;
  67300. };
  67301. }
  67302. declare module BABYLON {
  67303. /** @hidden */
  67304. export var gpuUpdateParticlesVertexShader: {
  67305. name: string;
  67306. shader: string;
  67307. };
  67308. }
  67309. declare module BABYLON {
  67310. /** @hidden */
  67311. export var clipPlaneFragmentDeclaration2: {
  67312. name: string;
  67313. shader: string;
  67314. };
  67315. }
  67316. declare module BABYLON {
  67317. /** @hidden */
  67318. export var gpuRenderParticlesPixelShader: {
  67319. name: string;
  67320. shader: string;
  67321. };
  67322. }
  67323. declare module BABYLON {
  67324. /** @hidden */
  67325. export var clipPlaneVertexDeclaration2: {
  67326. name: string;
  67327. shader: string;
  67328. };
  67329. }
  67330. declare module BABYLON {
  67331. /** @hidden */
  67332. export var gpuRenderParticlesVertexShader: {
  67333. name: string;
  67334. shader: string;
  67335. };
  67336. }
  67337. declare module BABYLON {
  67338. /**
  67339. * This represents a GPU particle system in Babylon
  67340. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67341. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67342. */
  67343. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67344. /**
  67345. * The layer mask we are rendering the particles through.
  67346. */
  67347. layerMask: number;
  67348. private _capacity;
  67349. private _activeCount;
  67350. private _currentActiveCount;
  67351. private _accumulatedCount;
  67352. private _renderEffect;
  67353. private _updateEffect;
  67354. private _buffer0;
  67355. private _buffer1;
  67356. private _spriteBuffer;
  67357. private _updateVAO;
  67358. private _renderVAO;
  67359. private _targetIndex;
  67360. private _sourceBuffer;
  67361. private _targetBuffer;
  67362. private _currentRenderId;
  67363. private _started;
  67364. private _stopped;
  67365. private _timeDelta;
  67366. private _randomTexture;
  67367. private _randomTexture2;
  67368. private _attributesStrideSize;
  67369. private _updateEffectOptions;
  67370. private _randomTextureSize;
  67371. private _actualFrame;
  67372. private _customEffect;
  67373. private readonly _rawTextureWidth;
  67374. /**
  67375. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67376. */
  67377. static get IsSupported(): boolean;
  67378. /**
  67379. * An event triggered when the system is disposed.
  67380. */
  67381. onDisposeObservable: Observable<IParticleSystem>;
  67382. /**
  67383. * Gets the maximum number of particles active at the same time.
  67384. * @returns The max number of active particles.
  67385. */
  67386. getCapacity(): number;
  67387. /**
  67388. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67389. * to override the particles.
  67390. */
  67391. forceDepthWrite: boolean;
  67392. /**
  67393. * Gets or set the number of active particles
  67394. */
  67395. get activeParticleCount(): number;
  67396. set activeParticleCount(value: number);
  67397. private _preWarmDone;
  67398. /**
  67399. * Specifies if the particles are updated in emitter local space or world space.
  67400. */
  67401. isLocal: boolean;
  67402. /** Gets or sets a matrix to use to compute projection */
  67403. defaultProjectionMatrix: Matrix;
  67404. /**
  67405. * Is this system ready to be used/rendered
  67406. * @return true if the system is ready
  67407. */
  67408. isReady(): boolean;
  67409. /**
  67410. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67411. * @returns True if it has been started, otherwise false.
  67412. */
  67413. isStarted(): boolean;
  67414. /**
  67415. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67416. * @returns True if it has been stopped, otherwise false.
  67417. */
  67418. isStopped(): boolean;
  67419. /**
  67420. * Gets a boolean indicating that the system is stopping
  67421. * @returns true if the system is currently stopping
  67422. */
  67423. isStopping(): boolean;
  67424. /**
  67425. * Gets the number of particles active at the same time.
  67426. * @returns The number of active particles.
  67427. */
  67428. getActiveCount(): number;
  67429. /**
  67430. * Starts the particle system and begins to emit
  67431. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67432. */
  67433. start(delay?: number): void;
  67434. /**
  67435. * Stops the particle system.
  67436. */
  67437. stop(): void;
  67438. /**
  67439. * Remove all active particles
  67440. */
  67441. reset(): void;
  67442. /**
  67443. * Returns the string "GPUParticleSystem"
  67444. * @returns a string containing the class name
  67445. */
  67446. getClassName(): string;
  67447. /**
  67448. * Gets the custom effect used to render the particles
  67449. * @param blendMode Blend mode for which the effect should be retrieved
  67450. * @returns The effect
  67451. */
  67452. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67453. /**
  67454. * Sets the custom effect used to render the particles
  67455. * @param effect The effect to set
  67456. * @param blendMode Blend mode for which the effect should be set
  67457. */
  67458. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67459. /** @hidden */
  67460. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67461. /**
  67462. * Observable that will be called just before the particles are drawn
  67463. */
  67464. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67465. /**
  67466. * Gets the name of the particle vertex shader
  67467. */
  67468. get vertexShaderName(): string;
  67469. private _colorGradientsTexture;
  67470. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67471. /**
  67472. * Adds a new color gradient
  67473. * @param gradient defines the gradient to use (between 0 and 1)
  67474. * @param color1 defines the color to affect to the specified gradient
  67475. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67476. * @returns the current particle system
  67477. */
  67478. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67479. private _refreshColorGradient;
  67480. /** Force the system to rebuild all gradients that need to be resync */
  67481. forceRefreshGradients(): void;
  67482. /**
  67483. * Remove a specific color gradient
  67484. * @param gradient defines the gradient to remove
  67485. * @returns the current particle system
  67486. */
  67487. removeColorGradient(gradient: number): GPUParticleSystem;
  67488. private _angularSpeedGradientsTexture;
  67489. private _sizeGradientsTexture;
  67490. private _velocityGradientsTexture;
  67491. private _limitVelocityGradientsTexture;
  67492. private _dragGradientsTexture;
  67493. private _addFactorGradient;
  67494. /**
  67495. * Adds a new size gradient
  67496. * @param gradient defines the gradient to use (between 0 and 1)
  67497. * @param factor defines the size factor to affect to the specified gradient
  67498. * @returns the current particle system
  67499. */
  67500. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67501. /**
  67502. * Remove a specific size gradient
  67503. * @param gradient defines the gradient to remove
  67504. * @returns the current particle system
  67505. */
  67506. removeSizeGradient(gradient: number): GPUParticleSystem;
  67507. private _refreshFactorGradient;
  67508. /**
  67509. * Adds a new angular speed gradient
  67510. * @param gradient defines the gradient to use (between 0 and 1)
  67511. * @param factor defines the angular speed to affect to the specified gradient
  67512. * @returns the current particle system
  67513. */
  67514. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67515. /**
  67516. * Remove a specific angular speed gradient
  67517. * @param gradient defines the gradient to remove
  67518. * @returns the current particle system
  67519. */
  67520. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67521. /**
  67522. * Adds a new velocity gradient
  67523. * @param gradient defines the gradient to use (between 0 and 1)
  67524. * @param factor defines the velocity to affect to the specified gradient
  67525. * @returns the current particle system
  67526. */
  67527. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67528. /**
  67529. * Remove a specific velocity gradient
  67530. * @param gradient defines the gradient to remove
  67531. * @returns the current particle system
  67532. */
  67533. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67534. /**
  67535. * Adds a new limit velocity gradient
  67536. * @param gradient defines the gradient to use (between 0 and 1)
  67537. * @param factor defines the limit velocity value to affect to the specified gradient
  67538. * @returns the current particle system
  67539. */
  67540. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67541. /**
  67542. * Remove a specific limit velocity gradient
  67543. * @param gradient defines the gradient to remove
  67544. * @returns the current particle system
  67545. */
  67546. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67547. /**
  67548. * Adds a new drag gradient
  67549. * @param gradient defines the gradient to use (between 0 and 1)
  67550. * @param factor defines the drag value to affect to the specified gradient
  67551. * @returns the current particle system
  67552. */
  67553. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67554. /**
  67555. * Remove a specific drag gradient
  67556. * @param gradient defines the gradient to remove
  67557. * @returns the current particle system
  67558. */
  67559. removeDragGradient(gradient: number): GPUParticleSystem;
  67560. /**
  67561. * Not supported by GPUParticleSystem
  67562. * @param gradient defines the gradient to use (between 0 and 1)
  67563. * @param factor defines the emit rate value to affect to the specified gradient
  67564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67565. * @returns the current particle system
  67566. */
  67567. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67568. /**
  67569. * Not supported by GPUParticleSystem
  67570. * @param gradient defines the gradient to remove
  67571. * @returns the current particle system
  67572. */
  67573. removeEmitRateGradient(gradient: number): IParticleSystem;
  67574. /**
  67575. * Not supported by GPUParticleSystem
  67576. * @param gradient defines the gradient to use (between 0 and 1)
  67577. * @param factor defines the start size value to affect to the specified gradient
  67578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67579. * @returns the current particle system
  67580. */
  67581. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67582. /**
  67583. * Not supported by GPUParticleSystem
  67584. * @param gradient defines the gradient to remove
  67585. * @returns the current particle system
  67586. */
  67587. removeStartSizeGradient(gradient: number): IParticleSystem;
  67588. /**
  67589. * Not supported by GPUParticleSystem
  67590. * @param gradient defines the gradient to use (between 0 and 1)
  67591. * @param min defines the color remap minimal range
  67592. * @param max defines the color remap maximal range
  67593. * @returns the current particle system
  67594. */
  67595. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67596. /**
  67597. * Not supported by GPUParticleSystem
  67598. * @param gradient defines the gradient to remove
  67599. * @returns the current particle system
  67600. */
  67601. removeColorRemapGradient(): IParticleSystem;
  67602. /**
  67603. * Not supported by GPUParticleSystem
  67604. * @param gradient defines the gradient to use (between 0 and 1)
  67605. * @param min defines the alpha remap minimal range
  67606. * @param max defines the alpha remap maximal range
  67607. * @returns the current particle system
  67608. */
  67609. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67610. /**
  67611. * Not supported by GPUParticleSystem
  67612. * @param gradient defines the gradient to remove
  67613. * @returns the current particle system
  67614. */
  67615. removeAlphaRemapGradient(): IParticleSystem;
  67616. /**
  67617. * Not supported by GPUParticleSystem
  67618. * @param gradient defines the gradient to use (between 0 and 1)
  67619. * @param color defines the color to affect to the specified gradient
  67620. * @returns the current particle system
  67621. */
  67622. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67623. /**
  67624. * Not supported by GPUParticleSystem
  67625. * @param gradient defines the gradient to remove
  67626. * @returns the current particle system
  67627. */
  67628. removeRampGradient(): IParticleSystem;
  67629. /**
  67630. * Not supported by GPUParticleSystem
  67631. * @returns the list of ramp gradients
  67632. */
  67633. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67634. /**
  67635. * Not supported by GPUParticleSystem
  67636. * Gets or sets a boolean indicating that ramp gradients must be used
  67637. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67638. */
  67639. get useRampGradients(): boolean;
  67640. set useRampGradients(value: boolean);
  67641. /**
  67642. * Not supported by GPUParticleSystem
  67643. * @param gradient defines the gradient to use (between 0 and 1)
  67644. * @param factor defines the life time factor to affect to the specified gradient
  67645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67646. * @returns the current particle system
  67647. */
  67648. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67649. /**
  67650. * Not supported by GPUParticleSystem
  67651. * @param gradient defines the gradient to remove
  67652. * @returns the current particle system
  67653. */
  67654. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67655. /**
  67656. * Instantiates a GPU particle system.
  67657. * 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.
  67658. * @param name The name of the particle system
  67659. * @param options The options used to create the system
  67660. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67661. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67662. * @param customEffect a custom effect used to change the way particles are rendered by default
  67663. */
  67664. constructor(name: string, options: Partial<{
  67665. capacity: number;
  67666. randomTextureSize: number;
  67667. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67668. protected _reset(): void;
  67669. private _createUpdateVAO;
  67670. private _createRenderVAO;
  67671. private _initialize;
  67672. /** @hidden */
  67673. _recreateUpdateEffect(): void;
  67674. private _getEffect;
  67675. /**
  67676. * Fill the defines array according to the current settings of the particle system
  67677. * @param defines Array to be updated
  67678. * @param blendMode blend mode to take into account when updating the array
  67679. */
  67680. fillDefines(defines: Array<string>, blendMode?: number): void;
  67681. /**
  67682. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67683. * @param uniforms Uniforms array to fill
  67684. * @param attributes Attributes array to fill
  67685. * @param samplers Samplers array to fill
  67686. */
  67687. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67688. /** @hidden */
  67689. _recreateRenderEffect(): Effect;
  67690. /**
  67691. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67692. * @param preWarm defines if we are in the pre-warmimg phase
  67693. */
  67694. animate(preWarm?: boolean): void;
  67695. private _createFactorGradientTexture;
  67696. private _createSizeGradientTexture;
  67697. private _createAngularSpeedGradientTexture;
  67698. private _createVelocityGradientTexture;
  67699. private _createLimitVelocityGradientTexture;
  67700. private _createDragGradientTexture;
  67701. private _createColorGradientTexture;
  67702. /**
  67703. * Renders the particle system in its current state
  67704. * @param preWarm defines if the system should only update the particles but not render them
  67705. * @returns the current number of particles
  67706. */
  67707. render(preWarm?: boolean): number;
  67708. /**
  67709. * Rebuilds the particle system
  67710. */
  67711. rebuild(): void;
  67712. private _releaseBuffers;
  67713. private _releaseVAOs;
  67714. /**
  67715. * Disposes the particle system and free the associated resources
  67716. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67717. */
  67718. dispose(disposeTexture?: boolean): void;
  67719. /**
  67720. * Clones the particle system.
  67721. * @param name The name of the cloned object
  67722. * @param newEmitter The new emitter to use
  67723. * @returns the cloned particle system
  67724. */
  67725. clone(name: string, newEmitter: any): GPUParticleSystem;
  67726. /**
  67727. * Serializes the particle system to a JSON object
  67728. * @param serializeTexture defines if the texture must be serialized as well
  67729. * @returns the JSON object
  67730. */
  67731. serialize(serializeTexture?: boolean): any;
  67732. /**
  67733. * Parses a JSON object to create a GPU particle system.
  67734. * @param parsedParticleSystem The JSON object to parse
  67735. * @param sceneOrEngine The scene or the engine to create the particle system in
  67736. * @param rootUrl The root url to use to load external dependencies like texture
  67737. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67738. * @returns the parsed GPU particle system
  67739. */
  67740. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67741. }
  67742. }
  67743. declare module BABYLON {
  67744. /**
  67745. * Represents a set of particle systems working together to create a specific effect
  67746. */
  67747. export class ParticleSystemSet implements IDisposable {
  67748. /**
  67749. * Gets or sets base Assets URL
  67750. */
  67751. static BaseAssetsUrl: string;
  67752. private _emitterCreationOptions;
  67753. private _emitterNode;
  67754. /**
  67755. * Gets the particle system list
  67756. */
  67757. systems: IParticleSystem[];
  67758. /**
  67759. * Gets the emitter node used with this set
  67760. */
  67761. get emitterNode(): Nullable<TransformNode>;
  67762. /**
  67763. * Creates a new emitter mesh as a sphere
  67764. * @param options defines the options used to create the sphere
  67765. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67766. * @param scene defines the hosting scene
  67767. */
  67768. setEmitterAsSphere(options: {
  67769. diameter: number;
  67770. segments: number;
  67771. color: Color3;
  67772. }, renderingGroupId: number, scene: Scene): void;
  67773. /**
  67774. * Starts all particle systems of the set
  67775. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67776. */
  67777. start(emitter?: AbstractMesh): void;
  67778. /**
  67779. * Release all associated resources
  67780. */
  67781. dispose(): void;
  67782. /**
  67783. * Serialize the set into a JSON compatible object
  67784. * @param serializeTexture defines if the texture must be serialized as well
  67785. * @returns a JSON compatible representation of the set
  67786. */
  67787. serialize(serializeTexture?: boolean): any;
  67788. /**
  67789. * Parse a new ParticleSystemSet from a serialized source
  67790. * @param data defines a JSON compatible representation of the set
  67791. * @param scene defines the hosting scene
  67792. * @param gpu defines if we want GPU particles or CPU particles
  67793. * @returns a new ParticleSystemSet
  67794. */
  67795. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67796. }
  67797. }
  67798. declare module BABYLON {
  67799. /**
  67800. * This class is made for on one-liner static method to help creating particle system set.
  67801. */
  67802. export class ParticleHelper {
  67803. /**
  67804. * Gets or sets base Assets URL
  67805. */
  67806. static BaseAssetsUrl: string;
  67807. /** Define the Url to load snippets */
  67808. static SnippetUrl: string;
  67809. /**
  67810. * Create a default particle system that you can tweak
  67811. * @param emitter defines the emitter to use
  67812. * @param capacity defines the system capacity (default is 500 particles)
  67813. * @param scene defines the hosting scene
  67814. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67815. * @returns the new Particle system
  67816. */
  67817. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67818. /**
  67819. * This is the main static method (one-liner) of this helper to create different particle systems
  67820. * @param type This string represents the type to the particle system to create
  67821. * @param scene The scene where the particle system should live
  67822. * @param gpu If the system will use gpu
  67823. * @returns the ParticleSystemSet created
  67824. */
  67825. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67826. /**
  67827. * Static function used to export a particle system to a ParticleSystemSet variable.
  67828. * Please note that the emitter shape is not exported
  67829. * @param systems defines the particle systems to export
  67830. * @returns the created particle system set
  67831. */
  67832. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67833. /**
  67834. * Creates a particle system from a snippet saved in a remote file
  67835. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67836. * @param url defines the url to load from
  67837. * @param scene defines the hosting scene
  67838. * @param gpu If the system will use gpu
  67839. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67840. * @returns a promise that will resolve to the new particle system
  67841. */
  67842. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67843. /**
  67844. * Creates a particle system from a snippet saved by the particle system editor
  67845. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  67846. * @param scene defines the hosting scene
  67847. * @param gpu If the system will use gpu
  67848. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67849. * @returns a promise that will resolve to the new particle system
  67850. */
  67851. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67852. }
  67853. }
  67854. declare module BABYLON {
  67855. interface Engine {
  67856. /**
  67857. * Create an effect to use with particle systems.
  67858. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67859. * the particle system for which you want to create a custom effect in the last parameter
  67860. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67861. * @param uniformsNames defines a list of attribute names
  67862. * @param samplers defines an array of string used to represent textures
  67863. * @param defines defines the string containing the defines to use to compile the shaders
  67864. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67865. * @param onCompiled defines a function to call when the effect creation is successful
  67866. * @param onError defines a function to call when the effect creation has failed
  67867. * @param particleSystem the particle system you want to create the effect for
  67868. * @returns the new Effect
  67869. */
  67870. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67871. }
  67872. interface Mesh {
  67873. /**
  67874. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67875. * @returns an array of IParticleSystem
  67876. */
  67877. getEmittedParticleSystems(): IParticleSystem[];
  67878. /**
  67879. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67880. * @returns an array of IParticleSystem
  67881. */
  67882. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67883. }
  67884. }
  67885. declare module BABYLON {
  67886. /** Defines the 4 color options */
  67887. export enum PointColor {
  67888. /** color value */
  67889. Color = 2,
  67890. /** uv value */
  67891. UV = 1,
  67892. /** random value */
  67893. Random = 0,
  67894. /** stated value */
  67895. Stated = 3
  67896. }
  67897. /**
  67898. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67899. * 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.
  67900. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67901. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67902. *
  67903. * Full documentation here : TO BE ENTERED
  67904. */
  67905. export class PointsCloudSystem implements IDisposable {
  67906. /**
  67907. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67908. * Example : var p = SPS.particles[i];
  67909. */
  67910. particles: CloudPoint[];
  67911. /**
  67912. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67913. */
  67914. nbParticles: number;
  67915. /**
  67916. * This a counter for your own usage. It's not set by any SPS functions.
  67917. */
  67918. counter: number;
  67919. /**
  67920. * The PCS name. This name is also given to the underlying mesh.
  67921. */
  67922. name: string;
  67923. /**
  67924. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67925. */
  67926. mesh: Mesh;
  67927. /**
  67928. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67929. * Please read :
  67930. */
  67931. vars: any;
  67932. /**
  67933. * @hidden
  67934. */
  67935. _size: number;
  67936. private _scene;
  67937. private _promises;
  67938. private _positions;
  67939. private _indices;
  67940. private _normals;
  67941. private _colors;
  67942. private _uvs;
  67943. private _indices32;
  67944. private _positions32;
  67945. private _colors32;
  67946. private _uvs32;
  67947. private _updatable;
  67948. private _isVisibilityBoxLocked;
  67949. private _alwaysVisible;
  67950. private _groups;
  67951. private _groupCounter;
  67952. private _computeParticleColor;
  67953. private _computeParticleTexture;
  67954. private _computeParticleRotation;
  67955. private _computeBoundingBox;
  67956. private _isReady;
  67957. /**
  67958. * Creates a PCS (Points Cloud System) object
  67959. * @param name (String) is the PCS name, this will be the underlying mesh name
  67960. * @param pointSize (number) is the size for each point
  67961. * @param scene (Scene) is the scene in which the PCS is added
  67962. * @param options defines the options of the PCS e.g.
  67963. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67964. */
  67965. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67966. updatable?: boolean;
  67967. });
  67968. /**
  67969. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67970. * If no points were added to the PCS, the returned mesh is just a single point.
  67971. * @returns a promise for the created mesh
  67972. */
  67973. buildMeshAsync(): Promise<Mesh>;
  67974. /**
  67975. * @hidden
  67976. */
  67977. private _buildMesh;
  67978. private _addParticle;
  67979. private _randomUnitVector;
  67980. private _getColorIndicesForCoord;
  67981. private _setPointsColorOrUV;
  67982. private _colorFromTexture;
  67983. private _calculateDensity;
  67984. /**
  67985. * Adds points to the PCS in random positions within a unit sphere
  67986. * @param nb (positive integer) the number of particles to be created from this model
  67987. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67988. * @returns the number of groups in the system
  67989. */
  67990. addPoints(nb: number, pointFunction?: any): number;
  67991. /**
  67992. * Adds points to the PCS from the surface of the model shape
  67993. * @param mesh is any Mesh object that will be used as a surface model for the points
  67994. * @param nb (positive integer) the number of particles to be created from this model
  67995. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67996. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67997. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67998. * @returns the number of groups in the system
  67999. */
  68000. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68001. /**
  68002. * Adds points to the PCS inside the model shape
  68003. * @param mesh is any Mesh object that will be used as a surface model for the points
  68004. * @param nb (positive integer) the number of particles to be created from this model
  68005. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68006. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68007. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68008. * @returns the number of groups in the system
  68009. */
  68010. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68011. /**
  68012. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68013. * This method calls `updateParticle()` for each particle of the SPS.
  68014. * For an animated SPS, it is usually called within the render loop.
  68015. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68016. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68017. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68018. * @returns the PCS.
  68019. */
  68020. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68021. /**
  68022. * Disposes the PCS.
  68023. */
  68024. dispose(): void;
  68025. /**
  68026. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68027. * doc :
  68028. * @returns the PCS.
  68029. */
  68030. refreshVisibleSize(): PointsCloudSystem;
  68031. /**
  68032. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68033. * @param size the size (float) of the visibility box
  68034. * note : this doesn't lock the PCS mesh bounding box.
  68035. * doc :
  68036. */
  68037. setVisibilityBox(size: number): void;
  68038. /**
  68039. * Gets whether the PCS is always visible or not
  68040. * doc :
  68041. */
  68042. get isAlwaysVisible(): boolean;
  68043. /**
  68044. * Sets the PCS as always visible or not
  68045. * doc :
  68046. */
  68047. set isAlwaysVisible(val: boolean);
  68048. /**
  68049. * Tells to `setParticles()` to compute the particle rotations or not
  68050. * Default value : false. The PCS is faster when it's set to false
  68051. * Note : particle rotations are only applied to parent particles
  68052. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68053. */
  68054. set computeParticleRotation(val: boolean);
  68055. /**
  68056. * Tells to `setParticles()` to compute the particle colors or not.
  68057. * Default value : true. The PCS is faster when it's set to false.
  68058. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68059. */
  68060. set computeParticleColor(val: boolean);
  68061. set computeParticleTexture(val: boolean);
  68062. /**
  68063. * Gets if `setParticles()` computes the particle colors or not.
  68064. * Default value : false. The PCS is faster when it's set to false.
  68065. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68066. */
  68067. get computeParticleColor(): boolean;
  68068. /**
  68069. * Gets if `setParticles()` computes the particle textures or not.
  68070. * Default value : false. The PCS is faster when it's set to false.
  68071. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68072. */
  68073. get computeParticleTexture(): boolean;
  68074. /**
  68075. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68076. */
  68077. set computeBoundingBox(val: boolean);
  68078. /**
  68079. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68080. */
  68081. get computeBoundingBox(): boolean;
  68082. /**
  68083. * This function does nothing. It may be overwritten to set all the particle first values.
  68084. * The PCS doesn't call this function, you may have to call it by your own.
  68085. * doc :
  68086. */
  68087. initParticles(): void;
  68088. /**
  68089. * This function does nothing. It may be overwritten to recycle a particle
  68090. * The PCS doesn't call this function, you can to call it
  68091. * doc :
  68092. * @param particle The particle to recycle
  68093. * @returns the recycled particle
  68094. */
  68095. recycleParticle(particle: CloudPoint): CloudPoint;
  68096. /**
  68097. * Updates a particle : this function should be overwritten by the user.
  68098. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68099. * doc :
  68100. * @example : just set a particle position or velocity and recycle conditions
  68101. * @param particle The particle to update
  68102. * @returns the updated particle
  68103. */
  68104. updateParticle(particle: CloudPoint): CloudPoint;
  68105. /**
  68106. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68107. * This does nothing and may be overwritten by the user.
  68108. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68109. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68110. * @param update the boolean update value actually passed to setParticles()
  68111. */
  68112. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68113. /**
  68114. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68115. * This will be passed three parameters.
  68116. * This does nothing and may be overwritten by the user.
  68117. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68118. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68119. * @param update the boolean update value actually passed to setParticles()
  68120. */
  68121. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68122. }
  68123. }
  68124. declare module BABYLON {
  68125. /**
  68126. * Represents one particle of a points cloud system.
  68127. */
  68128. export class CloudPoint {
  68129. /**
  68130. * particle global index
  68131. */
  68132. idx: number;
  68133. /**
  68134. * The color of the particle
  68135. */
  68136. color: Nullable<Color4>;
  68137. /**
  68138. * The world space position of the particle.
  68139. */
  68140. position: Vector3;
  68141. /**
  68142. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68143. */
  68144. rotation: Vector3;
  68145. /**
  68146. * The world space rotation quaternion of the particle.
  68147. */
  68148. rotationQuaternion: Nullable<Quaternion>;
  68149. /**
  68150. * The uv of the particle.
  68151. */
  68152. uv: Nullable<Vector2>;
  68153. /**
  68154. * The current speed of the particle.
  68155. */
  68156. velocity: Vector3;
  68157. /**
  68158. * The pivot point in the particle local space.
  68159. */
  68160. pivot: Vector3;
  68161. /**
  68162. * Must the particle be translated from its pivot point in its local space ?
  68163. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68164. * Default : false
  68165. */
  68166. translateFromPivot: boolean;
  68167. /**
  68168. * Index of this particle in the global "positions" array (Internal use)
  68169. * @hidden
  68170. */
  68171. _pos: number;
  68172. /**
  68173. * @hidden Index of this particle in the global "indices" array (Internal use)
  68174. */
  68175. _ind: number;
  68176. /**
  68177. * Group this particle belongs to
  68178. */
  68179. _group: PointsGroup;
  68180. /**
  68181. * Group id of this particle
  68182. */
  68183. groupId: number;
  68184. /**
  68185. * Index of the particle in its group id (Internal use)
  68186. */
  68187. idxInGroup: number;
  68188. /**
  68189. * @hidden Particle BoundingInfo object (Internal use)
  68190. */
  68191. _boundingInfo: BoundingInfo;
  68192. /**
  68193. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68194. */
  68195. _pcs: PointsCloudSystem;
  68196. /**
  68197. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68198. */
  68199. _stillInvisible: boolean;
  68200. /**
  68201. * @hidden Last computed particle rotation matrix
  68202. */
  68203. _rotationMatrix: number[];
  68204. /**
  68205. * Parent particle Id, if any.
  68206. * Default null.
  68207. */
  68208. parentId: Nullable<number>;
  68209. /**
  68210. * @hidden Internal global position in the PCS.
  68211. */
  68212. _globalPosition: Vector3;
  68213. /**
  68214. * Creates a Point Cloud object.
  68215. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68216. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68217. * @param group (PointsGroup) is the group the particle belongs to
  68218. * @param groupId (integer) is the group identifier in the PCS.
  68219. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68220. * @param pcs defines the PCS it is associated to
  68221. */
  68222. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68223. /**
  68224. * get point size
  68225. */
  68226. get size(): Vector3;
  68227. /**
  68228. * Set point size
  68229. */
  68230. set size(scale: Vector3);
  68231. /**
  68232. * Legacy support, changed quaternion to rotationQuaternion
  68233. */
  68234. get quaternion(): Nullable<Quaternion>;
  68235. /**
  68236. * Legacy support, changed quaternion to rotationQuaternion
  68237. */
  68238. set quaternion(q: Nullable<Quaternion>);
  68239. /**
  68240. * Returns a boolean. True if the particle intersects a mesh, else false
  68241. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68242. * @param target is the object (point or mesh) what the intersection is computed against
  68243. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68244. * @returns true if it intersects
  68245. */
  68246. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68247. /**
  68248. * get the rotation matrix of the particle
  68249. * @hidden
  68250. */
  68251. getRotationMatrix(m: Matrix): void;
  68252. }
  68253. /**
  68254. * Represents a group of points in a points cloud system
  68255. * * PCS internal tool, don't use it manually.
  68256. */
  68257. export class PointsGroup {
  68258. /**
  68259. * The group id
  68260. * @hidden
  68261. */
  68262. groupID: number;
  68263. /**
  68264. * image data for group (internal use)
  68265. * @hidden
  68266. */
  68267. _groupImageData: Nullable<ArrayBufferView>;
  68268. /**
  68269. * Image Width (internal use)
  68270. * @hidden
  68271. */
  68272. _groupImgWidth: number;
  68273. /**
  68274. * Image Height (internal use)
  68275. * @hidden
  68276. */
  68277. _groupImgHeight: number;
  68278. /**
  68279. * Custom position function (internal use)
  68280. * @hidden
  68281. */
  68282. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68283. /**
  68284. * density per facet for surface points
  68285. * @hidden
  68286. */
  68287. _groupDensity: number[];
  68288. /**
  68289. * Only when points are colored by texture carries pointer to texture list array
  68290. * @hidden
  68291. */
  68292. _textureNb: number;
  68293. /**
  68294. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68295. * PCS internal tool, don't use it manually.
  68296. * @hidden
  68297. */
  68298. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68299. }
  68300. }
  68301. declare module BABYLON {
  68302. interface Scene {
  68303. /** @hidden (Backing field) */
  68304. _physicsEngine: Nullable<IPhysicsEngine>;
  68305. /** @hidden */
  68306. _physicsTimeAccumulator: number;
  68307. /**
  68308. * Gets the current physics engine
  68309. * @returns a IPhysicsEngine or null if none attached
  68310. */
  68311. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68312. /**
  68313. * Enables physics to the current scene
  68314. * @param gravity defines the scene's gravity for the physics engine
  68315. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68316. * @return a boolean indicating if the physics engine was initialized
  68317. */
  68318. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68319. /**
  68320. * Disables and disposes the physics engine associated with the scene
  68321. */
  68322. disablePhysicsEngine(): void;
  68323. /**
  68324. * Gets a boolean indicating if there is an active physics engine
  68325. * @returns a boolean indicating if there is an active physics engine
  68326. */
  68327. isPhysicsEnabled(): boolean;
  68328. /**
  68329. * Deletes a physics compound impostor
  68330. * @param compound defines the compound to delete
  68331. */
  68332. deleteCompoundImpostor(compound: any): void;
  68333. /**
  68334. * An event triggered when physic simulation is about to be run
  68335. */
  68336. onBeforePhysicsObservable: Observable<Scene>;
  68337. /**
  68338. * An event triggered when physic simulation has been done
  68339. */
  68340. onAfterPhysicsObservable: Observable<Scene>;
  68341. }
  68342. interface AbstractMesh {
  68343. /** @hidden */
  68344. _physicsImpostor: Nullable<PhysicsImpostor>;
  68345. /**
  68346. * Gets or sets impostor used for physic simulation
  68347. * @see https://doc.babylonjs.com/features/physics_engine
  68348. */
  68349. physicsImpostor: Nullable<PhysicsImpostor>;
  68350. /**
  68351. * Gets the current physics impostor
  68352. * @see https://doc.babylonjs.com/features/physics_engine
  68353. * @returns a physics impostor or null
  68354. */
  68355. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68356. /** Apply a physic impulse to the mesh
  68357. * @param force defines the force to apply
  68358. * @param contactPoint defines where to apply the force
  68359. * @returns the current mesh
  68360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68361. */
  68362. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68363. /**
  68364. * Creates a physic joint between two meshes
  68365. * @param otherMesh defines the other mesh to use
  68366. * @param pivot1 defines the pivot to use on this mesh
  68367. * @param pivot2 defines the pivot to use on the other mesh
  68368. * @param options defines additional options (can be plugin dependent)
  68369. * @returns the current mesh
  68370. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68371. */
  68372. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68373. /** @hidden */
  68374. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68375. }
  68376. /**
  68377. * Defines the physics engine scene component responsible to manage a physics engine
  68378. */
  68379. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68380. /**
  68381. * The component name helpful to identify the component in the list of scene components.
  68382. */
  68383. readonly name: string;
  68384. /**
  68385. * The scene the component belongs to.
  68386. */
  68387. scene: Scene;
  68388. /**
  68389. * Creates a new instance of the component for the given scene
  68390. * @param scene Defines the scene to register the component in
  68391. */
  68392. constructor(scene: Scene);
  68393. /**
  68394. * Registers the component in a given scene
  68395. */
  68396. register(): void;
  68397. /**
  68398. * Rebuilds the elements related to this component in case of
  68399. * context lost for instance.
  68400. */
  68401. rebuild(): void;
  68402. /**
  68403. * Disposes the component and the associated ressources
  68404. */
  68405. dispose(): void;
  68406. }
  68407. }
  68408. declare module BABYLON {
  68409. /**
  68410. * A helper for physics simulations
  68411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68412. */
  68413. export class PhysicsHelper {
  68414. private _scene;
  68415. private _physicsEngine;
  68416. /**
  68417. * Initializes the Physics helper
  68418. * @param scene Babylon.js scene
  68419. */
  68420. constructor(scene: Scene);
  68421. /**
  68422. * Applies a radial explosion impulse
  68423. * @param origin the origin of the explosion
  68424. * @param radiusOrEventOptions the radius or the options of radial explosion
  68425. * @param strength the explosion strength
  68426. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68427. * @returns A physics radial explosion event, or null
  68428. */
  68429. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68430. /**
  68431. * Applies a radial explosion force
  68432. * @param origin the origin of the explosion
  68433. * @param radiusOrEventOptions the radius or the options of radial explosion
  68434. * @param strength the explosion strength
  68435. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68436. * @returns A physics radial explosion event, or null
  68437. */
  68438. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68439. /**
  68440. * Creates a gravitational field
  68441. * @param origin the origin of the explosion
  68442. * @param radiusOrEventOptions the radius or the options of radial explosion
  68443. * @param strength the explosion strength
  68444. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68445. * @returns A physics gravitational field event, or null
  68446. */
  68447. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68448. /**
  68449. * Creates a physics updraft event
  68450. * @param origin the origin of the updraft
  68451. * @param radiusOrEventOptions the radius or the options of the updraft
  68452. * @param strength the strength of the updraft
  68453. * @param height the height of the updraft
  68454. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68455. * @returns A physics updraft event, or null
  68456. */
  68457. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68458. /**
  68459. * Creates a physics vortex event
  68460. * @param origin the of the vortex
  68461. * @param radiusOrEventOptions the radius or the options of the vortex
  68462. * @param strength the strength of the vortex
  68463. * @param height the height of the vortex
  68464. * @returns a Physics vortex event, or null
  68465. * A physics vortex event or null
  68466. */
  68467. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68468. }
  68469. /**
  68470. * Represents a physics radial explosion event
  68471. */
  68472. class PhysicsRadialExplosionEvent {
  68473. private _scene;
  68474. private _options;
  68475. private _sphere;
  68476. private _dataFetched;
  68477. /**
  68478. * Initializes a radial explosioin event
  68479. * @param _scene BabylonJS scene
  68480. * @param _options The options for the vortex event
  68481. */
  68482. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68483. /**
  68484. * Returns the data related to the radial explosion event (sphere).
  68485. * @returns The radial explosion event data
  68486. */
  68487. getData(): PhysicsRadialExplosionEventData;
  68488. /**
  68489. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68490. * @param impostor A physics imposter
  68491. * @param origin the origin of the explosion
  68492. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68493. */
  68494. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68495. /**
  68496. * Triggers affecterd impostors callbacks
  68497. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68498. */
  68499. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68500. /**
  68501. * Disposes the sphere.
  68502. * @param force Specifies if the sphere should be disposed by force
  68503. */
  68504. dispose(force?: boolean): void;
  68505. /*** Helpers ***/
  68506. private _prepareSphere;
  68507. private _intersectsWithSphere;
  68508. }
  68509. /**
  68510. * Represents a gravitational field event
  68511. */
  68512. class PhysicsGravitationalFieldEvent {
  68513. private _physicsHelper;
  68514. private _scene;
  68515. private _origin;
  68516. private _options;
  68517. private _tickCallback;
  68518. private _sphere;
  68519. private _dataFetched;
  68520. /**
  68521. * Initializes the physics gravitational field event
  68522. * @param _physicsHelper A physics helper
  68523. * @param _scene BabylonJS scene
  68524. * @param _origin The origin position of the gravitational field event
  68525. * @param _options The options for the vortex event
  68526. */
  68527. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68528. /**
  68529. * Returns the data related to the gravitational field event (sphere).
  68530. * @returns A gravitational field event
  68531. */
  68532. getData(): PhysicsGravitationalFieldEventData;
  68533. /**
  68534. * Enables the gravitational field.
  68535. */
  68536. enable(): void;
  68537. /**
  68538. * Disables the gravitational field.
  68539. */
  68540. disable(): void;
  68541. /**
  68542. * Disposes the sphere.
  68543. * @param force The force to dispose from the gravitational field event
  68544. */
  68545. dispose(force?: boolean): void;
  68546. private _tick;
  68547. }
  68548. /**
  68549. * Represents a physics updraft event
  68550. */
  68551. class PhysicsUpdraftEvent {
  68552. private _scene;
  68553. private _origin;
  68554. private _options;
  68555. private _physicsEngine;
  68556. private _originTop;
  68557. private _originDirection;
  68558. private _tickCallback;
  68559. private _cylinder;
  68560. private _cylinderPosition;
  68561. private _dataFetched;
  68562. /**
  68563. * Initializes the physics updraft event
  68564. * @param _scene BabylonJS scene
  68565. * @param _origin The origin position of the updraft
  68566. * @param _options The options for the updraft event
  68567. */
  68568. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68569. /**
  68570. * Returns the data related to the updraft event (cylinder).
  68571. * @returns A physics updraft event
  68572. */
  68573. getData(): PhysicsUpdraftEventData;
  68574. /**
  68575. * Enables the updraft.
  68576. */
  68577. enable(): void;
  68578. /**
  68579. * Disables the updraft.
  68580. */
  68581. disable(): void;
  68582. /**
  68583. * Disposes the cylinder.
  68584. * @param force Specifies if the updraft should be disposed by force
  68585. */
  68586. dispose(force?: boolean): void;
  68587. private getImpostorHitData;
  68588. private _tick;
  68589. /*** Helpers ***/
  68590. private _prepareCylinder;
  68591. private _intersectsWithCylinder;
  68592. }
  68593. /**
  68594. * Represents a physics vortex event
  68595. */
  68596. class PhysicsVortexEvent {
  68597. private _scene;
  68598. private _origin;
  68599. private _options;
  68600. private _physicsEngine;
  68601. private _originTop;
  68602. private _tickCallback;
  68603. private _cylinder;
  68604. private _cylinderPosition;
  68605. private _dataFetched;
  68606. /**
  68607. * Initializes the physics vortex event
  68608. * @param _scene The BabylonJS scene
  68609. * @param _origin The origin position of the vortex
  68610. * @param _options The options for the vortex event
  68611. */
  68612. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68613. /**
  68614. * Returns the data related to the vortex event (cylinder).
  68615. * @returns The physics vortex event data
  68616. */
  68617. getData(): PhysicsVortexEventData;
  68618. /**
  68619. * Enables the vortex.
  68620. */
  68621. enable(): void;
  68622. /**
  68623. * Disables the cortex.
  68624. */
  68625. disable(): void;
  68626. /**
  68627. * Disposes the sphere.
  68628. * @param force
  68629. */
  68630. dispose(force?: boolean): void;
  68631. private getImpostorHitData;
  68632. private _tick;
  68633. /*** Helpers ***/
  68634. private _prepareCylinder;
  68635. private _intersectsWithCylinder;
  68636. }
  68637. /**
  68638. * Options fot the radial explosion event
  68639. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68640. */
  68641. export class PhysicsRadialExplosionEventOptions {
  68642. /**
  68643. * The radius of the sphere for the radial explosion.
  68644. */
  68645. radius: number;
  68646. /**
  68647. * The strenth of the explosion.
  68648. */
  68649. strength: number;
  68650. /**
  68651. * The strenght of the force in correspondence to the distance of the affected object
  68652. */
  68653. falloff: PhysicsRadialImpulseFalloff;
  68654. /**
  68655. * Sphere options for the radial explosion.
  68656. */
  68657. sphere: {
  68658. segments: number;
  68659. diameter: number;
  68660. };
  68661. /**
  68662. * Sphere options for the radial explosion.
  68663. */
  68664. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68665. }
  68666. /**
  68667. * Options fot the updraft event
  68668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68669. */
  68670. export class PhysicsUpdraftEventOptions {
  68671. /**
  68672. * The radius of the cylinder for the vortex
  68673. */
  68674. radius: number;
  68675. /**
  68676. * The strenth of the updraft.
  68677. */
  68678. strength: number;
  68679. /**
  68680. * The height of the cylinder for the updraft.
  68681. */
  68682. height: number;
  68683. /**
  68684. * The mode for the the updraft.
  68685. */
  68686. updraftMode: PhysicsUpdraftMode;
  68687. }
  68688. /**
  68689. * Options fot the vortex event
  68690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68691. */
  68692. export class PhysicsVortexEventOptions {
  68693. /**
  68694. * The radius of the cylinder for the vortex
  68695. */
  68696. radius: number;
  68697. /**
  68698. * The strenth of the vortex.
  68699. */
  68700. strength: number;
  68701. /**
  68702. * The height of the cylinder for the vortex.
  68703. */
  68704. height: number;
  68705. /**
  68706. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68707. */
  68708. centripetalForceThreshold: number;
  68709. /**
  68710. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68711. */
  68712. centripetalForceMultiplier: number;
  68713. /**
  68714. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68715. */
  68716. centrifugalForceMultiplier: number;
  68717. /**
  68718. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68719. */
  68720. updraftForceMultiplier: number;
  68721. }
  68722. /**
  68723. * The strenght of the force in correspondence to the distance of the affected object
  68724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68725. */
  68726. export enum PhysicsRadialImpulseFalloff {
  68727. /** Defines that impulse is constant in strength across it's whole radius */
  68728. Constant = 0,
  68729. /** Defines that impulse gets weaker if it's further from the origin */
  68730. Linear = 1
  68731. }
  68732. /**
  68733. * The strength of the force in correspondence to the distance of the affected object
  68734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68735. */
  68736. export enum PhysicsUpdraftMode {
  68737. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68738. Center = 0,
  68739. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68740. Perpendicular = 1
  68741. }
  68742. /**
  68743. * Interface for a physics hit data
  68744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68745. */
  68746. export interface PhysicsHitData {
  68747. /**
  68748. * The force applied at the contact point
  68749. */
  68750. force: Vector3;
  68751. /**
  68752. * The contact point
  68753. */
  68754. contactPoint: Vector3;
  68755. /**
  68756. * The distance from the origin to the contact point
  68757. */
  68758. distanceFromOrigin: number;
  68759. }
  68760. /**
  68761. * Interface for radial explosion event data
  68762. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68763. */
  68764. export interface PhysicsRadialExplosionEventData {
  68765. /**
  68766. * A sphere used for the radial explosion event
  68767. */
  68768. sphere: Mesh;
  68769. }
  68770. /**
  68771. * Interface for gravitational field event data
  68772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68773. */
  68774. export interface PhysicsGravitationalFieldEventData {
  68775. /**
  68776. * A sphere mesh used for the gravitational field event
  68777. */
  68778. sphere: Mesh;
  68779. }
  68780. /**
  68781. * Interface for updraft event data
  68782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68783. */
  68784. export interface PhysicsUpdraftEventData {
  68785. /**
  68786. * A cylinder used for the updraft event
  68787. */
  68788. cylinder: Mesh;
  68789. }
  68790. /**
  68791. * Interface for vortex event data
  68792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68793. */
  68794. export interface PhysicsVortexEventData {
  68795. /**
  68796. * A cylinder used for the vortex event
  68797. */
  68798. cylinder: Mesh;
  68799. }
  68800. /**
  68801. * Interface for an affected physics impostor
  68802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68803. */
  68804. export interface PhysicsAffectedImpostorWithData {
  68805. /**
  68806. * The impostor affected by the effect
  68807. */
  68808. impostor: PhysicsImpostor;
  68809. /**
  68810. * The data about the hit/horce from the explosion
  68811. */
  68812. hitData: PhysicsHitData;
  68813. }
  68814. }
  68815. declare module BABYLON {
  68816. /** @hidden */
  68817. export var blackAndWhitePixelShader: {
  68818. name: string;
  68819. shader: string;
  68820. };
  68821. }
  68822. declare module BABYLON {
  68823. /**
  68824. * Post process used to render in black and white
  68825. */
  68826. export class BlackAndWhitePostProcess extends PostProcess {
  68827. /**
  68828. * Linear about to convert he result to black and white (default: 1)
  68829. */
  68830. degree: number;
  68831. /**
  68832. * Gets a string identifying the name of the class
  68833. * @returns "BlackAndWhitePostProcess" string
  68834. */
  68835. getClassName(): string;
  68836. /**
  68837. * Creates a black and white post process
  68838. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68839. * @param name The name of the effect.
  68840. * @param options The required width/height ratio to downsize to before computing the render pass.
  68841. * @param camera The camera to apply the render pass to.
  68842. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68843. * @param engine The engine which the post process will be applied. (default: current engine)
  68844. * @param reusable If the post process can be reused on the same frame. (default: false)
  68845. */
  68846. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68847. /** @hidden */
  68848. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  68849. }
  68850. }
  68851. declare module BABYLON {
  68852. /**
  68853. * This represents a set of one or more post processes in Babylon.
  68854. * A post process can be used to apply a shader to a texture after it is rendered.
  68855. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68856. */
  68857. export class PostProcessRenderEffect {
  68858. private _postProcesses;
  68859. private _getPostProcesses;
  68860. private _singleInstance;
  68861. private _cameras;
  68862. private _indicesForCamera;
  68863. /**
  68864. * Name of the effect
  68865. * @hidden
  68866. */
  68867. _name: string;
  68868. /**
  68869. * Instantiates a post process render effect.
  68870. * A post process can be used to apply a shader to a texture after it is rendered.
  68871. * @param engine The engine the effect is tied to
  68872. * @param name The name of the effect
  68873. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68874. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68875. */
  68876. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68877. /**
  68878. * Checks if all the post processes in the effect are supported.
  68879. */
  68880. get isSupported(): boolean;
  68881. /**
  68882. * Updates the current state of the effect
  68883. * @hidden
  68884. */
  68885. _update(): void;
  68886. /**
  68887. * Attaches the effect on cameras
  68888. * @param cameras The camera to attach to.
  68889. * @hidden
  68890. */
  68891. _attachCameras(cameras: Camera): void;
  68892. /**
  68893. * Attaches the effect on cameras
  68894. * @param cameras The camera to attach to.
  68895. * @hidden
  68896. */
  68897. _attachCameras(cameras: Camera[]): void;
  68898. /**
  68899. * Detaches the effect on cameras
  68900. * @param cameras The camera to detatch from.
  68901. * @hidden
  68902. */
  68903. _detachCameras(cameras: Camera): void;
  68904. /**
  68905. * Detatches the effect on cameras
  68906. * @param cameras The camera to detatch from.
  68907. * @hidden
  68908. */
  68909. _detachCameras(cameras: Camera[]): void;
  68910. /**
  68911. * Enables the effect on given cameras
  68912. * @param cameras The camera to enable.
  68913. * @hidden
  68914. */
  68915. _enable(cameras: Camera): void;
  68916. /**
  68917. * Enables the effect on given cameras
  68918. * @param cameras The camera to enable.
  68919. * @hidden
  68920. */
  68921. _enable(cameras: Nullable<Camera[]>): void;
  68922. /**
  68923. * Disables the effect on the given cameras
  68924. * @param cameras The camera to disable.
  68925. * @hidden
  68926. */
  68927. _disable(cameras: Camera): void;
  68928. /**
  68929. * Disables the effect on the given cameras
  68930. * @param cameras The camera to disable.
  68931. * @hidden
  68932. */
  68933. _disable(cameras: Nullable<Camera[]>): void;
  68934. /**
  68935. * Gets a list of the post processes contained in the effect.
  68936. * @param camera The camera to get the post processes on.
  68937. * @returns The list of the post processes in the effect.
  68938. */
  68939. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68940. }
  68941. }
  68942. declare module BABYLON {
  68943. /** @hidden */
  68944. export var extractHighlightsPixelShader: {
  68945. name: string;
  68946. shader: string;
  68947. };
  68948. }
  68949. declare module BABYLON {
  68950. /**
  68951. * 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.
  68952. */
  68953. export class ExtractHighlightsPostProcess extends PostProcess {
  68954. /**
  68955. * The luminance threshold, pixels below this value will be set to black.
  68956. */
  68957. threshold: number;
  68958. /** @hidden */
  68959. _exposure: number;
  68960. /**
  68961. * Post process which has the input texture to be used when performing highlight extraction
  68962. * @hidden
  68963. */
  68964. _inputPostProcess: Nullable<PostProcess>;
  68965. /**
  68966. * Gets a string identifying the name of the class
  68967. * @returns "ExtractHighlightsPostProcess" string
  68968. */
  68969. getClassName(): string;
  68970. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68971. }
  68972. }
  68973. declare module BABYLON {
  68974. /** @hidden */
  68975. export var bloomMergePixelShader: {
  68976. name: string;
  68977. shader: string;
  68978. };
  68979. }
  68980. declare module BABYLON {
  68981. /**
  68982. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68983. */
  68984. export class BloomMergePostProcess extends PostProcess {
  68985. /** Weight of the bloom to be added to the original input. */
  68986. weight: number;
  68987. /**
  68988. * Gets a string identifying the name of the class
  68989. * @returns "BloomMergePostProcess" string
  68990. */
  68991. getClassName(): string;
  68992. /**
  68993. * Creates a new instance of @see BloomMergePostProcess
  68994. * @param name The name of the effect.
  68995. * @param originalFromInput Post process which's input will be used for the merge.
  68996. * @param blurred Blurred highlights post process which's output will be used.
  68997. * @param weight Weight of the bloom to be added to the original input.
  68998. * @param options The required width/height ratio to downsize to before computing the render pass.
  68999. * @param camera The camera to apply the render pass to.
  69000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69001. * @param engine The engine which the post process will be applied. (default: current engine)
  69002. * @param reusable If the post process can be reused on the same frame. (default: false)
  69003. * @param textureType Type of textures used when performing the post process. (default: 0)
  69004. * @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)
  69005. */
  69006. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69007. /** Weight of the bloom to be added to the original input. */
  69008. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69009. }
  69010. }
  69011. declare module BABYLON {
  69012. /**
  69013. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69014. */
  69015. export class BloomEffect extends PostProcessRenderEffect {
  69016. private bloomScale;
  69017. /**
  69018. * @hidden Internal
  69019. */
  69020. _effects: Array<PostProcess>;
  69021. /**
  69022. * @hidden Internal
  69023. */
  69024. _downscale: ExtractHighlightsPostProcess;
  69025. private _blurX;
  69026. private _blurY;
  69027. private _merge;
  69028. /**
  69029. * The luminance threshold to find bright areas of the image to bloom.
  69030. */
  69031. get threshold(): number;
  69032. set threshold(value: number);
  69033. /**
  69034. * The strength of the bloom.
  69035. */
  69036. get weight(): number;
  69037. set weight(value: number);
  69038. /**
  69039. * Specifies the size of the bloom blur kernel, relative to the final output size
  69040. */
  69041. get kernel(): number;
  69042. set kernel(value: number);
  69043. /**
  69044. * Creates a new instance of @see BloomEffect
  69045. * @param scene The scene the effect belongs to.
  69046. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69047. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69048. * @param bloomWeight The the strength of bloom.
  69049. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69050. * @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)
  69051. */
  69052. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69053. /**
  69054. * Disposes each of the internal effects for a given camera.
  69055. * @param camera The camera to dispose the effect on.
  69056. */
  69057. disposeEffects(camera: Camera): void;
  69058. /**
  69059. * @hidden Internal
  69060. */
  69061. _updateEffects(): void;
  69062. /**
  69063. * Internal
  69064. * @returns if all the contained post processes are ready.
  69065. * @hidden
  69066. */
  69067. _isReady(): boolean;
  69068. }
  69069. }
  69070. declare module BABYLON {
  69071. /** @hidden */
  69072. export var chromaticAberrationPixelShader: {
  69073. name: string;
  69074. shader: string;
  69075. };
  69076. }
  69077. declare module BABYLON {
  69078. /**
  69079. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69080. */
  69081. export class ChromaticAberrationPostProcess extends PostProcess {
  69082. /**
  69083. * The amount of seperation of rgb channels (default: 30)
  69084. */
  69085. aberrationAmount: number;
  69086. /**
  69087. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69088. */
  69089. radialIntensity: number;
  69090. /**
  69091. * 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))
  69092. */
  69093. direction: Vector2;
  69094. /**
  69095. * 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))
  69096. */
  69097. centerPosition: Vector2;
  69098. /** The width of the screen to apply the effect on */
  69099. screenWidth: number;
  69100. /** The height of the screen to apply the effect on */
  69101. screenHeight: number;
  69102. /**
  69103. * Gets a string identifying the name of the class
  69104. * @returns "ChromaticAberrationPostProcess" string
  69105. */
  69106. getClassName(): string;
  69107. /**
  69108. * Creates a new instance ChromaticAberrationPostProcess
  69109. * @param name The name of the effect.
  69110. * @param screenWidth The width of the screen to apply the effect on.
  69111. * @param screenHeight The height of the screen to apply the effect on.
  69112. * @param options The required width/height ratio to downsize to before computing the render pass.
  69113. * @param camera The camera to apply the render pass to.
  69114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69115. * @param engine The engine which the post process will be applied. (default: current engine)
  69116. * @param reusable If the post process can be reused on the same frame. (default: false)
  69117. * @param textureType Type of textures used when performing the post process. (default: 0)
  69118. * @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)
  69119. */
  69120. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69121. /** @hidden */
  69122. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69123. }
  69124. }
  69125. declare module BABYLON {
  69126. /** @hidden */
  69127. export var circleOfConfusionPixelShader: {
  69128. name: string;
  69129. shader: string;
  69130. };
  69131. }
  69132. declare module BABYLON {
  69133. /**
  69134. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69135. */
  69136. export class CircleOfConfusionPostProcess extends PostProcess {
  69137. /**
  69138. * 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.
  69139. */
  69140. lensSize: number;
  69141. /**
  69142. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69143. */
  69144. fStop: number;
  69145. /**
  69146. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69147. */
  69148. focusDistance: number;
  69149. /**
  69150. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69151. */
  69152. focalLength: number;
  69153. /**
  69154. * Gets a string identifying the name of the class
  69155. * @returns "CircleOfConfusionPostProcess" string
  69156. */
  69157. getClassName(): string;
  69158. private _depthTexture;
  69159. /**
  69160. * Creates a new instance CircleOfConfusionPostProcess
  69161. * @param name The name of the effect.
  69162. * @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.
  69163. * @param options The required width/height ratio to downsize to before computing the render pass.
  69164. * @param camera The camera to apply the render pass to.
  69165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69166. * @param engine The engine which the post process will be applied. (default: current engine)
  69167. * @param reusable If the post process can be reused on the same frame. (default: false)
  69168. * @param textureType Type of textures used when performing the post process. (default: 0)
  69169. * @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)
  69170. */
  69171. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69172. /**
  69173. * 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.
  69174. */
  69175. set depthTexture(value: RenderTargetTexture);
  69176. }
  69177. }
  69178. declare module BABYLON {
  69179. /** @hidden */
  69180. export var colorCorrectionPixelShader: {
  69181. name: string;
  69182. shader: string;
  69183. };
  69184. }
  69185. declare module BABYLON {
  69186. /**
  69187. *
  69188. * This post-process allows the modification of rendered colors by using
  69189. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69190. *
  69191. * The object needs to be provided an url to a texture containing the color
  69192. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69193. * Use an image editing software to tweak the LUT to match your needs.
  69194. *
  69195. * For an example of a color LUT, see here:
  69196. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69197. * For explanations on color grading, see here:
  69198. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69199. *
  69200. */
  69201. export class ColorCorrectionPostProcess extends PostProcess {
  69202. private _colorTableTexture;
  69203. /**
  69204. * Gets the color table url used to create the LUT texture
  69205. */
  69206. colorTableUrl: string;
  69207. /**
  69208. * Gets a string identifying the name of the class
  69209. * @returns "ColorCorrectionPostProcess" string
  69210. */
  69211. getClassName(): string;
  69212. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69213. /** @hidden */
  69214. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69215. }
  69216. }
  69217. declare module BABYLON {
  69218. /** @hidden */
  69219. export var convolutionPixelShader: {
  69220. name: string;
  69221. shader: string;
  69222. };
  69223. }
  69224. declare module BABYLON {
  69225. /**
  69226. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69227. * input texture to perform effects such as edge detection or sharpening
  69228. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69229. */
  69230. export class ConvolutionPostProcess extends PostProcess {
  69231. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69232. kernel: number[];
  69233. /**
  69234. * Gets a string identifying the name of the class
  69235. * @returns "ConvolutionPostProcess" string
  69236. */
  69237. getClassName(): string;
  69238. /**
  69239. * Creates a new instance ConvolutionPostProcess
  69240. * @param name The name of the effect.
  69241. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69242. * @param options The required width/height ratio to downsize to before computing the render pass.
  69243. * @param camera The camera to apply the render pass to.
  69244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69245. * @param engine The engine which the post process will be applied. (default: current engine)
  69246. * @param reusable If the post process can be reused on the same frame. (default: false)
  69247. * @param textureType Type of textures used when performing the post process. (default: 0)
  69248. */
  69249. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69250. /** @hidden */
  69251. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69252. /**
  69253. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69254. */
  69255. static EdgeDetect0Kernel: number[];
  69256. /**
  69257. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69258. */
  69259. static EdgeDetect1Kernel: number[];
  69260. /**
  69261. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69262. */
  69263. static EdgeDetect2Kernel: number[];
  69264. /**
  69265. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69266. */
  69267. static SharpenKernel: number[];
  69268. /**
  69269. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69270. */
  69271. static EmbossKernel: number[];
  69272. /**
  69273. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69274. */
  69275. static GaussianKernel: number[];
  69276. }
  69277. }
  69278. declare module BABYLON {
  69279. /**
  69280. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69281. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69282. * based on samples that have a large difference in distance than the center pixel.
  69283. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69284. */
  69285. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69286. /**
  69287. * The direction the blur should be applied
  69288. */
  69289. direction: Vector2;
  69290. /**
  69291. * Gets a string identifying the name of the class
  69292. * @returns "DepthOfFieldBlurPostProcess" string
  69293. */
  69294. getClassName(): string;
  69295. /**
  69296. * Creates a new instance CircleOfConfusionPostProcess
  69297. * @param name The name of the effect.
  69298. * @param scene The scene the effect belongs to.
  69299. * @param direction The direction the blur should be applied.
  69300. * @param kernel The size of the kernel used to blur.
  69301. * @param options The required width/height ratio to downsize to before computing the render pass.
  69302. * @param camera The camera to apply the render pass to.
  69303. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69304. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69305. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69306. * @param engine The engine which the post process will be applied. (default: current engine)
  69307. * @param reusable If the post process can be reused on the same frame. (default: false)
  69308. * @param textureType Type of textures used when performing the post process. (default: 0)
  69309. * @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)
  69310. */
  69311. 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);
  69312. }
  69313. }
  69314. declare module BABYLON {
  69315. /** @hidden */
  69316. export var depthOfFieldMergePixelShader: {
  69317. name: string;
  69318. shader: string;
  69319. };
  69320. }
  69321. declare module BABYLON {
  69322. /**
  69323. * Options to be set when merging outputs from the default pipeline.
  69324. */
  69325. export class DepthOfFieldMergePostProcessOptions {
  69326. /**
  69327. * The original image to merge on top of
  69328. */
  69329. originalFromInput: PostProcess;
  69330. /**
  69331. * Parameters to perform the merge of the depth of field effect
  69332. */
  69333. depthOfField?: {
  69334. circleOfConfusion: PostProcess;
  69335. blurSteps: Array<PostProcess>;
  69336. };
  69337. /**
  69338. * Parameters to perform the merge of bloom effect
  69339. */
  69340. bloom?: {
  69341. blurred: PostProcess;
  69342. weight: number;
  69343. };
  69344. }
  69345. /**
  69346. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69347. */
  69348. export class DepthOfFieldMergePostProcess extends PostProcess {
  69349. private blurSteps;
  69350. /**
  69351. * Gets a string identifying the name of the class
  69352. * @returns "DepthOfFieldMergePostProcess" string
  69353. */
  69354. getClassName(): string;
  69355. /**
  69356. * Creates a new instance of DepthOfFieldMergePostProcess
  69357. * @param name The name of the effect.
  69358. * @param originalFromInput Post process which's input will be used for the merge.
  69359. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69360. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69361. * @param options The required width/height ratio to downsize to before computing the render pass.
  69362. * @param camera The camera to apply the render pass to.
  69363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69364. * @param engine The engine which the post process will be applied. (default: current engine)
  69365. * @param reusable If the post process can be reused on the same frame. (default: false)
  69366. * @param textureType Type of textures used when performing the post process. (default: 0)
  69367. * @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)
  69368. */
  69369. 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);
  69370. /**
  69371. * Updates the effect with the current post process compile time values and recompiles the shader.
  69372. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69373. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69374. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69375. * @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
  69376. * @param onCompiled Called when the shader has been compiled.
  69377. * @param onError Called if there is an error when compiling a shader.
  69378. */
  69379. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69380. }
  69381. }
  69382. declare module BABYLON {
  69383. /**
  69384. * Specifies the level of max blur that should be applied when using the depth of field effect
  69385. */
  69386. export enum DepthOfFieldEffectBlurLevel {
  69387. /**
  69388. * Subtle blur
  69389. */
  69390. Low = 0,
  69391. /**
  69392. * Medium blur
  69393. */
  69394. Medium = 1,
  69395. /**
  69396. * Large blur
  69397. */
  69398. High = 2
  69399. }
  69400. /**
  69401. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69402. */
  69403. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69404. private _circleOfConfusion;
  69405. /**
  69406. * @hidden Internal, blurs from high to low
  69407. */
  69408. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69409. private _depthOfFieldBlurY;
  69410. private _dofMerge;
  69411. /**
  69412. * @hidden Internal post processes in depth of field effect
  69413. */
  69414. _effects: Array<PostProcess>;
  69415. /**
  69416. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69417. */
  69418. set focalLength(value: number);
  69419. get focalLength(): number;
  69420. /**
  69421. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69422. */
  69423. set fStop(value: number);
  69424. get fStop(): number;
  69425. /**
  69426. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69427. */
  69428. set focusDistance(value: number);
  69429. get focusDistance(): number;
  69430. /**
  69431. * 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.
  69432. */
  69433. set lensSize(value: number);
  69434. get lensSize(): number;
  69435. /**
  69436. * Creates a new instance DepthOfFieldEffect
  69437. * @param scene The scene the effect belongs to.
  69438. * @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.
  69439. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69440. * @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)
  69441. */
  69442. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69443. /**
  69444. * Get the current class name of the current effet
  69445. * @returns "DepthOfFieldEffect"
  69446. */
  69447. getClassName(): string;
  69448. /**
  69449. * 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.
  69450. */
  69451. set depthTexture(value: RenderTargetTexture);
  69452. /**
  69453. * Disposes each of the internal effects for a given camera.
  69454. * @param camera The camera to dispose the effect on.
  69455. */
  69456. disposeEffects(camera: Camera): void;
  69457. /**
  69458. * @hidden Internal
  69459. */
  69460. _updateEffects(): void;
  69461. /**
  69462. * Internal
  69463. * @returns if all the contained post processes are ready.
  69464. * @hidden
  69465. */
  69466. _isReady(): boolean;
  69467. }
  69468. }
  69469. declare module BABYLON {
  69470. /** @hidden */
  69471. export var displayPassPixelShader: {
  69472. name: string;
  69473. shader: string;
  69474. };
  69475. }
  69476. declare module BABYLON {
  69477. /**
  69478. * DisplayPassPostProcess which produces an output the same as it's input
  69479. */
  69480. export class DisplayPassPostProcess extends PostProcess {
  69481. /**
  69482. * Gets a string identifying the name of the class
  69483. * @returns "DisplayPassPostProcess" string
  69484. */
  69485. getClassName(): string;
  69486. /**
  69487. * Creates the DisplayPassPostProcess
  69488. * @param name The name of the effect.
  69489. * @param options The required width/height ratio to downsize to before computing the render pass.
  69490. * @param camera The camera to apply the render pass to.
  69491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69492. * @param engine The engine which the post process will be applied. (default: current engine)
  69493. * @param reusable If the post process can be reused on the same frame. (default: false)
  69494. */
  69495. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69496. /** @hidden */
  69497. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69498. }
  69499. }
  69500. declare module BABYLON {
  69501. /** @hidden */
  69502. export var filterPixelShader: {
  69503. name: string;
  69504. shader: string;
  69505. };
  69506. }
  69507. declare module BABYLON {
  69508. /**
  69509. * Applies a kernel filter to the image
  69510. */
  69511. export class FilterPostProcess extends PostProcess {
  69512. /** The matrix to be applied to the image */
  69513. kernelMatrix: Matrix;
  69514. /**
  69515. * Gets a string identifying the name of the class
  69516. * @returns "FilterPostProcess" string
  69517. */
  69518. getClassName(): string;
  69519. /**
  69520. *
  69521. * @param name The name of the effect.
  69522. * @param kernelMatrix The matrix to be applied to the image
  69523. * @param options The required width/height ratio to downsize to before computing the render pass.
  69524. * @param camera The camera to apply the render pass to.
  69525. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69526. * @param engine The engine which the post process will be applied. (default: current engine)
  69527. * @param reusable If the post process can be reused on the same frame. (default: false)
  69528. */
  69529. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69530. /** @hidden */
  69531. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69532. }
  69533. }
  69534. declare module BABYLON {
  69535. /** @hidden */
  69536. export var fxaaPixelShader: {
  69537. name: string;
  69538. shader: string;
  69539. };
  69540. }
  69541. declare module BABYLON {
  69542. /** @hidden */
  69543. export var fxaaVertexShader: {
  69544. name: string;
  69545. shader: string;
  69546. };
  69547. }
  69548. declare module BABYLON {
  69549. /**
  69550. * Fxaa post process
  69551. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69552. */
  69553. export class FxaaPostProcess extends PostProcess {
  69554. /**
  69555. * Gets a string identifying the name of the class
  69556. * @returns "FxaaPostProcess" string
  69557. */
  69558. getClassName(): string;
  69559. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69560. private _getDefines;
  69561. /** @hidden */
  69562. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69563. }
  69564. }
  69565. declare module BABYLON {
  69566. /** @hidden */
  69567. export var grainPixelShader: {
  69568. name: string;
  69569. shader: string;
  69570. };
  69571. }
  69572. declare module BABYLON {
  69573. /**
  69574. * The GrainPostProcess adds noise to the image at mid luminance levels
  69575. */
  69576. export class GrainPostProcess extends PostProcess {
  69577. /**
  69578. * The intensity of the grain added (default: 30)
  69579. */
  69580. intensity: number;
  69581. /**
  69582. * If the grain should be randomized on every frame
  69583. */
  69584. animated: boolean;
  69585. /**
  69586. * Gets a string identifying the name of the class
  69587. * @returns "GrainPostProcess" string
  69588. */
  69589. getClassName(): string;
  69590. /**
  69591. * Creates a new instance of @see GrainPostProcess
  69592. * @param name The name of the effect.
  69593. * @param options The required width/height ratio to downsize to before computing the render pass.
  69594. * @param camera The camera to apply the render pass to.
  69595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69596. * @param engine The engine which the post process will be applied. (default: current engine)
  69597. * @param reusable If the post process can be reused on the same frame. (default: false)
  69598. * @param textureType Type of textures used when performing the post process. (default: 0)
  69599. * @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)
  69600. */
  69601. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69602. /** @hidden */
  69603. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  69604. }
  69605. }
  69606. declare module BABYLON {
  69607. /** @hidden */
  69608. export var highlightsPixelShader: {
  69609. name: string;
  69610. shader: string;
  69611. };
  69612. }
  69613. declare module BABYLON {
  69614. /**
  69615. * Extracts highlights from the image
  69616. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69617. */
  69618. export class HighlightsPostProcess extends PostProcess {
  69619. /**
  69620. * Gets a string identifying the name of the class
  69621. * @returns "HighlightsPostProcess" string
  69622. */
  69623. getClassName(): string;
  69624. /**
  69625. * Extracts highlights from the image
  69626. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69627. * @param name The name of the effect.
  69628. * @param options The required width/height ratio to downsize to before computing the render pass.
  69629. * @param camera The camera to apply the render pass to.
  69630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69631. * @param engine The engine which the post process will be applied. (default: current engine)
  69632. * @param reusable If the post process can be reused on the same frame. (default: false)
  69633. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69634. */
  69635. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69636. }
  69637. }
  69638. declare module BABYLON {
  69639. /** @hidden */
  69640. export var mrtFragmentDeclaration: {
  69641. name: string;
  69642. shader: string;
  69643. };
  69644. }
  69645. declare module BABYLON {
  69646. /** @hidden */
  69647. export var geometryPixelShader: {
  69648. name: string;
  69649. shader: string;
  69650. };
  69651. }
  69652. declare module BABYLON {
  69653. /** @hidden */
  69654. export var geometryVertexShader: {
  69655. name: string;
  69656. shader: string;
  69657. };
  69658. }
  69659. declare module BABYLON {
  69660. /** @hidden */
  69661. interface ISavedTransformationMatrix {
  69662. world: Matrix;
  69663. viewProjection: Matrix;
  69664. }
  69665. /**
  69666. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69667. */
  69668. export class GeometryBufferRenderer {
  69669. /**
  69670. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69671. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69672. */
  69673. static readonly POSITION_TEXTURE_TYPE: number;
  69674. /**
  69675. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69676. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69677. */
  69678. static readonly VELOCITY_TEXTURE_TYPE: number;
  69679. /**
  69680. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69681. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69682. */
  69683. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69684. /**
  69685. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69686. * in order to compute objects velocities when enableVelocity is set to "true"
  69687. * @hidden
  69688. */
  69689. _previousTransformationMatrices: {
  69690. [index: number]: ISavedTransformationMatrix;
  69691. };
  69692. /**
  69693. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69694. * in order to compute objects velocities when enableVelocity is set to "true"
  69695. * @hidden
  69696. */
  69697. _previousBonesTransformationMatrices: {
  69698. [index: number]: Float32Array;
  69699. };
  69700. /**
  69701. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69702. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69703. */
  69704. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69705. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69706. renderTransparentMeshes: boolean;
  69707. private _scene;
  69708. private _resizeObserver;
  69709. private _multiRenderTarget;
  69710. private _ratio;
  69711. private _enablePosition;
  69712. private _enableVelocity;
  69713. private _enableReflectivity;
  69714. private _positionIndex;
  69715. private _velocityIndex;
  69716. private _reflectivityIndex;
  69717. protected _effect: Effect;
  69718. protected _cachedDefines: string;
  69719. /**
  69720. * Set the render list (meshes to be rendered) used in the G buffer.
  69721. */
  69722. set renderList(meshes: Mesh[]);
  69723. /**
  69724. * Gets wether or not G buffer are supported by the running hardware.
  69725. * This requires draw buffer supports
  69726. */
  69727. get isSupported(): boolean;
  69728. /**
  69729. * Returns the index of the given texture type in the G-Buffer textures array
  69730. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69731. * @returns the index of the given texture type in the G-Buffer textures array
  69732. */
  69733. getTextureIndex(textureType: number): number;
  69734. /**
  69735. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69736. */
  69737. get enablePosition(): boolean;
  69738. /**
  69739. * Sets whether or not objects positions are enabled for the G buffer.
  69740. */
  69741. set enablePosition(enable: boolean);
  69742. /**
  69743. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69744. */
  69745. get enableVelocity(): boolean;
  69746. /**
  69747. * Sets wether or not objects velocities are enabled for the G buffer.
  69748. */
  69749. set enableVelocity(enable: boolean);
  69750. /**
  69751. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69752. */
  69753. get enableReflectivity(): boolean;
  69754. /**
  69755. * Sets wether or not objects roughness are enabled for the G buffer.
  69756. */
  69757. set enableReflectivity(enable: boolean);
  69758. /**
  69759. * Gets the scene associated with the buffer.
  69760. */
  69761. get scene(): Scene;
  69762. /**
  69763. * Gets the ratio used by the buffer during its creation.
  69764. * How big is the buffer related to the main canvas.
  69765. */
  69766. get ratio(): number;
  69767. /** @hidden */
  69768. static _SceneComponentInitialization: (scene: Scene) => void;
  69769. /**
  69770. * Creates a new G Buffer for the scene
  69771. * @param scene The scene the buffer belongs to
  69772. * @param ratio How big is the buffer related to the main canvas.
  69773. */
  69774. constructor(scene: Scene, ratio?: number);
  69775. /**
  69776. * Checks wether everything is ready to render a submesh to the G buffer.
  69777. * @param subMesh the submesh to check readiness for
  69778. * @param useInstances is the mesh drawn using instance or not
  69779. * @returns true if ready otherwise false
  69780. */
  69781. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69782. /**
  69783. * Gets the current underlying G Buffer.
  69784. * @returns the buffer
  69785. */
  69786. getGBuffer(): MultiRenderTarget;
  69787. /**
  69788. * Gets the number of samples used to render the buffer (anti aliasing).
  69789. */
  69790. get samples(): number;
  69791. /**
  69792. * Sets the number of samples used to render the buffer (anti aliasing).
  69793. */
  69794. set samples(value: number);
  69795. /**
  69796. * Disposes the renderer and frees up associated resources.
  69797. */
  69798. dispose(): void;
  69799. protected _createRenderTargets(): void;
  69800. private _copyBonesTransformationMatrices;
  69801. }
  69802. }
  69803. declare module BABYLON {
  69804. interface Scene {
  69805. /** @hidden (Backing field) */
  69806. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69807. /**
  69808. * Gets or Sets the current geometry buffer associated to the scene.
  69809. */
  69810. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69811. /**
  69812. * Enables a GeometryBufferRender and associates it with the scene
  69813. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69814. * @returns the GeometryBufferRenderer
  69815. */
  69816. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69817. /**
  69818. * Disables the GeometryBufferRender associated with the scene
  69819. */
  69820. disableGeometryBufferRenderer(): void;
  69821. }
  69822. /**
  69823. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69824. * in several rendering techniques.
  69825. */
  69826. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69827. /**
  69828. * The component name helpful to identify the component in the list of scene components.
  69829. */
  69830. readonly name: string;
  69831. /**
  69832. * The scene the component belongs to.
  69833. */
  69834. scene: Scene;
  69835. /**
  69836. * Creates a new instance of the component for the given scene
  69837. * @param scene Defines the scene to register the component in
  69838. */
  69839. constructor(scene: Scene);
  69840. /**
  69841. * Registers the component in a given scene
  69842. */
  69843. register(): void;
  69844. /**
  69845. * Rebuilds the elements related to this component in case of
  69846. * context lost for instance.
  69847. */
  69848. rebuild(): void;
  69849. /**
  69850. * Disposes the component and the associated ressources
  69851. */
  69852. dispose(): void;
  69853. private _gatherRenderTargets;
  69854. }
  69855. }
  69856. declare module BABYLON {
  69857. /** @hidden */
  69858. export var motionBlurPixelShader: {
  69859. name: string;
  69860. shader: string;
  69861. };
  69862. }
  69863. declare module BABYLON {
  69864. /**
  69865. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69866. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69867. * As an example, all you have to do is to create the post-process:
  69868. * var mb = new BABYLON.MotionBlurPostProcess(
  69869. * 'mb', // The name of the effect.
  69870. * scene, // The scene containing the objects to blur according to their velocity.
  69871. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69872. * camera // The camera to apply the render pass to.
  69873. * );
  69874. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69875. */
  69876. export class MotionBlurPostProcess extends PostProcess {
  69877. /**
  69878. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69879. */
  69880. motionStrength: number;
  69881. /**
  69882. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69883. */
  69884. get motionBlurSamples(): number;
  69885. /**
  69886. * Sets the number of iterations to be used for motion blur quality
  69887. */
  69888. set motionBlurSamples(samples: number);
  69889. private _motionBlurSamples;
  69890. private _geometryBufferRenderer;
  69891. /**
  69892. * Gets a string identifying the name of the class
  69893. * @returns "MotionBlurPostProcess" string
  69894. */
  69895. getClassName(): string;
  69896. /**
  69897. * Creates a new instance MotionBlurPostProcess
  69898. * @param name The name of the effect.
  69899. * @param scene The scene containing the objects to blur according to their velocity.
  69900. * @param options The required width/height ratio to downsize to before computing the render pass.
  69901. * @param camera The camera to apply the render pass to.
  69902. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69903. * @param engine The engine which the post process will be applied. (default: current engine)
  69904. * @param reusable If the post process can be reused on the same frame. (default: false)
  69905. * @param textureType Type of textures used when performing the post process. (default: 0)
  69906. * @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)
  69907. */
  69908. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69909. /**
  69910. * Excludes the given skinned mesh from computing bones velocities.
  69911. * 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.
  69912. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69913. */
  69914. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69915. /**
  69916. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69917. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69918. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69919. */
  69920. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69921. /**
  69922. * Disposes the post process.
  69923. * @param camera The camera to dispose the post process on.
  69924. */
  69925. dispose(camera?: Camera): void;
  69926. /** @hidden */
  69927. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  69928. }
  69929. }
  69930. declare module BABYLON {
  69931. /** @hidden */
  69932. export var refractionPixelShader: {
  69933. name: string;
  69934. shader: string;
  69935. };
  69936. }
  69937. declare module BABYLON {
  69938. /**
  69939. * Post process which applies a refractin texture
  69940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69941. */
  69942. export class RefractionPostProcess extends PostProcess {
  69943. private _refTexture;
  69944. private _ownRefractionTexture;
  69945. /** the base color of the refraction (used to taint the rendering) */
  69946. color: Color3;
  69947. /** simulated refraction depth */
  69948. depth: number;
  69949. /** the coefficient of the base color (0 to remove base color tainting) */
  69950. colorLevel: number;
  69951. /** Gets the url used to load the refraction texture */
  69952. refractionTextureUrl: string;
  69953. /**
  69954. * Gets or sets the refraction texture
  69955. * Please note that you are responsible for disposing the texture if you set it manually
  69956. */
  69957. get refractionTexture(): Texture;
  69958. set refractionTexture(value: Texture);
  69959. /**
  69960. * Gets a string identifying the name of the class
  69961. * @returns "RefractionPostProcess" string
  69962. */
  69963. getClassName(): string;
  69964. /**
  69965. * Initializes the RefractionPostProcess
  69966. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69967. * @param name The name of the effect.
  69968. * @param refractionTextureUrl Url of the refraction texture to use
  69969. * @param color the base color of the refraction (used to taint the rendering)
  69970. * @param depth simulated refraction depth
  69971. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69972. * @param camera The camera to apply the render pass to.
  69973. * @param options The required width/height ratio to downsize to before computing the render pass.
  69974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69975. * @param engine The engine which the post process will be applied. (default: current engine)
  69976. * @param reusable If the post process can be reused on the same frame. (default: false)
  69977. */
  69978. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69979. /**
  69980. * Disposes of the post process
  69981. * @param camera Camera to dispose post process on
  69982. */
  69983. dispose(camera: Camera): void;
  69984. /** @hidden */
  69985. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  69986. }
  69987. }
  69988. declare module BABYLON {
  69989. /** @hidden */
  69990. export var sharpenPixelShader: {
  69991. name: string;
  69992. shader: string;
  69993. };
  69994. }
  69995. declare module BABYLON {
  69996. /**
  69997. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69998. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69999. */
  70000. export class SharpenPostProcess extends PostProcess {
  70001. /**
  70002. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70003. */
  70004. colorAmount: number;
  70005. /**
  70006. * How much sharpness should be applied (default: 0.3)
  70007. */
  70008. edgeAmount: number;
  70009. /**
  70010. * Gets a string identifying the name of the class
  70011. * @returns "SharpenPostProcess" string
  70012. */
  70013. getClassName(): string;
  70014. /**
  70015. * Creates a new instance ConvolutionPostProcess
  70016. * @param name The name of the effect.
  70017. * @param options The required width/height ratio to downsize to before computing the render pass.
  70018. * @param camera The camera to apply the render pass to.
  70019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70020. * @param engine The engine which the post process will be applied. (default: current engine)
  70021. * @param reusable If the post process can be reused on the same frame. (default: false)
  70022. * @param textureType Type of textures used when performing the post process. (default: 0)
  70023. * @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)
  70024. */
  70025. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70026. /** @hidden */
  70027. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70028. }
  70029. }
  70030. declare module BABYLON {
  70031. /**
  70032. * PostProcessRenderPipeline
  70033. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70034. */
  70035. export class PostProcessRenderPipeline {
  70036. private engine;
  70037. private _renderEffects;
  70038. private _renderEffectsForIsolatedPass;
  70039. /**
  70040. * List of inspectable custom properties (used by the Inspector)
  70041. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70042. */
  70043. inspectableCustomProperties: IInspectable[];
  70044. /**
  70045. * @hidden
  70046. */
  70047. protected _cameras: Camera[];
  70048. /** @hidden */
  70049. _name: string;
  70050. /**
  70051. * Gets pipeline name
  70052. */
  70053. get name(): string;
  70054. /** Gets the list of attached cameras */
  70055. get cameras(): Camera[];
  70056. /**
  70057. * Initializes a PostProcessRenderPipeline
  70058. * @param engine engine to add the pipeline to
  70059. * @param name name of the pipeline
  70060. */
  70061. constructor(engine: Engine, name: string);
  70062. /**
  70063. * Gets the class name
  70064. * @returns "PostProcessRenderPipeline"
  70065. */
  70066. getClassName(): string;
  70067. /**
  70068. * If all the render effects in the pipeline are supported
  70069. */
  70070. get isSupported(): boolean;
  70071. /**
  70072. * Adds an effect to the pipeline
  70073. * @param renderEffect the effect to add
  70074. */
  70075. addEffect(renderEffect: PostProcessRenderEffect): void;
  70076. /** @hidden */
  70077. _rebuild(): void;
  70078. /** @hidden */
  70079. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70080. /** @hidden */
  70081. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70082. /** @hidden */
  70083. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70084. /** @hidden */
  70085. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70086. /** @hidden */
  70087. _attachCameras(cameras: Camera, unique: boolean): void;
  70088. /** @hidden */
  70089. _attachCameras(cameras: Camera[], unique: boolean): void;
  70090. /** @hidden */
  70091. _detachCameras(cameras: Camera): void;
  70092. /** @hidden */
  70093. _detachCameras(cameras: Nullable<Camera[]>): void;
  70094. /** @hidden */
  70095. _update(): void;
  70096. /** @hidden */
  70097. _reset(): void;
  70098. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70099. /**
  70100. * Sets the required values to the prepass renderer.
  70101. * @param prePassRenderer defines the prepass renderer to setup.
  70102. * @returns true if the pre pass is needed.
  70103. */
  70104. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70105. /**
  70106. * Disposes of the pipeline
  70107. */
  70108. dispose(): void;
  70109. }
  70110. }
  70111. declare module BABYLON {
  70112. /**
  70113. * PostProcessRenderPipelineManager class
  70114. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70115. */
  70116. export class PostProcessRenderPipelineManager {
  70117. private _renderPipelines;
  70118. /**
  70119. * Initializes a PostProcessRenderPipelineManager
  70120. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70121. */
  70122. constructor();
  70123. /**
  70124. * Gets the list of supported render pipelines
  70125. */
  70126. get supportedPipelines(): PostProcessRenderPipeline[];
  70127. /**
  70128. * Adds a pipeline to the manager
  70129. * @param renderPipeline The pipeline to add
  70130. */
  70131. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70132. /**
  70133. * Attaches a camera to the pipeline
  70134. * @param renderPipelineName The name of the pipeline to attach to
  70135. * @param cameras the camera to attach
  70136. * @param unique if the camera can be attached multiple times to the pipeline
  70137. */
  70138. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70139. /**
  70140. * Detaches a camera from the pipeline
  70141. * @param renderPipelineName The name of the pipeline to detach from
  70142. * @param cameras the camera to detach
  70143. */
  70144. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70145. /**
  70146. * Enables an effect by name on a pipeline
  70147. * @param renderPipelineName the name of the pipeline to enable the effect in
  70148. * @param renderEffectName the name of the effect to enable
  70149. * @param cameras the cameras that the effect should be enabled on
  70150. */
  70151. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70152. /**
  70153. * Disables an effect by name on a pipeline
  70154. * @param renderPipelineName the name of the pipeline to disable the effect in
  70155. * @param renderEffectName the name of the effect to disable
  70156. * @param cameras the cameras that the effect should be disabled on
  70157. */
  70158. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70159. /**
  70160. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70161. */
  70162. update(): void;
  70163. /** @hidden */
  70164. _rebuild(): void;
  70165. /**
  70166. * Disposes of the manager and pipelines
  70167. */
  70168. dispose(): void;
  70169. }
  70170. }
  70171. declare module BABYLON {
  70172. interface Scene {
  70173. /** @hidden (Backing field) */
  70174. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70175. /**
  70176. * Gets the postprocess render pipeline manager
  70177. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70178. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70179. */
  70180. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70181. }
  70182. /**
  70183. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70184. */
  70185. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70186. /**
  70187. * The component name helpfull to identify the component in the list of scene components.
  70188. */
  70189. readonly name: string;
  70190. /**
  70191. * The scene the component belongs to.
  70192. */
  70193. scene: Scene;
  70194. /**
  70195. * Creates a new instance of the component for the given scene
  70196. * @param scene Defines the scene to register the component in
  70197. */
  70198. constructor(scene: Scene);
  70199. /**
  70200. * Registers the component in a given scene
  70201. */
  70202. register(): void;
  70203. /**
  70204. * Rebuilds the elements related to this component in case of
  70205. * context lost for instance.
  70206. */
  70207. rebuild(): void;
  70208. /**
  70209. * Disposes the component and the associated ressources
  70210. */
  70211. dispose(): void;
  70212. private _gatherRenderTargets;
  70213. }
  70214. }
  70215. declare module BABYLON {
  70216. /**
  70217. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70218. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70219. */
  70220. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70221. private _scene;
  70222. private _camerasToBeAttached;
  70223. /**
  70224. * ID of the sharpen post process,
  70225. */
  70226. private readonly SharpenPostProcessId;
  70227. /**
  70228. * @ignore
  70229. * ID of the image processing post process;
  70230. */
  70231. readonly ImageProcessingPostProcessId: string;
  70232. /**
  70233. * @ignore
  70234. * ID of the Fast Approximate Anti-Aliasing post process;
  70235. */
  70236. readonly FxaaPostProcessId: string;
  70237. /**
  70238. * ID of the chromatic aberration post process,
  70239. */
  70240. private readonly ChromaticAberrationPostProcessId;
  70241. /**
  70242. * ID of the grain post process
  70243. */
  70244. private readonly GrainPostProcessId;
  70245. /**
  70246. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70247. */
  70248. sharpen: SharpenPostProcess;
  70249. private _sharpenEffect;
  70250. private bloom;
  70251. /**
  70252. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70253. */
  70254. depthOfField: DepthOfFieldEffect;
  70255. /**
  70256. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70257. */
  70258. fxaa: FxaaPostProcess;
  70259. /**
  70260. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70261. */
  70262. imageProcessing: ImageProcessingPostProcess;
  70263. /**
  70264. * Chromatic aberration post process which will shift rgb colors in the image
  70265. */
  70266. chromaticAberration: ChromaticAberrationPostProcess;
  70267. private _chromaticAberrationEffect;
  70268. /**
  70269. * Grain post process which add noise to the image
  70270. */
  70271. grain: GrainPostProcess;
  70272. private _grainEffect;
  70273. /**
  70274. * Glow post process which adds a glow to emissive areas of the image
  70275. */
  70276. private _glowLayer;
  70277. /**
  70278. * Animations which can be used to tweak settings over a period of time
  70279. */
  70280. animations: Animation[];
  70281. private _imageProcessingConfigurationObserver;
  70282. private _sharpenEnabled;
  70283. private _bloomEnabled;
  70284. private _depthOfFieldEnabled;
  70285. private _depthOfFieldBlurLevel;
  70286. private _fxaaEnabled;
  70287. private _imageProcessingEnabled;
  70288. private _defaultPipelineTextureType;
  70289. private _bloomScale;
  70290. private _chromaticAberrationEnabled;
  70291. private _grainEnabled;
  70292. private _buildAllowed;
  70293. /**
  70294. * Gets active scene
  70295. */
  70296. get scene(): Scene;
  70297. /**
  70298. * Enable or disable the sharpen process from the pipeline
  70299. */
  70300. set sharpenEnabled(enabled: boolean);
  70301. get sharpenEnabled(): boolean;
  70302. private _resizeObserver;
  70303. private _hardwareScaleLevel;
  70304. private _bloomKernel;
  70305. /**
  70306. * Specifies the size of the bloom blur kernel, relative to the final output size
  70307. */
  70308. get bloomKernel(): number;
  70309. set bloomKernel(value: number);
  70310. /**
  70311. * Specifies the weight of the bloom in the final rendering
  70312. */
  70313. private _bloomWeight;
  70314. /**
  70315. * Specifies the luma threshold for the area that will be blurred by the bloom
  70316. */
  70317. private _bloomThreshold;
  70318. private _hdr;
  70319. /**
  70320. * The strength of the bloom.
  70321. */
  70322. set bloomWeight(value: number);
  70323. get bloomWeight(): number;
  70324. /**
  70325. * The strength of the bloom.
  70326. */
  70327. set bloomThreshold(value: number);
  70328. get bloomThreshold(): number;
  70329. /**
  70330. * The scale of the bloom, lower value will provide better performance.
  70331. */
  70332. set bloomScale(value: number);
  70333. get bloomScale(): number;
  70334. /**
  70335. * Enable or disable the bloom from the pipeline
  70336. */
  70337. set bloomEnabled(enabled: boolean);
  70338. get bloomEnabled(): boolean;
  70339. private _rebuildBloom;
  70340. /**
  70341. * If the depth of field is enabled.
  70342. */
  70343. get depthOfFieldEnabled(): boolean;
  70344. set depthOfFieldEnabled(enabled: boolean);
  70345. /**
  70346. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70347. */
  70348. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70349. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70350. /**
  70351. * If the anti aliasing is enabled.
  70352. */
  70353. set fxaaEnabled(enabled: boolean);
  70354. get fxaaEnabled(): boolean;
  70355. private _samples;
  70356. /**
  70357. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70358. */
  70359. set samples(sampleCount: number);
  70360. get samples(): number;
  70361. /**
  70362. * If image processing is enabled.
  70363. */
  70364. set imageProcessingEnabled(enabled: boolean);
  70365. get imageProcessingEnabled(): boolean;
  70366. /**
  70367. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70368. */
  70369. set glowLayerEnabled(enabled: boolean);
  70370. get glowLayerEnabled(): boolean;
  70371. /**
  70372. * Gets the glow layer (or null if not defined)
  70373. */
  70374. get glowLayer(): Nullable<GlowLayer>;
  70375. /**
  70376. * Enable or disable the chromaticAberration process from the pipeline
  70377. */
  70378. set chromaticAberrationEnabled(enabled: boolean);
  70379. get chromaticAberrationEnabled(): boolean;
  70380. /**
  70381. * Enable or disable the grain process from the pipeline
  70382. */
  70383. set grainEnabled(enabled: boolean);
  70384. get grainEnabled(): boolean;
  70385. /**
  70386. * @constructor
  70387. * @param name - The rendering pipeline name (default: "")
  70388. * @param hdr - If high dynamic range textures should be used (default: true)
  70389. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70390. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70391. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70392. */
  70393. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70394. /**
  70395. * Get the class name
  70396. * @returns "DefaultRenderingPipeline"
  70397. */
  70398. getClassName(): string;
  70399. /**
  70400. * Force the compilation of the entire pipeline.
  70401. */
  70402. prepare(): void;
  70403. private _hasCleared;
  70404. private _prevPostProcess;
  70405. private _prevPrevPostProcess;
  70406. private _setAutoClearAndTextureSharing;
  70407. private _depthOfFieldSceneObserver;
  70408. private _buildPipeline;
  70409. private _disposePostProcesses;
  70410. /**
  70411. * Adds a camera to the pipeline
  70412. * @param camera the camera to be added
  70413. */
  70414. addCamera(camera: Camera): void;
  70415. /**
  70416. * Removes a camera from the pipeline
  70417. * @param camera the camera to remove
  70418. */
  70419. removeCamera(camera: Camera): void;
  70420. /**
  70421. * Dispose of the pipeline and stop all post processes
  70422. */
  70423. dispose(): void;
  70424. /**
  70425. * Serialize the rendering pipeline (Used when exporting)
  70426. * @returns the serialized object
  70427. */
  70428. serialize(): any;
  70429. /**
  70430. * Parse the serialized pipeline
  70431. * @param source Source pipeline.
  70432. * @param scene The scene to load the pipeline to.
  70433. * @param rootUrl The URL of the serialized pipeline.
  70434. * @returns An instantiated pipeline from the serialized object.
  70435. */
  70436. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70437. }
  70438. }
  70439. declare module BABYLON {
  70440. /** @hidden */
  70441. export var lensHighlightsPixelShader: {
  70442. name: string;
  70443. shader: string;
  70444. };
  70445. }
  70446. declare module BABYLON {
  70447. /** @hidden */
  70448. export var depthOfFieldPixelShader: {
  70449. name: string;
  70450. shader: string;
  70451. };
  70452. }
  70453. declare module BABYLON {
  70454. /**
  70455. * BABYLON.JS Chromatic Aberration GLSL Shader
  70456. * Author: Olivier Guyot
  70457. * Separates very slightly R, G and B colors on the edges of the screen
  70458. * Inspired by Francois Tarlier & Martins Upitis
  70459. */
  70460. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70461. /**
  70462. * @ignore
  70463. * The chromatic aberration PostProcess id in the pipeline
  70464. */
  70465. LensChromaticAberrationEffect: string;
  70466. /**
  70467. * @ignore
  70468. * The highlights enhancing PostProcess id in the pipeline
  70469. */
  70470. HighlightsEnhancingEffect: string;
  70471. /**
  70472. * @ignore
  70473. * The depth-of-field PostProcess id in the pipeline
  70474. */
  70475. LensDepthOfFieldEffect: string;
  70476. private _scene;
  70477. private _depthTexture;
  70478. private _grainTexture;
  70479. private _chromaticAberrationPostProcess;
  70480. private _highlightsPostProcess;
  70481. private _depthOfFieldPostProcess;
  70482. private _edgeBlur;
  70483. private _grainAmount;
  70484. private _chromaticAberration;
  70485. private _distortion;
  70486. private _highlightsGain;
  70487. private _highlightsThreshold;
  70488. private _dofDistance;
  70489. private _dofAperture;
  70490. private _dofDarken;
  70491. private _dofPentagon;
  70492. private _blurNoise;
  70493. /**
  70494. * @constructor
  70495. *
  70496. * Effect parameters are as follow:
  70497. * {
  70498. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70499. * edge_blur: number; // from 0 to x (1 for realism)
  70500. * distortion: number; // from 0 to x (1 for realism)
  70501. * grain_amount: number; // from 0 to 1
  70502. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70503. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70504. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70505. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70506. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70507. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70508. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70509. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70510. * }
  70511. * Note: if an effect parameter is unset, effect is disabled
  70512. *
  70513. * @param name The rendering pipeline name
  70514. * @param parameters - An object containing all parameters (see above)
  70515. * @param scene The scene linked to this pipeline
  70516. * @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)
  70517. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70518. */
  70519. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70520. /**
  70521. * Get the class name
  70522. * @returns "LensRenderingPipeline"
  70523. */
  70524. getClassName(): string;
  70525. /**
  70526. * Gets associated scene
  70527. */
  70528. get scene(): Scene;
  70529. /**
  70530. * Gets or sets the edge blur
  70531. */
  70532. get edgeBlur(): number;
  70533. set edgeBlur(value: number);
  70534. /**
  70535. * Gets or sets the grain amount
  70536. */
  70537. get grainAmount(): number;
  70538. set grainAmount(value: number);
  70539. /**
  70540. * Gets or sets the chromatic aberration amount
  70541. */
  70542. get chromaticAberration(): number;
  70543. set chromaticAberration(value: number);
  70544. /**
  70545. * Gets or sets the depth of field aperture
  70546. */
  70547. get dofAperture(): number;
  70548. set dofAperture(value: number);
  70549. /**
  70550. * Gets or sets the edge distortion
  70551. */
  70552. get edgeDistortion(): number;
  70553. set edgeDistortion(value: number);
  70554. /**
  70555. * Gets or sets the depth of field distortion
  70556. */
  70557. get dofDistortion(): number;
  70558. set dofDistortion(value: number);
  70559. /**
  70560. * Gets or sets the darken out of focus amount
  70561. */
  70562. get darkenOutOfFocus(): number;
  70563. set darkenOutOfFocus(value: number);
  70564. /**
  70565. * Gets or sets a boolean indicating if blur noise is enabled
  70566. */
  70567. get blurNoise(): boolean;
  70568. set blurNoise(value: boolean);
  70569. /**
  70570. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70571. */
  70572. get pentagonBokeh(): boolean;
  70573. set pentagonBokeh(value: boolean);
  70574. /**
  70575. * Gets or sets the highlight grain amount
  70576. */
  70577. get highlightsGain(): number;
  70578. set highlightsGain(value: number);
  70579. /**
  70580. * Gets or sets the highlight threshold
  70581. */
  70582. get highlightsThreshold(): number;
  70583. set highlightsThreshold(value: number);
  70584. /**
  70585. * Sets the amount of blur at the edges
  70586. * @param amount blur amount
  70587. */
  70588. setEdgeBlur(amount: number): void;
  70589. /**
  70590. * Sets edge blur to 0
  70591. */
  70592. disableEdgeBlur(): void;
  70593. /**
  70594. * Sets the amout of grain
  70595. * @param amount Amount of grain
  70596. */
  70597. setGrainAmount(amount: number): void;
  70598. /**
  70599. * Set grain amount to 0
  70600. */
  70601. disableGrain(): void;
  70602. /**
  70603. * Sets the chromatic aberration amount
  70604. * @param amount amount of chromatic aberration
  70605. */
  70606. setChromaticAberration(amount: number): void;
  70607. /**
  70608. * Sets chromatic aberration amount to 0
  70609. */
  70610. disableChromaticAberration(): void;
  70611. /**
  70612. * Sets the EdgeDistortion amount
  70613. * @param amount amount of EdgeDistortion
  70614. */
  70615. setEdgeDistortion(amount: number): void;
  70616. /**
  70617. * Sets edge distortion to 0
  70618. */
  70619. disableEdgeDistortion(): void;
  70620. /**
  70621. * Sets the FocusDistance amount
  70622. * @param amount amount of FocusDistance
  70623. */
  70624. setFocusDistance(amount: number): void;
  70625. /**
  70626. * Disables depth of field
  70627. */
  70628. disableDepthOfField(): void;
  70629. /**
  70630. * Sets the Aperture amount
  70631. * @param amount amount of Aperture
  70632. */
  70633. setAperture(amount: number): void;
  70634. /**
  70635. * Sets the DarkenOutOfFocus amount
  70636. * @param amount amount of DarkenOutOfFocus
  70637. */
  70638. setDarkenOutOfFocus(amount: number): void;
  70639. private _pentagonBokehIsEnabled;
  70640. /**
  70641. * Creates a pentagon bokeh effect
  70642. */
  70643. enablePentagonBokeh(): void;
  70644. /**
  70645. * Disables the pentagon bokeh effect
  70646. */
  70647. disablePentagonBokeh(): void;
  70648. /**
  70649. * Enables noise blur
  70650. */
  70651. enableNoiseBlur(): void;
  70652. /**
  70653. * Disables noise blur
  70654. */
  70655. disableNoiseBlur(): void;
  70656. /**
  70657. * Sets the HighlightsGain amount
  70658. * @param amount amount of HighlightsGain
  70659. */
  70660. setHighlightsGain(amount: number): void;
  70661. /**
  70662. * Sets the HighlightsThreshold amount
  70663. * @param amount amount of HighlightsThreshold
  70664. */
  70665. setHighlightsThreshold(amount: number): void;
  70666. /**
  70667. * Disables highlights
  70668. */
  70669. disableHighlights(): void;
  70670. /**
  70671. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70672. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70673. */
  70674. dispose(disableDepthRender?: boolean): void;
  70675. private _createChromaticAberrationPostProcess;
  70676. private _createHighlightsPostProcess;
  70677. private _createDepthOfFieldPostProcess;
  70678. private _createGrainTexture;
  70679. }
  70680. }
  70681. declare module BABYLON {
  70682. /** @hidden */
  70683. export var ssao2PixelShader: {
  70684. name: string;
  70685. shader: string;
  70686. };
  70687. }
  70688. declare module BABYLON {
  70689. /** @hidden */
  70690. export var ssaoCombinePixelShader: {
  70691. name: string;
  70692. shader: string;
  70693. };
  70694. }
  70695. declare module BABYLON {
  70696. /**
  70697. * Render pipeline to produce ssao effect
  70698. */
  70699. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70700. /**
  70701. * @ignore
  70702. * The PassPostProcess id in the pipeline that contains the original scene color
  70703. */
  70704. SSAOOriginalSceneColorEffect: string;
  70705. /**
  70706. * @ignore
  70707. * The SSAO PostProcess id in the pipeline
  70708. */
  70709. SSAORenderEffect: string;
  70710. /**
  70711. * @ignore
  70712. * The horizontal blur PostProcess id in the pipeline
  70713. */
  70714. SSAOBlurHRenderEffect: string;
  70715. /**
  70716. * @ignore
  70717. * The vertical blur PostProcess id in the pipeline
  70718. */
  70719. SSAOBlurVRenderEffect: string;
  70720. /**
  70721. * @ignore
  70722. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70723. */
  70724. SSAOCombineRenderEffect: string;
  70725. /**
  70726. * The output strength of the SSAO post-process. Default value is 1.0.
  70727. */
  70728. totalStrength: number;
  70729. /**
  70730. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70731. */
  70732. maxZ: number;
  70733. /**
  70734. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70735. */
  70736. minZAspect: number;
  70737. private _samples;
  70738. /**
  70739. * Number of samples used for the SSAO calculations. Default value is 8
  70740. */
  70741. set samples(n: number);
  70742. get samples(): number;
  70743. private _textureSamples;
  70744. /**
  70745. * Number of samples to use for antialiasing
  70746. */
  70747. set textureSamples(n: number);
  70748. get textureSamples(): number;
  70749. /**
  70750. * Force rendering the geometry through geometry buffer
  70751. */
  70752. private _forceGeometryBuffer;
  70753. /**
  70754. * Ratio object used for SSAO ratio and blur ratio
  70755. */
  70756. private _ratio;
  70757. /**
  70758. * Dynamically generated sphere sampler.
  70759. */
  70760. private _sampleSphere;
  70761. /**
  70762. * Blur filter offsets
  70763. */
  70764. private _samplerOffsets;
  70765. private _expensiveBlur;
  70766. /**
  70767. * If bilateral blur should be used
  70768. */
  70769. set expensiveBlur(b: boolean);
  70770. get expensiveBlur(): boolean;
  70771. /**
  70772. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70773. */
  70774. radius: number;
  70775. /**
  70776. * The base color of the SSAO post-process
  70777. * The final result is "base + ssao" between [0, 1]
  70778. */
  70779. base: number;
  70780. /**
  70781. * Support test.
  70782. */
  70783. static get IsSupported(): boolean;
  70784. private _scene;
  70785. private _randomTexture;
  70786. private _originalColorPostProcess;
  70787. private _ssaoPostProcess;
  70788. private _blurHPostProcess;
  70789. private _blurVPostProcess;
  70790. private _ssaoCombinePostProcess;
  70791. private _prePassRenderer;
  70792. /**
  70793. * Gets active scene
  70794. */
  70795. get scene(): Scene;
  70796. /**
  70797. * @constructor
  70798. * @param name The rendering pipeline name
  70799. * @param scene The scene linked to this pipeline
  70800. * @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 }
  70801. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70802. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70803. */
  70804. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70805. /**
  70806. * Get the class name
  70807. * @returns "SSAO2RenderingPipeline"
  70808. */
  70809. getClassName(): string;
  70810. /**
  70811. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70812. */
  70813. dispose(disableGeometryBufferRenderer?: boolean): void;
  70814. private _createBlurPostProcess;
  70815. /** @hidden */
  70816. _rebuild(): void;
  70817. private _bits;
  70818. private _radicalInverse_VdC;
  70819. private _hammersley;
  70820. private _hemisphereSample_uniform;
  70821. private _generateHemisphere;
  70822. private _getDefinesForSSAO;
  70823. private _createSSAOPostProcess;
  70824. private _createSSAOCombinePostProcess;
  70825. private _createRandomTexture;
  70826. /**
  70827. * Serialize the rendering pipeline (Used when exporting)
  70828. * @returns the serialized object
  70829. */
  70830. serialize(): any;
  70831. /**
  70832. * Parse the serialized pipeline
  70833. * @param source Source pipeline.
  70834. * @param scene The scene to load the pipeline to.
  70835. * @param rootUrl The URL of the serialized pipeline.
  70836. * @returns An instantiated pipeline from the serialized object.
  70837. */
  70838. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70839. /**
  70840. * Sets the required values to the prepass renderer.
  70841. * @param prePassRenderer defines the prepass renderer to setup
  70842. * @returns true if the pre pass is needed.
  70843. */
  70844. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70845. }
  70846. }
  70847. declare module BABYLON {
  70848. /** @hidden */
  70849. export var ssaoPixelShader: {
  70850. name: string;
  70851. shader: string;
  70852. };
  70853. }
  70854. declare module BABYLON {
  70855. /**
  70856. * Render pipeline to produce ssao effect
  70857. */
  70858. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70859. /**
  70860. * @ignore
  70861. * The PassPostProcess id in the pipeline that contains the original scene color
  70862. */
  70863. SSAOOriginalSceneColorEffect: string;
  70864. /**
  70865. * @ignore
  70866. * The SSAO PostProcess id in the pipeline
  70867. */
  70868. SSAORenderEffect: string;
  70869. /**
  70870. * @ignore
  70871. * The horizontal blur PostProcess id in the pipeline
  70872. */
  70873. SSAOBlurHRenderEffect: string;
  70874. /**
  70875. * @ignore
  70876. * The vertical blur PostProcess id in the pipeline
  70877. */
  70878. SSAOBlurVRenderEffect: string;
  70879. /**
  70880. * @ignore
  70881. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70882. */
  70883. SSAOCombineRenderEffect: string;
  70884. /**
  70885. * The output strength of the SSAO post-process. Default value is 1.0.
  70886. */
  70887. totalStrength: number;
  70888. /**
  70889. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70890. */
  70891. radius: number;
  70892. /**
  70893. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70894. * Must not be equal to fallOff and superior to fallOff.
  70895. * Default value is 0.0075
  70896. */
  70897. area: number;
  70898. /**
  70899. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70900. * Must not be equal to area and inferior to area.
  70901. * Default value is 0.000001
  70902. */
  70903. fallOff: number;
  70904. /**
  70905. * The base color of the SSAO post-process
  70906. * The final result is "base + ssao" between [0, 1]
  70907. */
  70908. base: number;
  70909. private _scene;
  70910. private _depthTexture;
  70911. private _randomTexture;
  70912. private _originalColorPostProcess;
  70913. private _ssaoPostProcess;
  70914. private _blurHPostProcess;
  70915. private _blurVPostProcess;
  70916. private _ssaoCombinePostProcess;
  70917. private _firstUpdate;
  70918. /**
  70919. * Gets active scene
  70920. */
  70921. get scene(): Scene;
  70922. /**
  70923. * @constructor
  70924. * @param name - The rendering pipeline name
  70925. * @param scene - The scene linked to this pipeline
  70926. * @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 }
  70927. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70928. */
  70929. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70930. /**
  70931. * Get the class name
  70932. * @returns "SSAORenderingPipeline"
  70933. */
  70934. getClassName(): string;
  70935. /**
  70936. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70937. */
  70938. dispose(disableDepthRender?: boolean): void;
  70939. private _createBlurPostProcess;
  70940. /** @hidden */
  70941. _rebuild(): void;
  70942. private _createSSAOPostProcess;
  70943. private _createSSAOCombinePostProcess;
  70944. private _createRandomTexture;
  70945. }
  70946. }
  70947. declare module BABYLON {
  70948. /** @hidden */
  70949. export var screenSpaceReflectionPixelShader: {
  70950. name: string;
  70951. shader: string;
  70952. };
  70953. }
  70954. declare module BABYLON {
  70955. /**
  70956. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70957. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70958. */
  70959. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70960. /**
  70961. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70962. */
  70963. threshold: number;
  70964. /**
  70965. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70966. */
  70967. strength: number;
  70968. /**
  70969. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70970. */
  70971. reflectionSpecularFalloffExponent: number;
  70972. /**
  70973. * 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]
  70974. */
  70975. step: number;
  70976. /**
  70977. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70978. */
  70979. roughnessFactor: number;
  70980. private _geometryBufferRenderer;
  70981. private _enableSmoothReflections;
  70982. private _reflectionSamples;
  70983. private _smoothSteps;
  70984. /**
  70985. * Gets a string identifying the name of the class
  70986. * @returns "ScreenSpaceReflectionPostProcess" string
  70987. */
  70988. getClassName(): string;
  70989. /**
  70990. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70991. * @param name The name of the effect.
  70992. * @param scene The scene containing the objects to calculate reflections.
  70993. * @param options The required width/height ratio to downsize to before computing the render pass.
  70994. * @param camera The camera to apply the render pass to.
  70995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70996. * @param engine The engine which the post process will be applied. (default: current engine)
  70997. * @param reusable If the post process can be reused on the same frame. (default: false)
  70998. * @param textureType Type of textures used when performing the post process. (default: 0)
  70999. * @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)
  71000. */
  71001. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71002. /**
  71003. * Gets wether or not smoothing reflections is enabled.
  71004. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71005. */
  71006. get enableSmoothReflections(): boolean;
  71007. /**
  71008. * Sets wether or not smoothing reflections is enabled.
  71009. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71010. */
  71011. set enableSmoothReflections(enabled: boolean);
  71012. /**
  71013. * Gets the number of samples taken while computing reflections. More samples count is high,
  71014. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71015. */
  71016. get reflectionSamples(): number;
  71017. /**
  71018. * Sets the number of samples taken while computing reflections. More samples count is high,
  71019. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71020. */
  71021. set reflectionSamples(samples: number);
  71022. /**
  71023. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71024. * more the post-process will require GPU power and can generate a drop in FPS.
  71025. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71026. */
  71027. get smoothSteps(): number;
  71028. set smoothSteps(steps: number);
  71029. private _updateEffectDefines;
  71030. /** @hidden */
  71031. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71032. }
  71033. }
  71034. declare module BABYLON {
  71035. /** @hidden */
  71036. export var standardPixelShader: {
  71037. name: string;
  71038. shader: string;
  71039. };
  71040. }
  71041. declare module BABYLON {
  71042. /**
  71043. * Standard rendering pipeline
  71044. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71045. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71046. */
  71047. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71048. /**
  71049. * Public members
  71050. */
  71051. /**
  71052. * Post-process which contains the original scene color before the pipeline applies all the effects
  71053. */
  71054. originalPostProcess: Nullable<PostProcess>;
  71055. /**
  71056. * Post-process used to down scale an image x4
  71057. */
  71058. downSampleX4PostProcess: Nullable<PostProcess>;
  71059. /**
  71060. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71061. */
  71062. brightPassPostProcess: Nullable<PostProcess>;
  71063. /**
  71064. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71065. */
  71066. blurHPostProcesses: PostProcess[];
  71067. /**
  71068. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71069. */
  71070. blurVPostProcesses: PostProcess[];
  71071. /**
  71072. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71073. */
  71074. textureAdderPostProcess: Nullable<PostProcess>;
  71075. /**
  71076. * Post-process used to create volumetric lighting effect
  71077. */
  71078. volumetricLightPostProcess: Nullable<PostProcess>;
  71079. /**
  71080. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71081. */
  71082. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71083. /**
  71084. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71085. */
  71086. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71087. /**
  71088. * Post-process used to merge the volumetric light effect and the real scene color
  71089. */
  71090. volumetricLightMergePostProces: Nullable<PostProcess>;
  71091. /**
  71092. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71093. */
  71094. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71095. /**
  71096. * Base post-process used to calculate the average luminance of the final image for HDR
  71097. */
  71098. luminancePostProcess: Nullable<PostProcess>;
  71099. /**
  71100. * Post-processes used to create down sample post-processes in order to get
  71101. * the average luminance of the final image for HDR
  71102. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71103. */
  71104. luminanceDownSamplePostProcesses: PostProcess[];
  71105. /**
  71106. * Post-process used to create a HDR effect (light adaptation)
  71107. */
  71108. hdrPostProcess: Nullable<PostProcess>;
  71109. /**
  71110. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71111. */
  71112. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71113. /**
  71114. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71115. */
  71116. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71117. /**
  71118. * Post-process used to merge the final HDR post-process and the real scene color
  71119. */
  71120. hdrFinalPostProcess: Nullable<PostProcess>;
  71121. /**
  71122. * Post-process used to create a lens flare effect
  71123. */
  71124. lensFlarePostProcess: Nullable<PostProcess>;
  71125. /**
  71126. * Post-process that merges the result of the lens flare post-process and the real scene color
  71127. */
  71128. lensFlareComposePostProcess: Nullable<PostProcess>;
  71129. /**
  71130. * Post-process used to create a motion blur effect
  71131. */
  71132. motionBlurPostProcess: Nullable<PostProcess>;
  71133. /**
  71134. * Post-process used to create a depth of field effect
  71135. */
  71136. depthOfFieldPostProcess: Nullable<PostProcess>;
  71137. /**
  71138. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71139. */
  71140. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71141. /**
  71142. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71143. */
  71144. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71145. /**
  71146. * Represents the brightness threshold in order to configure the illuminated surfaces
  71147. */
  71148. brightThreshold: number;
  71149. /**
  71150. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71151. */
  71152. blurWidth: number;
  71153. /**
  71154. * Sets if the blur for highlighted surfaces must be only horizontal
  71155. */
  71156. horizontalBlur: boolean;
  71157. /**
  71158. * Gets the overall exposure used by the pipeline
  71159. */
  71160. get exposure(): number;
  71161. /**
  71162. * Sets the overall exposure used by the pipeline
  71163. */
  71164. set exposure(value: number);
  71165. /**
  71166. * Texture used typically to simulate "dirty" on camera lens
  71167. */
  71168. lensTexture: Nullable<Texture>;
  71169. /**
  71170. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71171. */
  71172. volumetricLightCoefficient: number;
  71173. /**
  71174. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71175. */
  71176. volumetricLightPower: number;
  71177. /**
  71178. * Used the set the blur intensity to smooth the volumetric lights
  71179. */
  71180. volumetricLightBlurScale: number;
  71181. /**
  71182. * Light (spot or directional) used to generate the volumetric lights rays
  71183. * The source light must have a shadow generate so the pipeline can get its
  71184. * depth map
  71185. */
  71186. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71187. /**
  71188. * For eye adaptation, represents the minimum luminance the eye can see
  71189. */
  71190. hdrMinimumLuminance: number;
  71191. /**
  71192. * For eye adaptation, represents the decrease luminance speed
  71193. */
  71194. hdrDecreaseRate: number;
  71195. /**
  71196. * For eye adaptation, represents the increase luminance speed
  71197. */
  71198. hdrIncreaseRate: number;
  71199. /**
  71200. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71201. */
  71202. get hdrAutoExposure(): boolean;
  71203. /**
  71204. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71205. */
  71206. set hdrAutoExposure(value: boolean);
  71207. /**
  71208. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71209. */
  71210. lensColorTexture: Nullable<Texture>;
  71211. /**
  71212. * The overall strengh for the lens flare effect
  71213. */
  71214. lensFlareStrength: number;
  71215. /**
  71216. * Dispersion coefficient for lens flare ghosts
  71217. */
  71218. lensFlareGhostDispersal: number;
  71219. /**
  71220. * Main lens flare halo width
  71221. */
  71222. lensFlareHaloWidth: number;
  71223. /**
  71224. * Based on the lens distortion effect, defines how much the lens flare result
  71225. * is distorted
  71226. */
  71227. lensFlareDistortionStrength: number;
  71228. /**
  71229. * Configures the blur intensity used for for lens flare (halo)
  71230. */
  71231. lensFlareBlurWidth: number;
  71232. /**
  71233. * Lens star texture must be used to simulate rays on the flares and is available
  71234. * in the documentation
  71235. */
  71236. lensStarTexture: Nullable<Texture>;
  71237. /**
  71238. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71239. * flare effect by taking account of the dirt texture
  71240. */
  71241. lensFlareDirtTexture: Nullable<Texture>;
  71242. /**
  71243. * Represents the focal length for the depth of field effect
  71244. */
  71245. depthOfFieldDistance: number;
  71246. /**
  71247. * Represents the blur intensity for the blurred part of the depth of field effect
  71248. */
  71249. depthOfFieldBlurWidth: number;
  71250. /**
  71251. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71252. */
  71253. get motionStrength(): number;
  71254. /**
  71255. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71256. */
  71257. set motionStrength(strength: number);
  71258. /**
  71259. * Gets wether or not the motion blur post-process is object based or screen based.
  71260. */
  71261. get objectBasedMotionBlur(): boolean;
  71262. /**
  71263. * Sets wether or not the motion blur post-process should be object based or screen based
  71264. */
  71265. set objectBasedMotionBlur(value: boolean);
  71266. /**
  71267. * List of animations for the pipeline (IAnimatable implementation)
  71268. */
  71269. animations: Animation[];
  71270. /**
  71271. * Private members
  71272. */
  71273. private _scene;
  71274. private _currentDepthOfFieldSource;
  71275. private _basePostProcess;
  71276. private _fixedExposure;
  71277. private _currentExposure;
  71278. private _hdrAutoExposure;
  71279. private _hdrCurrentLuminance;
  71280. private _motionStrength;
  71281. private _isObjectBasedMotionBlur;
  71282. private _floatTextureType;
  71283. private _camerasToBeAttached;
  71284. private _ratio;
  71285. private _bloomEnabled;
  71286. private _depthOfFieldEnabled;
  71287. private _vlsEnabled;
  71288. private _lensFlareEnabled;
  71289. private _hdrEnabled;
  71290. private _motionBlurEnabled;
  71291. private _fxaaEnabled;
  71292. private _screenSpaceReflectionsEnabled;
  71293. private _motionBlurSamples;
  71294. private _volumetricLightStepsCount;
  71295. private _samples;
  71296. /**
  71297. * @ignore
  71298. * Specifies if the bloom pipeline is enabled
  71299. */
  71300. get BloomEnabled(): boolean;
  71301. set BloomEnabled(enabled: boolean);
  71302. /**
  71303. * @ignore
  71304. * Specifies if the depth of field pipeline is enabed
  71305. */
  71306. get DepthOfFieldEnabled(): boolean;
  71307. set DepthOfFieldEnabled(enabled: boolean);
  71308. /**
  71309. * @ignore
  71310. * Specifies if the lens flare pipeline is enabed
  71311. */
  71312. get LensFlareEnabled(): boolean;
  71313. set LensFlareEnabled(enabled: boolean);
  71314. /**
  71315. * @ignore
  71316. * Specifies if the HDR pipeline is enabled
  71317. */
  71318. get HDREnabled(): boolean;
  71319. set HDREnabled(enabled: boolean);
  71320. /**
  71321. * @ignore
  71322. * Specifies if the volumetric lights scattering effect is enabled
  71323. */
  71324. get VLSEnabled(): boolean;
  71325. set VLSEnabled(enabled: boolean);
  71326. /**
  71327. * @ignore
  71328. * Specifies if the motion blur effect is enabled
  71329. */
  71330. get MotionBlurEnabled(): boolean;
  71331. set MotionBlurEnabled(enabled: boolean);
  71332. /**
  71333. * Specifies if anti-aliasing is enabled
  71334. */
  71335. get fxaaEnabled(): boolean;
  71336. set fxaaEnabled(enabled: boolean);
  71337. /**
  71338. * Specifies if screen space reflections are enabled.
  71339. */
  71340. get screenSpaceReflectionsEnabled(): boolean;
  71341. set screenSpaceReflectionsEnabled(enabled: boolean);
  71342. /**
  71343. * Specifies the number of steps used to calculate the volumetric lights
  71344. * Typically in interval [50, 200]
  71345. */
  71346. get volumetricLightStepsCount(): number;
  71347. set volumetricLightStepsCount(count: number);
  71348. /**
  71349. * Specifies the number of samples used for the motion blur effect
  71350. * Typically in interval [16, 64]
  71351. */
  71352. get motionBlurSamples(): number;
  71353. set motionBlurSamples(samples: number);
  71354. /**
  71355. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71356. */
  71357. get samples(): number;
  71358. set samples(sampleCount: number);
  71359. /**
  71360. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71361. * @constructor
  71362. * @param name The rendering pipeline name
  71363. * @param scene The scene linked to this pipeline
  71364. * @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)
  71365. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71366. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71367. */
  71368. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71369. private _buildPipeline;
  71370. private _createDownSampleX4PostProcess;
  71371. private _createBrightPassPostProcess;
  71372. private _createBlurPostProcesses;
  71373. private _createTextureAdderPostProcess;
  71374. private _createVolumetricLightPostProcess;
  71375. private _createLuminancePostProcesses;
  71376. private _createHdrPostProcess;
  71377. private _createLensFlarePostProcess;
  71378. private _createDepthOfFieldPostProcess;
  71379. private _createMotionBlurPostProcess;
  71380. private _getDepthTexture;
  71381. private _disposePostProcesses;
  71382. /**
  71383. * Dispose of the pipeline and stop all post processes
  71384. */
  71385. dispose(): void;
  71386. /**
  71387. * Serialize the rendering pipeline (Used when exporting)
  71388. * @returns the serialized object
  71389. */
  71390. serialize(): any;
  71391. /**
  71392. * Parse the serialized pipeline
  71393. * @param source Source pipeline.
  71394. * @param scene The scene to load the pipeline to.
  71395. * @param rootUrl The URL of the serialized pipeline.
  71396. * @returns An instantiated pipeline from the serialized object.
  71397. */
  71398. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71399. /**
  71400. * Luminance steps
  71401. */
  71402. static LuminanceSteps: number;
  71403. }
  71404. }
  71405. declare module BABYLON {
  71406. /** @hidden */
  71407. export var stereoscopicInterlacePixelShader: {
  71408. name: string;
  71409. shader: string;
  71410. };
  71411. }
  71412. declare module BABYLON {
  71413. /**
  71414. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71415. */
  71416. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71417. private _stepSize;
  71418. private _passedProcess;
  71419. /**
  71420. * Gets a string identifying the name of the class
  71421. * @returns "StereoscopicInterlacePostProcessI" string
  71422. */
  71423. getClassName(): string;
  71424. /**
  71425. * Initializes a StereoscopicInterlacePostProcessI
  71426. * @param name The name of the effect.
  71427. * @param rigCameras The rig cameras to be appled to the post process
  71428. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71429. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71430. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71431. * @param engine The engine which the post process will be applied. (default: current engine)
  71432. * @param reusable If the post process can be reused on the same frame. (default: false)
  71433. */
  71434. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71435. }
  71436. /**
  71437. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71438. */
  71439. export class StereoscopicInterlacePostProcess extends PostProcess {
  71440. private _stepSize;
  71441. private _passedProcess;
  71442. /**
  71443. * Gets a string identifying the name of the class
  71444. * @returns "StereoscopicInterlacePostProcess" string
  71445. */
  71446. getClassName(): string;
  71447. /**
  71448. * Initializes a StereoscopicInterlacePostProcess
  71449. * @param name The name of the effect.
  71450. * @param rigCameras The rig cameras to be appled to the post process
  71451. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71453. * @param engine The engine which the post process will be applied. (default: current engine)
  71454. * @param reusable If the post process can be reused on the same frame. (default: false)
  71455. */
  71456. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71457. }
  71458. }
  71459. declare module BABYLON {
  71460. /** @hidden */
  71461. export var tonemapPixelShader: {
  71462. name: string;
  71463. shader: string;
  71464. };
  71465. }
  71466. declare module BABYLON {
  71467. /** Defines operator used for tonemapping */
  71468. export enum TonemappingOperator {
  71469. /** Hable */
  71470. Hable = 0,
  71471. /** Reinhard */
  71472. Reinhard = 1,
  71473. /** HejiDawson */
  71474. HejiDawson = 2,
  71475. /** Photographic */
  71476. Photographic = 3
  71477. }
  71478. /**
  71479. * Defines a post process to apply tone mapping
  71480. */
  71481. export class TonemapPostProcess extends PostProcess {
  71482. private _operator;
  71483. /** Defines the required exposure adjustement */
  71484. exposureAdjustment: number;
  71485. /**
  71486. * Gets a string identifying the name of the class
  71487. * @returns "TonemapPostProcess" string
  71488. */
  71489. getClassName(): string;
  71490. /**
  71491. * Creates a new TonemapPostProcess
  71492. * @param name defines the name of the postprocess
  71493. * @param _operator defines the operator to use
  71494. * @param exposureAdjustment defines the required exposure adjustement
  71495. * @param camera defines the camera to use (can be null)
  71496. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71497. * @param engine defines the hosting engine (can be ignore if camera is set)
  71498. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71499. */
  71500. constructor(name: string, _operator: TonemappingOperator,
  71501. /** Defines the required exposure adjustement */
  71502. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71503. }
  71504. }
  71505. declare module BABYLON {
  71506. /** @hidden */
  71507. export var volumetricLightScatteringPixelShader: {
  71508. name: string;
  71509. shader: string;
  71510. };
  71511. }
  71512. declare module BABYLON {
  71513. /** @hidden */
  71514. export var volumetricLightScatteringPassVertexShader: {
  71515. name: string;
  71516. shader: string;
  71517. };
  71518. }
  71519. declare module BABYLON {
  71520. /** @hidden */
  71521. export var volumetricLightScatteringPassPixelShader: {
  71522. name: string;
  71523. shader: string;
  71524. };
  71525. }
  71526. declare module BABYLON {
  71527. /**
  71528. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71529. */
  71530. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71531. private _volumetricLightScatteringPass;
  71532. private _volumetricLightScatteringRTT;
  71533. private _viewPort;
  71534. private _screenCoordinates;
  71535. private _cachedDefines;
  71536. /**
  71537. * If not undefined, the mesh position is computed from the attached node position
  71538. */
  71539. attachedNode: {
  71540. position: Vector3;
  71541. };
  71542. /**
  71543. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71544. */
  71545. customMeshPosition: Vector3;
  71546. /**
  71547. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71548. */
  71549. useCustomMeshPosition: boolean;
  71550. /**
  71551. * If the post-process should inverse the light scattering direction
  71552. */
  71553. invert: boolean;
  71554. /**
  71555. * The internal mesh used by the post-process
  71556. */
  71557. mesh: Mesh;
  71558. /**
  71559. * @hidden
  71560. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71561. */
  71562. get useDiffuseColor(): boolean;
  71563. set useDiffuseColor(useDiffuseColor: boolean);
  71564. /**
  71565. * Array containing the excluded meshes not rendered in the internal pass
  71566. */
  71567. excludedMeshes: AbstractMesh[];
  71568. /**
  71569. * Controls the overall intensity of the post-process
  71570. */
  71571. exposure: number;
  71572. /**
  71573. * Dissipates each sample's contribution in range [0, 1]
  71574. */
  71575. decay: number;
  71576. /**
  71577. * Controls the overall intensity of each sample
  71578. */
  71579. weight: number;
  71580. /**
  71581. * Controls the density of each sample
  71582. */
  71583. density: number;
  71584. /**
  71585. * @constructor
  71586. * @param name The post-process name
  71587. * @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)
  71588. * @param camera The camera that the post-process will be attached to
  71589. * @param mesh The mesh used to create the light scattering
  71590. * @param samples The post-process quality, default 100
  71591. * @param samplingModeThe post-process filtering mode
  71592. * @param engine The babylon engine
  71593. * @param reusable If the post-process is reusable
  71594. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71595. */
  71596. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71597. /**
  71598. * Returns the string "VolumetricLightScatteringPostProcess"
  71599. * @returns "VolumetricLightScatteringPostProcess"
  71600. */
  71601. getClassName(): string;
  71602. private _isReady;
  71603. /**
  71604. * Sets the new light position for light scattering effect
  71605. * @param position The new custom light position
  71606. */
  71607. setCustomMeshPosition(position: Vector3): void;
  71608. /**
  71609. * Returns the light position for light scattering effect
  71610. * @return Vector3 The custom light position
  71611. */
  71612. getCustomMeshPosition(): Vector3;
  71613. /**
  71614. * Disposes the internal assets and detaches the post-process from the camera
  71615. */
  71616. dispose(camera: Camera): void;
  71617. /**
  71618. * Returns the render target texture used by the post-process
  71619. * @return the render target texture used by the post-process
  71620. */
  71621. getPass(): RenderTargetTexture;
  71622. private _meshExcluded;
  71623. private _createPass;
  71624. private _updateMeshScreenCoordinates;
  71625. /**
  71626. * Creates a default mesh for the Volumeric Light Scattering post-process
  71627. * @param name The mesh name
  71628. * @param scene The scene where to create the mesh
  71629. * @return the default mesh
  71630. */
  71631. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71632. }
  71633. }
  71634. declare module BABYLON {
  71635. /** @hidden */
  71636. export var screenSpaceCurvaturePixelShader: {
  71637. name: string;
  71638. shader: string;
  71639. };
  71640. }
  71641. declare module BABYLON {
  71642. /**
  71643. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71644. */
  71645. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71646. /**
  71647. * Defines how much ridge the curvature effect displays.
  71648. */
  71649. ridge: number;
  71650. /**
  71651. * Defines how much valley the curvature effect displays.
  71652. */
  71653. valley: number;
  71654. private _geometryBufferRenderer;
  71655. /**
  71656. * Gets a string identifying the name of the class
  71657. * @returns "ScreenSpaceCurvaturePostProcess" string
  71658. */
  71659. getClassName(): string;
  71660. /**
  71661. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71662. * @param name The name of the effect.
  71663. * @param scene The scene containing the objects to blur according to their velocity.
  71664. * @param options The required width/height ratio to downsize to before computing the render pass.
  71665. * @param camera The camera to apply the render pass to.
  71666. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71667. * @param engine The engine which the post process will be applied. (default: current engine)
  71668. * @param reusable If the post process can be reused on the same frame. (default: false)
  71669. * @param textureType Type of textures used when performing the post process. (default: 0)
  71670. * @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)
  71671. */
  71672. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71673. /**
  71674. * Support test.
  71675. */
  71676. static get IsSupported(): boolean;
  71677. /** @hidden */
  71678. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  71679. }
  71680. }
  71681. declare module BABYLON {
  71682. interface Scene {
  71683. /** @hidden (Backing field) */
  71684. _boundingBoxRenderer: BoundingBoxRenderer;
  71685. /** @hidden (Backing field) */
  71686. _forceShowBoundingBoxes: boolean;
  71687. /**
  71688. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71689. */
  71690. forceShowBoundingBoxes: boolean;
  71691. /**
  71692. * Gets the bounding box renderer associated with the scene
  71693. * @returns a BoundingBoxRenderer
  71694. */
  71695. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71696. }
  71697. interface AbstractMesh {
  71698. /** @hidden (Backing field) */
  71699. _showBoundingBox: boolean;
  71700. /**
  71701. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71702. */
  71703. showBoundingBox: boolean;
  71704. }
  71705. /**
  71706. * Component responsible of rendering the bounding box of the meshes in a scene.
  71707. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71708. */
  71709. export class BoundingBoxRenderer implements ISceneComponent {
  71710. /**
  71711. * The component name helpfull to identify the component in the list of scene components.
  71712. */
  71713. readonly name: string;
  71714. /**
  71715. * The scene the component belongs to.
  71716. */
  71717. scene: Scene;
  71718. /**
  71719. * Color of the bounding box lines placed in front of an object
  71720. */
  71721. frontColor: Color3;
  71722. /**
  71723. * Color of the bounding box lines placed behind an object
  71724. */
  71725. backColor: Color3;
  71726. /**
  71727. * Defines if the renderer should show the back lines or not
  71728. */
  71729. showBackLines: boolean;
  71730. /**
  71731. * Observable raised before rendering a bounding box
  71732. */
  71733. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71734. /**
  71735. * Observable raised after rendering a bounding box
  71736. */
  71737. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71738. /**
  71739. * @hidden
  71740. */
  71741. renderList: SmartArray<BoundingBox>;
  71742. private _colorShader;
  71743. private _vertexBuffers;
  71744. private _indexBuffer;
  71745. private _fillIndexBuffer;
  71746. private _fillIndexData;
  71747. /**
  71748. * Instantiates a new bounding box renderer in a scene.
  71749. * @param scene the scene the renderer renders in
  71750. */
  71751. constructor(scene: Scene);
  71752. /**
  71753. * Registers the component in a given scene
  71754. */
  71755. register(): void;
  71756. private _evaluateSubMesh;
  71757. private _activeMesh;
  71758. private _prepareRessources;
  71759. private _createIndexBuffer;
  71760. /**
  71761. * Rebuilds the elements related to this component in case of
  71762. * context lost for instance.
  71763. */
  71764. rebuild(): void;
  71765. /**
  71766. * @hidden
  71767. */
  71768. reset(): void;
  71769. /**
  71770. * Render the bounding boxes of a specific rendering group
  71771. * @param renderingGroupId defines the rendering group to render
  71772. */
  71773. render(renderingGroupId: number): void;
  71774. /**
  71775. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71776. * @param mesh Define the mesh to render the occlusion bounding box for
  71777. */
  71778. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71779. /**
  71780. * Dispose and release the resources attached to this renderer.
  71781. */
  71782. dispose(): void;
  71783. }
  71784. }
  71785. declare module BABYLON {
  71786. interface Scene {
  71787. /** @hidden (Backing field) */
  71788. _depthRenderer: {
  71789. [id: string]: DepthRenderer;
  71790. };
  71791. /**
  71792. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71793. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71794. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71795. * @returns the created depth renderer
  71796. */
  71797. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71798. /**
  71799. * Disables a depth renderer for a given camera
  71800. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71801. */
  71802. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71803. }
  71804. /**
  71805. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71806. * in several rendering techniques.
  71807. */
  71808. export class DepthRendererSceneComponent implements ISceneComponent {
  71809. /**
  71810. * The component name helpfull to identify the component in the list of scene components.
  71811. */
  71812. readonly name: string;
  71813. /**
  71814. * The scene the component belongs to.
  71815. */
  71816. scene: Scene;
  71817. /**
  71818. * Creates a new instance of the component for the given scene
  71819. * @param scene Defines the scene to register the component in
  71820. */
  71821. constructor(scene: Scene);
  71822. /**
  71823. * Registers the component in a given scene
  71824. */
  71825. register(): void;
  71826. /**
  71827. * Rebuilds the elements related to this component in case of
  71828. * context lost for instance.
  71829. */
  71830. rebuild(): void;
  71831. /**
  71832. * Disposes the component and the associated ressources
  71833. */
  71834. dispose(): void;
  71835. private _gatherRenderTargets;
  71836. private _gatherActiveCameraRenderTargets;
  71837. }
  71838. }
  71839. declare module BABYLON {
  71840. interface AbstractScene {
  71841. /** @hidden (Backing field) */
  71842. _prePassRenderer: Nullable<PrePassRenderer>;
  71843. /**
  71844. * Gets or Sets the current prepass renderer associated to the scene.
  71845. */
  71846. prePassRenderer: Nullable<PrePassRenderer>;
  71847. /**
  71848. * Enables the prepass and associates it with the scene
  71849. * @returns the PrePassRenderer
  71850. */
  71851. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71852. /**
  71853. * Disables the prepass associated with the scene
  71854. */
  71855. disablePrePassRenderer(): void;
  71856. }
  71857. /**
  71858. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71859. * in several rendering techniques.
  71860. */
  71861. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71862. /**
  71863. * The component name helpful to identify the component in the list of scene components.
  71864. */
  71865. readonly name: string;
  71866. /**
  71867. * The scene the component belongs to.
  71868. */
  71869. scene: Scene;
  71870. /**
  71871. * Creates a new instance of the component for the given scene
  71872. * @param scene Defines the scene to register the component in
  71873. */
  71874. constructor(scene: Scene);
  71875. /**
  71876. * Registers the component in a given scene
  71877. */
  71878. register(): void;
  71879. private _beforeCameraDraw;
  71880. private _afterCameraDraw;
  71881. private _beforeClearStage;
  71882. /**
  71883. * Serializes the component data to the specified json object
  71884. * @param serializationObject The object to serialize to
  71885. */
  71886. serialize(serializationObject: any): void;
  71887. /**
  71888. * Adds all the elements from the container to the scene
  71889. * @param container the container holding the elements
  71890. */
  71891. addFromContainer(container: AbstractScene): void;
  71892. /**
  71893. * Removes all the elements in the container from the scene
  71894. * @param container contains the elements to remove
  71895. * @param dispose if the removed element should be disposed (default: false)
  71896. */
  71897. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71898. /**
  71899. * Rebuilds the elements related to this component in case of
  71900. * context lost for instance.
  71901. */
  71902. rebuild(): void;
  71903. /**
  71904. * Disposes the component and the associated ressources
  71905. */
  71906. dispose(): void;
  71907. }
  71908. }
  71909. declare module BABYLON {
  71910. /** @hidden */
  71911. export var outlinePixelShader: {
  71912. name: string;
  71913. shader: string;
  71914. };
  71915. }
  71916. declare module BABYLON {
  71917. /** @hidden */
  71918. export var outlineVertexShader: {
  71919. name: string;
  71920. shader: string;
  71921. };
  71922. }
  71923. declare module BABYLON {
  71924. interface Scene {
  71925. /** @hidden */
  71926. _outlineRenderer: OutlineRenderer;
  71927. /**
  71928. * Gets the outline renderer associated with the scene
  71929. * @returns a OutlineRenderer
  71930. */
  71931. getOutlineRenderer(): OutlineRenderer;
  71932. }
  71933. interface AbstractMesh {
  71934. /** @hidden (Backing field) */
  71935. _renderOutline: boolean;
  71936. /**
  71937. * Gets or sets a boolean indicating if the outline must be rendered as well
  71938. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71939. */
  71940. renderOutline: boolean;
  71941. /** @hidden (Backing field) */
  71942. _renderOverlay: boolean;
  71943. /**
  71944. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71945. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71946. */
  71947. renderOverlay: boolean;
  71948. }
  71949. /**
  71950. * This class is responsible to draw bothe outline/overlay of meshes.
  71951. * It should not be used directly but through the available method on mesh.
  71952. */
  71953. export class OutlineRenderer implements ISceneComponent {
  71954. /**
  71955. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71956. */
  71957. private static _StencilReference;
  71958. /**
  71959. * The name of the component. Each component must have a unique name.
  71960. */
  71961. name: string;
  71962. /**
  71963. * The scene the component belongs to.
  71964. */
  71965. scene: Scene;
  71966. /**
  71967. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71968. */
  71969. zOffset: number;
  71970. private _engine;
  71971. private _effect;
  71972. private _cachedDefines;
  71973. private _savedDepthWrite;
  71974. /**
  71975. * Instantiates a new outline renderer. (There could be only one per scene).
  71976. * @param scene Defines the scene it belongs to
  71977. */
  71978. constructor(scene: Scene);
  71979. /**
  71980. * Register the component to one instance of a scene.
  71981. */
  71982. register(): void;
  71983. /**
  71984. * Rebuilds the elements related to this component in case of
  71985. * context lost for instance.
  71986. */
  71987. rebuild(): void;
  71988. /**
  71989. * Disposes the component and the associated ressources.
  71990. */
  71991. dispose(): void;
  71992. /**
  71993. * Renders the outline in the canvas.
  71994. * @param subMesh Defines the sumesh to render
  71995. * @param batch Defines the batch of meshes in case of instances
  71996. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71997. */
  71998. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71999. /**
  72000. * Returns whether or not the outline renderer is ready for a given submesh.
  72001. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72002. * @param subMesh Defines the submesh to check readyness for
  72003. * @param useInstances Defines wheter wee are trying to render instances or not
  72004. * @returns true if ready otherwise false
  72005. */
  72006. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72007. private _beforeRenderingMesh;
  72008. private _afterRenderingMesh;
  72009. }
  72010. }
  72011. declare module BABYLON {
  72012. /**
  72013. * Defines the basic options interface of a Sprite Frame Source Size.
  72014. */
  72015. export interface ISpriteJSONSpriteSourceSize {
  72016. /**
  72017. * number of the original width of the Frame
  72018. */
  72019. w: number;
  72020. /**
  72021. * number of the original height of the Frame
  72022. */
  72023. h: number;
  72024. }
  72025. /**
  72026. * Defines the basic options interface of a Sprite Frame Data.
  72027. */
  72028. export interface ISpriteJSONSpriteFrameData {
  72029. /**
  72030. * number of the x offset of the Frame
  72031. */
  72032. x: number;
  72033. /**
  72034. * number of the y offset of the Frame
  72035. */
  72036. y: number;
  72037. /**
  72038. * number of the width of the Frame
  72039. */
  72040. w: number;
  72041. /**
  72042. * number of the height of the Frame
  72043. */
  72044. h: number;
  72045. }
  72046. /**
  72047. * Defines the basic options interface of a JSON Sprite.
  72048. */
  72049. export interface ISpriteJSONSprite {
  72050. /**
  72051. * string name of the Frame
  72052. */
  72053. filename: string;
  72054. /**
  72055. * ISpriteJSONSpriteFrame basic object of the frame data
  72056. */
  72057. frame: ISpriteJSONSpriteFrameData;
  72058. /**
  72059. * boolean to flag is the frame was rotated.
  72060. */
  72061. rotated: boolean;
  72062. /**
  72063. * boolean to flag is the frame was trimmed.
  72064. */
  72065. trimmed: boolean;
  72066. /**
  72067. * ISpriteJSONSpriteFrame basic object of the source data
  72068. */
  72069. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72070. /**
  72071. * ISpriteJSONSpriteFrame basic object of the source data
  72072. */
  72073. sourceSize: ISpriteJSONSpriteSourceSize;
  72074. }
  72075. /**
  72076. * Defines the basic options interface of a JSON atlas.
  72077. */
  72078. export interface ISpriteJSONAtlas {
  72079. /**
  72080. * Array of objects that contain the frame data.
  72081. */
  72082. frames: Array<ISpriteJSONSprite>;
  72083. /**
  72084. * object basic object containing the sprite meta data.
  72085. */
  72086. meta?: object;
  72087. }
  72088. }
  72089. declare module BABYLON {
  72090. /** @hidden */
  72091. export var spriteMapPixelShader: {
  72092. name: string;
  72093. shader: string;
  72094. };
  72095. }
  72096. declare module BABYLON {
  72097. /** @hidden */
  72098. export var spriteMapVertexShader: {
  72099. name: string;
  72100. shader: string;
  72101. };
  72102. }
  72103. declare module BABYLON {
  72104. /**
  72105. * Defines the basic options interface of a SpriteMap
  72106. */
  72107. export interface ISpriteMapOptions {
  72108. /**
  72109. * Vector2 of the number of cells in the grid.
  72110. */
  72111. stageSize?: Vector2;
  72112. /**
  72113. * Vector2 of the size of the output plane in World Units.
  72114. */
  72115. outputSize?: Vector2;
  72116. /**
  72117. * Vector3 of the position of the output plane in World Units.
  72118. */
  72119. outputPosition?: Vector3;
  72120. /**
  72121. * Vector3 of the rotation of the output plane.
  72122. */
  72123. outputRotation?: Vector3;
  72124. /**
  72125. * number of layers that the system will reserve in resources.
  72126. */
  72127. layerCount?: number;
  72128. /**
  72129. * number of max animation frames a single cell will reserve in resources.
  72130. */
  72131. maxAnimationFrames?: number;
  72132. /**
  72133. * number cell index of the base tile when the system compiles.
  72134. */
  72135. baseTile?: number;
  72136. /**
  72137. * boolean flip the sprite after its been repositioned by the framing data.
  72138. */
  72139. flipU?: boolean;
  72140. /**
  72141. * Vector3 scalar of the global RGB values of the SpriteMap.
  72142. */
  72143. colorMultiply?: Vector3;
  72144. }
  72145. /**
  72146. * Defines the IDisposable interface in order to be cleanable from resources.
  72147. */
  72148. export interface ISpriteMap extends IDisposable {
  72149. /**
  72150. * String name of the SpriteMap.
  72151. */
  72152. name: string;
  72153. /**
  72154. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72155. */
  72156. atlasJSON: ISpriteJSONAtlas;
  72157. /**
  72158. * Texture of the SpriteMap.
  72159. */
  72160. spriteSheet: Texture;
  72161. /**
  72162. * The parameters to initialize the SpriteMap with.
  72163. */
  72164. options: ISpriteMapOptions;
  72165. }
  72166. /**
  72167. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72168. */
  72169. export class SpriteMap implements ISpriteMap {
  72170. /** The Name of the spriteMap */
  72171. name: string;
  72172. /** The JSON file with the frame and meta data */
  72173. atlasJSON: ISpriteJSONAtlas;
  72174. /** The systems Sprite Sheet Texture */
  72175. spriteSheet: Texture;
  72176. /** Arguments passed with the Constructor */
  72177. options: ISpriteMapOptions;
  72178. /** Public Sprite Storage array, parsed from atlasJSON */
  72179. sprites: Array<ISpriteJSONSprite>;
  72180. /** Returns the Number of Sprites in the System */
  72181. get spriteCount(): number;
  72182. /** Returns the Position of Output Plane*/
  72183. get position(): Vector3;
  72184. /** Returns the Position of Output Plane*/
  72185. set position(v: Vector3);
  72186. /** Returns the Rotation of Output Plane*/
  72187. get rotation(): Vector3;
  72188. /** Returns the Rotation of Output Plane*/
  72189. set rotation(v: Vector3);
  72190. /** Sets the AnimationMap*/
  72191. get animationMap(): RawTexture;
  72192. /** Sets the AnimationMap*/
  72193. set animationMap(v: RawTexture);
  72194. /** Scene that the SpriteMap was created in */
  72195. private _scene;
  72196. /** Texture Buffer of Float32 that holds tile frame data*/
  72197. private _frameMap;
  72198. /** Texture Buffers of Float32 that holds tileMap data*/
  72199. private _tileMaps;
  72200. /** Texture Buffer of Float32 that holds Animation Data*/
  72201. private _animationMap;
  72202. /** Custom ShaderMaterial Central to the System*/
  72203. private _material;
  72204. /** Custom ShaderMaterial Central to the System*/
  72205. private _output;
  72206. /** Systems Time Ticker*/
  72207. private _time;
  72208. /**
  72209. * Creates a new SpriteMap
  72210. * @param name defines the SpriteMaps Name
  72211. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72212. * @param spriteSheet is the Texture that the Sprites are on.
  72213. * @param options a basic deployment configuration
  72214. * @param scene The Scene that the map is deployed on
  72215. */
  72216. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72217. /**
  72218. * Returns tileID location
  72219. * @returns Vector2 the cell position ID
  72220. */
  72221. getTileID(): Vector2;
  72222. /**
  72223. * Gets the UV location of the mouse over the SpriteMap.
  72224. * @returns Vector2 the UV position of the mouse interaction
  72225. */
  72226. getMousePosition(): Vector2;
  72227. /**
  72228. * Creates the "frame" texture Buffer
  72229. * -------------------------------------
  72230. * Structure of frames
  72231. * "filename": "Falling-Water-2.png",
  72232. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72233. * "rotated": true,
  72234. * "trimmed": true,
  72235. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72236. * "sourceSize": {"w":32,"h":32}
  72237. * @returns RawTexture of the frameMap
  72238. */
  72239. private _createFrameBuffer;
  72240. /**
  72241. * Creates the tileMap texture Buffer
  72242. * @param buffer normally and array of numbers, or a false to generate from scratch
  72243. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72244. * @returns RawTexture of the tileMap
  72245. */
  72246. private _createTileBuffer;
  72247. /**
  72248. * Modifies the data of the tileMaps
  72249. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72250. * @param pos is the iVector2 Coordinates of the Tile
  72251. * @param tile The SpriteIndex of the new Tile
  72252. */
  72253. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72254. /**
  72255. * Creates the animationMap texture Buffer
  72256. * @param buffer normally and array of numbers, or a false to generate from scratch
  72257. * @returns RawTexture of the animationMap
  72258. */
  72259. private _createTileAnimationBuffer;
  72260. /**
  72261. * Modifies the data of the animationMap
  72262. * @param cellID is the Index of the Sprite
  72263. * @param _frame is the target Animation frame
  72264. * @param toCell is the Target Index of the next frame of the animation
  72265. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72266. * @param speed is a global scalar of the time variable on the map.
  72267. */
  72268. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72269. /**
  72270. * Exports the .tilemaps file
  72271. */
  72272. saveTileMaps(): void;
  72273. /**
  72274. * Imports the .tilemaps file
  72275. * @param url of the .tilemaps file
  72276. */
  72277. loadTileMaps(url: string): void;
  72278. /**
  72279. * Release associated resources
  72280. */
  72281. dispose(): void;
  72282. }
  72283. }
  72284. declare module BABYLON {
  72285. /**
  72286. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72287. * @see https://doc.babylonjs.com/babylon101/sprites
  72288. */
  72289. export class SpritePackedManager extends SpriteManager {
  72290. /** defines the packed manager's name */
  72291. name: string;
  72292. /**
  72293. * Creates a new sprite manager from a packed sprite sheet
  72294. * @param name defines the manager's name
  72295. * @param imgUrl defines the sprite sheet url
  72296. * @param capacity defines the maximum allowed number of sprites
  72297. * @param scene defines the hosting scene
  72298. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72299. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72300. * @param samplingMode defines the smapling mode to use with spritesheet
  72301. * @param fromPacked set to true; do not alter
  72302. */
  72303. constructor(
  72304. /** defines the packed manager's name */
  72305. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72306. }
  72307. }
  72308. declare module BABYLON {
  72309. /**
  72310. * Defines the list of states available for a task inside a AssetsManager
  72311. */
  72312. export enum AssetTaskState {
  72313. /**
  72314. * Initialization
  72315. */
  72316. INIT = 0,
  72317. /**
  72318. * Running
  72319. */
  72320. RUNNING = 1,
  72321. /**
  72322. * Done
  72323. */
  72324. DONE = 2,
  72325. /**
  72326. * Error
  72327. */
  72328. ERROR = 3
  72329. }
  72330. /**
  72331. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72332. */
  72333. export abstract class AbstractAssetTask {
  72334. /**
  72335. * Task name
  72336. */ name: string;
  72337. /**
  72338. * Callback called when the task is successful
  72339. */
  72340. onSuccess: (task: any) => void;
  72341. /**
  72342. * Callback called when the task is not successful
  72343. */
  72344. onError: (task: any, message?: string, exception?: any) => void;
  72345. /**
  72346. * Creates a new AssetsManager
  72347. * @param name defines the name of the task
  72348. */
  72349. constructor(
  72350. /**
  72351. * Task name
  72352. */ name: string);
  72353. private _isCompleted;
  72354. private _taskState;
  72355. private _errorObject;
  72356. /**
  72357. * Get if the task is completed
  72358. */
  72359. get isCompleted(): boolean;
  72360. /**
  72361. * Gets the current state of the task
  72362. */
  72363. get taskState(): AssetTaskState;
  72364. /**
  72365. * Gets the current error object (if task is in error)
  72366. */
  72367. get errorObject(): {
  72368. message?: string;
  72369. exception?: any;
  72370. };
  72371. /**
  72372. * Internal only
  72373. * @hidden
  72374. */
  72375. _setErrorObject(message?: string, exception?: any): void;
  72376. /**
  72377. * Execute the current task
  72378. * @param scene defines the scene where you want your assets to be loaded
  72379. * @param onSuccess is a callback called when the task is successfully executed
  72380. * @param onError is a callback called if an error occurs
  72381. */
  72382. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72383. /**
  72384. * Execute the current task
  72385. * @param scene defines the scene where you want your assets to be loaded
  72386. * @param onSuccess is a callback called when the task is successfully executed
  72387. * @param onError is a callback called if an error occurs
  72388. */
  72389. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72390. /**
  72391. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72392. * This can be used with failed tasks that have the reason for failure fixed.
  72393. */
  72394. reset(): void;
  72395. private onErrorCallback;
  72396. private onDoneCallback;
  72397. }
  72398. /**
  72399. * Define the interface used by progress events raised during assets loading
  72400. */
  72401. export interface IAssetsProgressEvent {
  72402. /**
  72403. * Defines the number of remaining tasks to process
  72404. */
  72405. remainingCount: number;
  72406. /**
  72407. * Defines the total number of tasks
  72408. */
  72409. totalCount: number;
  72410. /**
  72411. * Defines the task that was just processed
  72412. */
  72413. task: AbstractAssetTask;
  72414. }
  72415. /**
  72416. * Class used to share progress information about assets loading
  72417. */
  72418. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72419. /**
  72420. * Defines the number of remaining tasks to process
  72421. */
  72422. remainingCount: number;
  72423. /**
  72424. * Defines the total number of tasks
  72425. */
  72426. totalCount: number;
  72427. /**
  72428. * Defines the task that was just processed
  72429. */
  72430. task: AbstractAssetTask;
  72431. /**
  72432. * Creates a AssetsProgressEvent
  72433. * @param remainingCount defines the number of remaining tasks to process
  72434. * @param totalCount defines the total number of tasks
  72435. * @param task defines the task that was just processed
  72436. */
  72437. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72438. }
  72439. /**
  72440. * Define a task used by AssetsManager to load assets into a container
  72441. */
  72442. export class ContainerAssetTask extends AbstractAssetTask {
  72443. /**
  72444. * Defines the name of the task
  72445. */
  72446. name: string;
  72447. /**
  72448. * Defines the list of mesh's names you want to load
  72449. */
  72450. meshesNames: any;
  72451. /**
  72452. * Defines the root url to use as a base to load your meshes and associated resources
  72453. */
  72454. rootUrl: string;
  72455. /**
  72456. * Defines the filename or File of the scene to load from
  72457. */
  72458. sceneFilename: string | File;
  72459. /**
  72460. * Get the loaded asset container
  72461. */
  72462. loadedContainer: AssetContainer;
  72463. /**
  72464. * Gets the list of loaded meshes
  72465. */
  72466. loadedMeshes: Array<AbstractMesh>;
  72467. /**
  72468. * Gets the list of loaded particle systems
  72469. */
  72470. loadedParticleSystems: Array<IParticleSystem>;
  72471. /**
  72472. * Gets the list of loaded skeletons
  72473. */
  72474. loadedSkeletons: Array<Skeleton>;
  72475. /**
  72476. * Gets the list of loaded animation groups
  72477. */
  72478. loadedAnimationGroups: Array<AnimationGroup>;
  72479. /**
  72480. * Callback called when the task is successful
  72481. */
  72482. onSuccess: (task: ContainerAssetTask) => void;
  72483. /**
  72484. * Callback called when the task is successful
  72485. */
  72486. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72487. /**
  72488. * Creates a new ContainerAssetTask
  72489. * @param name defines the name of the task
  72490. * @param meshesNames defines the list of mesh's names you want to load
  72491. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72492. * @param sceneFilename defines the filename or File of the scene to load from
  72493. */
  72494. constructor(
  72495. /**
  72496. * Defines the name of the task
  72497. */
  72498. name: string,
  72499. /**
  72500. * Defines the list of mesh's names you want to load
  72501. */
  72502. meshesNames: any,
  72503. /**
  72504. * Defines the root url to use as a base to load your meshes and associated resources
  72505. */
  72506. rootUrl: string,
  72507. /**
  72508. * Defines the filename or File of the scene to load from
  72509. */
  72510. sceneFilename: string | File);
  72511. /**
  72512. * Execute the current task
  72513. * @param scene defines the scene where you want your assets to be loaded
  72514. * @param onSuccess is a callback called when the task is successfully executed
  72515. * @param onError is a callback called if an error occurs
  72516. */
  72517. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72518. }
  72519. /**
  72520. * Define a task used by AssetsManager to load meshes
  72521. */
  72522. export class MeshAssetTask extends AbstractAssetTask {
  72523. /**
  72524. * Defines the name of the task
  72525. */
  72526. name: string;
  72527. /**
  72528. * Defines the list of mesh's names you want to load
  72529. */
  72530. meshesNames: any;
  72531. /**
  72532. * Defines the root url to use as a base to load your meshes and associated resources
  72533. */
  72534. rootUrl: string;
  72535. /**
  72536. * Defines the filename or File of the scene to load from
  72537. */
  72538. sceneFilename: string | File;
  72539. /**
  72540. * Gets the list of loaded meshes
  72541. */
  72542. loadedMeshes: Array<AbstractMesh>;
  72543. /**
  72544. * Gets the list of loaded particle systems
  72545. */
  72546. loadedParticleSystems: Array<IParticleSystem>;
  72547. /**
  72548. * Gets the list of loaded skeletons
  72549. */
  72550. loadedSkeletons: Array<Skeleton>;
  72551. /**
  72552. * Gets the list of loaded animation groups
  72553. */
  72554. loadedAnimationGroups: Array<AnimationGroup>;
  72555. /**
  72556. * Callback called when the task is successful
  72557. */
  72558. onSuccess: (task: MeshAssetTask) => void;
  72559. /**
  72560. * Callback called when the task is successful
  72561. */
  72562. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  72563. /**
  72564. * Creates a new MeshAssetTask
  72565. * @param name defines the name of the task
  72566. * @param meshesNames defines the list of mesh's names you want to load
  72567. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72568. * @param sceneFilename defines the filename or File of the scene to load from
  72569. */
  72570. constructor(
  72571. /**
  72572. * Defines the name of the task
  72573. */
  72574. name: string,
  72575. /**
  72576. * Defines the list of mesh's names you want to load
  72577. */
  72578. meshesNames: any,
  72579. /**
  72580. * Defines the root url to use as a base to load your meshes and associated resources
  72581. */
  72582. rootUrl: string,
  72583. /**
  72584. * Defines the filename or File of the scene to load from
  72585. */
  72586. sceneFilename: string | File);
  72587. /**
  72588. * Execute the current task
  72589. * @param scene defines the scene where you want your assets to be loaded
  72590. * @param onSuccess is a callback called when the task is successfully executed
  72591. * @param onError is a callback called if an error occurs
  72592. */
  72593. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72594. }
  72595. /**
  72596. * Define a task used by AssetsManager to load text content
  72597. */
  72598. export class TextFileAssetTask extends AbstractAssetTask {
  72599. /**
  72600. * Defines the name of the task
  72601. */
  72602. name: string;
  72603. /**
  72604. * Defines the location of the file to load
  72605. */
  72606. url: string;
  72607. /**
  72608. * Gets the loaded text string
  72609. */
  72610. text: string;
  72611. /**
  72612. * Callback called when the task is successful
  72613. */
  72614. onSuccess: (task: TextFileAssetTask) => void;
  72615. /**
  72616. * Callback called when the task is successful
  72617. */
  72618. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72619. /**
  72620. * Creates a new TextFileAssetTask object
  72621. * @param name defines the name of the task
  72622. * @param url defines the location of the file to load
  72623. */
  72624. constructor(
  72625. /**
  72626. * Defines the name of the task
  72627. */
  72628. name: string,
  72629. /**
  72630. * Defines the location of the file to load
  72631. */
  72632. url: string);
  72633. /**
  72634. * Execute the current task
  72635. * @param scene defines the scene where you want your assets to be loaded
  72636. * @param onSuccess is a callback called when the task is successfully executed
  72637. * @param onError is a callback called if an error occurs
  72638. */
  72639. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72640. }
  72641. /**
  72642. * Define a task used by AssetsManager to load binary data
  72643. */
  72644. export class BinaryFileAssetTask extends AbstractAssetTask {
  72645. /**
  72646. * Defines the name of the task
  72647. */
  72648. name: string;
  72649. /**
  72650. * Defines the location of the file to load
  72651. */
  72652. url: string;
  72653. /**
  72654. * Gets the lodaded data (as an array buffer)
  72655. */
  72656. data: ArrayBuffer;
  72657. /**
  72658. * Callback called when the task is successful
  72659. */
  72660. onSuccess: (task: BinaryFileAssetTask) => void;
  72661. /**
  72662. * Callback called when the task is successful
  72663. */
  72664. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72665. /**
  72666. * Creates a new BinaryFileAssetTask object
  72667. * @param name defines the name of the new task
  72668. * @param url defines the location of the file to load
  72669. */
  72670. constructor(
  72671. /**
  72672. * Defines the name of the task
  72673. */
  72674. name: string,
  72675. /**
  72676. * Defines the location of the file to load
  72677. */
  72678. url: string);
  72679. /**
  72680. * Execute the current task
  72681. * @param scene defines the scene where you want your assets to be loaded
  72682. * @param onSuccess is a callback called when the task is successfully executed
  72683. * @param onError is a callback called if an error occurs
  72684. */
  72685. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72686. }
  72687. /**
  72688. * Define a task used by AssetsManager to load images
  72689. */
  72690. export class ImageAssetTask extends AbstractAssetTask {
  72691. /**
  72692. * Defines the name of the task
  72693. */
  72694. name: string;
  72695. /**
  72696. * Defines the location of the image to load
  72697. */
  72698. url: string;
  72699. /**
  72700. * Gets the loaded images
  72701. */
  72702. image: HTMLImageElement;
  72703. /**
  72704. * Callback called when the task is successful
  72705. */
  72706. onSuccess: (task: ImageAssetTask) => void;
  72707. /**
  72708. * Callback called when the task is successful
  72709. */
  72710. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72711. /**
  72712. * Creates a new ImageAssetTask
  72713. * @param name defines the name of the task
  72714. * @param url defines the location of the image to load
  72715. */
  72716. constructor(
  72717. /**
  72718. * Defines the name of the task
  72719. */
  72720. name: string,
  72721. /**
  72722. * Defines the location of the image to load
  72723. */
  72724. url: string);
  72725. /**
  72726. * Execute the current task
  72727. * @param scene defines the scene where you want your assets to be loaded
  72728. * @param onSuccess is a callback called when the task is successfully executed
  72729. * @param onError is a callback called if an error occurs
  72730. */
  72731. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72732. }
  72733. /**
  72734. * Defines the interface used by texture loading tasks
  72735. */
  72736. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72737. /**
  72738. * Gets the loaded texture
  72739. */
  72740. texture: TEX;
  72741. }
  72742. /**
  72743. * Define a task used by AssetsManager to load 2D textures
  72744. */
  72745. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72746. /**
  72747. * Defines the name of the task
  72748. */
  72749. name: string;
  72750. /**
  72751. * Defines the location of the file to load
  72752. */
  72753. url: string;
  72754. /**
  72755. * Defines if mipmap should not be generated (default is false)
  72756. */
  72757. noMipmap?: boolean | undefined;
  72758. /**
  72759. * Defines if texture must be inverted on Y axis (default is true)
  72760. */
  72761. invertY: boolean;
  72762. /**
  72763. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72764. */
  72765. samplingMode: number;
  72766. /**
  72767. * Gets the loaded texture
  72768. */
  72769. texture: Texture;
  72770. /**
  72771. * Callback called when the task is successful
  72772. */
  72773. onSuccess: (task: TextureAssetTask) => void;
  72774. /**
  72775. * Callback called when the task is successful
  72776. */
  72777. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72778. /**
  72779. * Creates a new TextureAssetTask object
  72780. * @param name defines the name of the task
  72781. * @param url defines the location of the file to load
  72782. * @param noMipmap defines if mipmap should not be generated (default is false)
  72783. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72784. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72785. */
  72786. constructor(
  72787. /**
  72788. * Defines the name of the task
  72789. */
  72790. name: string,
  72791. /**
  72792. * Defines the location of the file to load
  72793. */
  72794. url: string,
  72795. /**
  72796. * Defines if mipmap should not be generated (default is false)
  72797. */
  72798. noMipmap?: boolean | undefined,
  72799. /**
  72800. * Defines if texture must be inverted on Y axis (default is true)
  72801. */
  72802. invertY?: boolean,
  72803. /**
  72804. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72805. */
  72806. samplingMode?: number);
  72807. /**
  72808. * Execute the current task
  72809. * @param scene defines the scene where you want your assets to be loaded
  72810. * @param onSuccess is a callback called when the task is successfully executed
  72811. * @param onError is a callback called if an error occurs
  72812. */
  72813. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72814. }
  72815. /**
  72816. * Define a task used by AssetsManager to load cube textures
  72817. */
  72818. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72819. /**
  72820. * Defines the name of the task
  72821. */
  72822. name: string;
  72823. /**
  72824. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72825. */
  72826. url: string;
  72827. /**
  72828. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72829. */
  72830. extensions?: string[] | undefined;
  72831. /**
  72832. * Defines if mipmaps should not be generated (default is false)
  72833. */
  72834. noMipmap?: boolean | undefined;
  72835. /**
  72836. * Defines the explicit list of files (undefined by default)
  72837. */
  72838. files?: string[] | undefined;
  72839. /**
  72840. * Gets the loaded texture
  72841. */
  72842. texture: CubeTexture;
  72843. /**
  72844. * Callback called when the task is successful
  72845. */
  72846. onSuccess: (task: CubeTextureAssetTask) => void;
  72847. /**
  72848. * Callback called when the task is successful
  72849. */
  72850. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72851. /**
  72852. * Creates a new CubeTextureAssetTask
  72853. * @param name defines the name of the task
  72854. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72855. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72856. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72857. * @param files defines the explicit list of files (undefined by default)
  72858. */
  72859. constructor(
  72860. /**
  72861. * Defines the name of the task
  72862. */
  72863. name: string,
  72864. /**
  72865. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72866. */
  72867. url: string,
  72868. /**
  72869. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72870. */
  72871. extensions?: string[] | undefined,
  72872. /**
  72873. * Defines if mipmaps should not be generated (default is false)
  72874. */
  72875. noMipmap?: boolean | undefined,
  72876. /**
  72877. * Defines the explicit list of files (undefined by default)
  72878. */
  72879. files?: string[] | undefined);
  72880. /**
  72881. * Execute the current task
  72882. * @param scene defines the scene where you want your assets to be loaded
  72883. * @param onSuccess is a callback called when the task is successfully executed
  72884. * @param onError is a callback called if an error occurs
  72885. */
  72886. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72887. }
  72888. /**
  72889. * Define a task used by AssetsManager to load HDR cube textures
  72890. */
  72891. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  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. * Defines the desired size (the more it increases the longer the generation will be)
  72902. */
  72903. size: number;
  72904. /**
  72905. * Defines if mipmaps should not be generated (default is false)
  72906. */
  72907. noMipmap: boolean;
  72908. /**
  72909. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72910. */
  72911. generateHarmonics: boolean;
  72912. /**
  72913. * 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)
  72914. */
  72915. gammaSpace: boolean;
  72916. /**
  72917. * Internal Use Only
  72918. */
  72919. reserved: boolean;
  72920. /**
  72921. * Gets the loaded texture
  72922. */
  72923. texture: HDRCubeTexture;
  72924. /**
  72925. * Callback called when the task is successful
  72926. */
  72927. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72928. /**
  72929. * Callback called when the task is successful
  72930. */
  72931. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72932. /**
  72933. * Creates a new HDRCubeTextureAssetTask object
  72934. * @param name defines the name of the task
  72935. * @param url defines the location of the file to load
  72936. * @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.
  72937. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72938. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72939. * @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)
  72940. * @param reserved Internal use only
  72941. */
  72942. constructor(
  72943. /**
  72944. * Defines the name of the task
  72945. */
  72946. name: string,
  72947. /**
  72948. * Defines the location of the file to load
  72949. */
  72950. url: string,
  72951. /**
  72952. * Defines the desired size (the more it increases the longer the generation will be)
  72953. */
  72954. size: number,
  72955. /**
  72956. * Defines if mipmaps should not be generated (default is false)
  72957. */
  72958. noMipmap?: boolean,
  72959. /**
  72960. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72961. */
  72962. generateHarmonics?: boolean,
  72963. /**
  72964. * 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)
  72965. */
  72966. gammaSpace?: boolean,
  72967. /**
  72968. * Internal Use Only
  72969. */
  72970. reserved?: boolean);
  72971. /**
  72972. * Execute the current task
  72973. * @param scene defines the scene where you want your assets to be loaded
  72974. * @param onSuccess is a callback called when the task is successfully executed
  72975. * @param onError is a callback called if an error occurs
  72976. */
  72977. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72978. }
  72979. /**
  72980. * Define a task used by AssetsManager to load Equirectangular cube textures
  72981. */
  72982. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72983. /**
  72984. * Defines the name of the task
  72985. */
  72986. name: string;
  72987. /**
  72988. * Defines the location of the file to load
  72989. */
  72990. url: string;
  72991. /**
  72992. * Defines the desired size (the more it increases the longer the generation will be)
  72993. */
  72994. size: number;
  72995. /**
  72996. * Defines if mipmaps should not be generated (default is false)
  72997. */
  72998. noMipmap: boolean;
  72999. /**
  73000. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73001. * but the standard material would require them in Gamma space) (default is true)
  73002. */
  73003. gammaSpace: boolean;
  73004. /**
  73005. * Gets the loaded texture
  73006. */
  73007. texture: EquiRectangularCubeTexture;
  73008. /**
  73009. * Callback called when the task is successful
  73010. */
  73011. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73012. /**
  73013. * Callback called when the task is successful
  73014. */
  73015. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73016. /**
  73017. * Creates a new EquiRectangularCubeTextureAssetTask object
  73018. * @param name defines the name of the task
  73019. * @param url defines the location of the file to load
  73020. * @param size defines the desired size (the more it increases the longer the generation will be)
  73021. * If the size is omitted this implies you are using a preprocessed cubemap.
  73022. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73023. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73024. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73025. * (default is true)
  73026. */
  73027. constructor(
  73028. /**
  73029. * Defines the name of the task
  73030. */
  73031. name: string,
  73032. /**
  73033. * Defines the location of the file to load
  73034. */
  73035. url: string,
  73036. /**
  73037. * Defines the desired size (the more it increases the longer the generation will be)
  73038. */
  73039. size: number,
  73040. /**
  73041. * Defines if mipmaps should not be generated (default is false)
  73042. */
  73043. noMipmap?: boolean,
  73044. /**
  73045. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73046. * but the standard material would require them in Gamma space) (default is true)
  73047. */
  73048. gammaSpace?: boolean);
  73049. /**
  73050. * Execute the current task
  73051. * @param scene defines the scene where you want your assets to be loaded
  73052. * @param onSuccess is a callback called when the task is successfully executed
  73053. * @param onError is a callback called if an error occurs
  73054. */
  73055. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73056. }
  73057. /**
  73058. * This class can be used to easily import assets into a scene
  73059. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73060. */
  73061. export class AssetsManager {
  73062. private _scene;
  73063. private _isLoading;
  73064. protected _tasks: AbstractAssetTask[];
  73065. protected _waitingTasksCount: number;
  73066. protected _totalTasksCount: number;
  73067. /**
  73068. * Callback called when all tasks are processed
  73069. */
  73070. onFinish: (tasks: AbstractAssetTask[]) => void;
  73071. /**
  73072. * Callback called when a task is successful
  73073. */
  73074. onTaskSuccess: (task: AbstractAssetTask) => void;
  73075. /**
  73076. * Callback called when a task had an error
  73077. */
  73078. onTaskError: (task: AbstractAssetTask) => void;
  73079. /**
  73080. * Callback called when a task is done (whatever the result is)
  73081. */
  73082. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73083. /**
  73084. * Observable called when all tasks are processed
  73085. */
  73086. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73087. /**
  73088. * Observable called when a task had an error
  73089. */
  73090. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73091. /**
  73092. * Observable called when all tasks were executed
  73093. */
  73094. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73095. /**
  73096. * Observable called when a task is done (whatever the result is)
  73097. */
  73098. onProgressObservable: Observable<IAssetsProgressEvent>;
  73099. /**
  73100. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73101. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73102. */
  73103. useDefaultLoadingScreen: boolean;
  73104. /**
  73105. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73106. * when all assets have been downloaded.
  73107. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73108. */
  73109. autoHideLoadingUI: boolean;
  73110. /**
  73111. * Creates a new AssetsManager
  73112. * @param scene defines the scene to work on
  73113. */
  73114. constructor(scene: Scene);
  73115. /**
  73116. * Add a ContainerAssetTask to the list of active tasks
  73117. * @param taskName defines the name of the new task
  73118. * @param meshesNames defines the name of meshes to load
  73119. * @param rootUrl defines the root url to use to locate files
  73120. * @param sceneFilename defines the filename of the scene file
  73121. * @returns a new ContainerAssetTask object
  73122. */
  73123. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73124. /**
  73125. * Add a MeshAssetTask to the list of active tasks
  73126. * @param taskName defines the name of the new task
  73127. * @param meshesNames defines the name of meshes to load
  73128. * @param rootUrl defines the root url to use to locate files
  73129. * @param sceneFilename defines the filename of the scene file
  73130. * @returns a new MeshAssetTask object
  73131. */
  73132. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73133. /**
  73134. * Add a TextFileAssetTask to the list of active tasks
  73135. * @param taskName defines the name of the new task
  73136. * @param url defines the url of the file to load
  73137. * @returns a new TextFileAssetTask object
  73138. */
  73139. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73140. /**
  73141. * Add a BinaryFileAssetTask to the list of active tasks
  73142. * @param taskName defines the name of the new task
  73143. * @param url defines the url of the file to load
  73144. * @returns a new BinaryFileAssetTask object
  73145. */
  73146. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73147. /**
  73148. * Add a ImageAssetTask to the list of active tasks
  73149. * @param taskName defines the name of the new task
  73150. * @param url defines the url of the file to load
  73151. * @returns a new ImageAssetTask object
  73152. */
  73153. addImageTask(taskName: string, url: string): ImageAssetTask;
  73154. /**
  73155. * Add a TextureAssetTask to the list of active tasks
  73156. * @param taskName defines the name of the new task
  73157. * @param url defines the url of the file to load
  73158. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73159. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73160. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73161. * @returns a new TextureAssetTask object
  73162. */
  73163. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73164. /**
  73165. * Add a CubeTextureAssetTask to the list of active tasks
  73166. * @param taskName defines the name of the new task
  73167. * @param url defines the url of the file to load
  73168. * @param extensions defines the extension to use to load the cube map (can be null)
  73169. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73170. * @param files defines the list of files to load (can be null)
  73171. * @returns a new CubeTextureAssetTask object
  73172. */
  73173. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73174. /**
  73175. *
  73176. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73177. * @param taskName defines the name of the new task
  73178. * @param url defines the url of the file to load
  73179. * @param size defines the size you want for the cubemap (can be null)
  73180. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73181. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73182. * @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)
  73183. * @param reserved Internal use only
  73184. * @returns a new HDRCubeTextureAssetTask object
  73185. */
  73186. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73187. /**
  73188. *
  73189. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73190. * @param taskName defines the name of the new task
  73191. * @param url defines the url of the file to load
  73192. * @param size defines the size you want for the cubemap (can be null)
  73193. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73194. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73195. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73196. * @returns a new EquiRectangularCubeTextureAssetTask object
  73197. */
  73198. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73199. /**
  73200. * Remove a task from the assets manager.
  73201. * @param task the task to remove
  73202. */
  73203. removeTask(task: AbstractAssetTask): void;
  73204. private _decreaseWaitingTasksCount;
  73205. private _runTask;
  73206. /**
  73207. * Reset the AssetsManager and remove all tasks
  73208. * @return the current instance of the AssetsManager
  73209. */
  73210. reset(): AssetsManager;
  73211. /**
  73212. * Start the loading process
  73213. * @return the current instance of the AssetsManager
  73214. */
  73215. load(): AssetsManager;
  73216. /**
  73217. * Start the loading process as an async operation
  73218. * @return a promise returning the list of failed tasks
  73219. */
  73220. loadAsync(): Promise<void>;
  73221. }
  73222. }
  73223. declare module BABYLON {
  73224. /**
  73225. * Wrapper class for promise with external resolve and reject.
  73226. */
  73227. export class Deferred<T> {
  73228. /**
  73229. * The promise associated with this deferred object.
  73230. */
  73231. readonly promise: Promise<T>;
  73232. private _resolve;
  73233. private _reject;
  73234. /**
  73235. * The resolve method of the promise associated with this deferred object.
  73236. */
  73237. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73238. /**
  73239. * The reject method of the promise associated with this deferred object.
  73240. */
  73241. get reject(): (reason?: any) => void;
  73242. /**
  73243. * Constructor for this deferred object.
  73244. */
  73245. constructor();
  73246. }
  73247. }
  73248. declare module BABYLON {
  73249. /**
  73250. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73251. */
  73252. export class MeshExploder {
  73253. private _centerMesh;
  73254. private _meshes;
  73255. private _meshesOrigins;
  73256. private _toCenterVectors;
  73257. private _scaledDirection;
  73258. private _newPosition;
  73259. private _centerPosition;
  73260. /**
  73261. * Explodes meshes from a center mesh.
  73262. * @param meshes The meshes to explode.
  73263. * @param centerMesh The mesh to be center of explosion.
  73264. */
  73265. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73266. private _setCenterMesh;
  73267. /**
  73268. * Get class name
  73269. * @returns "MeshExploder"
  73270. */
  73271. getClassName(): string;
  73272. /**
  73273. * "Exploded meshes"
  73274. * @returns Array of meshes with the centerMesh at index 0.
  73275. */
  73276. getMeshes(): Array<Mesh>;
  73277. /**
  73278. * Explodes meshes giving a specific direction
  73279. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73280. */
  73281. explode(direction?: number): void;
  73282. }
  73283. }
  73284. declare module BABYLON {
  73285. /**
  73286. * Class used to help managing file picking and drag'n'drop
  73287. */
  73288. export class FilesInput {
  73289. /**
  73290. * List of files ready to be loaded
  73291. */
  73292. static get FilesToLoad(): {
  73293. [key: string]: File;
  73294. };
  73295. /**
  73296. * Callback called when a file is processed
  73297. */
  73298. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73299. private _engine;
  73300. private _currentScene;
  73301. private _sceneLoadedCallback;
  73302. private _progressCallback;
  73303. private _additionalRenderLoopLogicCallback;
  73304. private _textureLoadingCallback;
  73305. private _startingProcessingFilesCallback;
  73306. private _onReloadCallback;
  73307. private _errorCallback;
  73308. private _elementToMonitor;
  73309. private _sceneFileToLoad;
  73310. private _filesToLoad;
  73311. /**
  73312. * Creates a new FilesInput
  73313. * @param engine defines the rendering engine
  73314. * @param scene defines the hosting scene
  73315. * @param sceneLoadedCallback callback called when scene is loaded
  73316. * @param progressCallback callback called to track progress
  73317. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73318. * @param textureLoadingCallback callback called when a texture is loading
  73319. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73320. * @param onReloadCallback callback called when a reload is requested
  73321. * @param errorCallback callback call if an error occurs
  73322. */
  73323. 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>);
  73324. private _dragEnterHandler;
  73325. private _dragOverHandler;
  73326. private _dropHandler;
  73327. /**
  73328. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73329. * @param elementToMonitor defines the DOM element to track
  73330. */
  73331. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73332. /** Gets the current list of files to load */
  73333. get filesToLoad(): File[];
  73334. /**
  73335. * Release all associated resources
  73336. */
  73337. dispose(): void;
  73338. private renderFunction;
  73339. private drag;
  73340. private drop;
  73341. private _traverseFolder;
  73342. private _processFiles;
  73343. /**
  73344. * Load files from a drop event
  73345. * @param event defines the drop event to use as source
  73346. */
  73347. loadFiles(event: any): void;
  73348. private _processReload;
  73349. /**
  73350. * Reload the current scene from the loaded files
  73351. */
  73352. reload(): void;
  73353. }
  73354. }
  73355. declare module BABYLON {
  73356. /**
  73357. * Defines the root class used to create scene optimization to use with SceneOptimizer
  73358. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73359. */
  73360. export class SceneOptimization {
  73361. /**
  73362. * Defines the priority of this optimization (0 by default which means first in the list)
  73363. */
  73364. priority: number;
  73365. /**
  73366. * Gets a string describing the action executed by the current optimization
  73367. * @returns description string
  73368. */
  73369. getDescription(): string;
  73370. /**
  73371. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73372. * @param scene defines the current scene where to apply this optimization
  73373. * @param optimizer defines the current optimizer
  73374. * @returns true if everything that can be done was applied
  73375. */
  73376. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73377. /**
  73378. * Creates the SceneOptimization object
  73379. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73380. * @param desc defines the description associated with the optimization
  73381. */
  73382. constructor(
  73383. /**
  73384. * Defines the priority of this optimization (0 by default which means first in the list)
  73385. */
  73386. priority?: number);
  73387. }
  73388. /**
  73389. * Defines an optimization used to reduce the size of render target textures
  73390. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73391. */
  73392. export class TextureOptimization extends SceneOptimization {
  73393. /**
  73394. * Defines the priority of this optimization (0 by default which means first in the list)
  73395. */
  73396. priority: number;
  73397. /**
  73398. * 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
  73399. */
  73400. maximumSize: number;
  73401. /**
  73402. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73403. */
  73404. step: number;
  73405. /**
  73406. * Gets a string describing the action executed by the current optimization
  73407. * @returns description string
  73408. */
  73409. getDescription(): string;
  73410. /**
  73411. * Creates the TextureOptimization object
  73412. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73413. * @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
  73414. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73415. */
  73416. constructor(
  73417. /**
  73418. * Defines the priority of this optimization (0 by default which means first in the list)
  73419. */
  73420. priority?: number,
  73421. /**
  73422. * 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
  73423. */
  73424. maximumSize?: number,
  73425. /**
  73426. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73427. */
  73428. step?: number);
  73429. /**
  73430. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73431. * @param scene defines the current scene where to apply this optimization
  73432. * @param optimizer defines the current optimizer
  73433. * @returns true if everything that can be done was applied
  73434. */
  73435. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73436. }
  73437. /**
  73438. * Defines an optimization used to increase or decrease the rendering resolution
  73439. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73440. */
  73441. export class HardwareScalingOptimization extends SceneOptimization {
  73442. /**
  73443. * Defines the priority of this optimization (0 by default which means first in the list)
  73444. */
  73445. priority: number;
  73446. /**
  73447. * Defines the maximum scale to use (2 by default)
  73448. */
  73449. maximumScale: number;
  73450. /**
  73451. * Defines the step to use between two passes (0.5 by default)
  73452. */
  73453. step: number;
  73454. private _currentScale;
  73455. private _directionOffset;
  73456. /**
  73457. * Gets a string describing the action executed by the current optimization
  73458. * @return description string
  73459. */
  73460. getDescription(): string;
  73461. /**
  73462. * Creates the HardwareScalingOptimization object
  73463. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73464. * @param maximumScale defines the maximum scale to use (2 by default)
  73465. * @param step defines the step to use between two passes (0.5 by default)
  73466. */
  73467. constructor(
  73468. /**
  73469. * Defines the priority of this optimization (0 by default which means first in the list)
  73470. */
  73471. priority?: number,
  73472. /**
  73473. * Defines the maximum scale to use (2 by default)
  73474. */
  73475. maximumScale?: number,
  73476. /**
  73477. * Defines the step to use between two passes (0.5 by default)
  73478. */
  73479. step?: number);
  73480. /**
  73481. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73482. * @param scene defines the current scene where to apply this optimization
  73483. * @param optimizer defines the current optimizer
  73484. * @returns true if everything that can be done was applied
  73485. */
  73486. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73487. }
  73488. /**
  73489. * Defines an optimization used to remove shadows
  73490. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73491. */
  73492. export class ShadowsOptimization extends SceneOptimization {
  73493. /**
  73494. * Gets a string describing the action executed by the current optimization
  73495. * @return description string
  73496. */
  73497. getDescription(): string;
  73498. /**
  73499. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73500. * @param scene defines the current scene where to apply this optimization
  73501. * @param optimizer defines the current optimizer
  73502. * @returns true if everything that can be done was applied
  73503. */
  73504. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73505. }
  73506. /**
  73507. * Defines an optimization used to turn post-processes off
  73508. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73509. */
  73510. export class PostProcessesOptimization extends SceneOptimization {
  73511. /**
  73512. * Gets a string describing the action executed by the current optimization
  73513. * @return description string
  73514. */
  73515. getDescription(): string;
  73516. /**
  73517. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73518. * @param scene defines the current scene where to apply this optimization
  73519. * @param optimizer defines the current optimizer
  73520. * @returns true if everything that can be done was applied
  73521. */
  73522. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73523. }
  73524. /**
  73525. * Defines an optimization used to turn lens flares off
  73526. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73527. */
  73528. export class LensFlaresOptimization extends SceneOptimization {
  73529. /**
  73530. * Gets a string describing the action executed by the current optimization
  73531. * @return description string
  73532. */
  73533. getDescription(): string;
  73534. /**
  73535. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73536. * @param scene defines the current scene where to apply this optimization
  73537. * @param optimizer defines the current optimizer
  73538. * @returns true if everything that can be done was applied
  73539. */
  73540. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73541. }
  73542. /**
  73543. * Defines an optimization based on user defined callback.
  73544. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73545. */
  73546. export class CustomOptimization extends SceneOptimization {
  73547. /**
  73548. * Callback called to apply the custom optimization.
  73549. */
  73550. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  73551. /**
  73552. * Callback called to get custom description
  73553. */
  73554. onGetDescription: () => string;
  73555. /**
  73556. * Gets a string describing the action executed by the current optimization
  73557. * @returns description string
  73558. */
  73559. getDescription(): string;
  73560. /**
  73561. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73562. * @param scene defines the current scene where to apply this optimization
  73563. * @param optimizer defines the current optimizer
  73564. * @returns true if everything that can be done was applied
  73565. */
  73566. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73567. }
  73568. /**
  73569. * Defines an optimization used to turn particles off
  73570. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73571. */
  73572. export class ParticlesOptimization extends SceneOptimization {
  73573. /**
  73574. * Gets a string describing the action executed by the current optimization
  73575. * @return description string
  73576. */
  73577. getDescription(): string;
  73578. /**
  73579. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73580. * @param scene defines the current scene where to apply this optimization
  73581. * @param optimizer defines the current optimizer
  73582. * @returns true if everything that can be done was applied
  73583. */
  73584. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73585. }
  73586. /**
  73587. * Defines an optimization used to turn render targets off
  73588. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73589. */
  73590. export class RenderTargetsOptimization extends SceneOptimization {
  73591. /**
  73592. * Gets a string describing the action executed by the current optimization
  73593. * @return description string
  73594. */
  73595. getDescription(): string;
  73596. /**
  73597. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73598. * @param scene defines the current scene where to apply this optimization
  73599. * @param optimizer defines the current optimizer
  73600. * @returns true if everything that can be done was applied
  73601. */
  73602. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73603. }
  73604. /**
  73605. * Defines an optimization used to merge meshes with compatible materials
  73606. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73607. */
  73608. export class MergeMeshesOptimization extends SceneOptimization {
  73609. private static _UpdateSelectionTree;
  73610. /**
  73611. * Gets or sets a boolean which defines if optimization octree has to be updated
  73612. */
  73613. static get UpdateSelectionTree(): boolean;
  73614. /**
  73615. * Gets or sets a boolean which defines if optimization octree has to be updated
  73616. */
  73617. static set UpdateSelectionTree(value: boolean);
  73618. /**
  73619. * Gets a string describing the action executed by the current optimization
  73620. * @return description string
  73621. */
  73622. getDescription(): string;
  73623. private _canBeMerged;
  73624. /**
  73625. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73626. * @param scene defines the current scene where to apply this optimization
  73627. * @param optimizer defines the current optimizer
  73628. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73629. * @returns true if everything that can be done was applied
  73630. */
  73631. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73632. }
  73633. /**
  73634. * Defines a list of options used by SceneOptimizer
  73635. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73636. */
  73637. export class SceneOptimizerOptions {
  73638. /**
  73639. * Defines the target frame rate to reach (60 by default)
  73640. */
  73641. targetFrameRate: number;
  73642. /**
  73643. * Defines the interval between two checkes (2000ms by default)
  73644. */
  73645. trackerDuration: number;
  73646. /**
  73647. * Gets the list of optimizations to apply
  73648. */
  73649. optimizations: SceneOptimization[];
  73650. /**
  73651. * Creates a new list of options used by SceneOptimizer
  73652. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73653. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73654. */
  73655. constructor(
  73656. /**
  73657. * Defines the target frame rate to reach (60 by default)
  73658. */
  73659. targetFrameRate?: number,
  73660. /**
  73661. * Defines the interval between two checkes (2000ms by default)
  73662. */
  73663. trackerDuration?: number);
  73664. /**
  73665. * Add a new optimization
  73666. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73667. * @returns the current SceneOptimizerOptions
  73668. */
  73669. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73670. /**
  73671. * Add a new custom optimization
  73672. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73673. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73674. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73675. * @returns the current SceneOptimizerOptions
  73676. */
  73677. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73678. /**
  73679. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73680. * @param targetFrameRate defines the target frame rate (60 by default)
  73681. * @returns a SceneOptimizerOptions object
  73682. */
  73683. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73684. /**
  73685. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73686. * @param targetFrameRate defines the target frame rate (60 by default)
  73687. * @returns a SceneOptimizerOptions object
  73688. */
  73689. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73690. /**
  73691. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73692. * @param targetFrameRate defines the target frame rate (60 by default)
  73693. * @returns a SceneOptimizerOptions object
  73694. */
  73695. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73696. }
  73697. /**
  73698. * Class used to run optimizations in order to reach a target frame rate
  73699. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73700. */
  73701. export class SceneOptimizer implements IDisposable {
  73702. private _isRunning;
  73703. private _options;
  73704. private _scene;
  73705. private _currentPriorityLevel;
  73706. private _targetFrameRate;
  73707. private _trackerDuration;
  73708. private _currentFrameRate;
  73709. private _sceneDisposeObserver;
  73710. private _improvementMode;
  73711. /**
  73712. * Defines an observable called when the optimizer reaches the target frame rate
  73713. */
  73714. onSuccessObservable: Observable<SceneOptimizer>;
  73715. /**
  73716. * Defines an observable called when the optimizer enables an optimization
  73717. */
  73718. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73719. /**
  73720. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73721. */
  73722. onFailureObservable: Observable<SceneOptimizer>;
  73723. /**
  73724. * Gets a boolean indicating if the optimizer is in improvement mode
  73725. */
  73726. get isInImprovementMode(): boolean;
  73727. /**
  73728. * Gets the current priority level (0 at start)
  73729. */
  73730. get currentPriorityLevel(): number;
  73731. /**
  73732. * Gets the current frame rate checked by the SceneOptimizer
  73733. */
  73734. get currentFrameRate(): number;
  73735. /**
  73736. * Gets or sets the current target frame rate (60 by default)
  73737. */
  73738. get targetFrameRate(): number;
  73739. /**
  73740. * Gets or sets the current target frame rate (60 by default)
  73741. */
  73742. set targetFrameRate(value: number);
  73743. /**
  73744. * Gets or sets the current interval between two checks (every 2000ms by default)
  73745. */
  73746. get trackerDuration(): number;
  73747. /**
  73748. * Gets or sets the current interval between two checks (every 2000ms by default)
  73749. */
  73750. set trackerDuration(value: number);
  73751. /**
  73752. * Gets the list of active optimizations
  73753. */
  73754. get optimizations(): SceneOptimization[];
  73755. /**
  73756. * Creates a new SceneOptimizer
  73757. * @param scene defines the scene to work on
  73758. * @param options defines the options to use with the SceneOptimizer
  73759. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73760. * @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)
  73761. */
  73762. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73763. /**
  73764. * Stops the current optimizer
  73765. */
  73766. stop(): void;
  73767. /**
  73768. * Reset the optimizer to initial step (current priority level = 0)
  73769. */
  73770. reset(): void;
  73771. /**
  73772. * Start the optimizer. By default it will try to reach a specific framerate
  73773. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73774. */
  73775. start(): void;
  73776. private _checkCurrentState;
  73777. /**
  73778. * Release all resources
  73779. */
  73780. dispose(): void;
  73781. /**
  73782. * Helper function to create a SceneOptimizer with one single line of code
  73783. * @param scene defines the scene to work on
  73784. * @param options defines the options to use with the SceneOptimizer
  73785. * @param onSuccess defines a callback to call on success
  73786. * @param onFailure defines a callback to call on failure
  73787. * @returns the new SceneOptimizer object
  73788. */
  73789. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73790. }
  73791. }
  73792. declare module BABYLON {
  73793. /**
  73794. * Class used to serialize a scene into a string
  73795. */
  73796. export class SceneSerializer {
  73797. /**
  73798. * Clear cache used by a previous serialization
  73799. */
  73800. static ClearCache(): void;
  73801. /**
  73802. * Serialize a scene into a JSON compatible object
  73803. * @param scene defines the scene to serialize
  73804. * @returns a JSON compatible object
  73805. */
  73806. static Serialize(scene: Scene): any;
  73807. /**
  73808. * Serialize a mesh into a JSON compatible object
  73809. * @param toSerialize defines the mesh to serialize
  73810. * @param withParents defines if parents must be serialized as well
  73811. * @param withChildren defines if children must be serialized as well
  73812. * @returns a JSON compatible object
  73813. */
  73814. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73815. }
  73816. }
  73817. declare module BABYLON {
  73818. /**
  73819. * Class used to host texture specific utilities
  73820. */
  73821. export class TextureTools {
  73822. /**
  73823. * Uses the GPU to create a copy texture rescaled at a given size
  73824. * @param texture Texture to copy from
  73825. * @param width defines the desired width
  73826. * @param height defines the desired height
  73827. * @param useBilinearMode defines if bilinear mode has to be used
  73828. * @return the generated texture
  73829. */
  73830. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73831. }
  73832. }
  73833. declare module BABYLON {
  73834. /**
  73835. * This represents the different options available for the video capture.
  73836. */
  73837. export interface VideoRecorderOptions {
  73838. /** Defines the mime type of the video. */
  73839. mimeType: string;
  73840. /** Defines the FPS the video should be recorded at. */
  73841. fps: number;
  73842. /** Defines the chunk size for the recording data. */
  73843. recordChunckSize: number;
  73844. /** The audio tracks to attach to the recording. */
  73845. audioTracks?: MediaStreamTrack[];
  73846. }
  73847. /**
  73848. * This can help with recording videos from BabylonJS.
  73849. * This is based on the available WebRTC functionalities of the browser.
  73850. *
  73851. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73852. */
  73853. export class VideoRecorder {
  73854. private static readonly _defaultOptions;
  73855. /**
  73856. * Returns whether or not the VideoRecorder is available in your browser.
  73857. * @param engine Defines the Babylon Engine.
  73858. * @returns true if supported otherwise false.
  73859. */
  73860. static IsSupported(engine: Engine): boolean;
  73861. private readonly _options;
  73862. private _canvas;
  73863. private _mediaRecorder;
  73864. private _recordedChunks;
  73865. private _fileName;
  73866. private _resolve;
  73867. private _reject;
  73868. /**
  73869. * True when a recording is already in progress.
  73870. */
  73871. get isRecording(): boolean;
  73872. /**
  73873. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73874. * @param engine Defines the BabylonJS Engine you wish to record.
  73875. * @param options Defines options that can be used to customize the capture.
  73876. */
  73877. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73878. /**
  73879. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73880. */
  73881. stopRecording(): void;
  73882. /**
  73883. * Starts recording the canvas for a max duration specified in parameters.
  73884. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  73885. * If null no automatic download will start and you can rely on the promise to get the data back.
  73886. * @param maxDuration Defines the maximum recording time in seconds.
  73887. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73888. * @return A promise callback at the end of the recording with the video data in Blob.
  73889. */
  73890. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73891. /**
  73892. * Releases internal resources used during the recording.
  73893. */
  73894. dispose(): void;
  73895. private _handleDataAvailable;
  73896. private _handleError;
  73897. private _handleStop;
  73898. }
  73899. }
  73900. declare module BABYLON {
  73901. /**
  73902. * Class containing a set of static utilities functions for screenshots
  73903. */
  73904. export class ScreenshotTools {
  73905. /**
  73906. * Captures a screenshot of the current rendering
  73907. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73908. * @param engine defines the rendering engine
  73909. * @param camera defines the source camera
  73910. * @param size This parameter can be set to a single number or to an object with the
  73911. * following (optional) properties: precision, width, height. If a single number is passed,
  73912. * it will be used for both width and height. If an object is passed, the screenshot size
  73913. * will be derived from the parameters. The precision property is a multiplier allowing
  73914. * rendering at a higher or lower resolution
  73915. * @param successCallback defines the callback receives a single parameter which contains the
  73916. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73917. * src parameter of an <img> to display it
  73918. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73919. * Check your browser for supported MIME types
  73920. */
  73921. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73922. /**
  73923. * Captures a screenshot of the current rendering
  73924. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73925. * @param engine defines the rendering engine
  73926. * @param camera defines the source camera
  73927. * @param size This parameter can be set to a single number or to an object with the
  73928. * following (optional) properties: precision, width, height. If a single number is passed,
  73929. * it will be used for both width and height. If an object is passed, the screenshot size
  73930. * will be derived from the parameters. The precision property is a multiplier allowing
  73931. * rendering at a higher or lower resolution
  73932. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73933. * Check your browser for supported MIME types
  73934. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73935. * to the src parameter of an <img> to display it
  73936. */
  73937. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73938. /**
  73939. * Generates an image screenshot from the specified camera.
  73940. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73941. * @param engine The engine to use for rendering
  73942. * @param camera The camera to use for rendering
  73943. * @param size This parameter can be set to a single number or to an object with the
  73944. * following (optional) properties: precision, width, height. If a single number is passed,
  73945. * it will be used for both width and height. If an object is passed, the screenshot size
  73946. * will be derived from the parameters. The precision property is a multiplier allowing
  73947. * rendering at a higher or lower resolution
  73948. * @param successCallback The callback receives a single parameter which contains the
  73949. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73950. * src parameter of an <img> to display it
  73951. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73952. * Check your browser for supported MIME types
  73953. * @param samples Texture samples (default: 1)
  73954. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73955. * @param fileName A name for for the downloaded file.
  73956. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73957. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  73958. */
  73959. 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;
  73960. /**
  73961. * Generates an image screenshot from the specified camera.
  73962. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73963. * @param engine The engine to use for rendering
  73964. * @param camera The camera to use for rendering
  73965. * @param size This parameter can be set to a single number or to an object with the
  73966. * following (optional) properties: precision, width, height. If a single number is passed,
  73967. * it will be used for both width and height. If an object is passed, the screenshot size
  73968. * will be derived from the parameters. The precision property is a multiplier allowing
  73969. * rendering at a higher or lower resolution
  73970. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73971. * Check your browser for supported MIME types
  73972. * @param samples Texture samples (default: 1)
  73973. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73974. * @param fileName A name for for the downloaded file.
  73975. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73976. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73977. * to the src parameter of an <img> to display it
  73978. */
  73979. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73980. /**
  73981. * Gets height and width for screenshot size
  73982. * @private
  73983. */
  73984. private static _getScreenshotSize;
  73985. }
  73986. }
  73987. declare module BABYLON {
  73988. /**
  73989. * Interface for a data buffer
  73990. */
  73991. export interface IDataBuffer {
  73992. /**
  73993. * Reads bytes from the data buffer.
  73994. * @param byteOffset The byte offset to read
  73995. * @param byteLength The byte length to read
  73996. * @returns A promise that resolves when the bytes are read
  73997. */
  73998. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73999. /**
  74000. * The byte length of the buffer.
  74001. */
  74002. readonly byteLength: number;
  74003. }
  74004. /**
  74005. * Utility class for reading from a data buffer
  74006. */
  74007. export class DataReader {
  74008. /**
  74009. * The data buffer associated with this data reader.
  74010. */
  74011. readonly buffer: IDataBuffer;
  74012. /**
  74013. * The current byte offset from the beginning of the data buffer.
  74014. */
  74015. byteOffset: number;
  74016. private _dataView;
  74017. private _dataByteOffset;
  74018. /**
  74019. * Constructor
  74020. * @param buffer The buffer to read
  74021. */
  74022. constructor(buffer: IDataBuffer);
  74023. /**
  74024. * Loads the given byte length.
  74025. * @param byteLength The byte length to load
  74026. * @returns A promise that resolves when the load is complete
  74027. */
  74028. loadAsync(byteLength: number): Promise<void>;
  74029. /**
  74030. * Read a unsigned 32-bit integer from the currently loaded data range.
  74031. * @returns The 32-bit integer read
  74032. */
  74033. readUint32(): number;
  74034. /**
  74035. * Read a byte array from the currently loaded data range.
  74036. * @param byteLength The byte length to read
  74037. * @returns The byte array read
  74038. */
  74039. readUint8Array(byteLength: number): Uint8Array;
  74040. /**
  74041. * Read a string from the currently loaded data range.
  74042. * @param byteLength The byte length to read
  74043. * @returns The string read
  74044. */
  74045. readString(byteLength: number): string;
  74046. /**
  74047. * Skips the given byte length the currently loaded data range.
  74048. * @param byteLength The byte length to skip
  74049. */
  74050. skipBytes(byteLength: number): void;
  74051. }
  74052. }
  74053. declare module BABYLON {
  74054. /**
  74055. * Class for storing data to local storage if available or in-memory storage otherwise
  74056. */
  74057. export class DataStorage {
  74058. private static _Storage;
  74059. private static _GetStorage;
  74060. /**
  74061. * Reads a string from the data storage
  74062. * @param key The key to read
  74063. * @param defaultValue The value if the key doesn't exist
  74064. * @returns The string value
  74065. */
  74066. static ReadString(key: string, defaultValue: string): string;
  74067. /**
  74068. * Writes a string to the data storage
  74069. * @param key The key to write
  74070. * @param value The value to write
  74071. */
  74072. static WriteString(key: string, value: string): void;
  74073. /**
  74074. * Reads a boolean from the data storage
  74075. * @param key The key to read
  74076. * @param defaultValue The value if the key doesn't exist
  74077. * @returns The boolean value
  74078. */
  74079. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74080. /**
  74081. * Writes a boolean to the data storage
  74082. * @param key The key to write
  74083. * @param value The value to write
  74084. */
  74085. static WriteBoolean(key: string, value: boolean): void;
  74086. /**
  74087. * Reads a number from the data storage
  74088. * @param key The key to read
  74089. * @param defaultValue The value if the key doesn't exist
  74090. * @returns The number value
  74091. */
  74092. static ReadNumber(key: string, defaultValue: number): number;
  74093. /**
  74094. * Writes a number to the data storage
  74095. * @param key The key to write
  74096. * @param value The value to write
  74097. */
  74098. static WriteNumber(key: string, value: number): void;
  74099. }
  74100. }
  74101. declare module BABYLON {
  74102. /**
  74103. * Class used to record delta files between 2 scene states
  74104. */
  74105. export class SceneRecorder {
  74106. private _trackedScene;
  74107. private _savedJSON;
  74108. /**
  74109. * Track a given scene. This means the current scene state will be considered the original state
  74110. * @param scene defines the scene to track
  74111. */
  74112. track(scene: Scene): void;
  74113. /**
  74114. * Get the delta between current state and original state
  74115. * @returns a string containing the delta
  74116. */
  74117. getDelta(): any;
  74118. private _compareArray;
  74119. private _compareObjects;
  74120. private _compareCollections;
  74121. private static GetShadowGeneratorById;
  74122. /**
  74123. * Apply a given delta to a given scene
  74124. * @param deltaJSON defines the JSON containing the delta
  74125. * @param scene defines the scene to apply the delta to
  74126. */
  74127. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74128. private static _ApplyPropertiesToEntity;
  74129. private static _ApplyDeltaForEntity;
  74130. }
  74131. }
  74132. declare module BABYLON {
  74133. /**
  74134. * An interface for all Hit test features
  74135. */
  74136. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74137. /**
  74138. * Triggered when new babylon (transformed) hit test results are available
  74139. */
  74140. onHitTestResultObservable: Observable<T[]>;
  74141. }
  74142. /**
  74143. * Options used for hit testing
  74144. */
  74145. export interface IWebXRLegacyHitTestOptions {
  74146. /**
  74147. * Only test when user interacted with the scene. Default - hit test every frame
  74148. */
  74149. testOnPointerDownOnly?: boolean;
  74150. /**
  74151. * The node to use to transform the local results to world coordinates
  74152. */
  74153. worldParentNode?: TransformNode;
  74154. }
  74155. /**
  74156. * Interface defining the babylon result of raycasting/hit-test
  74157. */
  74158. export interface IWebXRLegacyHitResult {
  74159. /**
  74160. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74161. */
  74162. transformationMatrix: Matrix;
  74163. /**
  74164. * The native hit test result
  74165. */
  74166. xrHitResult: XRHitResult | XRHitTestResult;
  74167. }
  74168. /**
  74169. * The currently-working hit-test module.
  74170. * Hit test (or Ray-casting) is used to interact with the real world.
  74171. * For further information read here - https://github.com/immersive-web/hit-test
  74172. */
  74173. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74174. /**
  74175. * options to use when constructing this feature
  74176. */
  74177. readonly options: IWebXRLegacyHitTestOptions;
  74178. private _direction;
  74179. private _mat;
  74180. private _onSelectEnabled;
  74181. private _origin;
  74182. /**
  74183. * The module's name
  74184. */
  74185. static readonly Name: string;
  74186. /**
  74187. * The (Babylon) version of this module.
  74188. * This is an integer representing the implementation version.
  74189. * This number does not correspond to the WebXR specs version
  74190. */
  74191. static readonly Version: number;
  74192. /**
  74193. * Populated with the last native XR Hit Results
  74194. */
  74195. lastNativeXRHitResults: XRHitResult[];
  74196. /**
  74197. * Triggered when new babylon (transformed) hit test results are available
  74198. */
  74199. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74200. /**
  74201. * Creates a new instance of the (legacy version) hit test feature
  74202. * @param _xrSessionManager an instance of WebXRSessionManager
  74203. * @param options options to use when constructing this feature
  74204. */
  74205. constructor(_xrSessionManager: WebXRSessionManager,
  74206. /**
  74207. * options to use when constructing this feature
  74208. */
  74209. options?: IWebXRLegacyHitTestOptions);
  74210. /**
  74211. * execute a hit test with an XR Ray
  74212. *
  74213. * @param xrSession a native xrSession that will execute this hit test
  74214. * @param xrRay the ray (position and direction) to use for ray-casting
  74215. * @param referenceSpace native XR reference space to use for the hit-test
  74216. * @param filter filter function that will filter the results
  74217. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74218. */
  74219. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  74220. /**
  74221. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  74222. * @param event the (select) event to use to select with
  74223. * @param referenceSpace the reference space to use for this hit test
  74224. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  74225. */
  74226. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74227. /**
  74228. * attach this feature
  74229. * Will usually be called by the features manager
  74230. *
  74231. * @returns true if successful.
  74232. */
  74233. attach(): boolean;
  74234. /**
  74235. * detach this feature.
  74236. * Will usually be called by the features manager
  74237. *
  74238. * @returns true if successful.
  74239. */
  74240. detach(): boolean;
  74241. /**
  74242. * Dispose this feature and all of the resources attached
  74243. */
  74244. dispose(): void;
  74245. protected _onXRFrame(frame: XRFrame): void;
  74246. private _onHitTestResults;
  74247. private _onSelect;
  74248. }
  74249. }
  74250. declare module BABYLON {
  74251. /**
  74252. * Options used for hit testing (version 2)
  74253. */
  74254. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  74255. /**
  74256. * Do not create a permanent hit test. Will usually be used when only
  74257. * transient inputs are needed.
  74258. */
  74259. disablePermanentHitTest?: boolean;
  74260. /**
  74261. * Enable transient (for example touch-based) hit test inspections
  74262. */
  74263. enableTransientHitTest?: boolean;
  74264. /**
  74265. * Offset ray for the permanent hit test
  74266. */
  74267. offsetRay?: Vector3;
  74268. /**
  74269. * Offset ray for the transient hit test
  74270. */
  74271. transientOffsetRay?: Vector3;
  74272. /**
  74273. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  74274. */
  74275. useReferenceSpace?: boolean;
  74276. /**
  74277. * Override the default entity type(s) of the hit-test result
  74278. */
  74279. entityTypes?: XRHitTestTrackableType[];
  74280. }
  74281. /**
  74282. * Interface defining the babylon result of hit-test
  74283. */
  74284. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  74285. /**
  74286. * The input source that generated this hit test (if transient)
  74287. */
  74288. inputSource?: XRInputSource;
  74289. /**
  74290. * Is this a transient hit test
  74291. */
  74292. isTransient?: boolean;
  74293. /**
  74294. * Position of the hit test result
  74295. */
  74296. position: Vector3;
  74297. /**
  74298. * Rotation of the hit test result
  74299. */
  74300. rotationQuaternion: Quaternion;
  74301. /**
  74302. * The native hit test result
  74303. */
  74304. xrHitResult: XRHitTestResult;
  74305. }
  74306. /**
  74307. * The currently-working hit-test module.
  74308. * Hit test (or Ray-casting) is used to interact with the real world.
  74309. * For further information read here - https://github.com/immersive-web/hit-test
  74310. *
  74311. * Tested on chrome (mobile) 80.
  74312. */
  74313. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  74314. /**
  74315. * options to use when constructing this feature
  74316. */
  74317. readonly options: IWebXRHitTestOptions;
  74318. private _tmpMat;
  74319. private _tmpPos;
  74320. private _tmpQuat;
  74321. private _transientXrHitTestSource;
  74322. private _xrHitTestSource;
  74323. private initHitTestSource;
  74324. /**
  74325. * The module's name
  74326. */
  74327. static readonly Name: string;
  74328. /**
  74329. * The (Babylon) version of this module.
  74330. * This is an integer representing the implementation version.
  74331. * This number does not correspond to the WebXR specs version
  74332. */
  74333. static readonly Version: number;
  74334. /**
  74335. * When set to true, each hit test will have its own position/rotation objects
  74336. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  74337. * the developers will clone them or copy them as they see fit.
  74338. */
  74339. autoCloneTransformation: boolean;
  74340. /**
  74341. * Triggered when new babylon (transformed) hit test results are available
  74342. */
  74343. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  74344. /**
  74345. * Use this to temporarily pause hit test checks.
  74346. */
  74347. paused: boolean;
  74348. /**
  74349. * Creates a new instance of the hit test feature
  74350. * @param _xrSessionManager an instance of WebXRSessionManager
  74351. * @param options options to use when constructing this feature
  74352. */
  74353. constructor(_xrSessionManager: WebXRSessionManager,
  74354. /**
  74355. * options to use when constructing this feature
  74356. */
  74357. options?: IWebXRHitTestOptions);
  74358. /**
  74359. * attach this feature
  74360. * Will usually be called by the features manager
  74361. *
  74362. * @returns true if successful.
  74363. */
  74364. attach(): boolean;
  74365. /**
  74366. * detach this feature.
  74367. * Will usually be called by the features manager
  74368. *
  74369. * @returns true if successful.
  74370. */
  74371. detach(): boolean;
  74372. /**
  74373. * Dispose this feature and all of the resources attached
  74374. */
  74375. dispose(): void;
  74376. protected _onXRFrame(frame: XRFrame): void;
  74377. private _processWebXRHitTestResult;
  74378. }
  74379. }
  74380. declare module BABYLON {
  74381. /**
  74382. * Configuration options of the anchor system
  74383. */
  74384. export interface IWebXRAnchorSystemOptions {
  74385. /**
  74386. * a node that will be used to convert local to world coordinates
  74387. */
  74388. worldParentNode?: TransformNode;
  74389. /**
  74390. * If set to true a reference of the created anchors will be kept until the next session starts
  74391. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  74392. */
  74393. doNotRemoveAnchorsOnSessionEnded?: boolean;
  74394. }
  74395. /**
  74396. * A babylon container for an XR Anchor
  74397. */
  74398. export interface IWebXRAnchor {
  74399. /**
  74400. * A babylon-assigned ID for this anchor
  74401. */
  74402. id: number;
  74403. /**
  74404. * Transformation matrix to apply to an object attached to this anchor
  74405. */
  74406. transformationMatrix: Matrix;
  74407. /**
  74408. * The native anchor object
  74409. */
  74410. xrAnchor: XRAnchor;
  74411. /**
  74412. * if defined, this object will be constantly updated by the anchor's position and rotation
  74413. */
  74414. attachedNode?: TransformNode;
  74415. }
  74416. /**
  74417. * An implementation of the anchor system for WebXR.
  74418. * For further information see https://github.com/immersive-web/anchors/
  74419. */
  74420. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74421. private _options;
  74422. private _lastFrameDetected;
  74423. private _trackedAnchors;
  74424. private _referenceSpaceForFrameAnchors;
  74425. private _futureAnchors;
  74426. /**
  74427. * The module's name
  74428. */
  74429. static readonly Name: string;
  74430. /**
  74431. * The (Babylon) version of this module.
  74432. * This is an integer representing the implementation version.
  74433. * This number does not correspond to the WebXR specs version
  74434. */
  74435. static readonly Version: number;
  74436. /**
  74437. * Observers registered here will be executed when a new anchor was added to the session
  74438. */
  74439. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  74440. /**
  74441. * Observers registered here will be executed when an anchor was removed from the session
  74442. */
  74443. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  74444. /**
  74445. * Observers registered here will be executed when an existing anchor updates
  74446. * This can execute N times every frame
  74447. */
  74448. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  74449. /**
  74450. * Set the reference space to use for anchor creation, when not using a hit test.
  74451. * Will default to the session's reference space if not defined
  74452. */
  74453. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  74454. /**
  74455. * constructs a new anchor system
  74456. * @param _xrSessionManager an instance of WebXRSessionManager
  74457. * @param _options configuration object for this feature
  74458. */
  74459. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  74460. private _tmpVector;
  74461. private _tmpQuaternion;
  74462. private _populateTmpTransformation;
  74463. /**
  74464. * Create a new anchor point using a hit test result at a specific point in the scene
  74465. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74466. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74467. *
  74468. * @param hitTestResult The hit test result to use for this anchor creation
  74469. * @param position an optional position offset for this anchor
  74470. * @param rotationQuaternion an optional rotation offset for this anchor
  74471. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74472. */
  74473. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  74474. /**
  74475. * Add a new anchor at a specific position and rotation
  74476. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  74477. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  74478. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74479. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74480. *
  74481. * @param position the position in which to add an anchor
  74482. * @param rotationQuaternion an optional rotation for the anchor transformation
  74483. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  74484. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74485. */
  74486. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  74487. /**
  74488. * detach this feature.
  74489. * Will usually be called by the features manager
  74490. *
  74491. * @returns true if successful.
  74492. */
  74493. detach(): boolean;
  74494. /**
  74495. * Dispose this feature and all of the resources attached
  74496. */
  74497. dispose(): void;
  74498. protected _onXRFrame(frame: XRFrame): void;
  74499. /**
  74500. * avoiding using Array.find for global support.
  74501. * @param xrAnchor the plane to find in the array
  74502. */
  74503. private _findIndexInAnchorArray;
  74504. private _updateAnchorWithXRFrame;
  74505. private _createAnchorAtTransformation;
  74506. }
  74507. }
  74508. declare module BABYLON {
  74509. /**
  74510. * Options used in the plane detector module
  74511. */
  74512. export interface IWebXRPlaneDetectorOptions {
  74513. /**
  74514. * The node to use to transform the local results to world coordinates
  74515. */
  74516. worldParentNode?: TransformNode;
  74517. /**
  74518. * If set to true a reference of the created planes will be kept until the next session starts
  74519. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  74520. */
  74521. doNotRemovePlanesOnSessionEnded?: boolean;
  74522. }
  74523. /**
  74524. * A babylon interface for a WebXR plane.
  74525. * A Plane is actually a polygon, built from N points in space
  74526. *
  74527. * Supported in chrome 79, not supported in canary 81 ATM
  74528. */
  74529. export interface IWebXRPlane {
  74530. /**
  74531. * a babylon-assigned ID for this polygon
  74532. */
  74533. id: number;
  74534. /**
  74535. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74536. */
  74537. polygonDefinition: Array<Vector3>;
  74538. /**
  74539. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74540. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74541. */
  74542. transformationMatrix: Matrix;
  74543. /**
  74544. * the native xr-plane object
  74545. */
  74546. xrPlane: XRPlane;
  74547. }
  74548. /**
  74549. * The plane detector is used to detect planes in the real world when in AR
  74550. * For more information see https://github.com/immersive-web/real-world-geometry/
  74551. */
  74552. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74553. private _options;
  74554. private _detectedPlanes;
  74555. private _enabled;
  74556. private _lastFrameDetected;
  74557. /**
  74558. * The module's name
  74559. */
  74560. static readonly Name: string;
  74561. /**
  74562. * The (Babylon) version of this module.
  74563. * This is an integer representing the implementation version.
  74564. * This number does not correspond to the WebXR specs version
  74565. */
  74566. static readonly Version: number;
  74567. /**
  74568. * Observers registered here will be executed when a new plane was added to the session
  74569. */
  74570. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74571. /**
  74572. * Observers registered here will be executed when a plane is no longer detected in the session
  74573. */
  74574. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74575. /**
  74576. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74577. * This can execute N times every frame
  74578. */
  74579. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74580. /**
  74581. * construct a new Plane Detector
  74582. * @param _xrSessionManager an instance of xr Session manager
  74583. * @param _options configuration to use when constructing this feature
  74584. */
  74585. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74586. /**
  74587. * detach this feature.
  74588. * Will usually be called by the features manager
  74589. *
  74590. * @returns true if successful.
  74591. */
  74592. detach(): boolean;
  74593. /**
  74594. * Dispose this feature and all of the resources attached
  74595. */
  74596. dispose(): void;
  74597. protected _onXRFrame(frame: XRFrame): void;
  74598. private _init;
  74599. private _updatePlaneWithXRPlane;
  74600. /**
  74601. * avoiding using Array.find for global support.
  74602. * @param xrPlane the plane to find in the array
  74603. */
  74604. private findIndexInPlaneArray;
  74605. }
  74606. }
  74607. declare module BABYLON {
  74608. /**
  74609. * Options interface for the background remover plugin
  74610. */
  74611. export interface IWebXRBackgroundRemoverOptions {
  74612. /**
  74613. * Further background meshes to disable when entering AR
  74614. */
  74615. backgroundMeshes?: AbstractMesh[];
  74616. /**
  74617. * flags to configure the removal of the environment helper.
  74618. * If not set, the entire background will be removed. If set, flags should be set as well.
  74619. */
  74620. environmentHelperRemovalFlags?: {
  74621. /**
  74622. * Should the skybox be removed (default false)
  74623. */
  74624. skyBox?: boolean;
  74625. /**
  74626. * Should the ground be removed (default false)
  74627. */
  74628. ground?: boolean;
  74629. };
  74630. /**
  74631. * don't disable the environment helper
  74632. */
  74633. ignoreEnvironmentHelper?: boolean;
  74634. }
  74635. /**
  74636. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74637. */
  74638. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74639. /**
  74640. * read-only options to be used in this module
  74641. */
  74642. readonly options: IWebXRBackgroundRemoverOptions;
  74643. /**
  74644. * The module's name
  74645. */
  74646. static readonly Name: string;
  74647. /**
  74648. * The (Babylon) version of this module.
  74649. * This is an integer representing the implementation version.
  74650. * This number does not correspond to the WebXR specs version
  74651. */
  74652. static readonly Version: number;
  74653. /**
  74654. * registered observers will be triggered when the background state changes
  74655. */
  74656. onBackgroundStateChangedObservable: Observable<boolean>;
  74657. /**
  74658. * constructs a new background remover module
  74659. * @param _xrSessionManager the session manager for this module
  74660. * @param options read-only options to be used in this module
  74661. */
  74662. constructor(_xrSessionManager: WebXRSessionManager,
  74663. /**
  74664. * read-only options to be used in this module
  74665. */
  74666. options?: IWebXRBackgroundRemoverOptions);
  74667. /**
  74668. * attach this feature
  74669. * Will usually be called by the features manager
  74670. *
  74671. * @returns true if successful.
  74672. */
  74673. attach(): boolean;
  74674. /**
  74675. * detach this feature.
  74676. * Will usually be called by the features manager
  74677. *
  74678. * @returns true if successful.
  74679. */
  74680. detach(): boolean;
  74681. /**
  74682. * Dispose this feature and all of the resources attached
  74683. */
  74684. dispose(): void;
  74685. protected _onXRFrame(_xrFrame: XRFrame): void;
  74686. private _setBackgroundState;
  74687. }
  74688. }
  74689. declare module BABYLON {
  74690. /**
  74691. * Options for the controller physics feature
  74692. */
  74693. export class IWebXRControllerPhysicsOptions {
  74694. /**
  74695. * Should the headset get its own impostor
  74696. */
  74697. enableHeadsetImpostor?: boolean;
  74698. /**
  74699. * Optional parameters for the headset impostor
  74700. */
  74701. headsetImpostorParams?: {
  74702. /**
  74703. * The type of impostor to create. Default is sphere
  74704. */
  74705. impostorType: number;
  74706. /**
  74707. * the size of the impostor. Defaults to 10cm
  74708. */
  74709. impostorSize?: number | {
  74710. width: number;
  74711. height: number;
  74712. depth: number;
  74713. };
  74714. /**
  74715. * Friction definitions
  74716. */
  74717. friction?: number;
  74718. /**
  74719. * Restitution
  74720. */
  74721. restitution?: number;
  74722. };
  74723. /**
  74724. * The physics properties of the future impostors
  74725. */
  74726. physicsProperties?: {
  74727. /**
  74728. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74729. * Note that this requires a physics engine that supports mesh impostors!
  74730. */
  74731. useControllerMesh?: boolean;
  74732. /**
  74733. * The type of impostor to create. Default is sphere
  74734. */
  74735. impostorType?: number;
  74736. /**
  74737. * the size of the impostor. Defaults to 10cm
  74738. */
  74739. impostorSize?: number | {
  74740. width: number;
  74741. height: number;
  74742. depth: number;
  74743. };
  74744. /**
  74745. * Friction definitions
  74746. */
  74747. friction?: number;
  74748. /**
  74749. * Restitution
  74750. */
  74751. restitution?: number;
  74752. };
  74753. /**
  74754. * the xr input to use with this pointer selection
  74755. */
  74756. xrInput: WebXRInput;
  74757. }
  74758. /**
  74759. * Add physics impostor to your webxr controllers,
  74760. * including naive calculation of their linear and angular velocity
  74761. */
  74762. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74763. private readonly _options;
  74764. private _attachController;
  74765. private _controllers;
  74766. private _debugMode;
  74767. private _delta;
  74768. private _headsetImpostor?;
  74769. private _headsetMesh?;
  74770. private _lastTimestamp;
  74771. private _tmpQuaternion;
  74772. private _tmpVector;
  74773. /**
  74774. * The module's name
  74775. */
  74776. static readonly Name: string;
  74777. /**
  74778. * The (Babylon) version of this module.
  74779. * This is an integer representing the implementation version.
  74780. * This number does not correspond to the webxr specs version
  74781. */
  74782. static readonly Version: number;
  74783. /**
  74784. * Construct a new Controller Physics Feature
  74785. * @param _xrSessionManager the corresponding xr session manager
  74786. * @param _options options to create this feature with
  74787. */
  74788. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74789. /**
  74790. * @hidden
  74791. * enable debugging - will show console outputs and the impostor mesh
  74792. */
  74793. _enablePhysicsDebug(): void;
  74794. /**
  74795. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74796. * @param xrController the controller to add
  74797. */
  74798. addController(xrController: WebXRInputSource): void;
  74799. /**
  74800. * attach this feature
  74801. * Will usually be called by the features manager
  74802. *
  74803. * @returns true if successful.
  74804. */
  74805. attach(): boolean;
  74806. /**
  74807. * detach this feature.
  74808. * Will usually be called by the features manager
  74809. *
  74810. * @returns true if successful.
  74811. */
  74812. detach(): boolean;
  74813. /**
  74814. * Get the headset impostor, if enabled
  74815. * @returns the impostor
  74816. */
  74817. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74818. /**
  74819. * Get the physics impostor of a specific controller.
  74820. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74821. * @param controller the controller or the controller id of which to get the impostor
  74822. * @returns the impostor or null
  74823. */
  74824. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74825. /**
  74826. * Update the physics properties provided in the constructor
  74827. * @param newProperties the new properties object
  74828. */
  74829. setPhysicsProperties(newProperties: {
  74830. impostorType?: number;
  74831. impostorSize?: number | {
  74832. width: number;
  74833. height: number;
  74834. depth: number;
  74835. };
  74836. friction?: number;
  74837. restitution?: number;
  74838. }): void;
  74839. protected _onXRFrame(_xrFrame: any): void;
  74840. private _detachController;
  74841. }
  74842. }
  74843. declare module BABYLON {
  74844. /**
  74845. * A babylon interface for a "WebXR" feature point.
  74846. * Represents the position and confidence value of a given feature point.
  74847. */
  74848. export interface IWebXRFeaturePoint {
  74849. /**
  74850. * Represents the position of the feature point in world space.
  74851. */
  74852. position: Vector3;
  74853. /**
  74854. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  74855. */
  74856. confidenceValue: number;
  74857. }
  74858. /**
  74859. * The feature point system is used to detect feature points from real world geometry.
  74860. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  74861. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  74862. */
  74863. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  74864. private _enabled;
  74865. private _featurePointCloud;
  74866. /**
  74867. * The module's name
  74868. */
  74869. static readonly Name: string;
  74870. /**
  74871. * The (Babylon) version of this module.
  74872. * This is an integer representing the implementation version.
  74873. * This number does not correspond to the WebXR specs version
  74874. */
  74875. static readonly Version: number;
  74876. /**
  74877. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  74878. * Will notify the observers about which feature points have been added.
  74879. */
  74880. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  74881. /**
  74882. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  74883. * Will notify the observers about which feature points have been updated.
  74884. */
  74885. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  74886. /**
  74887. * The current feature point cloud maintained across frames.
  74888. */
  74889. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  74890. /**
  74891. * construct the feature point system
  74892. * @param _xrSessionManager an instance of xr Session manager
  74893. */
  74894. constructor(_xrSessionManager: WebXRSessionManager);
  74895. /**
  74896. * Detach this feature.
  74897. * Will usually be called by the features manager
  74898. *
  74899. * @returns true if successful.
  74900. */
  74901. detach(): boolean;
  74902. /**
  74903. * Dispose this feature and all of the resources attached
  74904. */
  74905. dispose(): void;
  74906. /**
  74907. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  74908. */
  74909. protected _onXRFrame(frame: XRFrame): void;
  74910. /**
  74911. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  74912. */
  74913. private _init;
  74914. }
  74915. }
  74916. declare module BABYLON {
  74917. /**
  74918. * Configuration interface for the hand tracking feature
  74919. */
  74920. export interface IWebXRHandTrackingOptions {
  74921. /**
  74922. * The xrInput that will be used as source for new hands
  74923. */
  74924. xrInput: WebXRInput;
  74925. /**
  74926. * Configuration object for the joint meshes
  74927. */
  74928. jointMeshes?: {
  74929. /**
  74930. * Should the meshes created be invisible (defaults to false)
  74931. */
  74932. invisible?: boolean;
  74933. /**
  74934. * A source mesh to be used to create instances. Defaults to a sphere.
  74935. * This mesh will be the source for all other (25) meshes.
  74936. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  74937. */
  74938. sourceMesh?: Mesh;
  74939. /**
  74940. * Should the source mesh stay visible. Defaults to false
  74941. */
  74942. keepOriginalVisible?: boolean;
  74943. /**
  74944. * Scale factor for all instances (defaults to 2)
  74945. */
  74946. scaleFactor?: number;
  74947. /**
  74948. * Should each instance have its own physics impostor
  74949. */
  74950. enablePhysics?: boolean;
  74951. /**
  74952. * If enabled, override default physics properties
  74953. */
  74954. physicsProps?: {
  74955. friction?: number;
  74956. restitution?: number;
  74957. impostorType?: number;
  74958. };
  74959. /**
  74960. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  74961. */
  74962. handMesh?: AbstractMesh;
  74963. };
  74964. }
  74965. /**
  74966. * Parts of the hands divided to writs and finger names
  74967. */
  74968. export const enum HandPart {
  74969. /**
  74970. * HandPart - Wrist
  74971. */
  74972. WRIST = "wrist",
  74973. /**
  74974. * HandPart - The THumb
  74975. */
  74976. THUMB = "thumb",
  74977. /**
  74978. * HandPart - Index finger
  74979. */
  74980. INDEX = "index",
  74981. /**
  74982. * HandPart - Middle finger
  74983. */
  74984. MIDDLE = "middle",
  74985. /**
  74986. * HandPart - Ring finger
  74987. */
  74988. RING = "ring",
  74989. /**
  74990. * HandPart - Little finger
  74991. */
  74992. LITTLE = "little"
  74993. }
  74994. /**
  74995. * Representing a single hand (with its corresponding native XRHand object)
  74996. */
  74997. export class WebXRHand implements IDisposable {
  74998. /** the controller to which the hand correlates */
  74999. readonly xrController: WebXRInputSource;
  75000. /** the meshes to be used to track the hand joints */
  75001. readonly trackedMeshes: AbstractMesh[];
  75002. /**
  75003. * Hand-parts definition (key is HandPart)
  75004. */
  75005. static HandPartsDefinition: {
  75006. [key: string]: number[];
  75007. };
  75008. /**
  75009. * Populate the HandPartsDefinition object.
  75010. * This is called as a side effect since certain browsers don't have XRHand defined.
  75011. */
  75012. static _PopulateHandPartsDefinition(): void;
  75013. /**
  75014. * Construct a new hand object
  75015. * @param xrController the controller to which the hand correlates
  75016. * @param trackedMeshes the meshes to be used to track the hand joints
  75017. */
  75018. constructor(
  75019. /** the controller to which the hand correlates */
  75020. xrController: WebXRInputSource,
  75021. /** the meshes to be used to track the hand joints */
  75022. trackedMeshes: AbstractMesh[]);
  75023. /**
  75024. * Update this hand from the latest xr frame
  75025. * @param xrFrame xrFrame to update from
  75026. * @param referenceSpace The current viewer reference space
  75027. * @param scaleFactor optional scale factor for the meshes
  75028. */
  75029. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75030. /**
  75031. * Get meshes of part of the hand
  75032. * @param part the part of hand to get
  75033. * @returns An array of meshes that correlate to the hand part requested
  75034. */
  75035. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75036. /**
  75037. * Dispose this Hand object
  75038. */
  75039. dispose(): void;
  75040. }
  75041. /**
  75042. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75043. */
  75044. export class WebXRHandTracking extends WebXRAbstractFeature {
  75045. /**
  75046. * options to use when constructing this feature
  75047. */
  75048. readonly options: IWebXRHandTrackingOptions;
  75049. private static _idCounter;
  75050. /**
  75051. * The module's name
  75052. */
  75053. static readonly Name: string;
  75054. /**
  75055. * The (Babylon) version of this module.
  75056. * This is an integer representing the implementation version.
  75057. * This number does not correspond to the WebXR specs version
  75058. */
  75059. static readonly Version: number;
  75060. /**
  75061. * This observable will notify registered observers when a new hand object was added and initialized
  75062. */
  75063. onHandAddedObservable: Observable<WebXRHand>;
  75064. /**
  75065. * This observable will notify its observers right before the hand object is disposed
  75066. */
  75067. onHandRemovedObservable: Observable<WebXRHand>;
  75068. private _hands;
  75069. /**
  75070. * Creates a new instance of the hit test feature
  75071. * @param _xrSessionManager an instance of WebXRSessionManager
  75072. * @param options options to use when constructing this feature
  75073. */
  75074. constructor(_xrSessionManager: WebXRSessionManager,
  75075. /**
  75076. * options to use when constructing this feature
  75077. */
  75078. options: IWebXRHandTrackingOptions);
  75079. /**
  75080. * Check if the needed objects are defined.
  75081. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75082. */
  75083. isCompatible(): boolean;
  75084. /**
  75085. * attach this feature
  75086. * Will usually be called by the features manager
  75087. *
  75088. * @returns true if successful.
  75089. */
  75090. attach(): boolean;
  75091. /**
  75092. * detach this feature.
  75093. * Will usually be called by the features manager
  75094. *
  75095. * @returns true if successful.
  75096. */
  75097. detach(): boolean;
  75098. /**
  75099. * Dispose this feature and all of the resources attached
  75100. */
  75101. dispose(): void;
  75102. /**
  75103. * Get the hand object according to the controller id
  75104. * @param controllerId the controller id to which we want to get the hand
  75105. * @returns null if not found or the WebXRHand object if found
  75106. */
  75107. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75108. /**
  75109. * Get a hand object according to the requested handedness
  75110. * @param handedness the handedness to request
  75111. * @returns null if not found or the WebXRHand object if found
  75112. */
  75113. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75114. protected _onXRFrame(_xrFrame: XRFrame): void;
  75115. private _attachHand;
  75116. private _detachHand;
  75117. }
  75118. }
  75119. declare module BABYLON {
  75120. /**
  75121. * The motion controller class for all microsoft mixed reality controllers
  75122. */
  75123. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75124. protected readonly _mapping: {
  75125. defaultButton: {
  75126. valueNodeName: string;
  75127. unpressedNodeName: string;
  75128. pressedNodeName: string;
  75129. };
  75130. defaultAxis: {
  75131. valueNodeName: string;
  75132. minNodeName: string;
  75133. maxNodeName: string;
  75134. };
  75135. buttons: {
  75136. "xr-standard-trigger": {
  75137. rootNodeName: string;
  75138. componentProperty: string;
  75139. states: string[];
  75140. };
  75141. "xr-standard-squeeze": {
  75142. rootNodeName: string;
  75143. componentProperty: string;
  75144. states: string[];
  75145. };
  75146. "xr-standard-touchpad": {
  75147. rootNodeName: string;
  75148. labelAnchorNodeName: string;
  75149. touchPointNodeName: string;
  75150. };
  75151. "xr-standard-thumbstick": {
  75152. rootNodeName: string;
  75153. componentProperty: string;
  75154. states: string[];
  75155. };
  75156. };
  75157. axes: {
  75158. "xr-standard-touchpad": {
  75159. "x-axis": {
  75160. rootNodeName: string;
  75161. };
  75162. "y-axis": {
  75163. rootNodeName: string;
  75164. };
  75165. };
  75166. "xr-standard-thumbstick": {
  75167. "x-axis": {
  75168. rootNodeName: string;
  75169. };
  75170. "y-axis": {
  75171. rootNodeName: string;
  75172. };
  75173. };
  75174. };
  75175. };
  75176. /**
  75177. * The base url used to load the left and right controller models
  75178. */
  75179. static MODEL_BASE_URL: string;
  75180. /**
  75181. * The name of the left controller model file
  75182. */
  75183. static MODEL_LEFT_FILENAME: string;
  75184. /**
  75185. * The name of the right controller model file
  75186. */
  75187. static MODEL_RIGHT_FILENAME: string;
  75188. profileId: string;
  75189. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75190. protected _getFilenameAndPath(): {
  75191. filename: string;
  75192. path: string;
  75193. };
  75194. protected _getModelLoadingConstraints(): boolean;
  75195. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75196. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75197. protected _updateModel(): void;
  75198. }
  75199. }
  75200. declare module BABYLON {
  75201. /**
  75202. * The motion controller class for oculus touch (quest, rift).
  75203. * This class supports legacy mapping as well the standard xr mapping
  75204. */
  75205. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75206. private _forceLegacyControllers;
  75207. private _modelRootNode;
  75208. /**
  75209. * The base url used to load the left and right controller models
  75210. */
  75211. static MODEL_BASE_URL: string;
  75212. /**
  75213. * The name of the left controller model file
  75214. */
  75215. static MODEL_LEFT_FILENAME: string;
  75216. /**
  75217. * The name of the right controller model file
  75218. */
  75219. static MODEL_RIGHT_FILENAME: string;
  75220. /**
  75221. * Base Url for the Quest controller model.
  75222. */
  75223. static QUEST_MODEL_BASE_URL: string;
  75224. profileId: string;
  75225. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  75226. protected _getFilenameAndPath(): {
  75227. filename: string;
  75228. path: string;
  75229. };
  75230. protected _getModelLoadingConstraints(): boolean;
  75231. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75232. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75233. protected _updateModel(): void;
  75234. /**
  75235. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  75236. * between the touch and touch 2.
  75237. */
  75238. private _isQuest;
  75239. }
  75240. }
  75241. declare module BABYLON {
  75242. /**
  75243. * The motion controller class for the standard HTC-Vive controllers
  75244. */
  75245. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  75246. private _modelRootNode;
  75247. /**
  75248. * The base url used to load the left and right controller models
  75249. */
  75250. static MODEL_BASE_URL: string;
  75251. /**
  75252. * File name for the controller model.
  75253. */
  75254. static MODEL_FILENAME: string;
  75255. profileId: string;
  75256. /**
  75257. * Create a new Vive motion controller object
  75258. * @param scene the scene to use to create this controller
  75259. * @param gamepadObject the corresponding gamepad object
  75260. * @param handedness the handedness of the controller
  75261. */
  75262. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75263. protected _getFilenameAndPath(): {
  75264. filename: string;
  75265. path: string;
  75266. };
  75267. protected _getModelLoadingConstraints(): boolean;
  75268. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75269. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75270. protected _updateModel(): void;
  75271. }
  75272. }
  75273. declare module BABYLON {
  75274. /**
  75275. * A cursor which tracks a point on a path
  75276. */
  75277. export class PathCursor {
  75278. private path;
  75279. /**
  75280. * Stores path cursor callbacks for when an onchange event is triggered
  75281. */
  75282. private _onchange;
  75283. /**
  75284. * The value of the path cursor
  75285. */
  75286. value: number;
  75287. /**
  75288. * The animation array of the path cursor
  75289. */
  75290. animations: Animation[];
  75291. /**
  75292. * Initializes the path cursor
  75293. * @param path The path to track
  75294. */
  75295. constructor(path: Path2);
  75296. /**
  75297. * Gets the cursor point on the path
  75298. * @returns A point on the path cursor at the cursor location
  75299. */
  75300. getPoint(): Vector3;
  75301. /**
  75302. * Moves the cursor ahead by the step amount
  75303. * @param step The amount to move the cursor forward
  75304. * @returns This path cursor
  75305. */
  75306. moveAhead(step?: number): PathCursor;
  75307. /**
  75308. * Moves the cursor behind by the step amount
  75309. * @param step The amount to move the cursor back
  75310. * @returns This path cursor
  75311. */
  75312. moveBack(step?: number): PathCursor;
  75313. /**
  75314. * Moves the cursor by the step amount
  75315. * If the step amount is greater than one, an exception is thrown
  75316. * @param step The amount to move the cursor
  75317. * @returns This path cursor
  75318. */
  75319. move(step: number): PathCursor;
  75320. /**
  75321. * Ensures that the value is limited between zero and one
  75322. * @returns This path cursor
  75323. */
  75324. private ensureLimits;
  75325. /**
  75326. * Runs onchange callbacks on change (used by the animation engine)
  75327. * @returns This path cursor
  75328. */
  75329. private raiseOnChange;
  75330. /**
  75331. * Executes a function on change
  75332. * @param f A path cursor onchange callback
  75333. * @returns This path cursor
  75334. */
  75335. onchange(f: (cursor: PathCursor) => void): PathCursor;
  75336. }
  75337. }
  75338. declare module BABYLON {
  75339. /** @hidden */
  75340. export var blurPixelShader: {
  75341. name: string;
  75342. shader: string;
  75343. };
  75344. }
  75345. declare module BABYLON {
  75346. /** @hidden */
  75347. export var pointCloudVertexDeclaration: {
  75348. name: string;
  75349. shader: string;
  75350. };
  75351. }
  75352. // Mixins
  75353. interface Window {
  75354. mozIndexedDB: IDBFactory;
  75355. webkitIndexedDB: IDBFactory;
  75356. msIndexedDB: IDBFactory;
  75357. webkitURL: typeof URL;
  75358. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  75359. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  75360. WebGLRenderingContext: WebGLRenderingContext;
  75361. MSGesture: MSGesture;
  75362. CANNON: any;
  75363. AudioContext: AudioContext;
  75364. webkitAudioContext: AudioContext;
  75365. PointerEvent: any;
  75366. Math: Math;
  75367. Uint8Array: Uint8ArrayConstructor;
  75368. Float32Array: Float32ArrayConstructor;
  75369. mozURL: typeof URL;
  75370. msURL: typeof URL;
  75371. VRFrameData: any; // WebVR, from specs 1.1
  75372. DracoDecoderModule: any;
  75373. setImmediate(handler: (...args: any[]) => void): number;
  75374. }
  75375. interface HTMLCanvasElement {
  75376. requestPointerLock(): void;
  75377. msRequestPointerLock?(): void;
  75378. mozRequestPointerLock?(): void;
  75379. webkitRequestPointerLock?(): void;
  75380. /** Track wether a record is in progress */
  75381. isRecording: boolean;
  75382. /** Capture Stream method defined by some browsers */
  75383. captureStream(fps?: number): MediaStream;
  75384. }
  75385. interface CanvasRenderingContext2D {
  75386. msImageSmoothingEnabled: boolean;
  75387. }
  75388. interface MouseEvent {
  75389. mozMovementX: number;
  75390. mozMovementY: number;
  75391. webkitMovementX: number;
  75392. webkitMovementY: number;
  75393. msMovementX: number;
  75394. msMovementY: number;
  75395. }
  75396. interface Navigator {
  75397. mozGetVRDevices: (any: any) => any;
  75398. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75399. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75400. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  75401. webkitGetGamepads(): Gamepad[];
  75402. msGetGamepads(): Gamepad[];
  75403. webkitGamepads(): Gamepad[];
  75404. }
  75405. interface HTMLVideoElement {
  75406. mozSrcObject: any;
  75407. }
  75408. interface Math {
  75409. fround(x: number): number;
  75410. imul(a: number, b: number): number;
  75411. }
  75412. interface WebGLRenderingContext {
  75413. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  75414. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  75415. vertexAttribDivisor(index: number, divisor: number): void;
  75416. createVertexArray(): any;
  75417. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  75418. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  75419. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  75420. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  75421. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  75422. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  75423. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  75424. // Queries
  75425. createQuery(): WebGLQuery;
  75426. deleteQuery(query: WebGLQuery): void;
  75427. beginQuery(target: number, query: WebGLQuery): void;
  75428. endQuery(target: number): void;
  75429. getQueryParameter(query: WebGLQuery, pname: number): any;
  75430. getQuery(target: number, pname: number): any;
  75431. MAX_SAMPLES: number;
  75432. RGBA8: number;
  75433. READ_FRAMEBUFFER: number;
  75434. DRAW_FRAMEBUFFER: number;
  75435. UNIFORM_BUFFER: number;
  75436. HALF_FLOAT_OES: number;
  75437. RGBA16F: number;
  75438. RGBA32F: number;
  75439. R32F: number;
  75440. RG32F: number;
  75441. RGB32F: number;
  75442. R16F: number;
  75443. RG16F: number;
  75444. RGB16F: number;
  75445. RED: number;
  75446. RG: number;
  75447. R8: number;
  75448. RG8: number;
  75449. UNSIGNED_INT_24_8: number;
  75450. DEPTH24_STENCIL8: number;
  75451. MIN: number;
  75452. MAX: number;
  75453. /* Multiple Render Targets */
  75454. drawBuffers(buffers: number[]): void;
  75455. readBuffer(src: number): void;
  75456. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  75457. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  75458. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  75459. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  75460. // Occlusion Query
  75461. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  75462. ANY_SAMPLES_PASSED: number;
  75463. QUERY_RESULT_AVAILABLE: number;
  75464. QUERY_RESULT: number;
  75465. }
  75466. interface WebGLProgram {
  75467. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  75468. }
  75469. interface EXT_disjoint_timer_query {
  75470. QUERY_COUNTER_BITS_EXT: number;
  75471. TIME_ELAPSED_EXT: number;
  75472. TIMESTAMP_EXT: number;
  75473. GPU_DISJOINT_EXT: number;
  75474. QUERY_RESULT_EXT: number;
  75475. QUERY_RESULT_AVAILABLE_EXT: number;
  75476. queryCounterEXT(query: WebGLQuery, target: number): void;
  75477. createQueryEXT(): WebGLQuery;
  75478. beginQueryEXT(target: number, query: WebGLQuery): void;
  75479. endQueryEXT(target: number): void;
  75480. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  75481. deleteQueryEXT(query: WebGLQuery): void;
  75482. }
  75483. interface WebGLUniformLocation {
  75484. _currentState: any;
  75485. }
  75486. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  75487. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  75488. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  75489. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75490. interface WebGLRenderingContext {
  75491. readonly RASTERIZER_DISCARD: number;
  75492. readonly DEPTH_COMPONENT24: number;
  75493. readonly TEXTURE_3D: number;
  75494. readonly TEXTURE_2D_ARRAY: number;
  75495. readonly TEXTURE_COMPARE_FUNC: number;
  75496. readonly TEXTURE_COMPARE_MODE: number;
  75497. readonly COMPARE_REF_TO_TEXTURE: number;
  75498. readonly TEXTURE_WRAP_R: number;
  75499. readonly HALF_FLOAT: number;
  75500. readonly RGB8: number;
  75501. readonly RED_INTEGER: number;
  75502. readonly RG_INTEGER: number;
  75503. readonly RGB_INTEGER: number;
  75504. readonly RGBA_INTEGER: number;
  75505. readonly R8_SNORM: number;
  75506. readonly RG8_SNORM: number;
  75507. readonly RGB8_SNORM: number;
  75508. readonly RGBA8_SNORM: number;
  75509. readonly R8I: number;
  75510. readonly RG8I: number;
  75511. readonly RGB8I: number;
  75512. readonly RGBA8I: number;
  75513. readonly R8UI: number;
  75514. readonly RG8UI: number;
  75515. readonly RGB8UI: number;
  75516. readonly RGBA8UI: number;
  75517. readonly R16I: number;
  75518. readonly RG16I: number;
  75519. readonly RGB16I: number;
  75520. readonly RGBA16I: number;
  75521. readonly R16UI: number;
  75522. readonly RG16UI: number;
  75523. readonly RGB16UI: number;
  75524. readonly RGBA16UI: number;
  75525. readonly R32I: number;
  75526. readonly RG32I: number;
  75527. readonly RGB32I: number;
  75528. readonly RGBA32I: number;
  75529. readonly R32UI: number;
  75530. readonly RG32UI: number;
  75531. readonly RGB32UI: number;
  75532. readonly RGBA32UI: number;
  75533. readonly RGB10_A2UI: number;
  75534. readonly R11F_G11F_B10F: number;
  75535. readonly RGB9_E5: number;
  75536. readonly RGB10_A2: number;
  75537. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  75538. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  75539. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  75540. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75541. readonly DEPTH_COMPONENT32F: number;
  75542. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  75543. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  75544. 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;
  75545. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  75546. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  75547. readonly TRANSFORM_FEEDBACK: number;
  75548. readonly INTERLEAVED_ATTRIBS: number;
  75549. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  75550. createTransformFeedback(): WebGLTransformFeedback;
  75551. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  75552. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  75553. beginTransformFeedback(primitiveMode: number): void;
  75554. endTransformFeedback(): void;
  75555. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  75556. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75557. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75558. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  75559. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  75560. }
  75561. interface ImageBitmap {
  75562. readonly width: number;
  75563. readonly height: number;
  75564. close(): void;
  75565. }
  75566. interface WebGLQuery extends WebGLObject {
  75567. }
  75568. declare var WebGLQuery: {
  75569. prototype: WebGLQuery;
  75570. new(): WebGLQuery;
  75571. };
  75572. interface WebGLSampler extends WebGLObject {
  75573. }
  75574. declare var WebGLSampler: {
  75575. prototype: WebGLSampler;
  75576. new(): WebGLSampler;
  75577. };
  75578. interface WebGLSync extends WebGLObject {
  75579. }
  75580. declare var WebGLSync: {
  75581. prototype: WebGLSync;
  75582. new(): WebGLSync;
  75583. };
  75584. interface WebGLTransformFeedback extends WebGLObject {
  75585. }
  75586. declare var WebGLTransformFeedback: {
  75587. prototype: WebGLTransformFeedback;
  75588. new(): WebGLTransformFeedback;
  75589. };
  75590. interface WebGLVertexArrayObject extends WebGLObject {
  75591. }
  75592. declare var WebGLVertexArrayObject: {
  75593. prototype: WebGLVertexArrayObject;
  75594. new(): WebGLVertexArrayObject;
  75595. };
  75596. // Type definitions for WebVR API
  75597. // Project: https://w3c.github.io/webvr/
  75598. // Definitions by: six a <https://github.com/lostfictions>
  75599. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  75600. interface VRDisplay extends EventTarget {
  75601. /**
  75602. * Dictionary of capabilities describing the VRDisplay.
  75603. */
  75604. readonly capabilities: VRDisplayCapabilities;
  75605. /**
  75606. * z-depth defining the far plane of the eye view frustum
  75607. * enables mapping of values in the render target depth
  75608. * attachment to scene coordinates. Initially set to 10000.0.
  75609. */
  75610. depthFar: number;
  75611. /**
  75612. * z-depth defining the near plane of the eye view frustum
  75613. * enables mapping of values in the render target depth
  75614. * attachment to scene coordinates. Initially set to 0.01.
  75615. */
  75616. depthNear: number;
  75617. /**
  75618. * An identifier for this distinct VRDisplay. Used as an
  75619. * association point in the Gamepad API.
  75620. */
  75621. readonly displayId: number;
  75622. /**
  75623. * A display name, a user-readable name identifying it.
  75624. */
  75625. readonly displayName: string;
  75626. readonly isConnected: boolean;
  75627. readonly isPresenting: boolean;
  75628. /**
  75629. * If this VRDisplay supports room-scale experiences, the optional
  75630. * stage attribute contains details on the room-scale parameters.
  75631. */
  75632. readonly stageParameters: VRStageParameters | null;
  75633. /**
  75634. * Passing the value returned by `requestAnimationFrame` to
  75635. * `cancelAnimationFrame` will unregister the callback.
  75636. * @param handle Define the hanle of the request to cancel
  75637. */
  75638. cancelAnimationFrame(handle: number): void;
  75639. /**
  75640. * Stops presenting to the VRDisplay.
  75641. * @returns a promise to know when it stopped
  75642. */
  75643. exitPresent(): Promise<void>;
  75644. /**
  75645. * Return the current VREyeParameters for the given eye.
  75646. * @param whichEye Define the eye we want the parameter for
  75647. * @returns the eye parameters
  75648. */
  75649. getEyeParameters(whichEye: string): VREyeParameters;
  75650. /**
  75651. * Populates the passed VRFrameData with the information required to render
  75652. * the current frame.
  75653. * @param frameData Define the data structure to populate
  75654. * @returns true if ok otherwise false
  75655. */
  75656. getFrameData(frameData: VRFrameData): boolean;
  75657. /**
  75658. * Get the layers currently being presented.
  75659. * @returns the list of VR layers
  75660. */
  75661. getLayers(): VRLayer[];
  75662. /**
  75663. * Return a VRPose containing the future predicted pose of the VRDisplay
  75664. * when the current frame will be presented. The value returned will not
  75665. * change until JavaScript has returned control to the browser.
  75666. *
  75667. * The VRPose will contain the position, orientation, velocity,
  75668. * and acceleration of each of these properties.
  75669. * @returns the pose object
  75670. */
  75671. getPose(): VRPose;
  75672. /**
  75673. * Return the current instantaneous pose of the VRDisplay, with no
  75674. * prediction applied.
  75675. * @returns the current instantaneous pose
  75676. */
  75677. getImmediatePose(): VRPose;
  75678. /**
  75679. * The callback passed to `requestAnimationFrame` will be called
  75680. * any time a new frame should be rendered. When the VRDisplay is
  75681. * presenting the callback will be called at the native refresh
  75682. * rate of the HMD. When not presenting this function acts
  75683. * identically to how window.requestAnimationFrame acts. Content should
  75684. * make no assumptions of frame rate or vsync behavior as the HMD runs
  75685. * asynchronously from other displays and at differing refresh rates.
  75686. * @param callback Define the eaction to run next frame
  75687. * @returns the request handle it
  75688. */
  75689. requestAnimationFrame(callback: FrameRequestCallback): number;
  75690. /**
  75691. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  75692. * Repeat calls while already presenting will update the VRLayers being displayed.
  75693. * @param layers Define the list of layer to present
  75694. * @returns a promise to know when the request has been fulfilled
  75695. */
  75696. requestPresent(layers: VRLayer[]): Promise<void>;
  75697. /**
  75698. * Reset the pose for this display, treating its current position and
  75699. * orientation as the "origin/zero" values. VRPose.position,
  75700. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  75701. * updated when calling resetPose(). This should be called in only
  75702. * sitting-space experiences.
  75703. */
  75704. resetPose(): void;
  75705. /**
  75706. * The VRLayer provided to the VRDisplay will be captured and presented
  75707. * in the HMD. Calling this function has the same effect on the source
  75708. * canvas as any other operation that uses its source image, and canvases
  75709. * created without preserveDrawingBuffer set to true will be cleared.
  75710. * @param pose Define the pose to submit
  75711. */
  75712. submitFrame(pose?: VRPose): void;
  75713. }
  75714. declare var VRDisplay: {
  75715. prototype: VRDisplay;
  75716. new(): VRDisplay;
  75717. };
  75718. interface VRLayer {
  75719. leftBounds?: number[] | Float32Array | null;
  75720. rightBounds?: number[] | Float32Array | null;
  75721. source?: HTMLCanvasElement | null;
  75722. }
  75723. interface VRDisplayCapabilities {
  75724. readonly canPresent: boolean;
  75725. readonly hasExternalDisplay: boolean;
  75726. readonly hasOrientation: boolean;
  75727. readonly hasPosition: boolean;
  75728. readonly maxLayers: number;
  75729. }
  75730. interface VREyeParameters {
  75731. /** @deprecated */
  75732. readonly fieldOfView: VRFieldOfView;
  75733. readonly offset: Float32Array;
  75734. readonly renderHeight: number;
  75735. readonly renderWidth: number;
  75736. }
  75737. interface VRFieldOfView {
  75738. readonly downDegrees: number;
  75739. readonly leftDegrees: number;
  75740. readonly rightDegrees: number;
  75741. readonly upDegrees: number;
  75742. }
  75743. interface VRFrameData {
  75744. readonly leftProjectionMatrix: Float32Array;
  75745. readonly leftViewMatrix: Float32Array;
  75746. readonly pose: VRPose;
  75747. readonly rightProjectionMatrix: Float32Array;
  75748. readonly rightViewMatrix: Float32Array;
  75749. readonly timestamp: number;
  75750. }
  75751. interface VRPose {
  75752. readonly angularAcceleration: Float32Array | null;
  75753. readonly angularVelocity: Float32Array | null;
  75754. readonly linearAcceleration: Float32Array | null;
  75755. readonly linearVelocity: Float32Array | null;
  75756. readonly orientation: Float32Array | null;
  75757. readonly position: Float32Array | null;
  75758. readonly timestamp: number;
  75759. }
  75760. interface VRStageParameters {
  75761. sittingToStandingTransform?: Float32Array;
  75762. sizeX?: number;
  75763. sizeY?: number;
  75764. }
  75765. interface Navigator {
  75766. getVRDisplays(): Promise<VRDisplay[]>;
  75767. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  75768. }
  75769. interface Window {
  75770. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  75771. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  75772. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  75773. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75774. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75775. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  75776. }
  75777. interface Gamepad {
  75778. readonly displayId: number;
  75779. }
  75780. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  75781. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  75782. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  75783. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  75784. type XRHandedness = "none" | "left" | "right";
  75785. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  75786. type XREye = "none" | "left" | "right";
  75787. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  75788. interface XRSpace extends EventTarget {}
  75789. interface XRRenderState {
  75790. depthNear?: number;
  75791. depthFar?: number;
  75792. inlineVerticalFieldOfView?: number;
  75793. baseLayer?: XRWebGLLayer;
  75794. }
  75795. interface XRInputSource {
  75796. handedness: XRHandedness;
  75797. targetRayMode: XRTargetRayMode;
  75798. targetRaySpace: XRSpace;
  75799. gripSpace: XRSpace | undefined;
  75800. gamepad: Gamepad | undefined;
  75801. profiles: Array<string>;
  75802. hand: XRHand | undefined;
  75803. }
  75804. interface XRSessionInit {
  75805. optionalFeatures?: string[];
  75806. requiredFeatures?: string[];
  75807. }
  75808. interface XRSession {
  75809. addEventListener: Function;
  75810. removeEventListener: Function;
  75811. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  75812. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  75813. requestAnimationFrame: Function;
  75814. end(): Promise<void>;
  75815. renderState: XRRenderState;
  75816. inputSources: Array<XRInputSource>;
  75817. // hit test
  75818. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  75819. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  75820. // legacy AR hit test
  75821. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75822. // legacy plane detection
  75823. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  75824. }
  75825. interface XRReferenceSpace extends XRSpace {
  75826. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  75827. onreset: any;
  75828. }
  75829. type XRPlaneSet = Set<XRPlane>;
  75830. type XRAnchorSet = Set<XRAnchor>;
  75831. interface XRFrame {
  75832. session: XRSession;
  75833. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  75834. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  75835. // AR
  75836. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  75837. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  75838. // Anchors
  75839. trackedAnchors?: XRAnchorSet;
  75840. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  75841. // Planes
  75842. worldInformation: {
  75843. detectedPlanes?: XRPlaneSet;
  75844. };
  75845. // Hand tracking
  75846. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  75847. }
  75848. interface XRViewerPose extends XRPose {
  75849. views: Array<XRView>;
  75850. }
  75851. interface XRPose {
  75852. transform: XRRigidTransform;
  75853. emulatedPosition: boolean;
  75854. }
  75855. interface XRWebGLLayerOptions {
  75856. antialias?: boolean;
  75857. depth?: boolean;
  75858. stencil?: boolean;
  75859. alpha?: boolean;
  75860. multiview?: boolean;
  75861. framebufferScaleFactor?: number;
  75862. }
  75863. declare var XRWebGLLayer: {
  75864. prototype: XRWebGLLayer;
  75865. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  75866. };
  75867. interface XRWebGLLayer {
  75868. framebuffer: WebGLFramebuffer;
  75869. framebufferWidth: number;
  75870. framebufferHeight: number;
  75871. getViewport: Function;
  75872. }
  75873. declare class XRRigidTransform {
  75874. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  75875. position: DOMPointReadOnly;
  75876. orientation: DOMPointReadOnly;
  75877. matrix: Float32Array;
  75878. inverse: XRRigidTransform;
  75879. }
  75880. interface XRView {
  75881. eye: XREye;
  75882. projectionMatrix: Float32Array;
  75883. transform: XRRigidTransform;
  75884. }
  75885. interface XRInputSourceChangeEvent {
  75886. session: XRSession;
  75887. removed: Array<XRInputSource>;
  75888. added: Array<XRInputSource>;
  75889. }
  75890. interface XRInputSourceEvent extends Event {
  75891. readonly frame: XRFrame;
  75892. readonly inputSource: XRInputSource;
  75893. }
  75894. // Experimental(er) features
  75895. declare class XRRay {
  75896. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  75897. origin: DOMPointReadOnly;
  75898. direction: DOMPointReadOnly;
  75899. matrix: Float32Array;
  75900. }
  75901. declare enum XRHitTestTrackableType {
  75902. "point",
  75903. "plane",
  75904. "mesh",
  75905. }
  75906. interface XRHitResult {
  75907. hitMatrix: Float32Array;
  75908. }
  75909. interface XRTransientInputHitTestResult {
  75910. readonly inputSource: XRInputSource;
  75911. readonly results: Array<XRHitTestResult>;
  75912. }
  75913. interface XRHitTestResult {
  75914. getPose(baseSpace: XRSpace): XRPose | undefined;
  75915. // When anchor system is enabled
  75916. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  75917. }
  75918. interface XRHitTestSource {
  75919. cancel(): void;
  75920. }
  75921. interface XRTransientInputHitTestSource {
  75922. cancel(): void;
  75923. }
  75924. interface XRHitTestOptionsInit {
  75925. space: XRSpace;
  75926. entityTypes?: Array<XRHitTestTrackableType>;
  75927. offsetRay?: XRRay;
  75928. }
  75929. interface XRTransientInputHitTestOptionsInit {
  75930. profile: string;
  75931. entityTypes?: Array<XRHitTestTrackableType>;
  75932. offsetRay?: XRRay;
  75933. }
  75934. interface XRAnchor {
  75935. anchorSpace: XRSpace;
  75936. delete(): void;
  75937. }
  75938. interface XRPlane {
  75939. orientation: "Horizontal" | "Vertical";
  75940. planeSpace: XRSpace;
  75941. polygon: Array<DOMPointReadOnly>;
  75942. lastChangedTime: number;
  75943. }
  75944. interface XRJointSpace extends XRSpace {}
  75945. interface XRJointPose extends XRPose {
  75946. radius: number | undefined;
  75947. }
  75948. declare class XRHand extends Array<XRJointSpace> {
  75949. readonly length: number;
  75950. static readonly WRIST = 0;
  75951. static readonly THUMB_METACARPAL = 1;
  75952. static readonly THUMB_PHALANX_PROXIMAL = 2;
  75953. static readonly THUMB_PHALANX_DISTAL = 3;
  75954. static readonly THUMB_PHALANX_TIP = 4;
  75955. static readonly INDEX_METACARPAL = 5;
  75956. static readonly INDEX_PHALANX_PROXIMAL = 6;
  75957. static readonly INDEX_PHALANX_INTERMEDIATE = 7;
  75958. static readonly INDEX_PHALANX_DISTAL = 8;
  75959. static readonly INDEX_PHALANX_TIP = 9;
  75960. static readonly MIDDLE_METACARPAL = 10;
  75961. static readonly MIDDLE_PHALANX_PROXIMAL = 11;
  75962. static readonly MIDDLE_PHALANX_INTERMEDIATE = 12;
  75963. static readonly MIDDLE_PHALANX_DISTAL = 13;
  75964. static readonly MIDDLE_PHALANX_TIP = 14;
  75965. static readonly RING_METACARPAL = 15;
  75966. static readonly RING_PHALANX_PROXIMAL = 16;
  75967. static readonly RING_PHALANX_INTERMEDIATE = 17;
  75968. static readonly RING_PHALANX_DISTAL = 18;
  75969. static readonly RING_PHALANX_TIP = 19;
  75970. static readonly LITTLE_METACARPAL = 20;
  75971. static readonly LITTLE_PHALANX_PROXIMAL = 21;
  75972. static readonly LITTLE_PHALANX_INTERMEDIATE = 22;
  75973. static readonly LITTLE_PHALANX_DISTAL = 23;
  75974. static readonly LITTLE_PHALANX_TIP = 24;
  75975. }
  75976. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  75977. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  75978. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  75979. interface XRSession {
  75980. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  75981. }
  75982. interface XRFrame {
  75983. featurePointCloud? : Array<number>;
  75984. }
  75985. /**
  75986. * @ignore
  75987. */
  75988. declare module BABYLON.GLTF2.Exporter {
  75989. }
  75990. /**
  75991. * @ignore
  75992. */
  75993. declare module BABYLON.GLTF1 {
  75994. }
  75995. declare module BABYLON.GUI {
  75996. /**
  75997. * Class used to specific a value and its associated unit
  75998. */
  75999. export class ValueAndUnit {
  76000. /** defines the unit to store */
  76001. unit: number;
  76002. /** defines a boolean indicating if the value can be negative */
  76003. negativeValueAllowed: boolean;
  76004. private _value;
  76005. private _originalUnit;
  76006. /**
  76007. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  76008. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76009. */
  76010. ignoreAdaptiveScaling: boolean;
  76011. /**
  76012. * Creates a new ValueAndUnit
  76013. * @param value defines the value to store
  76014. * @param unit defines the unit to store
  76015. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  76016. */
  76017. constructor(value: number,
  76018. /** defines the unit to store */
  76019. unit?: number,
  76020. /** defines a boolean indicating if the value can be negative */
  76021. negativeValueAllowed?: boolean);
  76022. /** Gets a boolean indicating if the value is a percentage */
  76023. get isPercentage(): boolean;
  76024. /** Gets a boolean indicating if the value is store as pixel */
  76025. get isPixel(): boolean;
  76026. /** Gets direct internal value */
  76027. get internalValue(): number;
  76028. /**
  76029. * Gets value as pixel
  76030. * @param host defines the root host
  76031. * @param refValue defines the reference value for percentages
  76032. * @returns the value as pixel
  76033. */
  76034. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  76035. /**
  76036. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  76037. * @param value defines the value to store
  76038. * @param unit defines the unit to store
  76039. * @returns the current ValueAndUnit
  76040. */
  76041. updateInPlace(value: number, unit?: number): ValueAndUnit;
  76042. /**
  76043. * Gets the value accordingly to its unit
  76044. * @param host defines the root host
  76045. * @returns the value
  76046. */
  76047. getValue(host: AdvancedDynamicTexture): number;
  76048. /**
  76049. * Gets a string representation of the value
  76050. * @param host defines the root host
  76051. * @param decimals defines an optional number of decimals to display
  76052. * @returns a string
  76053. */
  76054. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  76055. /**
  76056. * Store a value parsed from a string
  76057. * @param source defines the source string
  76058. * @returns true if the value was successfully parsed
  76059. */
  76060. fromString(source: string | number): boolean;
  76061. private static _Regex;
  76062. private static _UNITMODE_PERCENTAGE;
  76063. private static _UNITMODE_PIXEL;
  76064. /** UNITMODE_PERCENTAGE */
  76065. static get UNITMODE_PERCENTAGE(): number;
  76066. /** UNITMODE_PIXEL */
  76067. static get UNITMODE_PIXEL(): number;
  76068. }
  76069. }
  76070. declare module BABYLON.GUI {
  76071. /**
  76072. * Define a style used by control to automatically setup properties based on a template.
  76073. * Only support font related properties so far
  76074. */
  76075. export class Style implements BABYLON.IDisposable {
  76076. private _fontFamily;
  76077. private _fontStyle;
  76078. private _fontWeight;
  76079. /** @hidden */
  76080. _host: AdvancedDynamicTexture;
  76081. /** @hidden */
  76082. _fontSize: ValueAndUnit;
  76083. /**
  76084. * BABYLON.Observable raised when the style values are changed
  76085. */
  76086. onChangedObservable: BABYLON.Observable<Style>;
  76087. /**
  76088. * Creates a new style object
  76089. * @param host defines the AdvancedDynamicTexture which hosts this style
  76090. */
  76091. constructor(host: AdvancedDynamicTexture);
  76092. /**
  76093. * Gets or sets the font size
  76094. */
  76095. get fontSize(): string | number;
  76096. set fontSize(value: string | number);
  76097. /**
  76098. * Gets or sets the font family
  76099. */
  76100. get fontFamily(): string;
  76101. set fontFamily(value: string);
  76102. /**
  76103. * Gets or sets the font style
  76104. */
  76105. get fontStyle(): string;
  76106. set fontStyle(value: string);
  76107. /** Gets or sets font weight */
  76108. get fontWeight(): string;
  76109. set fontWeight(value: string);
  76110. /** Dispose all associated resources */
  76111. dispose(): void;
  76112. }
  76113. }
  76114. declare module BABYLON.GUI {
  76115. /**
  76116. * Class used to transport BABYLON.Vector2 information for pointer events
  76117. */
  76118. export class Vector2WithInfo extends BABYLON.Vector2 {
  76119. /** defines the current mouse button index */
  76120. buttonIndex: number;
  76121. /**
  76122. * Creates a new Vector2WithInfo
  76123. * @param source defines the vector2 data to transport
  76124. * @param buttonIndex defines the current mouse button index
  76125. */
  76126. constructor(source: BABYLON.Vector2,
  76127. /** defines the current mouse button index */
  76128. buttonIndex?: number);
  76129. }
  76130. /** Class used to provide 2D matrix features */
  76131. export class Matrix2D {
  76132. /** Gets the internal array of 6 floats used to store matrix data */
  76133. m: Float32Array;
  76134. /**
  76135. * Creates a new matrix
  76136. * @param m00 defines value for (0, 0)
  76137. * @param m01 defines value for (0, 1)
  76138. * @param m10 defines value for (1, 0)
  76139. * @param m11 defines value for (1, 1)
  76140. * @param m20 defines value for (2, 0)
  76141. * @param m21 defines value for (2, 1)
  76142. */
  76143. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  76144. /**
  76145. * Fills the matrix from direct values
  76146. * @param m00 defines value for (0, 0)
  76147. * @param m01 defines value for (0, 1)
  76148. * @param m10 defines value for (1, 0)
  76149. * @param m11 defines value for (1, 1)
  76150. * @param m20 defines value for (2, 0)
  76151. * @param m21 defines value for (2, 1)
  76152. * @returns the current modified matrix
  76153. */
  76154. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  76155. /**
  76156. * Gets matrix determinant
  76157. * @returns the determinant
  76158. */
  76159. determinant(): number;
  76160. /**
  76161. * Inverses the matrix and stores it in a target matrix
  76162. * @param result defines the target matrix
  76163. * @returns the current matrix
  76164. */
  76165. invertToRef(result: Matrix2D): Matrix2D;
  76166. /**
  76167. * Multiplies the current matrix with another one
  76168. * @param other defines the second operand
  76169. * @param result defines the target matrix
  76170. * @returns the current matrix
  76171. */
  76172. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  76173. /**
  76174. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  76175. * @param x defines the x coordinate to transform
  76176. * @param y defines the x coordinate to transform
  76177. * @param result defines the target vector2
  76178. * @returns the current matrix
  76179. */
  76180. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  76181. /**
  76182. * Creates an identity matrix
  76183. * @returns a new matrix
  76184. */
  76185. static Identity(): Matrix2D;
  76186. /**
  76187. * Creates a translation matrix and stores it in a target matrix
  76188. * @param x defines the x coordinate of the translation
  76189. * @param y defines the y coordinate of the translation
  76190. * @param result defines the target matrix
  76191. */
  76192. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  76193. /**
  76194. * Creates a scaling matrix and stores it in a target matrix
  76195. * @param x defines the x coordinate of the scaling
  76196. * @param y defines the y coordinate of the scaling
  76197. * @param result defines the target matrix
  76198. */
  76199. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  76200. /**
  76201. * Creates a rotation matrix and stores it in a target matrix
  76202. * @param angle defines the rotation angle
  76203. * @param result defines the target matrix
  76204. */
  76205. static RotationToRef(angle: number, result: Matrix2D): void;
  76206. private static _TempPreTranslationMatrix;
  76207. private static _TempPostTranslationMatrix;
  76208. private static _TempRotationMatrix;
  76209. private static _TempScalingMatrix;
  76210. private static _TempCompose0;
  76211. private static _TempCompose1;
  76212. private static _TempCompose2;
  76213. /**
  76214. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  76215. * @param tx defines the x coordinate of the translation
  76216. * @param ty defines the y coordinate of the translation
  76217. * @param angle defines the rotation angle
  76218. * @param scaleX defines the x coordinate of the scaling
  76219. * @param scaleY defines the y coordinate of the scaling
  76220. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  76221. * @param result defines the target matrix
  76222. */
  76223. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  76224. }
  76225. }
  76226. declare module BABYLON.GUI {
  76227. /**
  76228. * Class used to store 2D control sizes
  76229. */
  76230. export class Measure {
  76231. /** defines left coordinate */
  76232. left: number;
  76233. /** defines top coordinate */
  76234. top: number;
  76235. /** defines width dimension */
  76236. width: number;
  76237. /** defines height dimension */
  76238. height: number;
  76239. /**
  76240. * Creates a new measure
  76241. * @param left defines left coordinate
  76242. * @param top defines top coordinate
  76243. * @param width defines width dimension
  76244. * @param height defines height dimension
  76245. */
  76246. constructor(
  76247. /** defines left coordinate */
  76248. left: number,
  76249. /** defines top coordinate */
  76250. top: number,
  76251. /** defines width dimension */
  76252. width: number,
  76253. /** defines height dimension */
  76254. height: number);
  76255. /**
  76256. * Copy from another measure
  76257. * @param other defines the other measure to copy from
  76258. */
  76259. copyFrom(other: Measure): void;
  76260. /**
  76261. * Copy from a group of 4 floats
  76262. * @param left defines left coordinate
  76263. * @param top defines top coordinate
  76264. * @param width defines width dimension
  76265. * @param height defines height dimension
  76266. */
  76267. copyFromFloats(left: number, top: number, width: number, height: number): void;
  76268. /**
  76269. * Computes the axis aligned bounding box measure for two given measures
  76270. * @param a Input measure
  76271. * @param b Input measure
  76272. * @param result the resulting bounding measure
  76273. */
  76274. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  76275. /**
  76276. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76277. * @param transform the matrix to transform the measure before computing the AABB
  76278. * @param addX number to add to left
  76279. * @param addY number to add to top
  76280. * @param addWidth number to add to width
  76281. * @param addHeight number to add to height
  76282. * @param result the resulting AABB
  76283. */
  76284. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  76285. /**
  76286. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  76287. * @param transform the matrix to transform the measure before computing the AABB
  76288. * @param result the resulting AABB
  76289. */
  76290. transformToRef(transform: Matrix2D, result: Measure): void;
  76291. /**
  76292. * Check equality between this measure and another one
  76293. * @param other defines the other measures
  76294. * @returns true if both measures are equals
  76295. */
  76296. isEqualsTo(other: Measure): boolean;
  76297. /**
  76298. * Creates an empty measure
  76299. * @returns a new measure
  76300. */
  76301. static Empty(): Measure;
  76302. }
  76303. }
  76304. declare module BABYLON.GUI {
  76305. /**
  76306. * Interface used to define a control that can receive focus
  76307. */
  76308. export interface IFocusableControl {
  76309. /**
  76310. * Function called when the control receives the focus
  76311. */
  76312. onFocus(): void;
  76313. /**
  76314. * Function called when the control loses the focus
  76315. */
  76316. onBlur(): void;
  76317. /**
  76318. * Function called to let the control handle keyboard events
  76319. * @param evt defines the current keyboard event
  76320. */
  76321. processKeyboard(evt: KeyboardEvent): void;
  76322. /**
  76323. * Function called to get the list of controls that should not steal the focus from this control
  76324. * @returns an array of controls
  76325. */
  76326. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76327. }
  76328. /**
  76329. * Class used to create texture to support 2D GUI elements
  76330. * @see https://doc.babylonjs.com/how_to/gui
  76331. */
  76332. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  76333. private _isDirty;
  76334. private _renderObserver;
  76335. private _resizeObserver;
  76336. private _preKeyboardObserver;
  76337. private _pointerMoveObserver;
  76338. private _pointerObserver;
  76339. private _canvasPointerOutObserver;
  76340. private _canvasBlurObserver;
  76341. private _background;
  76342. /** @hidden */
  76343. _rootContainer: Container;
  76344. /** @hidden */
  76345. _lastPickedControl: Control;
  76346. /** @hidden */
  76347. _lastControlOver: {
  76348. [pointerId: number]: Control;
  76349. };
  76350. /** @hidden */
  76351. _lastControlDown: {
  76352. [pointerId: number]: Control;
  76353. };
  76354. /** @hidden */
  76355. _capturingControl: {
  76356. [pointerId: number]: Control;
  76357. };
  76358. /** @hidden */
  76359. _shouldBlockPointer: boolean;
  76360. /** @hidden */
  76361. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  76362. /** @hidden */
  76363. _linkedControls: Control[];
  76364. private _isFullscreen;
  76365. private _fullscreenViewport;
  76366. private _idealWidth;
  76367. private _idealHeight;
  76368. private _useSmallestIdeal;
  76369. private _renderAtIdealSize;
  76370. private _focusedControl;
  76371. private _blockNextFocusCheck;
  76372. private _renderScale;
  76373. private _rootElement;
  76374. private _cursorChanged;
  76375. private _defaultMousePointerId;
  76376. /** @hidden */
  76377. _numLayoutCalls: number;
  76378. /** Gets the number of layout calls made the last time the ADT has been rendered */
  76379. get numLayoutCalls(): number;
  76380. /** @hidden */
  76381. _numRenderCalls: number;
  76382. /** Gets the number of render calls made the last time the ADT has been rendered */
  76383. get numRenderCalls(): number;
  76384. /**
  76385. * Define type to string to ensure compatibility across browsers
  76386. * Safari doesn't support DataTransfer constructor
  76387. */
  76388. private _clipboardData;
  76389. /**
  76390. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  76391. */
  76392. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  76393. /**
  76394. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  76395. */
  76396. onControlPickedObservable: BABYLON.Observable<Control>;
  76397. /**
  76398. * BABYLON.Observable event triggered before layout is evaluated
  76399. */
  76400. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76401. /**
  76402. * BABYLON.Observable event triggered after the layout was evaluated
  76403. */
  76404. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76405. /**
  76406. * BABYLON.Observable event triggered before the texture is rendered
  76407. */
  76408. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76409. /**
  76410. * BABYLON.Observable event triggered after the texture was rendered
  76411. */
  76412. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  76413. /**
  76414. * Gets or sets a boolean defining if alpha is stored as premultiplied
  76415. */
  76416. premulAlpha: boolean;
  76417. /**
  76418. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  76419. * Useful when you want more antialiasing
  76420. */
  76421. get renderScale(): number;
  76422. set renderScale(value: number);
  76423. /** Gets or sets the background color */
  76424. get background(): string;
  76425. set background(value: string);
  76426. /**
  76427. * Gets or sets the ideal width used to design controls.
  76428. * The GUI will then rescale everything accordingly
  76429. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76430. */
  76431. get idealWidth(): number;
  76432. set idealWidth(value: number);
  76433. /**
  76434. * Gets or sets the ideal height used to design controls.
  76435. * The GUI will then rescale everything accordingly
  76436. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76437. */
  76438. get idealHeight(): number;
  76439. set idealHeight(value: number);
  76440. /**
  76441. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  76442. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76443. */
  76444. get useSmallestIdeal(): boolean;
  76445. set useSmallestIdeal(value: boolean);
  76446. /**
  76447. * Gets or sets a boolean indicating if adaptive scaling must be used
  76448. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76449. */
  76450. get renderAtIdealSize(): boolean;
  76451. set renderAtIdealSize(value: boolean);
  76452. /**
  76453. * Gets the ratio used when in "ideal mode"
  76454. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76455. * */
  76456. get idealRatio(): number;
  76457. /**
  76458. * Gets the underlying layer used to render the texture when in fullscreen mode
  76459. */
  76460. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  76461. /**
  76462. * Gets the root container control
  76463. */
  76464. get rootContainer(): Container;
  76465. /**
  76466. * Returns an array containing the root container.
  76467. * This is mostly used to let the Inspector introspects the ADT
  76468. * @returns an array containing the rootContainer
  76469. */
  76470. getChildren(): Array<Container>;
  76471. /**
  76472. * Will return all controls that are inside this texture
  76473. * @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
  76474. * @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
  76475. * @return all child controls
  76476. */
  76477. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76478. /**
  76479. * Gets or sets the current focused control
  76480. */
  76481. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  76482. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  76483. /**
  76484. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  76485. */
  76486. get isForeground(): boolean;
  76487. set isForeground(value: boolean);
  76488. /**
  76489. * Gets or set information about clipboardData
  76490. */
  76491. get clipboardData(): string;
  76492. set clipboardData(value: string);
  76493. /**
  76494. * Creates a new AdvancedDynamicTexture
  76495. * @param name defines the name of the texture
  76496. * @param width defines the width of the texture
  76497. * @param height defines the height of the texture
  76498. * @param scene defines the hosting scene
  76499. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  76500. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  76501. */
  76502. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  76503. /**
  76504. * Get the current class name of the texture useful for serialization or dynamic coding.
  76505. * @returns "AdvancedDynamicTexture"
  76506. */
  76507. getClassName(): string;
  76508. /**
  76509. * Function used to execute a function on all controls
  76510. * @param func defines the function to execute
  76511. * @param container defines the container where controls belong. If null the root container will be used
  76512. */
  76513. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  76514. private _useInvalidateRectOptimization;
  76515. /**
  76516. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  76517. */
  76518. get useInvalidateRectOptimization(): boolean;
  76519. set useInvalidateRectOptimization(value: boolean);
  76520. private _invalidatedRectangle;
  76521. /**
  76522. * Invalidates a rectangle area on the gui texture
  76523. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  76524. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  76525. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  76526. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  76527. */
  76528. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  76529. /**
  76530. * Marks the texture as dirty forcing a complete update
  76531. */
  76532. markAsDirty(): void;
  76533. /**
  76534. * Helper function used to create a new style
  76535. * @returns a new style
  76536. * @see https://doc.babylonjs.com/how_to/gui#styles
  76537. */
  76538. createStyle(): Style;
  76539. /**
  76540. * Adds a new control to the root container
  76541. * @param control defines the control to add
  76542. * @returns the current texture
  76543. */
  76544. addControl(control: Control): AdvancedDynamicTexture;
  76545. /**
  76546. * Removes a control from the root container
  76547. * @param control defines the control to remove
  76548. * @returns the current texture
  76549. */
  76550. removeControl(control: Control): AdvancedDynamicTexture;
  76551. /**
  76552. * Release all resources
  76553. */
  76554. dispose(): void;
  76555. private _onResize;
  76556. /** @hidden */
  76557. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  76558. /**
  76559. * Get screen coordinates for a vector3
  76560. * @param position defines the position to project
  76561. * @param worldMatrix defines the world matrix to use
  76562. * @returns the projected position
  76563. */
  76564. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  76565. private _checkUpdate;
  76566. private _clearMeasure;
  76567. private _render;
  76568. /** @hidden */
  76569. _changeCursor(cursor: string): void;
  76570. /** @hidden */
  76571. _registerLastControlDown(control: Control, pointerId: number): void;
  76572. private _doPicking;
  76573. /** @hidden */
  76574. _cleanControlAfterRemovalFromList(list: {
  76575. [pointerId: number]: Control;
  76576. }, control: Control): void;
  76577. /** @hidden */
  76578. _cleanControlAfterRemoval(control: Control): void;
  76579. /** Attach to all scene events required to support pointer events */
  76580. attach(): void;
  76581. /** @hidden */
  76582. private onClipboardCopy;
  76583. /** @hidden */
  76584. private onClipboardCut;
  76585. /** @hidden */
  76586. private onClipboardPaste;
  76587. /**
  76588. * Register the clipboard Events onto the canvas
  76589. */
  76590. registerClipboardEvents(): void;
  76591. /**
  76592. * Unregister the clipboard Events from the canvas
  76593. */
  76594. unRegisterClipboardEvents(): void;
  76595. /**
  76596. * Connect the texture to a hosting mesh to enable interactions
  76597. * @param mesh defines the mesh to attach to
  76598. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  76599. */
  76600. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  76601. /**
  76602. * Move the focus to a specific control
  76603. * @param control defines the control which will receive the focus
  76604. */
  76605. moveFocusToControl(control: IFocusableControl): void;
  76606. private _manageFocus;
  76607. private _attachToOnPointerOut;
  76608. private _attachToOnBlur;
  76609. /**
  76610. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  76611. * @param mesh defines the mesh which will receive the texture
  76612. * @param width defines the texture width (1024 by default)
  76613. * @param height defines the texture height (1024 by default)
  76614. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  76615. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  76616. * @returns a new AdvancedDynamicTexture
  76617. */
  76618. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  76619. /**
  76620. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  76621. * In this mode the texture will rely on a layer for its rendering.
  76622. * This allows it to be treated like any other layer.
  76623. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  76624. * LayerMask is set through advancedTexture.layer.layerMask
  76625. * @param name defines name for the texture
  76626. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  76627. * @param scene defines the hsoting scene
  76628. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  76629. * @returns a new AdvancedDynamicTexture
  76630. */
  76631. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  76632. }
  76633. }
  76634. declare module BABYLON.GUI {
  76635. /**
  76636. * Root class used for all 2D controls
  76637. * @see https://doc.babylonjs.com/how_to/gui#controls
  76638. */
  76639. export class Control {
  76640. /** defines the name of the control */
  76641. name?: string | undefined;
  76642. /**
  76643. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  76644. */
  76645. static AllowAlphaInheritance: boolean;
  76646. private _alpha;
  76647. private _alphaSet;
  76648. private _zIndex;
  76649. /** @hidden */
  76650. _host: AdvancedDynamicTexture;
  76651. /** Gets or sets the control parent */
  76652. parent: BABYLON.Nullable<Container>;
  76653. /** @hidden */
  76654. _currentMeasure: Measure;
  76655. private _fontFamily;
  76656. private _fontStyle;
  76657. private _fontWeight;
  76658. private _fontSize;
  76659. private _font;
  76660. /** @hidden */
  76661. _width: ValueAndUnit;
  76662. /** @hidden */
  76663. _height: ValueAndUnit;
  76664. /** @hidden */
  76665. protected _fontOffset: {
  76666. ascent: number;
  76667. height: number;
  76668. descent: number;
  76669. };
  76670. private _color;
  76671. private _style;
  76672. private _styleObserver;
  76673. /** @hidden */
  76674. protected _horizontalAlignment: number;
  76675. /** @hidden */
  76676. protected _verticalAlignment: number;
  76677. /** @hidden */
  76678. protected _isDirty: boolean;
  76679. /** @hidden */
  76680. protected _wasDirty: boolean;
  76681. /** @hidden */
  76682. _tempParentMeasure: Measure;
  76683. /** @hidden */
  76684. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  76685. /** @hidden */
  76686. protected _cachedParentMeasure: Measure;
  76687. private _paddingLeft;
  76688. private _paddingRight;
  76689. private _paddingTop;
  76690. private _paddingBottom;
  76691. /** @hidden */
  76692. _left: ValueAndUnit;
  76693. /** @hidden */
  76694. _top: ValueAndUnit;
  76695. private _scaleX;
  76696. private _scaleY;
  76697. private _rotation;
  76698. private _transformCenterX;
  76699. private _transformCenterY;
  76700. /** @hidden */
  76701. _transformMatrix: Matrix2D;
  76702. /** @hidden */
  76703. protected _invertTransformMatrix: Matrix2D;
  76704. /** @hidden */
  76705. protected _transformedPosition: BABYLON.Vector2;
  76706. private _isMatrixDirty;
  76707. private _cachedOffsetX;
  76708. private _cachedOffsetY;
  76709. private _isVisible;
  76710. private _isHighlighted;
  76711. /** @hidden */
  76712. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  76713. private _fontSet;
  76714. private _dummyVector2;
  76715. private _downCount;
  76716. private _enterCount;
  76717. private _doNotRender;
  76718. private _downPointerIds;
  76719. protected _isEnabled: boolean;
  76720. protected _disabledColor: string;
  76721. protected _disabledColorItem: string;
  76722. /** @hidden */
  76723. protected _rebuildLayout: boolean;
  76724. /** @hidden */
  76725. _customData: any;
  76726. /** @hidden */
  76727. _isClipped: boolean;
  76728. /** @hidden */
  76729. _automaticSize: boolean;
  76730. /** @hidden */
  76731. _tag: any;
  76732. /**
  76733. * 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
  76734. */
  76735. uniqueId: number;
  76736. /**
  76737. * Gets or sets an object used to store user defined information for the node
  76738. */
  76739. metadata: any;
  76740. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  76741. isHitTestVisible: boolean;
  76742. /** Gets or sets a boolean indicating if the control can block pointer events */
  76743. isPointerBlocker: boolean;
  76744. /** Gets or sets a boolean indicating if the control can be focusable */
  76745. isFocusInvisible: boolean;
  76746. /**
  76747. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  76748. * 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
  76749. */
  76750. clipChildren: boolean;
  76751. /**
  76752. * Gets or sets a boolean indicating that control content must be clipped
  76753. * 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
  76754. */
  76755. clipContent: boolean;
  76756. /**
  76757. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  76758. */
  76759. useBitmapCache: boolean;
  76760. private _cacheData;
  76761. private _shadowOffsetX;
  76762. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  76763. get shadowOffsetX(): number;
  76764. set shadowOffsetX(value: number);
  76765. private _shadowOffsetY;
  76766. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  76767. get shadowOffsetY(): number;
  76768. set shadowOffsetY(value: number);
  76769. private _shadowBlur;
  76770. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  76771. get shadowBlur(): number;
  76772. set shadowBlur(value: number);
  76773. private _shadowColor;
  76774. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  76775. get shadowColor(): string;
  76776. set shadowColor(value: string);
  76777. /** Gets or sets the cursor to use when the control is hovered */
  76778. hoverCursor: string;
  76779. /** @hidden */
  76780. protected _linkOffsetX: ValueAndUnit;
  76781. /** @hidden */
  76782. protected _linkOffsetY: ValueAndUnit;
  76783. /** Gets the control type name */
  76784. get typeName(): string;
  76785. /**
  76786. * Get the current class name of the control.
  76787. * @returns current class name
  76788. */
  76789. getClassName(): string;
  76790. /**
  76791. * An event triggered when pointer wheel is scrolled
  76792. */
  76793. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  76794. /**
  76795. * An event triggered when the pointer move over the control.
  76796. */
  76797. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  76798. /**
  76799. * An event triggered when the pointer move out of the control.
  76800. */
  76801. onPointerOutObservable: BABYLON.Observable<Control>;
  76802. /**
  76803. * An event triggered when the pointer taps the control
  76804. */
  76805. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  76806. /**
  76807. * An event triggered when pointer up
  76808. */
  76809. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  76810. /**
  76811. * An event triggered when a control is clicked on
  76812. */
  76813. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  76814. /**
  76815. * An event triggered when pointer enters the control
  76816. */
  76817. onPointerEnterObservable: BABYLON.Observable<Control>;
  76818. /**
  76819. * An event triggered when the control is marked as dirty
  76820. */
  76821. onDirtyObservable: BABYLON.Observable<Control>;
  76822. /**
  76823. * An event triggered before drawing the control
  76824. */
  76825. onBeforeDrawObservable: BABYLON.Observable<Control>;
  76826. /**
  76827. * An event triggered after the control was drawn
  76828. */
  76829. onAfterDrawObservable: BABYLON.Observable<Control>;
  76830. /**
  76831. * An event triggered when the control has been disposed
  76832. */
  76833. onDisposeObservable: BABYLON.Observable<Control>;
  76834. /**
  76835. * Get the hosting AdvancedDynamicTexture
  76836. */
  76837. get host(): AdvancedDynamicTexture;
  76838. /** Gets or set information about font offsets (used to render and align text) */
  76839. get fontOffset(): {
  76840. ascent: number;
  76841. height: number;
  76842. descent: number;
  76843. };
  76844. set fontOffset(offset: {
  76845. ascent: number;
  76846. height: number;
  76847. descent: number;
  76848. });
  76849. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  76850. get alpha(): number;
  76851. set alpha(value: number);
  76852. /**
  76853. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  76854. */
  76855. get isHighlighted(): boolean;
  76856. set isHighlighted(value: boolean);
  76857. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  76858. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76859. */
  76860. get scaleX(): number;
  76861. set scaleX(value: number);
  76862. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  76863. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76864. */
  76865. get scaleY(): number;
  76866. set scaleY(value: number);
  76867. /** Gets or sets the rotation angle (0 by default)
  76868. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76869. */
  76870. get rotation(): number;
  76871. set rotation(value: number);
  76872. /** Gets or sets the transformation center on Y axis (0 by default)
  76873. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76874. */
  76875. get transformCenterY(): number;
  76876. set transformCenterY(value: number);
  76877. /** Gets or sets the transformation center on X axis (0 by default)
  76878. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76879. */
  76880. get transformCenterX(): number;
  76881. set transformCenterX(value: number);
  76882. /**
  76883. * Gets or sets the horizontal alignment
  76884. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76885. */
  76886. get horizontalAlignment(): number;
  76887. set horizontalAlignment(value: number);
  76888. /**
  76889. * Gets or sets the vertical alignment
  76890. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76891. */
  76892. get verticalAlignment(): number;
  76893. set verticalAlignment(value: number);
  76894. /**
  76895. * Gets or sets a fixed ratio for this control.
  76896. * When different from 0, the ratio is used to compute the "second" dimension.
  76897. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  76898. * second dimension is computed as first dimension * fixedRatio
  76899. */
  76900. fixedRatio: number;
  76901. private _fixedRatioMasterIsWidth;
  76902. /**
  76903. * Gets or sets control width
  76904. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76905. */
  76906. get width(): string | number;
  76907. set width(value: string | number);
  76908. /**
  76909. * Gets or sets the control width in pixel
  76910. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76911. */
  76912. get widthInPixels(): number;
  76913. set widthInPixels(value: number);
  76914. /**
  76915. * Gets or sets control height
  76916. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76917. */
  76918. get height(): string | number;
  76919. set height(value: string | number);
  76920. /**
  76921. * Gets or sets control height in pixel
  76922. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76923. */
  76924. get heightInPixels(): number;
  76925. set heightInPixels(value: number);
  76926. /** Gets or set font family */
  76927. get fontFamily(): string;
  76928. set fontFamily(value: string);
  76929. /** Gets or sets font style */
  76930. get fontStyle(): string;
  76931. set fontStyle(value: string);
  76932. /** Gets or sets font weight */
  76933. get fontWeight(): string;
  76934. set fontWeight(value: string);
  76935. /**
  76936. * Gets or sets style
  76937. * @see https://doc.babylonjs.com/how_to/gui#styles
  76938. */
  76939. get style(): BABYLON.Nullable<Style>;
  76940. set style(value: BABYLON.Nullable<Style>);
  76941. /** @hidden */
  76942. get _isFontSizeInPercentage(): boolean;
  76943. /** Gets or sets font size in pixels */
  76944. get fontSizeInPixels(): number;
  76945. set fontSizeInPixels(value: number);
  76946. /** Gets or sets font size */
  76947. get fontSize(): string | number;
  76948. set fontSize(value: string | number);
  76949. /** Gets or sets foreground color */
  76950. get color(): string;
  76951. set color(value: string);
  76952. /** Gets or sets z index which is used to reorder controls on the z axis */
  76953. get zIndex(): number;
  76954. set zIndex(value: number);
  76955. /** Gets or sets a boolean indicating if the control can be rendered */
  76956. get notRenderable(): boolean;
  76957. set notRenderable(value: boolean);
  76958. /** Gets or sets a boolean indicating if the control is visible */
  76959. get isVisible(): boolean;
  76960. set isVisible(value: boolean);
  76961. /** Gets a boolean indicating that the control needs to update its rendering */
  76962. get isDirty(): boolean;
  76963. /**
  76964. * Gets the current linked mesh (or null if none)
  76965. */
  76966. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76967. /**
  76968. * Gets or sets a value indicating the padding to use on the left of the control
  76969. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76970. */
  76971. get paddingLeft(): string | number;
  76972. set paddingLeft(value: string | number);
  76973. /**
  76974. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  76975. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76976. */
  76977. get paddingLeftInPixels(): number;
  76978. set paddingLeftInPixels(value: number);
  76979. /**
  76980. * Gets or sets a value indicating the padding to use on the right of the control
  76981. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76982. */
  76983. get paddingRight(): string | number;
  76984. set paddingRight(value: string | number);
  76985. /**
  76986. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  76987. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76988. */
  76989. get paddingRightInPixels(): number;
  76990. set paddingRightInPixels(value: number);
  76991. /**
  76992. * Gets or sets a value indicating the padding to use on the top of the control
  76993. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76994. */
  76995. get paddingTop(): string | number;
  76996. set paddingTop(value: string | number);
  76997. /**
  76998. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  76999. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77000. */
  77001. get paddingTopInPixels(): number;
  77002. set paddingTopInPixels(value: number);
  77003. /**
  77004. * Gets or sets a value indicating the padding to use on the bottom of the control
  77005. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77006. */
  77007. get paddingBottom(): string | number;
  77008. set paddingBottom(value: string | number);
  77009. /**
  77010. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  77011. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77012. */
  77013. get paddingBottomInPixels(): number;
  77014. set paddingBottomInPixels(value: number);
  77015. /**
  77016. * Gets or sets a value indicating the left coordinate of the control
  77017. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77018. */
  77019. get left(): string | number;
  77020. set left(value: string | number);
  77021. /**
  77022. * Gets or sets a value indicating the left coordinate in pixels of the control
  77023. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77024. */
  77025. get leftInPixels(): number;
  77026. set leftInPixels(value: number);
  77027. /**
  77028. * Gets or sets a value indicating the top coordinate of the control
  77029. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77030. */
  77031. get top(): string | number;
  77032. set top(value: string | number);
  77033. /**
  77034. * Gets or sets a value indicating the top coordinate in pixels of the control
  77035. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77036. */
  77037. get topInPixels(): number;
  77038. set topInPixels(value: number);
  77039. /**
  77040. * Gets or sets a value indicating the offset on X axis to the linked mesh
  77041. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77042. */
  77043. get linkOffsetX(): string | number;
  77044. set linkOffsetX(value: string | number);
  77045. /**
  77046. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  77047. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77048. */
  77049. get linkOffsetXInPixels(): number;
  77050. set linkOffsetXInPixels(value: number);
  77051. /**
  77052. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  77053. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77054. */
  77055. get linkOffsetY(): string | number;
  77056. set linkOffsetY(value: string | number);
  77057. /**
  77058. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  77059. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77060. */
  77061. get linkOffsetYInPixels(): number;
  77062. set linkOffsetYInPixels(value: number);
  77063. /** Gets the center coordinate on X axis */
  77064. get centerX(): number;
  77065. /** Gets the center coordinate on Y axis */
  77066. get centerY(): number;
  77067. /** Gets or sets if control is Enabled*/
  77068. get isEnabled(): boolean;
  77069. set isEnabled(value: boolean);
  77070. /** Gets or sets background color of control if it's disabled*/
  77071. get disabledColor(): string;
  77072. set disabledColor(value: string);
  77073. /** Gets or sets front color of control if it's disabled*/
  77074. get disabledColorItem(): string;
  77075. set disabledColorItem(value: string);
  77076. /**
  77077. * Creates a new control
  77078. * @param name defines the name of the control
  77079. */
  77080. constructor(
  77081. /** defines the name of the control */
  77082. name?: string | undefined);
  77083. /** @hidden */
  77084. protected _getTypeName(): string;
  77085. /**
  77086. * Gets the first ascendant in the hierarchy of the given type
  77087. * @param className defines the required type
  77088. * @returns the ascendant or null if not found
  77089. */
  77090. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  77091. /** @hidden */
  77092. _resetFontCache(): void;
  77093. /**
  77094. * Determines if a container is an ascendant of the current control
  77095. * @param container defines the container to look for
  77096. * @returns true if the container is one of the ascendant of the control
  77097. */
  77098. isAscendant(container: Control): boolean;
  77099. /**
  77100. * Gets coordinates in local control space
  77101. * @param globalCoordinates defines the coordinates to transform
  77102. * @returns the new coordinates in local space
  77103. */
  77104. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77105. /**
  77106. * Gets coordinates in local control space
  77107. * @param globalCoordinates defines the coordinates to transform
  77108. * @param result defines the target vector2 where to store the result
  77109. * @returns the current control
  77110. */
  77111. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  77112. /**
  77113. * Gets coordinates in parent local control space
  77114. * @param globalCoordinates defines the coordinates to transform
  77115. * @returns the new coordinates in parent local space
  77116. */
  77117. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77118. /**
  77119. * Move the current control to a vector3 position projected onto the screen.
  77120. * @param position defines the target position
  77121. * @param scene defines the hosting scene
  77122. */
  77123. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  77124. /**
  77125. * Will store all controls that have this control as ascendant in a given array
  77126. * @param results defines the array where to store the descendants
  77127. * @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
  77128. * @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
  77129. */
  77130. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77131. /**
  77132. * Will return all controls that have this control as ascendant
  77133. * @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
  77134. * @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
  77135. * @return all child controls
  77136. */
  77137. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77138. /**
  77139. * Link current control with a target mesh
  77140. * @param mesh defines the mesh to link with
  77141. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77142. */
  77143. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  77144. /** @hidden */
  77145. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  77146. /** @hidden */
  77147. _offsetLeft(offset: number): void;
  77148. /** @hidden */
  77149. _offsetTop(offset: number): void;
  77150. /** @hidden */
  77151. _markMatrixAsDirty(): void;
  77152. /** @hidden */
  77153. _flagDescendantsAsMatrixDirty(): void;
  77154. /** @hidden */
  77155. _intersectsRect(rect: Measure): boolean;
  77156. /** @hidden */
  77157. protected invalidateRect(): void;
  77158. /** @hidden */
  77159. _markAsDirty(force?: boolean): void;
  77160. /** @hidden */
  77161. _markAllAsDirty(): void;
  77162. /** @hidden */
  77163. _link(host: AdvancedDynamicTexture): void;
  77164. /** @hidden */
  77165. protected _transform(context?: CanvasRenderingContext2D): void;
  77166. /** @hidden */
  77167. _renderHighlight(context: CanvasRenderingContext2D): void;
  77168. /** @hidden */
  77169. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77170. /** @hidden */
  77171. protected _applyStates(context: CanvasRenderingContext2D): void;
  77172. /** @hidden */
  77173. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77174. /** @hidden */
  77175. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77176. protected _evaluateClippingState(parentMeasure: Measure): void;
  77177. /** @hidden */
  77178. _measure(): void;
  77179. /** @hidden */
  77180. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77181. /** @hidden */
  77182. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77183. /** @hidden */
  77184. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77185. /** @hidden */
  77186. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77187. private static _ClipMeasure;
  77188. private _tmpMeasureA;
  77189. private _clip;
  77190. /** @hidden */
  77191. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  77192. /** @hidden */
  77193. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77194. /**
  77195. * Tests if a given coordinates belong to the current control
  77196. * @param x defines x coordinate to test
  77197. * @param y defines y coordinate to test
  77198. * @returns true if the coordinates are inside the control
  77199. */
  77200. contains(x: number, y: number): boolean;
  77201. /** @hidden */
  77202. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77203. /** @hidden */
  77204. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77205. /** @hidden */
  77206. _onPointerEnter(target: Control): boolean;
  77207. /** @hidden */
  77208. _onPointerOut(target: Control, force?: boolean): void;
  77209. /** @hidden */
  77210. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77211. /** @hidden */
  77212. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77213. /** @hidden */
  77214. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  77215. /** @hidden */
  77216. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  77217. /** @hidden */
  77218. _onCanvasBlur(): void;
  77219. /** @hidden */
  77220. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77221. private _prepareFont;
  77222. /** Releases associated resources */
  77223. dispose(): void;
  77224. private static _HORIZONTAL_ALIGNMENT_LEFT;
  77225. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  77226. private static _HORIZONTAL_ALIGNMENT_CENTER;
  77227. private static _VERTICAL_ALIGNMENT_TOP;
  77228. private static _VERTICAL_ALIGNMENT_BOTTOM;
  77229. private static _VERTICAL_ALIGNMENT_CENTER;
  77230. /** HORIZONTAL_ALIGNMENT_LEFT */
  77231. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  77232. /** HORIZONTAL_ALIGNMENT_RIGHT */
  77233. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  77234. /** HORIZONTAL_ALIGNMENT_CENTER */
  77235. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  77236. /** VERTICAL_ALIGNMENT_TOP */
  77237. static get VERTICAL_ALIGNMENT_TOP(): number;
  77238. /** VERTICAL_ALIGNMENT_BOTTOM */
  77239. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  77240. /** VERTICAL_ALIGNMENT_CENTER */
  77241. static get VERTICAL_ALIGNMENT_CENTER(): number;
  77242. private static _FontHeightSizes;
  77243. /** @hidden */
  77244. static _GetFontOffset(font: string): {
  77245. ascent: number;
  77246. height: number;
  77247. descent: number;
  77248. };
  77249. /**
  77250. * Creates a stack panel that can be used to render headers
  77251. * @param control defines the control to associate with the header
  77252. * @param text defines the text of the header
  77253. * @param size defines the size of the header
  77254. * @param options defines options used to configure the header
  77255. * @returns a new StackPanel
  77256. * @ignore
  77257. * @hidden
  77258. */
  77259. static AddHeader: (control: Control, text: string, size: string | number, options: {
  77260. isHorizontal: boolean;
  77261. controlFirst: boolean;
  77262. }) => any;
  77263. /** @hidden */
  77264. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  77265. }
  77266. }
  77267. declare module BABYLON.GUI {
  77268. /**
  77269. * Root class for 2D containers
  77270. * @see https://doc.babylonjs.com/how_to/gui#containers
  77271. */
  77272. export class Container extends Control {
  77273. name?: string | undefined;
  77274. /** @hidden */
  77275. _children: Control[];
  77276. /** @hidden */
  77277. protected _measureForChildren: Measure;
  77278. /** @hidden */
  77279. protected _background: string;
  77280. /** @hidden */
  77281. protected _adaptWidthToChildren: boolean;
  77282. /** @hidden */
  77283. protected _adaptHeightToChildren: boolean;
  77284. /**
  77285. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  77286. */
  77287. logLayoutCycleErrors: boolean;
  77288. /**
  77289. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  77290. */
  77291. maxLayoutCycle: number;
  77292. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  77293. get adaptHeightToChildren(): boolean;
  77294. set adaptHeightToChildren(value: boolean);
  77295. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  77296. get adaptWidthToChildren(): boolean;
  77297. set adaptWidthToChildren(value: boolean);
  77298. /** Gets or sets background color */
  77299. get background(): string;
  77300. set background(value: string);
  77301. /** Gets the list of children */
  77302. get children(): Control[];
  77303. /**
  77304. * Creates a new Container
  77305. * @param name defines the name of the container
  77306. */
  77307. constructor(name?: string | undefined);
  77308. protected _getTypeName(): string;
  77309. _flagDescendantsAsMatrixDirty(): void;
  77310. /**
  77311. * Gets a child using its name
  77312. * @param name defines the child name to look for
  77313. * @returns the child control if found
  77314. */
  77315. getChildByName(name: string): BABYLON.Nullable<Control>;
  77316. /**
  77317. * Gets a child using its type and its name
  77318. * @param name defines the child name to look for
  77319. * @param type defines the child type to look for
  77320. * @returns the child control if found
  77321. */
  77322. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  77323. /**
  77324. * Search for a specific control in children
  77325. * @param control defines the control to look for
  77326. * @returns true if the control is in child list
  77327. */
  77328. containsControl(control: Control): boolean;
  77329. /**
  77330. * Adds a new control to the current container
  77331. * @param control defines the control to add
  77332. * @returns the current container
  77333. */
  77334. addControl(control: BABYLON.Nullable<Control>): Container;
  77335. /**
  77336. * Removes all controls from the current container
  77337. * @returns the current container
  77338. */
  77339. clearControls(): Container;
  77340. /**
  77341. * Removes a control from the current container
  77342. * @param control defines the control to remove
  77343. * @returns the current container
  77344. */
  77345. removeControl(control: Control): Container;
  77346. /** @hidden */
  77347. _reOrderControl(control: Control): void;
  77348. /** @hidden */
  77349. _offsetLeft(offset: number): void;
  77350. /** @hidden */
  77351. _offsetTop(offset: number): void;
  77352. /** @hidden */
  77353. _markAllAsDirty(): void;
  77354. /** @hidden */
  77355. protected _localDraw(context: CanvasRenderingContext2D): void;
  77356. /** @hidden */
  77357. _link(host: AdvancedDynamicTexture): void;
  77358. /** @hidden */
  77359. protected _beforeLayout(): void;
  77360. /** @hidden */
  77361. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77362. /** @hidden */
  77363. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77364. protected _postMeasure(): void;
  77365. /** @hidden */
  77366. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77367. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77368. /** @hidden */
  77369. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77370. /** @hidden */
  77371. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77372. /** Releases associated resources */
  77373. dispose(): void;
  77374. }
  77375. }
  77376. declare module BABYLON.GUI {
  77377. /** Class used to create rectangle container */
  77378. export class Rectangle extends Container {
  77379. name?: string | undefined;
  77380. private _thickness;
  77381. private _cornerRadius;
  77382. /** Gets or sets border thickness */
  77383. get thickness(): number;
  77384. set thickness(value: number);
  77385. /** Gets or sets the corner radius angle */
  77386. get cornerRadius(): number;
  77387. set cornerRadius(value: number);
  77388. /**
  77389. * Creates a new Rectangle
  77390. * @param name defines the control name
  77391. */
  77392. constructor(name?: string | undefined);
  77393. protected _getTypeName(): string;
  77394. protected _localDraw(context: CanvasRenderingContext2D): void;
  77395. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77396. private _drawRoundedRect;
  77397. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77398. }
  77399. }
  77400. declare module BABYLON.GUI {
  77401. /**
  77402. * Enum that determines the text-wrapping mode to use.
  77403. */
  77404. export enum TextWrapping {
  77405. /**
  77406. * Clip the text when it's larger than Control.width; this is the default mode.
  77407. */
  77408. Clip = 0,
  77409. /**
  77410. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  77411. */
  77412. WordWrap = 1,
  77413. /**
  77414. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  77415. */
  77416. Ellipsis = 2
  77417. }
  77418. /**
  77419. * Class used to create text block control
  77420. */
  77421. export class TextBlock extends Control {
  77422. /**
  77423. * Defines the name of the control
  77424. */
  77425. name?: string | undefined;
  77426. private _text;
  77427. private _textWrapping;
  77428. private _textHorizontalAlignment;
  77429. private _textVerticalAlignment;
  77430. private _lines;
  77431. private _resizeToFit;
  77432. private _lineSpacing;
  77433. private _outlineWidth;
  77434. private _outlineColor;
  77435. private _underline;
  77436. private _lineThrough;
  77437. /**
  77438. * An event triggered after the text is changed
  77439. */
  77440. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  77441. /**
  77442. * An event triggered after the text was broken up into lines
  77443. */
  77444. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  77445. /**
  77446. * Function used to split a string into words. By default, a string is split at each space character found
  77447. */
  77448. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  77449. /**
  77450. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  77451. */
  77452. get lines(): any[];
  77453. /**
  77454. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77455. */
  77456. get resizeToFit(): boolean;
  77457. /**
  77458. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  77459. */
  77460. set resizeToFit(value: boolean);
  77461. /**
  77462. * Gets or sets a boolean indicating if text must be wrapped
  77463. */
  77464. get textWrapping(): TextWrapping | boolean;
  77465. /**
  77466. * Gets or sets a boolean indicating if text must be wrapped
  77467. */
  77468. set textWrapping(value: TextWrapping | boolean);
  77469. /**
  77470. * Gets or sets text to display
  77471. */
  77472. get text(): string;
  77473. /**
  77474. * Gets or sets text to display
  77475. */
  77476. set text(value: string);
  77477. /**
  77478. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77479. */
  77480. get textHorizontalAlignment(): number;
  77481. /**
  77482. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  77483. */
  77484. set textHorizontalAlignment(value: number);
  77485. /**
  77486. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77487. */
  77488. get textVerticalAlignment(): number;
  77489. /**
  77490. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  77491. */
  77492. set textVerticalAlignment(value: number);
  77493. /**
  77494. * Gets or sets line spacing value
  77495. */
  77496. set lineSpacing(value: string | number);
  77497. /**
  77498. * Gets or sets line spacing value
  77499. */
  77500. get lineSpacing(): string | number;
  77501. /**
  77502. * Gets or sets outlineWidth of the text to display
  77503. */
  77504. get outlineWidth(): number;
  77505. /**
  77506. * Gets or sets outlineWidth of the text to display
  77507. */
  77508. set outlineWidth(value: number);
  77509. /**
  77510. * Gets or sets a boolean indicating that text must have underline
  77511. */
  77512. get underline(): boolean;
  77513. /**
  77514. * Gets or sets a boolean indicating that text must have underline
  77515. */
  77516. set underline(value: boolean);
  77517. /**
  77518. * Gets or sets an boolean indicating that text must be crossed out
  77519. */
  77520. get lineThrough(): boolean;
  77521. /**
  77522. * Gets or sets an boolean indicating that text must be crossed out
  77523. */
  77524. set lineThrough(value: boolean);
  77525. /**
  77526. * Gets or sets outlineColor of the text to display
  77527. */
  77528. get outlineColor(): string;
  77529. /**
  77530. * Gets or sets outlineColor of the text to display
  77531. */
  77532. set outlineColor(value: string);
  77533. /**
  77534. * Creates a new TextBlock object
  77535. * @param name defines the name of the control
  77536. * @param text defines the text to display (emptry string by default)
  77537. */
  77538. constructor(
  77539. /**
  77540. * Defines the name of the control
  77541. */
  77542. name?: string | undefined, text?: string);
  77543. protected _getTypeName(): string;
  77544. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77545. private _drawText;
  77546. /** @hidden */
  77547. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77548. protected _applyStates(context: CanvasRenderingContext2D): void;
  77549. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  77550. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  77551. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  77552. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  77553. protected _renderLines(context: CanvasRenderingContext2D): void;
  77554. /**
  77555. * Given a width constraint applied on the text block, find the expected height
  77556. * @returns expected height
  77557. */
  77558. computeExpectedHeight(): number;
  77559. dispose(): void;
  77560. }
  77561. }
  77562. declare module BABYLON.GUI {
  77563. /**
  77564. * Class used to create 2D images
  77565. */
  77566. export class Image extends Control {
  77567. name?: string | undefined;
  77568. private _workingCanvas;
  77569. private _domImage;
  77570. private _imageWidth;
  77571. private _imageHeight;
  77572. private _loaded;
  77573. private _stretch;
  77574. private _source;
  77575. private _autoScale;
  77576. private _sourceLeft;
  77577. private _sourceTop;
  77578. private _sourceWidth;
  77579. private _sourceHeight;
  77580. private _svgAttributesComputationCompleted;
  77581. private _isSVG;
  77582. private _cellWidth;
  77583. private _cellHeight;
  77584. private _cellId;
  77585. private _populateNinePatchSlicesFromImage;
  77586. private _sliceLeft;
  77587. private _sliceRight;
  77588. private _sliceTop;
  77589. private _sliceBottom;
  77590. private _detectPointerOnOpaqueOnly;
  77591. private _imageDataCache;
  77592. /**
  77593. * BABYLON.Observable notified when the content is loaded
  77594. */
  77595. onImageLoadedObservable: BABYLON.Observable<Image>;
  77596. /**
  77597. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  77598. */
  77599. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  77600. /**
  77601. * Gets a boolean indicating that the content is loaded
  77602. */
  77603. get isLoaded(): boolean;
  77604. /**
  77605. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  77606. */
  77607. get populateNinePatchSlicesFromImage(): boolean;
  77608. set populateNinePatchSlicesFromImage(value: boolean);
  77609. /**
  77610. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  77611. * Beware using this as this will comsume more memory as the image has to be stored twice
  77612. */
  77613. get detectPointerOnOpaqueOnly(): boolean;
  77614. set detectPointerOnOpaqueOnly(value: boolean);
  77615. /**
  77616. * Gets or sets the left value for slicing (9-patch)
  77617. */
  77618. get sliceLeft(): number;
  77619. set sliceLeft(value: number);
  77620. /**
  77621. * Gets or sets the right value for slicing (9-patch)
  77622. */
  77623. get sliceRight(): number;
  77624. set sliceRight(value: number);
  77625. /**
  77626. * Gets or sets the top value for slicing (9-patch)
  77627. */
  77628. get sliceTop(): number;
  77629. set sliceTop(value: number);
  77630. /**
  77631. * Gets or sets the bottom value for slicing (9-patch)
  77632. */
  77633. get sliceBottom(): number;
  77634. set sliceBottom(value: number);
  77635. /**
  77636. * Gets or sets the left coordinate in the source image
  77637. */
  77638. get sourceLeft(): number;
  77639. set sourceLeft(value: number);
  77640. /**
  77641. * Gets or sets the top coordinate in the source image
  77642. */
  77643. get sourceTop(): number;
  77644. set sourceTop(value: number);
  77645. /**
  77646. * Gets or sets the width to capture in the source image
  77647. */
  77648. get sourceWidth(): number;
  77649. set sourceWidth(value: number);
  77650. /**
  77651. * Gets or sets the height to capture in the source image
  77652. */
  77653. get sourceHeight(): number;
  77654. set sourceHeight(value: number);
  77655. /** Indicates if the format of the image is SVG */
  77656. get isSVG(): boolean;
  77657. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  77658. get svgAttributesComputationCompleted(): boolean;
  77659. /**
  77660. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  77661. * @see https://doc.babylonjs.com/how_to/gui#image
  77662. */
  77663. get autoScale(): boolean;
  77664. set autoScale(value: boolean);
  77665. /** Gets or sets the streching mode used by the image */
  77666. get stretch(): number;
  77667. set stretch(value: number);
  77668. /** @hidden */
  77669. _rotate90(n: number, preserveProperties?: boolean): Image;
  77670. private _handleRotationForSVGImage;
  77671. private _rotate90SourceProperties;
  77672. /**
  77673. * Gets or sets the internal DOM image used to render the control
  77674. */
  77675. set domImage(value: HTMLImageElement);
  77676. get domImage(): HTMLImageElement;
  77677. private _onImageLoaded;
  77678. private _extractNinePatchSliceDataFromImage;
  77679. /**
  77680. * Gets or sets image source url
  77681. */
  77682. set source(value: BABYLON.Nullable<string>);
  77683. /**
  77684. * Checks for svg document with icon id present
  77685. */
  77686. private _svgCheck;
  77687. /**
  77688. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  77689. * given external svg file and icon id
  77690. */
  77691. private _getSVGAttribs;
  77692. /**
  77693. * Gets or sets the cell width to use when animation sheet is enabled
  77694. * @see https://doc.babylonjs.com/how_to/gui#image
  77695. */
  77696. get cellWidth(): number;
  77697. set cellWidth(value: number);
  77698. /**
  77699. * Gets or sets the cell height to use when animation sheet is enabled
  77700. * @see https://doc.babylonjs.com/how_to/gui#image
  77701. */
  77702. get cellHeight(): number;
  77703. set cellHeight(value: number);
  77704. /**
  77705. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  77706. * @see https://doc.babylonjs.com/how_to/gui#image
  77707. */
  77708. get cellId(): number;
  77709. set cellId(value: number);
  77710. /**
  77711. * Creates a new Image
  77712. * @param name defines the control name
  77713. * @param url defines the image url
  77714. */
  77715. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  77716. /**
  77717. * Tests if a given coordinates belong to the current control
  77718. * @param x defines x coordinate to test
  77719. * @param y defines y coordinate to test
  77720. * @returns true if the coordinates are inside the control
  77721. */
  77722. contains(x: number, y: number): boolean;
  77723. protected _getTypeName(): string;
  77724. /** Force the control to synchronize with its content */
  77725. synchronizeSizeWithContent(): void;
  77726. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77727. private _prepareWorkingCanvasForOpaqueDetection;
  77728. private _drawImage;
  77729. _draw(context: CanvasRenderingContext2D): void;
  77730. private _renderCornerPatch;
  77731. private _renderNinePatch;
  77732. dispose(): void;
  77733. /** STRETCH_NONE */
  77734. static readonly STRETCH_NONE: number;
  77735. /** STRETCH_FILL */
  77736. static readonly STRETCH_FILL: number;
  77737. /** STRETCH_UNIFORM */
  77738. static readonly STRETCH_UNIFORM: number;
  77739. /** STRETCH_EXTEND */
  77740. static readonly STRETCH_EXTEND: number;
  77741. /** NINE_PATCH */
  77742. static readonly STRETCH_NINE_PATCH: number;
  77743. }
  77744. }
  77745. declare module BABYLON.GUI {
  77746. /**
  77747. * Class used to create 2D buttons
  77748. */
  77749. export class Button extends Rectangle {
  77750. name?: string | undefined;
  77751. /**
  77752. * Function called to generate a pointer enter animation
  77753. */
  77754. pointerEnterAnimation: () => void;
  77755. /**
  77756. * Function called to generate a pointer out animation
  77757. */
  77758. pointerOutAnimation: () => void;
  77759. /**
  77760. * Function called to generate a pointer down animation
  77761. */
  77762. pointerDownAnimation: () => void;
  77763. /**
  77764. * Function called to generate a pointer up animation
  77765. */
  77766. pointerUpAnimation: () => void;
  77767. /**
  77768. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  77769. */
  77770. delegatePickingToChildren: boolean;
  77771. private _image;
  77772. /**
  77773. * Returns the image part of the button (if any)
  77774. */
  77775. get image(): BABYLON.Nullable<Image>;
  77776. private _textBlock;
  77777. /**
  77778. * Returns the image part of the button (if any)
  77779. */
  77780. get textBlock(): BABYLON.Nullable<TextBlock>;
  77781. /**
  77782. * Creates a new Button
  77783. * @param name defines the name of the button
  77784. */
  77785. constructor(name?: string | undefined);
  77786. protected _getTypeName(): string;
  77787. /** @hidden */
  77788. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77789. /** @hidden */
  77790. _onPointerEnter(target: Control): boolean;
  77791. /** @hidden */
  77792. _onPointerOut(target: Control, force?: boolean): void;
  77793. /** @hidden */
  77794. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77795. /** @hidden */
  77796. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77797. /**
  77798. * Creates a new button made with an image and a text
  77799. * @param name defines the name of the button
  77800. * @param text defines the text of the button
  77801. * @param imageUrl defines the url of the image
  77802. * @returns a new Button
  77803. */
  77804. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  77805. /**
  77806. * Creates a new button made with an image
  77807. * @param name defines the name of the button
  77808. * @param imageUrl defines the url of the image
  77809. * @returns a new Button
  77810. */
  77811. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  77812. /**
  77813. * Creates a new button made with a text
  77814. * @param name defines the name of the button
  77815. * @param text defines the text of the button
  77816. * @returns a new Button
  77817. */
  77818. static CreateSimpleButton(name: string, text: string): Button;
  77819. /**
  77820. * Creates a new button made with an image and a centered text
  77821. * @param name defines the name of the button
  77822. * @param text defines the text of the button
  77823. * @param imageUrl defines the url of the image
  77824. * @returns a new Button
  77825. */
  77826. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  77827. }
  77828. }
  77829. declare module BABYLON.GUI {
  77830. /**
  77831. * Class used to create a 2D stack panel container
  77832. */
  77833. export class StackPanel extends Container {
  77834. name?: string | undefined;
  77835. private _isVertical;
  77836. private _manualWidth;
  77837. private _manualHeight;
  77838. private _doNotTrackManualChanges;
  77839. /**
  77840. * Gets or sets a boolean indicating that layou warnings should be ignored
  77841. */
  77842. ignoreLayoutWarnings: boolean;
  77843. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  77844. get isVertical(): boolean;
  77845. set isVertical(value: boolean);
  77846. /**
  77847. * Gets or sets panel width.
  77848. * This value should not be set when in horizontal mode as it will be computed automatically
  77849. */
  77850. set width(value: string | number);
  77851. get width(): string | number;
  77852. /**
  77853. * Gets or sets panel height.
  77854. * This value should not be set when in vertical mode as it will be computed automatically
  77855. */
  77856. set height(value: string | number);
  77857. get height(): string | number;
  77858. /**
  77859. * Creates a new StackPanel
  77860. * @param name defines control name
  77861. */
  77862. constructor(name?: string | undefined);
  77863. protected _getTypeName(): string;
  77864. /** @hidden */
  77865. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77866. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77867. protected _postMeasure(): void;
  77868. }
  77869. }
  77870. declare module BABYLON.GUI {
  77871. /**
  77872. * Class used to represent a 2D checkbox
  77873. */
  77874. export class Checkbox extends Control {
  77875. name?: string | undefined;
  77876. private _isChecked;
  77877. private _background;
  77878. private _checkSizeRatio;
  77879. private _thickness;
  77880. /** Gets or sets border thickness */
  77881. get thickness(): number;
  77882. set thickness(value: number);
  77883. /**
  77884. * BABYLON.Observable raised when isChecked property changes
  77885. */
  77886. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77887. /** Gets or sets a value indicating the ratio between overall size and check size */
  77888. get checkSizeRatio(): number;
  77889. set checkSizeRatio(value: number);
  77890. /** Gets or sets background color */
  77891. get background(): string;
  77892. set background(value: string);
  77893. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77894. get isChecked(): boolean;
  77895. set isChecked(value: boolean);
  77896. /**
  77897. * Creates a new CheckBox
  77898. * @param name defines the control name
  77899. */
  77900. constructor(name?: string | undefined);
  77901. protected _getTypeName(): string;
  77902. /** @hidden */
  77903. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77904. /** @hidden */
  77905. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77906. /**
  77907. * Utility function to easily create a checkbox with a header
  77908. * @param title defines the label to use for the header
  77909. * @param onValueChanged defines the callback to call when value changes
  77910. * @returns a StackPanel containing the checkbox and a textBlock
  77911. */
  77912. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  77913. }
  77914. }
  77915. declare module BABYLON.GUI {
  77916. /**
  77917. * Class used to store key control properties
  77918. */
  77919. export class KeyPropertySet {
  77920. /** Width */
  77921. width?: string;
  77922. /** Height */
  77923. height?: string;
  77924. /** Left padding */
  77925. paddingLeft?: string;
  77926. /** Right padding */
  77927. paddingRight?: string;
  77928. /** Top padding */
  77929. paddingTop?: string;
  77930. /** Bottom padding */
  77931. paddingBottom?: string;
  77932. /** Foreground color */
  77933. color?: string;
  77934. /** Background color */
  77935. background?: string;
  77936. }
  77937. /**
  77938. * Class used to create virtual keyboard
  77939. */
  77940. export class VirtualKeyboard extends StackPanel {
  77941. /** BABYLON.Observable raised when a key is pressed */
  77942. onKeyPressObservable: BABYLON.Observable<string>;
  77943. /** Gets or sets default key button width */
  77944. defaultButtonWidth: string;
  77945. /** Gets or sets default key button height */
  77946. defaultButtonHeight: string;
  77947. /** Gets or sets default key button left padding */
  77948. defaultButtonPaddingLeft: string;
  77949. /** Gets or sets default key button right padding */
  77950. defaultButtonPaddingRight: string;
  77951. /** Gets or sets default key button top padding */
  77952. defaultButtonPaddingTop: string;
  77953. /** Gets or sets default key button bottom padding */
  77954. defaultButtonPaddingBottom: string;
  77955. /** Gets or sets default key button foreground color */
  77956. defaultButtonColor: string;
  77957. /** Gets or sets default key button background color */
  77958. defaultButtonBackground: string;
  77959. /** Gets or sets shift button foreground color */
  77960. shiftButtonColor: string;
  77961. /** Gets or sets shift button thickness*/
  77962. selectedShiftThickness: number;
  77963. /** Gets shift key state */
  77964. shiftState: number;
  77965. protected _getTypeName(): string;
  77966. private _createKey;
  77967. /**
  77968. * Adds a new row of keys
  77969. * @param keys defines the list of keys to add
  77970. * @param propertySets defines the associated property sets
  77971. */
  77972. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  77973. /**
  77974. * Set the shift key to a specific state
  77975. * @param shiftState defines the new shift state
  77976. */
  77977. applyShiftState(shiftState: number): void;
  77978. private _currentlyConnectedInputText;
  77979. private _connectedInputTexts;
  77980. private _onKeyPressObserver;
  77981. /** Gets the input text control currently attached to the keyboard */
  77982. get connectedInputText(): BABYLON.Nullable<InputText>;
  77983. /**
  77984. * Connects the keyboard with an input text control
  77985. *
  77986. * @param input defines the target control
  77987. */
  77988. connect(input: InputText): void;
  77989. /**
  77990. * Disconnects the keyboard from connected InputText controls
  77991. *
  77992. * @param input optionally defines a target control, otherwise all are disconnected
  77993. */
  77994. disconnect(input?: InputText): void;
  77995. private _removeConnectedInputObservables;
  77996. /**
  77997. * Release all resources
  77998. */
  77999. dispose(): void;
  78000. /**
  78001. * Creates a new keyboard using a default layout
  78002. *
  78003. * @param name defines control name
  78004. * @returns a new VirtualKeyboard
  78005. */
  78006. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  78007. }
  78008. }
  78009. declare module BABYLON.GUI {
  78010. /**
  78011. * Class used to create input text control
  78012. */
  78013. export class InputText extends Control implements IFocusableControl {
  78014. name?: string | undefined;
  78015. private _text;
  78016. private _placeholderText;
  78017. private _background;
  78018. private _focusedBackground;
  78019. private _focusedColor;
  78020. private _placeholderColor;
  78021. private _thickness;
  78022. private _margin;
  78023. private _autoStretchWidth;
  78024. private _maxWidth;
  78025. private _isFocused;
  78026. private _blinkTimeout;
  78027. private _blinkIsEven;
  78028. private _cursorOffset;
  78029. private _scrollLeft;
  78030. private _textWidth;
  78031. private _clickedCoordinate;
  78032. private _deadKey;
  78033. private _addKey;
  78034. private _currentKey;
  78035. private _isTextHighlightOn;
  78036. private _textHighlightColor;
  78037. private _highligherOpacity;
  78038. private _highlightedText;
  78039. private _startHighlightIndex;
  78040. private _endHighlightIndex;
  78041. private _cursorIndex;
  78042. private _onFocusSelectAll;
  78043. private _isPointerDown;
  78044. private _onClipboardObserver;
  78045. private _onPointerDblTapObserver;
  78046. /** @hidden */
  78047. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  78048. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  78049. promptMessage: string;
  78050. /** Force disable prompt on mobile device */
  78051. disableMobilePrompt: boolean;
  78052. /** BABYLON.Observable raised when the text changes */
  78053. onTextChangedObservable: BABYLON.Observable<InputText>;
  78054. /** BABYLON.Observable raised just before an entered character is to be added */
  78055. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  78056. /** BABYLON.Observable raised when the control gets the focus */
  78057. onFocusObservable: BABYLON.Observable<InputText>;
  78058. /** BABYLON.Observable raised when the control loses the focus */
  78059. onBlurObservable: BABYLON.Observable<InputText>;
  78060. /**Observable raised when the text is highlighted */
  78061. onTextHighlightObservable: BABYLON.Observable<InputText>;
  78062. /**Observable raised when copy event is triggered */
  78063. onTextCopyObservable: BABYLON.Observable<InputText>;
  78064. /** BABYLON.Observable raised when cut event is triggered */
  78065. onTextCutObservable: BABYLON.Observable<InputText>;
  78066. /** BABYLON.Observable raised when paste event is triggered */
  78067. onTextPasteObservable: BABYLON.Observable<InputText>;
  78068. /** BABYLON.Observable raised when a key event was processed */
  78069. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  78070. /** Gets or sets the maximum width allowed by the control */
  78071. get maxWidth(): string | number;
  78072. /** Gets the maximum width allowed by the control in pixels */
  78073. get maxWidthInPixels(): number;
  78074. set maxWidth(value: string | number);
  78075. /** Gets or sets the text highlighter transparency; default: 0.4 */
  78076. get highligherOpacity(): number;
  78077. set highligherOpacity(value: number);
  78078. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  78079. get onFocusSelectAll(): boolean;
  78080. set onFocusSelectAll(value: boolean);
  78081. /** Gets or sets the text hightlight color */
  78082. get textHighlightColor(): string;
  78083. set textHighlightColor(value: string);
  78084. /** Gets or sets control margin */
  78085. get margin(): string;
  78086. /** Gets control margin in pixels */
  78087. get marginInPixels(): number;
  78088. set margin(value: string);
  78089. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  78090. get autoStretchWidth(): boolean;
  78091. set autoStretchWidth(value: boolean);
  78092. /** Gets or sets border thickness */
  78093. get thickness(): number;
  78094. set thickness(value: number);
  78095. /** Gets or sets the background color when focused */
  78096. get focusedBackground(): string;
  78097. set focusedBackground(value: string);
  78098. /** Gets or sets the background color when focused */
  78099. get focusedColor(): string;
  78100. set focusedColor(value: string);
  78101. /** Gets or sets the background color */
  78102. get background(): string;
  78103. set background(value: string);
  78104. /** Gets or sets the placeholder color */
  78105. get placeholderColor(): string;
  78106. set placeholderColor(value: string);
  78107. /** Gets or sets the text displayed when the control is empty */
  78108. get placeholderText(): string;
  78109. set placeholderText(value: string);
  78110. /** Gets or sets the dead key flag */
  78111. get deadKey(): boolean;
  78112. set deadKey(flag: boolean);
  78113. /** Gets or sets the highlight text */
  78114. get highlightedText(): string;
  78115. set highlightedText(text: string);
  78116. /** Gets or sets if the current key should be added */
  78117. get addKey(): boolean;
  78118. set addKey(flag: boolean);
  78119. /** Gets or sets the value of the current key being entered */
  78120. get currentKey(): string;
  78121. set currentKey(key: string);
  78122. /** Gets or sets the text displayed in the control */
  78123. get text(): string;
  78124. set text(value: string);
  78125. /** Gets or sets control width */
  78126. get width(): string | number;
  78127. set width(value: string | number);
  78128. /**
  78129. * Creates a new InputText
  78130. * @param name defines the control name
  78131. * @param text defines the text of the control
  78132. */
  78133. constructor(name?: string | undefined, text?: string);
  78134. /** @hidden */
  78135. onBlur(): void;
  78136. /** @hidden */
  78137. onFocus(): void;
  78138. protected _getTypeName(): string;
  78139. /**
  78140. * Function called to get the list of controls that should not steal the focus from this control
  78141. * @returns an array of controls
  78142. */
  78143. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78144. /** @hidden */
  78145. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  78146. /** @hidden */
  78147. private _updateValueFromCursorIndex;
  78148. /** @hidden */
  78149. private _processDblClick;
  78150. /** @hidden */
  78151. private _selectAllText;
  78152. /**
  78153. * Handles the keyboard event
  78154. * @param evt Defines the KeyboardEvent
  78155. */
  78156. processKeyboard(evt: KeyboardEvent): void;
  78157. /** @hidden */
  78158. private _onCopyText;
  78159. /** @hidden */
  78160. private _onCutText;
  78161. /** @hidden */
  78162. private _onPasteText;
  78163. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78164. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78165. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78166. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78167. protected _beforeRenderText(text: string): string;
  78168. dispose(): void;
  78169. }
  78170. }
  78171. declare module BABYLON.GUI {
  78172. /**
  78173. * Class used to create a 2D grid container
  78174. */
  78175. export class Grid extends Container {
  78176. name?: string | undefined;
  78177. private _rowDefinitions;
  78178. private _columnDefinitions;
  78179. private _cells;
  78180. private _childControls;
  78181. /**
  78182. * Gets the number of columns
  78183. */
  78184. get columnCount(): number;
  78185. /**
  78186. * Gets the number of rows
  78187. */
  78188. get rowCount(): number;
  78189. /** Gets the list of children */
  78190. get children(): Control[];
  78191. /** Gets the list of cells (e.g. the containers) */
  78192. get cells(): {
  78193. [key: string]: Container;
  78194. };
  78195. /**
  78196. * Gets the definition of a specific row
  78197. * @param index defines the index of the row
  78198. * @returns the row definition
  78199. */
  78200. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78201. /**
  78202. * Gets the definition of a specific column
  78203. * @param index defines the index of the column
  78204. * @returns the column definition
  78205. */
  78206. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78207. /**
  78208. * Adds a new row to the grid
  78209. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78210. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  78211. * @returns the current grid
  78212. */
  78213. addRowDefinition(height: number, isPixel?: boolean): Grid;
  78214. /**
  78215. * Adds a new column to the grid
  78216. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78217. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78218. * @returns the current grid
  78219. */
  78220. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  78221. /**
  78222. * Update a row definition
  78223. * @param index defines the index of the row to update
  78224. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  78225. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  78226. * @returns the current grid
  78227. */
  78228. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  78229. /**
  78230. * Update a column definition
  78231. * @param index defines the index of the column to update
  78232. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  78233. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  78234. * @returns the current grid
  78235. */
  78236. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  78237. /**
  78238. * Gets the list of children stored in a specific cell
  78239. * @param row defines the row to check
  78240. * @param column defines the column to check
  78241. * @returns the list of controls
  78242. */
  78243. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  78244. /**
  78245. * Gets a string representing the child cell info (row x column)
  78246. * @param child defines the control to get info from
  78247. * @returns a string containing the child cell info (row x column)
  78248. */
  78249. getChildCellInfo(child: Control): string;
  78250. private _removeCell;
  78251. private _offsetCell;
  78252. /**
  78253. * Remove a column definition at specified index
  78254. * @param index defines the index of the column to remove
  78255. * @returns the current grid
  78256. */
  78257. removeColumnDefinition(index: number): Grid;
  78258. /**
  78259. * Remove a row definition at specified index
  78260. * @param index defines the index of the row to remove
  78261. * @returns the current grid
  78262. */
  78263. removeRowDefinition(index: number): Grid;
  78264. /**
  78265. * Adds a new control to the current grid
  78266. * @param control defines the control to add
  78267. * @param row defines the row where to add the control (0 by default)
  78268. * @param column defines the column where to add the control (0 by default)
  78269. * @returns the current grid
  78270. */
  78271. addControl(control: Control, row?: number, column?: number): Grid;
  78272. /**
  78273. * Removes a control from the current container
  78274. * @param control defines the control to remove
  78275. * @returns the current container
  78276. */
  78277. removeControl(control: Control): Container;
  78278. /**
  78279. * Creates a new Grid
  78280. * @param name defines control name
  78281. */
  78282. constructor(name?: string | undefined);
  78283. protected _getTypeName(): string;
  78284. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  78285. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78286. _flagDescendantsAsMatrixDirty(): void;
  78287. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78288. /** Releases associated resources */
  78289. dispose(): void;
  78290. }
  78291. }
  78292. declare module BABYLON.GUI {
  78293. /** Class used to create color pickers */
  78294. export class ColorPicker extends Control {
  78295. name?: string | undefined;
  78296. private static _Epsilon;
  78297. private _colorWheelCanvas;
  78298. private _value;
  78299. private _tmpColor;
  78300. private _pointerStartedOnSquare;
  78301. private _pointerStartedOnWheel;
  78302. private _squareLeft;
  78303. private _squareTop;
  78304. private _squareSize;
  78305. private _h;
  78306. private _s;
  78307. private _v;
  78308. private _lastPointerDownID;
  78309. /**
  78310. * BABYLON.Observable raised when the value changes
  78311. */
  78312. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  78313. /** Gets or sets the color of the color picker */
  78314. get value(): BABYLON.Color3;
  78315. set value(value: BABYLON.Color3);
  78316. /**
  78317. * Gets or sets control width
  78318. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78319. */
  78320. get width(): string | number;
  78321. set width(value: string | number);
  78322. /**
  78323. * Gets or sets control height
  78324. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  78325. */
  78326. get height(): string | number;
  78327. /** Gets or sets control height */
  78328. set height(value: string | number);
  78329. /** Gets or sets control size */
  78330. get size(): string | number;
  78331. set size(value: string | number);
  78332. /**
  78333. * Creates a new ColorPicker
  78334. * @param name defines the control name
  78335. */
  78336. constructor(name?: string | undefined);
  78337. protected _getTypeName(): string;
  78338. /** @hidden */
  78339. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78340. private _updateSquareProps;
  78341. private _drawGradientSquare;
  78342. private _drawCircle;
  78343. private _createColorWheelCanvas;
  78344. /** @hidden */
  78345. _draw(context: CanvasRenderingContext2D): void;
  78346. private _pointerIsDown;
  78347. private _updateValueFromPointer;
  78348. private _isPointOnSquare;
  78349. private _isPointOnWheel;
  78350. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78351. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78352. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78353. _onCanvasBlur(): void;
  78354. /**
  78355. * This function expands the color picker by creating a color picker dialog with manual
  78356. * color value input and the ability to save colors into an array to be used later in
  78357. * subsequent launches of the dialogue.
  78358. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  78359. * @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.
  78360. * @returns picked color as a hex string and the saved colors array as hex strings.
  78361. */
  78362. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  78363. pickerWidth?: string;
  78364. pickerHeight?: string;
  78365. headerHeight?: string;
  78366. lastColor?: string;
  78367. swatchLimit?: number;
  78368. numSwatchesPerLine?: number;
  78369. savedColors?: Array<string>;
  78370. }): Promise<{
  78371. savedColors?: string[];
  78372. pickedColor: string;
  78373. }>;
  78374. }
  78375. }
  78376. declare module BABYLON.GUI {
  78377. /** Class used to create 2D ellipse containers */
  78378. export class Ellipse extends Container {
  78379. name?: string | undefined;
  78380. private _thickness;
  78381. /** Gets or sets border thickness */
  78382. get thickness(): number;
  78383. set thickness(value: number);
  78384. /**
  78385. * Creates a new Ellipse
  78386. * @param name defines the control name
  78387. */
  78388. constructor(name?: string | undefined);
  78389. protected _getTypeName(): string;
  78390. protected _localDraw(context: CanvasRenderingContext2D): void;
  78391. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78392. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78393. }
  78394. }
  78395. declare module BABYLON.GUI {
  78396. /**
  78397. * Class used to create a password control
  78398. */
  78399. export class InputPassword extends InputText {
  78400. protected _beforeRenderText(text: string): string;
  78401. }
  78402. }
  78403. declare module BABYLON.GUI {
  78404. /** Class used to render 2D lines */
  78405. export class Line extends Control {
  78406. name?: string | undefined;
  78407. private _lineWidth;
  78408. private _x1;
  78409. private _y1;
  78410. private _x2;
  78411. private _y2;
  78412. private _dash;
  78413. private _connectedControl;
  78414. private _connectedControlDirtyObserver;
  78415. /** Gets or sets the dash pattern */
  78416. get dash(): Array<number>;
  78417. set dash(value: Array<number>);
  78418. /** Gets or sets the control connected with the line end */
  78419. get connectedControl(): Control;
  78420. set connectedControl(value: Control);
  78421. /** Gets or sets start coordinates on X axis */
  78422. get x1(): string | number;
  78423. set x1(value: string | number);
  78424. /** Gets or sets start coordinates on Y axis */
  78425. get y1(): string | number;
  78426. set y1(value: string | number);
  78427. /** Gets or sets end coordinates on X axis */
  78428. get x2(): string | number;
  78429. set x2(value: string | number);
  78430. /** Gets or sets end coordinates on Y axis */
  78431. get y2(): string | number;
  78432. set y2(value: string | number);
  78433. /** Gets or sets line width */
  78434. get lineWidth(): number;
  78435. set lineWidth(value: number);
  78436. /** Gets or sets horizontal alignment */
  78437. set horizontalAlignment(value: number);
  78438. /** Gets or sets vertical alignment */
  78439. set verticalAlignment(value: number);
  78440. private get _effectiveX2();
  78441. private get _effectiveY2();
  78442. /**
  78443. * Creates a new Line
  78444. * @param name defines the control name
  78445. */
  78446. constructor(name?: string | undefined);
  78447. protected _getTypeName(): string;
  78448. _draw(context: CanvasRenderingContext2D): void;
  78449. _measure(): void;
  78450. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78451. /**
  78452. * Move one end of the line given 3D cartesian coordinates.
  78453. * @param position Targeted world position
  78454. * @param scene BABYLON.Scene
  78455. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78456. */
  78457. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  78458. /**
  78459. * Move one end of the line to a position in screen absolute space.
  78460. * @param projectedPosition Position in screen absolute space (X, Y)
  78461. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  78462. */
  78463. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  78464. }
  78465. }
  78466. declare module BABYLON.GUI {
  78467. /**
  78468. * Class used to store a point for a MultiLine object.
  78469. * The point can be pure 2D coordinates, a mesh or a control
  78470. */
  78471. export class MultiLinePoint {
  78472. private _multiLine;
  78473. private _x;
  78474. private _y;
  78475. private _control;
  78476. private _mesh;
  78477. private _controlObserver;
  78478. private _meshObserver;
  78479. /** @hidden */
  78480. _point: BABYLON.Vector2;
  78481. /**
  78482. * Creates a new MultiLinePoint
  78483. * @param multiLine defines the source MultiLine object
  78484. */
  78485. constructor(multiLine: MultiLine);
  78486. /** Gets or sets x coordinate */
  78487. get x(): string | number;
  78488. set x(value: string | number);
  78489. /** Gets or sets y coordinate */
  78490. get y(): string | number;
  78491. set y(value: string | number);
  78492. /** Gets or sets the control associated with this point */
  78493. get control(): BABYLON.Nullable<Control>;
  78494. set control(value: BABYLON.Nullable<Control>);
  78495. /** Gets or sets the mesh associated with this point */
  78496. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78497. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  78498. /** Resets links */
  78499. resetLinks(): void;
  78500. /**
  78501. * Gets a translation vector
  78502. * @returns the translation vector
  78503. */
  78504. translate(): BABYLON.Vector2;
  78505. private _translatePoint;
  78506. /** Release associated resources */
  78507. dispose(): void;
  78508. }
  78509. }
  78510. declare module BABYLON.GUI {
  78511. /**
  78512. * Class used to create multi line control
  78513. */
  78514. export class MultiLine extends Control {
  78515. name?: string | undefined;
  78516. private _lineWidth;
  78517. private _dash;
  78518. private _points;
  78519. private _minX;
  78520. private _minY;
  78521. private _maxX;
  78522. private _maxY;
  78523. /**
  78524. * Creates a new MultiLine
  78525. * @param name defines the control name
  78526. */
  78527. constructor(name?: string | undefined);
  78528. /** Gets or sets dash pattern */
  78529. get dash(): Array<number>;
  78530. set dash(value: Array<number>);
  78531. /**
  78532. * Gets point stored at specified index
  78533. * @param index defines the index to look for
  78534. * @returns the requested point if found
  78535. */
  78536. getAt(index: number): MultiLinePoint;
  78537. /** Function called when a point is updated */
  78538. onPointUpdate: () => void;
  78539. /**
  78540. * Adds new points to the point collection
  78541. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  78542. * @returns the list of created MultiLinePoint
  78543. */
  78544. add(...items: (AbstractMesh | Control | {
  78545. x: string | number;
  78546. y: string | number;
  78547. })[]): MultiLinePoint[];
  78548. /**
  78549. * Adds a new point to the point collection
  78550. * @param item defines the item (mesh, control or 2d coordiantes) to add
  78551. * @returns the created MultiLinePoint
  78552. */
  78553. push(item?: (AbstractMesh | Control | {
  78554. x: string | number;
  78555. y: string | number;
  78556. })): MultiLinePoint;
  78557. /**
  78558. * Remove a specific value or point from the active point collection
  78559. * @param value defines the value or point to remove
  78560. */
  78561. remove(value: number | MultiLinePoint): void;
  78562. /**
  78563. * Resets this object to initial state (no point)
  78564. */
  78565. reset(): void;
  78566. /**
  78567. * Resets all links
  78568. */
  78569. resetLinks(): void;
  78570. /** Gets or sets line width */
  78571. get lineWidth(): number;
  78572. set lineWidth(value: number);
  78573. set horizontalAlignment(value: number);
  78574. set verticalAlignment(value: number);
  78575. protected _getTypeName(): string;
  78576. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78577. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78578. _measure(): void;
  78579. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78580. dispose(): void;
  78581. }
  78582. }
  78583. declare module BABYLON.GUI {
  78584. /**
  78585. * Class used to create radio button controls
  78586. */
  78587. export class RadioButton extends Control {
  78588. name?: string | undefined;
  78589. private _isChecked;
  78590. private _background;
  78591. private _checkSizeRatio;
  78592. private _thickness;
  78593. /** Gets or sets border thickness */
  78594. get thickness(): number;
  78595. set thickness(value: number);
  78596. /** Gets or sets group name */
  78597. group: string;
  78598. /** BABYLON.Observable raised when isChecked is changed */
  78599. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78600. /** Gets or sets a value indicating the ratio between overall size and check size */
  78601. get checkSizeRatio(): number;
  78602. set checkSizeRatio(value: number);
  78603. /** Gets or sets background color */
  78604. get background(): string;
  78605. set background(value: string);
  78606. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78607. get isChecked(): boolean;
  78608. set isChecked(value: boolean);
  78609. /**
  78610. * Creates a new RadioButton
  78611. * @param name defines the control name
  78612. */
  78613. constructor(name?: string | undefined);
  78614. protected _getTypeName(): string;
  78615. _draw(context: CanvasRenderingContext2D): void;
  78616. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78617. /**
  78618. * Utility function to easily create a radio button with a header
  78619. * @param title defines the label to use for the header
  78620. * @param group defines the group to use for the radio button
  78621. * @param isChecked defines the initial state of the radio button
  78622. * @param onValueChanged defines the callback to call when value changes
  78623. * @returns a StackPanel containing the radio button and a textBlock
  78624. */
  78625. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  78626. }
  78627. }
  78628. declare module BABYLON.GUI {
  78629. /**
  78630. * Class used to create slider controls
  78631. */
  78632. export class BaseSlider extends Control {
  78633. name?: string | undefined;
  78634. protected _thumbWidth: ValueAndUnit;
  78635. private _minimum;
  78636. private _maximum;
  78637. private _value;
  78638. private _isVertical;
  78639. protected _barOffset: ValueAndUnit;
  78640. private _isThumbClamped;
  78641. protected _displayThumb: boolean;
  78642. private _step;
  78643. private _lastPointerDownID;
  78644. protected _effectiveBarOffset: number;
  78645. protected _renderLeft: number;
  78646. protected _renderTop: number;
  78647. protected _renderWidth: number;
  78648. protected _renderHeight: number;
  78649. protected _backgroundBoxLength: number;
  78650. protected _backgroundBoxThickness: number;
  78651. protected _effectiveThumbThickness: number;
  78652. /** BABYLON.Observable raised when the sldier value changes */
  78653. onValueChangedObservable: BABYLON.Observable<number>;
  78654. /** Gets or sets a boolean indicating if the thumb must be rendered */
  78655. get displayThumb(): boolean;
  78656. set displayThumb(value: boolean);
  78657. /** Gets or sets a step to apply to values (0 by default) */
  78658. get step(): number;
  78659. set step(value: number);
  78660. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  78661. get barOffset(): string | number;
  78662. /** Gets main bar offset in pixels*/
  78663. get barOffsetInPixels(): number;
  78664. set barOffset(value: string | number);
  78665. /** Gets or sets thumb width */
  78666. get thumbWidth(): string | number;
  78667. /** Gets thumb width in pixels */
  78668. get thumbWidthInPixels(): number;
  78669. set thumbWidth(value: string | number);
  78670. /** Gets or sets minimum value */
  78671. get minimum(): number;
  78672. set minimum(value: number);
  78673. /** Gets or sets maximum value */
  78674. get maximum(): number;
  78675. set maximum(value: number);
  78676. /** Gets or sets current value */
  78677. get value(): number;
  78678. set value(value: number);
  78679. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  78680. get isVertical(): boolean;
  78681. set isVertical(value: boolean);
  78682. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  78683. get isThumbClamped(): boolean;
  78684. set isThumbClamped(value: boolean);
  78685. /**
  78686. * Creates a new BaseSlider
  78687. * @param name defines the control name
  78688. */
  78689. constructor(name?: string | undefined);
  78690. protected _getTypeName(): string;
  78691. protected _getThumbPosition(): number;
  78692. protected _getThumbThickness(type: string): number;
  78693. protected _prepareRenderingData(type: string): void;
  78694. private _pointerIsDown;
  78695. /** @hidden */
  78696. protected _updateValueFromPointer(x: number, y: number): void;
  78697. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78698. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78699. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78700. _onCanvasBlur(): void;
  78701. }
  78702. }
  78703. declare module BABYLON.GUI {
  78704. /**
  78705. * Class used to create slider controls
  78706. */
  78707. export class Slider extends BaseSlider {
  78708. name?: string | undefined;
  78709. private _background;
  78710. private _borderColor;
  78711. private _isThumbCircle;
  78712. protected _displayValueBar: boolean;
  78713. /** Gets or sets a boolean indicating if the value bar must be rendered */
  78714. get displayValueBar(): boolean;
  78715. set displayValueBar(value: boolean);
  78716. /** Gets or sets border color */
  78717. get borderColor(): string;
  78718. set borderColor(value: string);
  78719. /** Gets or sets background color */
  78720. get background(): string;
  78721. set background(value: string);
  78722. /** Gets or sets a boolean indicating if the thumb should be round or square */
  78723. get isThumbCircle(): boolean;
  78724. set isThumbCircle(value: boolean);
  78725. /**
  78726. * Creates a new Slider
  78727. * @param name defines the control name
  78728. */
  78729. constructor(name?: string | undefined);
  78730. protected _getTypeName(): string;
  78731. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78732. }
  78733. }
  78734. declare module BABYLON.GUI {
  78735. /** Class used to create a RadioGroup
  78736. * which contains groups of radio buttons
  78737. */
  78738. export class SelectorGroup {
  78739. /** name of SelectorGroup */
  78740. name: string;
  78741. private _groupPanel;
  78742. private _selectors;
  78743. private _groupHeader;
  78744. /**
  78745. * Creates a new SelectorGroup
  78746. * @param name of group, used as a group heading
  78747. */
  78748. constructor(
  78749. /** name of SelectorGroup */
  78750. name: string);
  78751. /** Gets the groupPanel of the SelectorGroup */
  78752. get groupPanel(): StackPanel;
  78753. /** Gets the selectors array */
  78754. get selectors(): StackPanel[];
  78755. /** Gets and sets the group header */
  78756. get header(): string;
  78757. set header(label: string);
  78758. /** @hidden */
  78759. private _addGroupHeader;
  78760. /** @hidden*/
  78761. _getSelector(selectorNb: number): StackPanel | undefined;
  78762. /** Removes the selector at the given position
  78763. * @param selectorNb the position of the selector within the group
  78764. */
  78765. removeSelector(selectorNb: number): void;
  78766. }
  78767. /** Class used to create a CheckboxGroup
  78768. * which contains groups of checkbox buttons
  78769. */
  78770. export class CheckboxGroup extends SelectorGroup {
  78771. /** Adds a checkbox as a control
  78772. * @param text is the label for the selector
  78773. * @param func is the function called when the Selector is checked
  78774. * @param checked is true when Selector is checked
  78775. */
  78776. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  78777. /** @hidden */
  78778. _setSelectorLabel(selectorNb: number, label: string): void;
  78779. /** @hidden */
  78780. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78781. /** @hidden */
  78782. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78783. /** @hidden */
  78784. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78785. }
  78786. /** Class used to create a RadioGroup
  78787. * which contains groups of radio buttons
  78788. */
  78789. export class RadioGroup extends SelectorGroup {
  78790. private _selectNb;
  78791. /** Adds a radio button as a control
  78792. * @param label is the label for the selector
  78793. * @param func is the function called when the Selector is checked
  78794. * @param checked is true when Selector is checked
  78795. */
  78796. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  78797. /** @hidden */
  78798. _setSelectorLabel(selectorNb: number, label: string): void;
  78799. /** @hidden */
  78800. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78801. /** @hidden */
  78802. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78803. /** @hidden */
  78804. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78805. }
  78806. /** Class used to create a SliderGroup
  78807. * which contains groups of slider buttons
  78808. */
  78809. export class SliderGroup extends SelectorGroup {
  78810. /**
  78811. * Adds a slider to the SelectorGroup
  78812. * @param label is the label for the SliderBar
  78813. * @param func is the function called when the Slider moves
  78814. * @param unit is a string describing the units used, eg degrees or metres
  78815. * @param min is the minimum value for the Slider
  78816. * @param max is the maximum value for the Slider
  78817. * @param value is the start value for the Slider between min and max
  78818. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  78819. */
  78820. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  78821. /** @hidden */
  78822. _setSelectorLabel(selectorNb: number, label: string): void;
  78823. /** @hidden */
  78824. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78825. /** @hidden */
  78826. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78827. /** @hidden */
  78828. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78829. }
  78830. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  78831. * @see https://doc.babylonjs.com/how_to/selector
  78832. */
  78833. export class SelectionPanel extends Rectangle {
  78834. /** name of SelectionPanel */
  78835. name: string;
  78836. /** an array of SelectionGroups */
  78837. groups: SelectorGroup[];
  78838. private _panel;
  78839. private _buttonColor;
  78840. private _buttonBackground;
  78841. private _headerColor;
  78842. private _barColor;
  78843. private _barHeight;
  78844. private _spacerHeight;
  78845. private _labelColor;
  78846. private _groups;
  78847. private _bars;
  78848. /**
  78849. * Creates a new SelectionPanel
  78850. * @param name of SelectionPanel
  78851. * @param groups is an array of SelectionGroups
  78852. */
  78853. constructor(
  78854. /** name of SelectionPanel */
  78855. name: string,
  78856. /** an array of SelectionGroups */
  78857. groups?: SelectorGroup[]);
  78858. protected _getTypeName(): string;
  78859. /** Gets or sets the headerColor */
  78860. get headerColor(): string;
  78861. set headerColor(color: string);
  78862. private _setHeaderColor;
  78863. /** Gets or sets the button color */
  78864. get buttonColor(): string;
  78865. set buttonColor(color: string);
  78866. private _setbuttonColor;
  78867. /** Gets or sets the label color */
  78868. get labelColor(): string;
  78869. set labelColor(color: string);
  78870. private _setLabelColor;
  78871. /** Gets or sets the button background */
  78872. get buttonBackground(): string;
  78873. set buttonBackground(color: string);
  78874. private _setButtonBackground;
  78875. /** Gets or sets the color of separator bar */
  78876. get barColor(): string;
  78877. set barColor(color: string);
  78878. private _setBarColor;
  78879. /** Gets or sets the height of separator bar */
  78880. get barHeight(): string;
  78881. set barHeight(value: string);
  78882. private _setBarHeight;
  78883. /** Gets or sets the height of spacers*/
  78884. get spacerHeight(): string;
  78885. set spacerHeight(value: string);
  78886. private _setSpacerHeight;
  78887. /** Adds a bar between groups */
  78888. private _addSpacer;
  78889. /** Add a group to the selection panel
  78890. * @param group is the selector group to add
  78891. */
  78892. addGroup(group: SelectorGroup): void;
  78893. /** Remove the group from the given position
  78894. * @param groupNb is the position of the group in the list
  78895. */
  78896. removeGroup(groupNb: number): void;
  78897. /** Change a group header label
  78898. * @param label is the new group header label
  78899. * @param groupNb is the number of the group to relabel
  78900. * */
  78901. setHeaderName(label: string, groupNb: number): void;
  78902. /** Change selector label to the one given
  78903. * @param label is the new selector label
  78904. * @param groupNb is the number of the groupcontaining the selector
  78905. * @param selectorNb is the number of the selector within a group to relabel
  78906. * */
  78907. relabel(label: string, groupNb: number, selectorNb: number): void;
  78908. /** For a given group position remove the selector at the given position
  78909. * @param groupNb is the number of the group to remove the selector from
  78910. * @param selectorNb is the number of the selector within the group
  78911. */
  78912. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  78913. /** For a given group position of correct type add a checkbox button
  78914. * @param groupNb is the number of the group to remove the selector from
  78915. * @param label is the label for the selector
  78916. * @param func is the function called when the Selector is checked
  78917. * @param checked is true when Selector is checked
  78918. */
  78919. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78920. /** For a given group position of correct type add a radio button
  78921. * @param groupNb is the number of the group to remove the selector from
  78922. * @param label is the label for the selector
  78923. * @param func is the function called when the Selector is checked
  78924. * @param checked is true when Selector is checked
  78925. */
  78926. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78927. /**
  78928. * For a given slider group add a slider
  78929. * @param groupNb is the number of the group to add the slider to
  78930. * @param label is the label for the Slider
  78931. * @param func is the function called when the Slider moves
  78932. * @param unit is a string describing the units used, eg degrees or metres
  78933. * @param min is the minimum value for the Slider
  78934. * @param max is the maximum value for the Slider
  78935. * @param value is the start value for the Slider between min and max
  78936. * @param onVal is the function used to format the value displayed, eg radians to degrees
  78937. */
  78938. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  78939. }
  78940. }
  78941. declare module BABYLON.GUI {
  78942. /**
  78943. * Class used to hold a the container for ScrollViewer
  78944. * @hidden
  78945. */
  78946. export class _ScrollViewerWindow extends Container {
  78947. parentClientWidth: number;
  78948. parentClientHeight: number;
  78949. private _freezeControls;
  78950. private _parentMeasure;
  78951. private _oldLeft;
  78952. private _oldTop;
  78953. get freezeControls(): boolean;
  78954. set freezeControls(value: boolean);
  78955. private _bucketWidth;
  78956. private _bucketHeight;
  78957. private _buckets;
  78958. private _bucketLen;
  78959. get bucketWidth(): number;
  78960. get bucketHeight(): number;
  78961. setBucketSizes(width: number, height: number): void;
  78962. private _useBuckets;
  78963. private _makeBuckets;
  78964. private _dispatchInBuckets;
  78965. private _updateMeasures;
  78966. private _updateChildrenMeasures;
  78967. private _restoreMeasures;
  78968. /**
  78969. * Creates a new ScrollViewerWindow
  78970. * @param name of ScrollViewerWindow
  78971. */
  78972. constructor(name?: string);
  78973. protected _getTypeName(): string;
  78974. /** @hidden */
  78975. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78976. /** @hidden */
  78977. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78978. private _scrollChildren;
  78979. private _scrollChildrenWithBuckets;
  78980. /** @hidden */
  78981. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78982. protected _postMeasure(): void;
  78983. }
  78984. }
  78985. declare module BABYLON.GUI {
  78986. /**
  78987. * Class used to create slider controls
  78988. */
  78989. export class ScrollBar extends BaseSlider {
  78990. name?: string | undefined;
  78991. private _background;
  78992. private _borderColor;
  78993. private _tempMeasure;
  78994. /** Gets or sets border color */
  78995. get borderColor(): string;
  78996. set borderColor(value: string);
  78997. /** Gets or sets background color */
  78998. get background(): string;
  78999. set background(value: string);
  79000. /**
  79001. * Creates a new Slider
  79002. * @param name defines the control name
  79003. */
  79004. constructor(name?: string | undefined);
  79005. protected _getTypeName(): string;
  79006. protected _getThumbThickness(): number;
  79007. _draw(context: CanvasRenderingContext2D): void;
  79008. private _first;
  79009. private _originX;
  79010. private _originY;
  79011. /** @hidden */
  79012. protected _updateValueFromPointer(x: number, y: number): void;
  79013. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79014. }
  79015. }
  79016. declare module BABYLON.GUI {
  79017. /**
  79018. * Class used to create slider controls
  79019. */
  79020. export class ImageScrollBar extends BaseSlider {
  79021. name?: string | undefined;
  79022. private _backgroundBaseImage;
  79023. private _backgroundImage;
  79024. private _thumbImage;
  79025. private _thumbBaseImage;
  79026. private _thumbLength;
  79027. private _thumbHeight;
  79028. private _barImageHeight;
  79029. private _tempMeasure;
  79030. /** Number of 90° rotation to apply on the images when in vertical mode */
  79031. num90RotationInVerticalMode: number;
  79032. /**
  79033. * Gets or sets the image used to render the background for horizontal bar
  79034. */
  79035. get backgroundImage(): Image;
  79036. set backgroundImage(value: Image);
  79037. /**
  79038. * Gets or sets the image used to render the thumb
  79039. */
  79040. get thumbImage(): Image;
  79041. set thumbImage(value: Image);
  79042. /**
  79043. * Gets or sets the length of the thumb
  79044. */
  79045. get thumbLength(): number;
  79046. set thumbLength(value: number);
  79047. /**
  79048. * Gets or sets the height of the thumb
  79049. */
  79050. get thumbHeight(): number;
  79051. set thumbHeight(value: number);
  79052. /**
  79053. * Gets or sets the height of the bar image
  79054. */
  79055. get barImageHeight(): number;
  79056. set barImageHeight(value: number);
  79057. /**
  79058. * Creates a new ImageScrollBar
  79059. * @param name defines the control name
  79060. */
  79061. constructor(name?: string | undefined);
  79062. protected _getTypeName(): string;
  79063. protected _getThumbThickness(): number;
  79064. _draw(context: CanvasRenderingContext2D): void;
  79065. private _first;
  79066. private _originX;
  79067. private _originY;
  79068. /** @hidden */
  79069. protected _updateValueFromPointer(x: number, y: number): void;
  79070. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79071. }
  79072. }
  79073. declare module BABYLON.GUI {
  79074. /**
  79075. * Class used to hold a viewer window and sliders in a grid
  79076. */
  79077. export class ScrollViewer extends Rectangle {
  79078. private _grid;
  79079. private _horizontalBarSpace;
  79080. private _verticalBarSpace;
  79081. private _dragSpace;
  79082. private _horizontalBar;
  79083. private _verticalBar;
  79084. private _barColor;
  79085. private _barBackground;
  79086. private _barImage;
  79087. private _horizontalBarImage;
  79088. private _verticalBarImage;
  79089. private _barBackgroundImage;
  79090. private _horizontalBarBackgroundImage;
  79091. private _verticalBarBackgroundImage;
  79092. private _barSize;
  79093. private _window;
  79094. private _pointerIsOver;
  79095. private _wheelPrecision;
  79096. private _onWheelObserver;
  79097. private _clientWidth;
  79098. private _clientHeight;
  79099. private _useImageBar;
  79100. private _thumbLength;
  79101. private _thumbHeight;
  79102. private _barImageHeight;
  79103. private _horizontalBarImageHeight;
  79104. private _verticalBarImageHeight;
  79105. private _oldWindowContentsWidth;
  79106. private _oldWindowContentsHeight;
  79107. /**
  79108. * Gets the horizontal scrollbar
  79109. */
  79110. get horizontalBar(): ScrollBar | ImageScrollBar;
  79111. /**
  79112. * Gets the vertical scrollbar
  79113. */
  79114. get verticalBar(): ScrollBar | ImageScrollBar;
  79115. /**
  79116. * Adds a new control to the current container
  79117. * @param control defines the control to add
  79118. * @returns the current container
  79119. */
  79120. addControl(control: BABYLON.Nullable<Control>): Container;
  79121. /**
  79122. * Removes a control from the current container
  79123. * @param control defines the control to remove
  79124. * @returns the current container
  79125. */
  79126. removeControl(control: Control): Container;
  79127. /** Gets the list of children */
  79128. get children(): Control[];
  79129. _flagDescendantsAsMatrixDirty(): void;
  79130. /**
  79131. * Freezes or unfreezes the controls in the window.
  79132. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  79133. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  79134. */
  79135. get freezeControls(): boolean;
  79136. set freezeControls(value: boolean);
  79137. /** Gets the bucket width */
  79138. get bucketWidth(): number;
  79139. /** Gets the bucket height */
  79140. get bucketHeight(): number;
  79141. /**
  79142. * Sets the bucket sizes.
  79143. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  79144. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  79145. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  79146. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  79147. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  79148. * used), that's why it is not enabled by default.
  79149. * @param width width of the bucket
  79150. * @param height height of the bucket
  79151. */
  79152. setBucketSizes(width: number, height: number): void;
  79153. private _forceHorizontalBar;
  79154. private _forceVerticalBar;
  79155. /**
  79156. * Forces the horizontal scroll bar to be displayed
  79157. */
  79158. get forceHorizontalBar(): boolean;
  79159. set forceHorizontalBar(value: boolean);
  79160. /**
  79161. * Forces the vertical scroll bar to be displayed
  79162. */
  79163. get forceVerticalBar(): boolean;
  79164. set forceVerticalBar(value: boolean);
  79165. /**
  79166. * Creates a new ScrollViewer
  79167. * @param name of ScrollViewer
  79168. */
  79169. constructor(name?: string, isImageBased?: boolean);
  79170. /** Reset the scroll viewer window to initial size */
  79171. resetWindow(): void;
  79172. protected _getTypeName(): string;
  79173. private _buildClientSizes;
  79174. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79175. protected _postMeasure(): void;
  79176. /**
  79177. * Gets or sets the mouse wheel precision
  79178. * from 0 to 1 with a default value of 0.05
  79179. * */
  79180. get wheelPrecision(): number;
  79181. set wheelPrecision(value: number);
  79182. /** Gets or sets the scroll bar container background color */
  79183. get scrollBackground(): string;
  79184. set scrollBackground(color: string);
  79185. /** Gets or sets the bar color */
  79186. get barColor(): string;
  79187. set barColor(color: string);
  79188. /** Gets or sets the bar image */
  79189. get thumbImage(): Image;
  79190. set thumbImage(value: Image);
  79191. /** Gets or sets the horizontal bar image */
  79192. get horizontalThumbImage(): Image;
  79193. set horizontalThumbImage(value: Image);
  79194. /** Gets or sets the vertical bar image */
  79195. get verticalThumbImage(): Image;
  79196. set verticalThumbImage(value: Image);
  79197. /** Gets or sets the size of the bar */
  79198. get barSize(): number;
  79199. set barSize(value: number);
  79200. /** Gets or sets the length of the thumb */
  79201. get thumbLength(): number;
  79202. set thumbLength(value: number);
  79203. /** Gets or sets the height of the thumb */
  79204. get thumbHeight(): number;
  79205. set thumbHeight(value: number);
  79206. /** Gets or sets the height of the bar image */
  79207. get barImageHeight(): number;
  79208. set barImageHeight(value: number);
  79209. /** Gets or sets the height of the horizontal bar image */
  79210. get horizontalBarImageHeight(): number;
  79211. set horizontalBarImageHeight(value: number);
  79212. /** Gets or sets the height of the vertical bar image */
  79213. get verticalBarImageHeight(): number;
  79214. set verticalBarImageHeight(value: number);
  79215. /** Gets or sets the bar background */
  79216. get barBackground(): string;
  79217. set barBackground(color: string);
  79218. /** Gets or sets the bar background image */
  79219. get barImage(): Image;
  79220. set barImage(value: Image);
  79221. /** Gets or sets the horizontal bar background image */
  79222. get horizontalBarImage(): Image;
  79223. set horizontalBarImage(value: Image);
  79224. /** Gets or sets the vertical bar background image */
  79225. get verticalBarImage(): Image;
  79226. set verticalBarImage(value: Image);
  79227. private _setWindowPosition;
  79228. /** @hidden */
  79229. private _updateScroller;
  79230. _link(host: AdvancedDynamicTexture): void;
  79231. /** @hidden */
  79232. private _addBar;
  79233. /** @hidden */
  79234. private _attachWheel;
  79235. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79236. /** Releases associated resources */
  79237. dispose(): void;
  79238. }
  79239. }
  79240. declare module BABYLON.GUI {
  79241. /** Class used to render a grid */
  79242. export class DisplayGrid extends Control {
  79243. name?: string | undefined;
  79244. private _cellWidth;
  79245. private _cellHeight;
  79246. private _minorLineTickness;
  79247. private _minorLineColor;
  79248. private _majorLineTickness;
  79249. private _majorLineColor;
  79250. private _majorLineFrequency;
  79251. private _background;
  79252. private _displayMajorLines;
  79253. private _displayMinorLines;
  79254. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  79255. get displayMinorLines(): boolean;
  79256. set displayMinorLines(value: boolean);
  79257. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  79258. get displayMajorLines(): boolean;
  79259. set displayMajorLines(value: boolean);
  79260. /** Gets or sets background color (Black by default) */
  79261. get background(): string;
  79262. set background(value: string);
  79263. /** Gets or sets the width of each cell (20 by default) */
  79264. get cellWidth(): number;
  79265. set cellWidth(value: number);
  79266. /** Gets or sets the height of each cell (20 by default) */
  79267. get cellHeight(): number;
  79268. set cellHeight(value: number);
  79269. /** Gets or sets the tickness of minor lines (1 by default) */
  79270. get minorLineTickness(): number;
  79271. set minorLineTickness(value: number);
  79272. /** Gets or sets the color of minor lines (DarkGray by default) */
  79273. get minorLineColor(): string;
  79274. set minorLineColor(value: string);
  79275. /** Gets or sets the tickness of major lines (2 by default) */
  79276. get majorLineTickness(): number;
  79277. set majorLineTickness(value: number);
  79278. /** Gets or sets the color of major lines (White by default) */
  79279. get majorLineColor(): string;
  79280. set majorLineColor(value: string);
  79281. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  79282. get majorLineFrequency(): number;
  79283. set majorLineFrequency(value: number);
  79284. /**
  79285. * Creates a new GridDisplayRectangle
  79286. * @param name defines the control name
  79287. */
  79288. constructor(name?: string | undefined);
  79289. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79290. protected _getTypeName(): string;
  79291. }
  79292. }
  79293. declare module BABYLON.GUI {
  79294. /**
  79295. * Class used to create slider controls based on images
  79296. */
  79297. export class ImageBasedSlider extends BaseSlider {
  79298. name?: string | undefined;
  79299. private _backgroundImage;
  79300. private _thumbImage;
  79301. private _valueBarImage;
  79302. private _tempMeasure;
  79303. get displayThumb(): boolean;
  79304. set displayThumb(value: boolean);
  79305. /**
  79306. * Gets or sets the image used to render the background
  79307. */
  79308. get backgroundImage(): Image;
  79309. set backgroundImage(value: Image);
  79310. /**
  79311. * Gets or sets the image used to render the value bar
  79312. */
  79313. get valueBarImage(): Image;
  79314. set valueBarImage(value: Image);
  79315. /**
  79316. * Gets or sets the image used to render the thumb
  79317. */
  79318. get thumbImage(): Image;
  79319. set thumbImage(value: Image);
  79320. /**
  79321. * Creates a new ImageBasedSlider
  79322. * @param name defines the control name
  79323. */
  79324. constructor(name?: string | undefined);
  79325. protected _getTypeName(): string;
  79326. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79327. }
  79328. }
  79329. declare module BABYLON.GUI {
  79330. /**
  79331. * Forcing an export so that this code will execute
  79332. * @hidden
  79333. */
  79334. const name = "Statics";
  79335. }
  79336. declare module BABYLON.GUI {
  79337. /**
  79338. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  79339. */
  79340. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  79341. /**
  79342. * Define the instrumented AdvancedDynamicTexture.
  79343. */
  79344. texture: AdvancedDynamicTexture;
  79345. private _captureRenderTime;
  79346. private _renderTime;
  79347. private _captureLayoutTime;
  79348. private _layoutTime;
  79349. private _onBeginRenderObserver;
  79350. private _onEndRenderObserver;
  79351. private _onBeginLayoutObserver;
  79352. private _onEndLayoutObserver;
  79353. /**
  79354. * Gets the perf counter used to capture render time
  79355. */
  79356. get renderTimeCounter(): BABYLON.PerfCounter;
  79357. /**
  79358. * Gets the perf counter used to capture layout time
  79359. */
  79360. get layoutTimeCounter(): BABYLON.PerfCounter;
  79361. /**
  79362. * Enable or disable the render time capture
  79363. */
  79364. get captureRenderTime(): boolean;
  79365. set captureRenderTime(value: boolean);
  79366. /**
  79367. * Enable or disable the layout time capture
  79368. */
  79369. get captureLayoutTime(): boolean;
  79370. set captureLayoutTime(value: boolean);
  79371. /**
  79372. * Instantiates a new advanced dynamic texture instrumentation.
  79373. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  79374. * @param texture Defines the AdvancedDynamicTexture to instrument
  79375. */
  79376. constructor(
  79377. /**
  79378. * Define the instrumented AdvancedDynamicTexture.
  79379. */
  79380. texture: AdvancedDynamicTexture);
  79381. /**
  79382. * Dispose and release associated resources.
  79383. */
  79384. dispose(): void;
  79385. }
  79386. }
  79387. declare module BABYLON.GUI {
  79388. /**
  79389. * Class used to load GUI via XML.
  79390. */
  79391. export class XmlLoader {
  79392. private _nodes;
  79393. private _nodeTypes;
  79394. private _isLoaded;
  79395. private _objectAttributes;
  79396. private _parentClass;
  79397. /**
  79398. * Create a new xml loader
  79399. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  79400. */
  79401. constructor(parentClass?: null);
  79402. private _getChainElement;
  79403. private _getClassAttribute;
  79404. private _createGuiElement;
  79405. private _parseGrid;
  79406. private _parseElement;
  79407. private _prepareSourceElement;
  79408. private _parseElementsFromSource;
  79409. private _parseXml;
  79410. /**
  79411. * Gets if the loading has finished.
  79412. * @returns whether the loading has finished or not
  79413. */
  79414. isLoaded(): boolean;
  79415. /**
  79416. * Gets a loaded node / control by id.
  79417. * @param id the Controls id set in the xml
  79418. * @returns element of type Control
  79419. */
  79420. getNodeById(id: string): any;
  79421. /**
  79422. * Gets all loaded nodes / controls
  79423. * @returns Array of controls
  79424. */
  79425. getNodes(): any;
  79426. /**
  79427. * Initiates the xml layout loading
  79428. * @param xmlFile defines the xml layout to load
  79429. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  79430. * @param callback defines the callback called on layout load.
  79431. */
  79432. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  79433. }
  79434. }
  79435. declare module BABYLON.GUI {
  79436. /**
  79437. * Class used to create containers for controls
  79438. */
  79439. export class Container3D extends Control3D {
  79440. private _blockLayout;
  79441. /**
  79442. * Gets the list of child controls
  79443. */
  79444. protected _children: Control3D[];
  79445. /**
  79446. * Gets the list of child controls
  79447. */
  79448. get children(): Array<Control3D>;
  79449. /**
  79450. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  79451. * This is helpful to optimize layout operation when adding multiple children in a row
  79452. */
  79453. get blockLayout(): boolean;
  79454. set blockLayout(value: boolean);
  79455. /**
  79456. * Creates a new container
  79457. * @param name defines the container name
  79458. */
  79459. constructor(name?: string);
  79460. /**
  79461. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  79462. * @returns the current container
  79463. */
  79464. updateLayout(): Container3D;
  79465. /**
  79466. * Gets a boolean indicating if the given control is in the children of this control
  79467. * @param control defines the control to check
  79468. * @returns true if the control is in the child list
  79469. */
  79470. containsControl(control: Control3D): boolean;
  79471. /**
  79472. * Adds a control to the children of this control
  79473. * @param control defines the control to add
  79474. * @returns the current container
  79475. */
  79476. addControl(control: Control3D): Container3D;
  79477. /**
  79478. * This function will be called everytime a new control is added
  79479. */
  79480. protected _arrangeChildren(): void;
  79481. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79482. /**
  79483. * Removes a control from the children of this control
  79484. * @param control defines the control to remove
  79485. * @returns the current container
  79486. */
  79487. removeControl(control: Control3D): Container3D;
  79488. protected _getTypeName(): string;
  79489. /**
  79490. * Releases all associated resources
  79491. */
  79492. dispose(): void;
  79493. /** Control rotation will remain unchanged */
  79494. static readonly UNSET_ORIENTATION: number;
  79495. /** Control will rotate to make it look at sphere central axis */
  79496. static readonly FACEORIGIN_ORIENTATION: number;
  79497. /** Control will rotate to make it look back at sphere central axis */
  79498. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  79499. /** Control will rotate to look at z axis (0, 0, 1) */
  79500. static readonly FACEFORWARD_ORIENTATION: number;
  79501. /** Control will rotate to look at negative z axis (0, 0, -1) */
  79502. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  79503. }
  79504. }
  79505. declare module BABYLON.GUI {
  79506. /**
  79507. * Class used to manage 3D user interface
  79508. * @see https://doc.babylonjs.com/how_to/gui3d
  79509. */
  79510. export class GUI3DManager implements BABYLON.IDisposable {
  79511. private _scene;
  79512. private _sceneDisposeObserver;
  79513. private _utilityLayer;
  79514. private _rootContainer;
  79515. private _pointerObserver;
  79516. private _pointerOutObserver;
  79517. /** @hidden */
  79518. _lastPickedControl: Control3D;
  79519. /** @hidden */
  79520. _lastControlOver: {
  79521. [pointerId: number]: Control3D;
  79522. };
  79523. /** @hidden */
  79524. _lastControlDown: {
  79525. [pointerId: number]: Control3D;
  79526. };
  79527. /**
  79528. * BABYLON.Observable raised when the point picked by the pointer events changed
  79529. */
  79530. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  79531. /** @hidden */
  79532. _sharedMaterials: {
  79533. [key: string]: BABYLON.Material;
  79534. };
  79535. /** Gets the hosting scene */
  79536. get scene(): BABYLON.Scene;
  79537. /** Gets associated utility layer */
  79538. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  79539. /**
  79540. * Creates a new GUI3DManager
  79541. * @param scene
  79542. */
  79543. constructor(scene?: BABYLON.Scene);
  79544. private _handlePointerOut;
  79545. private _doPicking;
  79546. /**
  79547. * Gets the root container
  79548. */
  79549. get rootContainer(): Container3D;
  79550. /**
  79551. * Gets a boolean indicating if the given control is in the root child list
  79552. * @param control defines the control to check
  79553. * @returns true if the control is in the root child list
  79554. */
  79555. containsControl(control: Control3D): boolean;
  79556. /**
  79557. * Adds a control to the root child list
  79558. * @param control defines the control to add
  79559. * @returns the current manager
  79560. */
  79561. addControl(control: Control3D): GUI3DManager;
  79562. /**
  79563. * Removes a control from the root child list
  79564. * @param control defines the control to remove
  79565. * @returns the current container
  79566. */
  79567. removeControl(control: Control3D): GUI3DManager;
  79568. /**
  79569. * Releases all associated resources
  79570. */
  79571. dispose(): void;
  79572. }
  79573. }
  79574. declare module BABYLON.GUI {
  79575. /**
  79576. * Class used to transport BABYLON.Vector3 information for pointer events
  79577. */
  79578. export class Vector3WithInfo extends BABYLON.Vector3 {
  79579. /** defines the current mouse button index */
  79580. buttonIndex: number;
  79581. /**
  79582. * Creates a new Vector3WithInfo
  79583. * @param source defines the vector3 data to transport
  79584. * @param buttonIndex defines the current mouse button index
  79585. */
  79586. constructor(source: BABYLON.Vector3,
  79587. /** defines the current mouse button index */
  79588. buttonIndex?: number);
  79589. }
  79590. }
  79591. declare module BABYLON.GUI {
  79592. /**
  79593. * Class used as base class for controls
  79594. */
  79595. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  79596. /** Defines the control name */
  79597. name?: string | undefined;
  79598. /** @hidden */
  79599. _host: GUI3DManager;
  79600. private _node;
  79601. private _downCount;
  79602. private _enterCount;
  79603. private _downPointerIds;
  79604. private _isVisible;
  79605. /** Gets or sets the control position in world space */
  79606. get position(): BABYLON.Vector3;
  79607. set position(value: BABYLON.Vector3);
  79608. /** Gets or sets the control scaling in world space */
  79609. get scaling(): BABYLON.Vector3;
  79610. set scaling(value: BABYLON.Vector3);
  79611. /** Callback used to start pointer enter animation */
  79612. pointerEnterAnimation: () => void;
  79613. /** Callback used to start pointer out animation */
  79614. pointerOutAnimation: () => void;
  79615. /** Callback used to start pointer down animation */
  79616. pointerDownAnimation: () => void;
  79617. /** Callback used to start pointer up animation */
  79618. pointerUpAnimation: () => void;
  79619. /**
  79620. * An event triggered when the pointer move over the control
  79621. */
  79622. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  79623. /**
  79624. * An event triggered when the pointer move out of the control
  79625. */
  79626. onPointerOutObservable: BABYLON.Observable<Control3D>;
  79627. /**
  79628. * An event triggered when the pointer taps the control
  79629. */
  79630. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  79631. /**
  79632. * An event triggered when pointer is up
  79633. */
  79634. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  79635. /**
  79636. * An event triggered when a control is clicked on (with a mouse)
  79637. */
  79638. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  79639. /**
  79640. * An event triggered when pointer enters the control
  79641. */
  79642. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  79643. /**
  79644. * Gets or sets the parent container
  79645. */
  79646. parent: BABYLON.Nullable<Container3D>;
  79647. private _behaviors;
  79648. /**
  79649. * Gets the list of attached behaviors
  79650. * @see https://doc.babylonjs.com/features/behaviour
  79651. */
  79652. get behaviors(): BABYLON.Behavior<Control3D>[];
  79653. /**
  79654. * Attach a behavior to the control
  79655. * @see https://doc.babylonjs.com/features/behaviour
  79656. * @param behavior defines the behavior to attach
  79657. * @returns the current control
  79658. */
  79659. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79660. /**
  79661. * Remove an attached behavior
  79662. * @see https://doc.babylonjs.com/features/behaviour
  79663. * @param behavior defines the behavior to attach
  79664. * @returns the current control
  79665. */
  79666. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  79667. /**
  79668. * Gets an attached behavior by name
  79669. * @param name defines the name of the behavior to look for
  79670. * @see https://doc.babylonjs.com/features/behaviour
  79671. * @returns null if behavior was not found else the requested behavior
  79672. */
  79673. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  79674. /** Gets or sets a boolean indicating if the control is visible */
  79675. get isVisible(): boolean;
  79676. set isVisible(value: boolean);
  79677. /**
  79678. * Creates a new control
  79679. * @param name defines the control name
  79680. */
  79681. constructor(
  79682. /** Defines the control name */
  79683. name?: string | undefined);
  79684. /**
  79685. * Gets a string representing the class name
  79686. */
  79687. get typeName(): string;
  79688. /**
  79689. * Get the current class name of the control.
  79690. * @returns current class name
  79691. */
  79692. getClassName(): string;
  79693. protected _getTypeName(): string;
  79694. /**
  79695. * Gets the transform node used by this control
  79696. */
  79697. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  79698. /**
  79699. * Gets the mesh used to render this control
  79700. */
  79701. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79702. /**
  79703. * Link the control as child of the given node
  79704. * @param node defines the node to link to. Use null to unlink the control
  79705. * @returns the current control
  79706. */
  79707. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  79708. /** @hidden **/
  79709. _prepareNode(scene: BABYLON.Scene): void;
  79710. /**
  79711. * Node creation.
  79712. * Can be overriden by children
  79713. * @param scene defines the scene where the node must be attached
  79714. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  79715. */
  79716. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79717. /**
  79718. * Affect a material to the given mesh
  79719. * @param mesh defines the mesh which will represent the control
  79720. */
  79721. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79722. /** @hidden */
  79723. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  79724. /** @hidden */
  79725. _onPointerEnter(target: Control3D): boolean;
  79726. /** @hidden */
  79727. _onPointerOut(target: Control3D): void;
  79728. /** @hidden */
  79729. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79730. /** @hidden */
  79731. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79732. /** @hidden */
  79733. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79734. /** @hidden */
  79735. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79736. /** @hidden */
  79737. _disposeNode(): void;
  79738. /**
  79739. * Releases all associated resources
  79740. */
  79741. dispose(): void;
  79742. }
  79743. }
  79744. declare module BABYLON.GUI {
  79745. /**
  79746. * Class used as a root to all buttons
  79747. */
  79748. export class AbstractButton3D extends Control3D {
  79749. /**
  79750. * Creates a new button
  79751. * @param name defines the control name
  79752. */
  79753. constructor(name?: string);
  79754. protected _getTypeName(): string;
  79755. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79756. }
  79757. }
  79758. declare module BABYLON.GUI {
  79759. /**
  79760. * Class used to create a button in 3D
  79761. */
  79762. export class Button3D extends AbstractButton3D {
  79763. /** @hidden */
  79764. protected _currentMaterial: BABYLON.Material;
  79765. private _facadeTexture;
  79766. private _content;
  79767. private _contentResolution;
  79768. private _contentScaleRatio;
  79769. /**
  79770. * Gets or sets the texture resolution used to render content (512 by default)
  79771. */
  79772. get contentResolution(): BABYLON.int;
  79773. set contentResolution(value: BABYLON.int);
  79774. /**
  79775. * Gets or sets the texture scale ratio used to render content (2 by default)
  79776. */
  79777. get contentScaleRatio(): number;
  79778. set contentScaleRatio(value: number);
  79779. protected _disposeFacadeTexture(): void;
  79780. protected _resetContent(): void;
  79781. /**
  79782. * Creates a new button
  79783. * @param name defines the control name
  79784. */
  79785. constructor(name?: string);
  79786. /**
  79787. * Gets or sets the GUI 2D content used to display the button's facade
  79788. */
  79789. get content(): Control;
  79790. set content(value: Control);
  79791. /**
  79792. * Apply the facade texture (created from the content property).
  79793. * This function can be overloaded by child classes
  79794. * @param facadeTexture defines the AdvancedDynamicTexture to use
  79795. */
  79796. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79797. protected _getTypeName(): string;
  79798. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79799. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79800. /**
  79801. * Releases all associated resources
  79802. */
  79803. dispose(): void;
  79804. }
  79805. }
  79806. declare module BABYLON.GUI {
  79807. /**
  79808. * Abstract class used to create a container panel deployed on the surface of a volume
  79809. */
  79810. export abstract class VolumeBasedPanel extends Container3D {
  79811. private _columns;
  79812. private _rows;
  79813. private _rowThenColum;
  79814. private _orientation;
  79815. protected _cellWidth: number;
  79816. protected _cellHeight: number;
  79817. /**
  79818. * Gets or sets the distance between elements
  79819. */
  79820. margin: number;
  79821. /**
  79822. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  79823. * | Value | Type | Description |
  79824. * | ----- | ----------------------------------- | ----------- |
  79825. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  79826. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  79827. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  79828. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  79829. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  79830. */
  79831. get orientation(): number;
  79832. set orientation(value: number);
  79833. /**
  79834. * Gets or sets the number of columns requested (10 by default).
  79835. * The panel will automatically compute the number of rows based on number of child controls.
  79836. */
  79837. get columns(): BABYLON.int;
  79838. set columns(value: BABYLON.int);
  79839. /**
  79840. * Gets or sets a the number of rows requested.
  79841. * The panel will automatically compute the number of columns based on number of child controls.
  79842. */
  79843. get rows(): BABYLON.int;
  79844. set rows(value: BABYLON.int);
  79845. /**
  79846. * Creates new VolumeBasedPanel
  79847. */
  79848. constructor();
  79849. protected _arrangeChildren(): void;
  79850. /** Child classes must implement this function to provide correct control positioning */
  79851. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79852. /** Child classes can implement this function to provide additional processing */
  79853. protected _finalProcessing(): void;
  79854. }
  79855. }
  79856. declare module BABYLON.GUI {
  79857. /**
  79858. * Class used to create a container panel deployed on the surface of a cylinder
  79859. */
  79860. export class CylinderPanel extends VolumeBasedPanel {
  79861. private _radius;
  79862. /**
  79863. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  79864. */
  79865. get radius(): BABYLON.float;
  79866. set radius(value: BABYLON.float);
  79867. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79868. private _cylindricalMapping;
  79869. }
  79870. }
  79871. declare module BABYLON.GUI {
  79872. /** @hidden */
  79873. export var fluentVertexShader: {
  79874. name: string;
  79875. shader: string;
  79876. };
  79877. }
  79878. declare module BABYLON.GUI {
  79879. /** @hidden */
  79880. export var fluentPixelShader: {
  79881. name: string;
  79882. shader: string;
  79883. };
  79884. }
  79885. declare module BABYLON.GUI {
  79886. /** @hidden */
  79887. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  79888. INNERGLOW: boolean;
  79889. BORDER: boolean;
  79890. HOVERLIGHT: boolean;
  79891. TEXTURE: boolean;
  79892. constructor();
  79893. }
  79894. /**
  79895. * Class used to render controls with fluent desgin
  79896. */
  79897. export class FluentMaterial extends BABYLON.PushMaterial {
  79898. /**
  79899. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  79900. */
  79901. innerGlowColorIntensity: number;
  79902. /**
  79903. * Gets or sets the inner glow color (white by default)
  79904. */
  79905. innerGlowColor: BABYLON.Color3;
  79906. /**
  79907. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  79908. */
  79909. albedoColor: BABYLON.Color3;
  79910. /**
  79911. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  79912. */
  79913. renderBorders: boolean;
  79914. /**
  79915. * Gets or sets border width (default is 0.5)
  79916. */
  79917. borderWidth: number;
  79918. /**
  79919. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  79920. */
  79921. edgeSmoothingValue: number;
  79922. /**
  79923. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  79924. */
  79925. borderMinValue: number;
  79926. /**
  79927. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  79928. */
  79929. renderHoverLight: boolean;
  79930. /**
  79931. * Gets or sets the radius used to render the hover light (default is 1.0)
  79932. */
  79933. hoverRadius: number;
  79934. /**
  79935. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  79936. */
  79937. hoverColor: BABYLON.Color4;
  79938. /**
  79939. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  79940. */
  79941. hoverPosition: BABYLON.Vector3;
  79942. private _albedoTexture;
  79943. /** Gets or sets the texture to use for albedo color */
  79944. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79945. /**
  79946. * Creates a new Fluent material
  79947. * @param name defines the name of the material
  79948. * @param scene defines the hosting scene
  79949. */
  79950. constructor(name: string, scene: BABYLON.Scene);
  79951. needAlphaBlending(): boolean;
  79952. needAlphaTesting(): boolean;
  79953. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79954. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79955. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79956. getActiveTextures(): BABYLON.BaseTexture[];
  79957. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79958. dispose(forceDisposeEffect?: boolean): void;
  79959. clone(name: string): FluentMaterial;
  79960. serialize(): any;
  79961. getClassName(): string;
  79962. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  79963. }
  79964. }
  79965. declare module BABYLON.GUI {
  79966. /**
  79967. * Class used to create a holographic button in 3D
  79968. */
  79969. export class HolographicButton extends Button3D {
  79970. private _backPlate;
  79971. private _textPlate;
  79972. private _frontPlate;
  79973. private _text;
  79974. private _imageUrl;
  79975. private _shareMaterials;
  79976. private _frontMaterial;
  79977. private _backMaterial;
  79978. private _plateMaterial;
  79979. private _pickedPointObserver;
  79980. private _tooltipFade;
  79981. private _tooltipTextBlock;
  79982. private _tooltipTexture;
  79983. private _tooltipMesh;
  79984. private _tooltipHoverObserver;
  79985. private _tooltipOutObserver;
  79986. private _disposeTooltip;
  79987. /**
  79988. * Rendering ground id of all the mesh in the button
  79989. */
  79990. set renderingGroupId(id: number);
  79991. get renderingGroupId(): number;
  79992. /**
  79993. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  79994. */
  79995. set tooltipText(text: BABYLON.Nullable<string>);
  79996. get tooltipText(): BABYLON.Nullable<string>;
  79997. /**
  79998. * Gets or sets text for the button
  79999. */
  80000. get text(): string;
  80001. set text(value: string);
  80002. /**
  80003. * Gets or sets the image url for the button
  80004. */
  80005. get imageUrl(): string;
  80006. set imageUrl(value: string);
  80007. /**
  80008. * Gets the back material used by this button
  80009. */
  80010. get backMaterial(): FluentMaterial;
  80011. /**
  80012. * Gets the front material used by this button
  80013. */
  80014. get frontMaterial(): FluentMaterial;
  80015. /**
  80016. * Gets the plate material used by this button
  80017. */
  80018. get plateMaterial(): BABYLON.StandardMaterial;
  80019. /**
  80020. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  80021. */
  80022. get shareMaterials(): boolean;
  80023. /**
  80024. * Creates a new button
  80025. * @param name defines the control name
  80026. */
  80027. constructor(name?: string, shareMaterials?: boolean);
  80028. protected _getTypeName(): string;
  80029. private _rebuildContent;
  80030. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80031. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80032. private _createBackMaterial;
  80033. private _createFrontMaterial;
  80034. private _createPlateMaterial;
  80035. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  80036. /**
  80037. * Releases all associated resources
  80038. */
  80039. dispose(): void;
  80040. }
  80041. }
  80042. declare module BABYLON.GUI {
  80043. /**
  80044. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  80045. */
  80046. export class MeshButton3D extends Button3D {
  80047. /** @hidden */
  80048. protected _currentMesh: BABYLON.Mesh;
  80049. /**
  80050. * Creates a new 3D button based on a mesh
  80051. * @param mesh mesh to become a 3D button
  80052. * @param name defines the control name
  80053. */
  80054. constructor(mesh: BABYLON.Mesh, name?: string);
  80055. protected _getTypeName(): string;
  80056. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80057. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80058. }
  80059. }
  80060. declare module BABYLON.GUI {
  80061. /**
  80062. * Class used to create a container panel deployed on the surface of a plane
  80063. */
  80064. export class PlanePanel extends VolumeBasedPanel {
  80065. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80066. }
  80067. }
  80068. declare module BABYLON.GUI {
  80069. /**
  80070. * Class used to create a container panel where items get randomized planar mapping
  80071. */
  80072. export class ScatterPanel extends VolumeBasedPanel {
  80073. private _iteration;
  80074. /**
  80075. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  80076. */
  80077. get iteration(): BABYLON.float;
  80078. set iteration(value: BABYLON.float);
  80079. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80080. private _scatterMapping;
  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 sphere
  80087. */
  80088. export class SpherePanel extends VolumeBasedPanel {
  80089. private _radius;
  80090. /**
  80091. * Gets or sets the radius of the sphere 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 _sphericalMapping;
  80097. }
  80098. }
  80099. declare module BABYLON.GUI {
  80100. /**
  80101. * Class used to create a stack panel in 3D on XY plane
  80102. */
  80103. export class StackPanel3D extends Container3D {
  80104. private _isVertical;
  80105. /**
  80106. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  80107. */
  80108. get isVertical(): boolean;
  80109. set isVertical(value: boolean);
  80110. /**
  80111. * Gets or sets the distance between elements
  80112. */
  80113. margin: number;
  80114. /**
  80115. * Creates new StackPanel
  80116. * @param isVertical
  80117. */
  80118. constructor(isVertical?: boolean);
  80119. protected _arrangeChildren(): void;
  80120. }
  80121. }
  80122. declare module BABYLON {
  80123. /**
  80124. * Configuration for glTF validation
  80125. */
  80126. export interface IGLTFValidationConfiguration {
  80127. /**
  80128. * The url of the glTF validator.
  80129. */
  80130. url: string;
  80131. }
  80132. /**
  80133. * glTF validation
  80134. */
  80135. export class GLTFValidation {
  80136. /**
  80137. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  80138. */
  80139. static Configuration: IGLTFValidationConfiguration;
  80140. private static _LoadScriptPromise;
  80141. /**
  80142. * Validate a glTF asset using the glTF-Validator.
  80143. * @param data The JSON of a glTF or the array buffer of a binary glTF
  80144. * @param rootUrl The root url for the glTF
  80145. * @param fileName The file name for the glTF
  80146. * @param getExternalResource The callback to get external resources for the glTF validator
  80147. * @returns A promise that resolves with the glTF validation results once complete
  80148. */
  80149. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  80150. }
  80151. }
  80152. declare module BABYLON {
  80153. /**
  80154. * Mode that determines the coordinate system to use.
  80155. */
  80156. export enum GLTFLoaderCoordinateSystemMode {
  80157. /**
  80158. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  80159. */
  80160. AUTO = 0,
  80161. /**
  80162. * Sets the useRightHandedSystem flag on the scene.
  80163. */
  80164. FORCE_RIGHT_HANDED = 1
  80165. }
  80166. /**
  80167. * Mode that determines what animations will start.
  80168. */
  80169. export enum GLTFLoaderAnimationStartMode {
  80170. /**
  80171. * No animation will start.
  80172. */
  80173. NONE = 0,
  80174. /**
  80175. * The first animation will start.
  80176. */
  80177. FIRST = 1,
  80178. /**
  80179. * All animations will start.
  80180. */
  80181. ALL = 2
  80182. }
  80183. /**
  80184. * Interface that contains the data for the glTF asset.
  80185. */
  80186. export interface IGLTFLoaderData {
  80187. /**
  80188. * The object that represents the glTF JSON.
  80189. */
  80190. json: Object;
  80191. /**
  80192. * The BIN chunk of a binary glTF.
  80193. */
  80194. bin: Nullable<IDataBuffer>;
  80195. }
  80196. /**
  80197. * Interface for extending the loader.
  80198. */
  80199. export interface IGLTFLoaderExtension {
  80200. /**
  80201. * The name of this extension.
  80202. */
  80203. readonly name: string;
  80204. /**
  80205. * Defines whether this extension is enabled.
  80206. */
  80207. enabled: boolean;
  80208. /**
  80209. * Defines the order of this extension.
  80210. * The loader sorts the extensions using these values when loading.
  80211. */
  80212. order?: number;
  80213. }
  80214. /**
  80215. * Loader state.
  80216. */
  80217. export enum GLTFLoaderState {
  80218. /**
  80219. * The asset is loading.
  80220. */
  80221. LOADING = 0,
  80222. /**
  80223. * The asset is ready for rendering.
  80224. */
  80225. READY = 1,
  80226. /**
  80227. * The asset is completely loaded.
  80228. */
  80229. COMPLETE = 2
  80230. }
  80231. /** @hidden */
  80232. export interface IImportMeshAsyncOutput {
  80233. meshes: AbstractMesh[];
  80234. particleSystems: IParticleSystem[];
  80235. skeletons: Skeleton[];
  80236. animationGroups: AnimationGroup[];
  80237. lights: Light[];
  80238. transformNodes: TransformNode[];
  80239. }
  80240. /** @hidden */
  80241. export interface IGLTFLoader extends IDisposable {
  80242. readonly state: Nullable<GLTFLoaderState>;
  80243. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  80244. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  80245. }
  80246. /**
  80247. * File loader for loading glTF files into a scene.
  80248. */
  80249. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  80250. /** @hidden */
  80251. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80252. /** @hidden */
  80253. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  80254. /**
  80255. * Raised when the asset has been parsed
  80256. */
  80257. onParsedObservable: Observable<IGLTFLoaderData>;
  80258. private _onParsedObserver;
  80259. /**
  80260. * Raised when the asset has been parsed
  80261. */
  80262. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  80263. /**
  80264. * 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.
  80265. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  80266. * Defaults to true.
  80267. * @hidden
  80268. */
  80269. static IncrementalLoading: boolean;
  80270. /**
  80271. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  80272. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  80273. * @hidden
  80274. */
  80275. static HomogeneousCoordinates: boolean;
  80276. /**
  80277. * The coordinate system mode. Defaults to AUTO.
  80278. */
  80279. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  80280. /**
  80281. * The animation start mode. Defaults to FIRST.
  80282. */
  80283. animationStartMode: GLTFLoaderAnimationStartMode;
  80284. /**
  80285. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  80286. */
  80287. compileMaterials: boolean;
  80288. /**
  80289. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  80290. */
  80291. useClipPlane: boolean;
  80292. /**
  80293. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  80294. */
  80295. compileShadowGenerators: boolean;
  80296. /**
  80297. * Defines if the Alpha blended materials are only applied as coverage.
  80298. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  80299. * If true, no extra effects are applied to transparent pixels.
  80300. */
  80301. transparencyAsCoverage: boolean;
  80302. /**
  80303. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  80304. * Enabling will disable offline support and glTF validator.
  80305. * Defaults to false.
  80306. */
  80307. useRangeRequests: boolean;
  80308. /**
  80309. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  80310. */
  80311. createInstances: boolean;
  80312. /**
  80313. * 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.
  80314. */
  80315. alwaysComputeBoundingBox: boolean;
  80316. /**
  80317. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  80318. */
  80319. loadAllMaterials: boolean;
  80320. /**
  80321. * Function called before loading a url referenced by the asset.
  80322. */
  80323. preprocessUrlAsync: (url: string) => Promise<string>;
  80324. /**
  80325. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80326. * 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, ...)
  80327. */
  80328. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  80329. private _onMeshLoadedObserver;
  80330. /**
  80331. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  80332. * 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, ...)
  80333. */
  80334. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  80335. /**
  80336. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  80337. */
  80338. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  80339. private _onTextureLoadedObserver;
  80340. /**
  80341. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  80342. */
  80343. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  80344. /**
  80345. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  80346. */
  80347. readonly onMaterialLoadedObservable: Observable<Material>;
  80348. private _onMaterialLoadedObserver;
  80349. /**
  80350. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  80351. */
  80352. set onMaterialLoaded(callback: (material: Material) => void);
  80353. /**
  80354. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  80355. */
  80356. readonly onCameraLoadedObservable: Observable<Camera>;
  80357. private _onCameraLoadedObserver;
  80358. /**
  80359. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  80360. */
  80361. set onCameraLoaded(callback: (camera: Camera) => void);
  80362. /**
  80363. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  80364. * For assets with LODs, raised when all of the LODs are complete.
  80365. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80366. */
  80367. readonly onCompleteObservable: Observable<void>;
  80368. private _onCompleteObserver;
  80369. /**
  80370. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  80371. * For assets with LODs, raised when all of the LODs are complete.
  80372. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  80373. */
  80374. set onComplete(callback: () => void);
  80375. /**
  80376. * Observable raised when an error occurs.
  80377. */
  80378. readonly onErrorObservable: Observable<any>;
  80379. private _onErrorObserver;
  80380. /**
  80381. * Callback raised when an error occurs.
  80382. */
  80383. set onError(callback: (reason: any) => void);
  80384. /**
  80385. * Observable raised after the loader is disposed.
  80386. */
  80387. readonly onDisposeObservable: Observable<void>;
  80388. private _onDisposeObserver;
  80389. /**
  80390. * Callback raised after the loader is disposed.
  80391. */
  80392. set onDispose(callback: () => void);
  80393. /**
  80394. * Observable raised after a loader extension is created.
  80395. * Set additional options for a loader extension in this event.
  80396. */
  80397. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  80398. private _onExtensionLoadedObserver;
  80399. /**
  80400. * Callback raised after a loader extension is created.
  80401. */
  80402. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  80403. /**
  80404. * Defines if the loader logging is enabled.
  80405. */
  80406. get loggingEnabled(): boolean;
  80407. set loggingEnabled(value: boolean);
  80408. /**
  80409. * Defines if the loader should capture performance counters.
  80410. */
  80411. get capturePerformanceCounters(): boolean;
  80412. set capturePerformanceCounters(value: boolean);
  80413. /**
  80414. * Defines if the loader should validate the asset.
  80415. */
  80416. validate: boolean;
  80417. /**
  80418. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  80419. */
  80420. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  80421. private _onValidatedObserver;
  80422. /**
  80423. * Callback raised after a loader extension is created.
  80424. */
  80425. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  80426. private _loader;
  80427. private _progressCallback?;
  80428. private _requests;
  80429. private static magicBase64Encoded;
  80430. /**
  80431. * Name of the loader ("gltf")
  80432. */
  80433. name: string;
  80434. /** @hidden */
  80435. extensions: ISceneLoaderPluginExtensions;
  80436. /**
  80437. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  80438. */
  80439. dispose(): void;
  80440. /** @hidden */
  80441. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80442. /** @hidden */
  80443. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  80444. /** @hidden */
  80445. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  80446. meshes: AbstractMesh[];
  80447. particleSystems: IParticleSystem[];
  80448. skeletons: Skeleton[];
  80449. animationGroups: AnimationGroup[];
  80450. }>;
  80451. /** @hidden */
  80452. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80453. /** @hidden */
  80454. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  80455. /** @hidden */
  80456. canDirectLoad(data: string): boolean;
  80457. /** @hidden */
  80458. directLoad(scene: Scene, data: string): Promise<any>;
  80459. /**
  80460. * The callback that allows custom handling of the root url based on the response url.
  80461. * @param rootUrl the original root url
  80462. * @param responseURL the response url if available
  80463. * @returns the new root url
  80464. */
  80465. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  80466. /** @hidden */
  80467. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  80468. /**
  80469. * The loader state or null if the loader is not active.
  80470. */
  80471. get loaderState(): Nullable<GLTFLoaderState>;
  80472. /**
  80473. * Returns a promise that resolves when the asset is completely loaded.
  80474. * @returns a promise that resolves when the asset is completely loaded.
  80475. */
  80476. whenCompleteAsync(): Promise<void>;
  80477. /** @hidden */
  80478. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  80479. /** @hidden */
  80480. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  80481. private _onProgress;
  80482. private _validate;
  80483. private _getLoader;
  80484. private _parseJson;
  80485. private _unpackBinaryAsync;
  80486. private _unpackBinaryV1Async;
  80487. private _unpackBinaryV2Async;
  80488. private static _parseVersion;
  80489. private static _compareVersion;
  80490. private static readonly _logSpaces;
  80491. private _logIndentLevel;
  80492. private _loggingEnabled;
  80493. /** @hidden */
  80494. _log: (message: string) => void;
  80495. /** @hidden */
  80496. _logOpen(message: string): void;
  80497. /** @hidden */
  80498. _logClose(): void;
  80499. private _logEnabled;
  80500. private _logDisabled;
  80501. private _capturePerformanceCounters;
  80502. /** @hidden */
  80503. _startPerformanceCounter: (counterName: string) => void;
  80504. /** @hidden */
  80505. _endPerformanceCounter: (counterName: string) => void;
  80506. private _startPerformanceCounterEnabled;
  80507. private _startPerformanceCounterDisabled;
  80508. private _endPerformanceCounterEnabled;
  80509. private _endPerformanceCounterDisabled;
  80510. }
  80511. }
  80512. declare module BABYLON.GLTF1 {
  80513. /**
  80514. * Enums
  80515. * @hidden
  80516. */
  80517. export enum EComponentType {
  80518. BYTE = 5120,
  80519. UNSIGNED_BYTE = 5121,
  80520. SHORT = 5122,
  80521. UNSIGNED_SHORT = 5123,
  80522. FLOAT = 5126
  80523. }
  80524. /** @hidden */
  80525. export enum EShaderType {
  80526. FRAGMENT = 35632,
  80527. VERTEX = 35633
  80528. }
  80529. /** @hidden */
  80530. export enum EParameterType {
  80531. BYTE = 5120,
  80532. UNSIGNED_BYTE = 5121,
  80533. SHORT = 5122,
  80534. UNSIGNED_SHORT = 5123,
  80535. INT = 5124,
  80536. UNSIGNED_INT = 5125,
  80537. FLOAT = 5126,
  80538. FLOAT_VEC2 = 35664,
  80539. FLOAT_VEC3 = 35665,
  80540. FLOAT_VEC4 = 35666,
  80541. INT_VEC2 = 35667,
  80542. INT_VEC3 = 35668,
  80543. INT_VEC4 = 35669,
  80544. BOOL = 35670,
  80545. BOOL_VEC2 = 35671,
  80546. BOOL_VEC3 = 35672,
  80547. BOOL_VEC4 = 35673,
  80548. FLOAT_MAT2 = 35674,
  80549. FLOAT_MAT3 = 35675,
  80550. FLOAT_MAT4 = 35676,
  80551. SAMPLER_2D = 35678
  80552. }
  80553. /** @hidden */
  80554. export enum ETextureWrapMode {
  80555. CLAMP_TO_EDGE = 33071,
  80556. MIRRORED_REPEAT = 33648,
  80557. REPEAT = 10497
  80558. }
  80559. /** @hidden */
  80560. export enum ETextureFilterType {
  80561. NEAREST = 9728,
  80562. LINEAR = 9728,
  80563. NEAREST_MIPMAP_NEAREST = 9984,
  80564. LINEAR_MIPMAP_NEAREST = 9985,
  80565. NEAREST_MIPMAP_LINEAR = 9986,
  80566. LINEAR_MIPMAP_LINEAR = 9987
  80567. }
  80568. /** @hidden */
  80569. export enum ETextureFormat {
  80570. ALPHA = 6406,
  80571. RGB = 6407,
  80572. RGBA = 6408,
  80573. LUMINANCE = 6409,
  80574. LUMINANCE_ALPHA = 6410
  80575. }
  80576. /** @hidden */
  80577. export enum ECullingType {
  80578. FRONT = 1028,
  80579. BACK = 1029,
  80580. FRONT_AND_BACK = 1032
  80581. }
  80582. /** @hidden */
  80583. export enum EBlendingFunction {
  80584. ZERO = 0,
  80585. ONE = 1,
  80586. SRC_COLOR = 768,
  80587. ONE_MINUS_SRC_COLOR = 769,
  80588. DST_COLOR = 774,
  80589. ONE_MINUS_DST_COLOR = 775,
  80590. SRC_ALPHA = 770,
  80591. ONE_MINUS_SRC_ALPHA = 771,
  80592. DST_ALPHA = 772,
  80593. ONE_MINUS_DST_ALPHA = 773,
  80594. CONSTANT_COLOR = 32769,
  80595. ONE_MINUS_CONSTANT_COLOR = 32770,
  80596. CONSTANT_ALPHA = 32771,
  80597. ONE_MINUS_CONSTANT_ALPHA = 32772,
  80598. SRC_ALPHA_SATURATE = 776
  80599. }
  80600. /** @hidden */
  80601. export interface IGLTFProperty {
  80602. extensions?: {
  80603. [key: string]: any;
  80604. };
  80605. extras?: Object;
  80606. }
  80607. /** @hidden */
  80608. export interface IGLTFChildRootProperty extends IGLTFProperty {
  80609. name?: string;
  80610. }
  80611. /** @hidden */
  80612. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  80613. bufferView: string;
  80614. byteOffset: number;
  80615. byteStride: number;
  80616. count: number;
  80617. type: string;
  80618. componentType: EComponentType;
  80619. max?: number[];
  80620. min?: number[];
  80621. name?: string;
  80622. }
  80623. /** @hidden */
  80624. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  80625. buffer: string;
  80626. byteOffset: number;
  80627. byteLength: number;
  80628. byteStride: number;
  80629. target?: number;
  80630. }
  80631. /** @hidden */
  80632. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  80633. uri: string;
  80634. byteLength?: number;
  80635. type?: string;
  80636. }
  80637. /** @hidden */
  80638. export interface IGLTFShader extends IGLTFChildRootProperty {
  80639. uri: string;
  80640. type: EShaderType;
  80641. }
  80642. /** @hidden */
  80643. export interface IGLTFProgram extends IGLTFChildRootProperty {
  80644. attributes: string[];
  80645. fragmentShader: string;
  80646. vertexShader: string;
  80647. }
  80648. /** @hidden */
  80649. export interface IGLTFTechniqueParameter {
  80650. type: number;
  80651. count?: number;
  80652. semantic?: string;
  80653. node?: string;
  80654. value?: number | boolean | string | Array<any>;
  80655. source?: string;
  80656. babylonValue?: any;
  80657. }
  80658. /** @hidden */
  80659. export interface IGLTFTechniqueCommonProfile {
  80660. lightingModel: string;
  80661. texcoordBindings: Object;
  80662. parameters?: Array<any>;
  80663. }
  80664. /** @hidden */
  80665. export interface IGLTFTechniqueStatesFunctions {
  80666. blendColor?: number[];
  80667. blendEquationSeparate?: number[];
  80668. blendFuncSeparate?: number[];
  80669. colorMask: boolean[];
  80670. cullFace: number[];
  80671. }
  80672. /** @hidden */
  80673. export interface IGLTFTechniqueStates {
  80674. enable: number[];
  80675. functions: IGLTFTechniqueStatesFunctions;
  80676. }
  80677. /** @hidden */
  80678. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  80679. parameters: {
  80680. [key: string]: IGLTFTechniqueParameter;
  80681. };
  80682. program: string;
  80683. attributes: {
  80684. [key: string]: string;
  80685. };
  80686. uniforms: {
  80687. [key: string]: string;
  80688. };
  80689. states: IGLTFTechniqueStates;
  80690. }
  80691. /** @hidden */
  80692. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  80693. technique?: string;
  80694. values: string[];
  80695. }
  80696. /** @hidden */
  80697. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  80698. attributes: {
  80699. [key: string]: string;
  80700. };
  80701. indices: string;
  80702. material: string;
  80703. mode?: number;
  80704. }
  80705. /** @hidden */
  80706. export interface IGLTFMesh extends IGLTFChildRootProperty {
  80707. primitives: IGLTFMeshPrimitive[];
  80708. }
  80709. /** @hidden */
  80710. export interface IGLTFImage extends IGLTFChildRootProperty {
  80711. uri: string;
  80712. }
  80713. /** @hidden */
  80714. export interface IGLTFSampler extends IGLTFChildRootProperty {
  80715. magFilter?: number;
  80716. minFilter?: number;
  80717. wrapS?: number;
  80718. wrapT?: number;
  80719. }
  80720. /** @hidden */
  80721. export interface IGLTFTexture extends IGLTFChildRootProperty {
  80722. sampler: string;
  80723. source: string;
  80724. format?: ETextureFormat;
  80725. internalFormat?: ETextureFormat;
  80726. target?: number;
  80727. type?: number;
  80728. babylonTexture?: Texture;
  80729. }
  80730. /** @hidden */
  80731. export interface IGLTFAmbienLight {
  80732. color?: number[];
  80733. }
  80734. /** @hidden */
  80735. export interface IGLTFDirectionalLight {
  80736. color?: number[];
  80737. }
  80738. /** @hidden */
  80739. export interface IGLTFPointLight {
  80740. color?: number[];
  80741. constantAttenuation?: number;
  80742. linearAttenuation?: number;
  80743. quadraticAttenuation?: number;
  80744. }
  80745. /** @hidden */
  80746. export interface IGLTFSpotLight {
  80747. color?: number[];
  80748. constantAttenuation?: number;
  80749. fallOfAngle?: number;
  80750. fallOffExponent?: number;
  80751. linearAttenuation?: number;
  80752. quadraticAttenuation?: number;
  80753. }
  80754. /** @hidden */
  80755. export interface IGLTFLight extends IGLTFChildRootProperty {
  80756. type: string;
  80757. }
  80758. /** @hidden */
  80759. export interface IGLTFCameraOrthographic {
  80760. xmag: number;
  80761. ymag: number;
  80762. zfar: number;
  80763. znear: number;
  80764. }
  80765. /** @hidden */
  80766. export interface IGLTFCameraPerspective {
  80767. aspectRatio: number;
  80768. yfov: number;
  80769. zfar: number;
  80770. znear: number;
  80771. }
  80772. /** @hidden */
  80773. export interface IGLTFCamera extends IGLTFChildRootProperty {
  80774. type: string;
  80775. }
  80776. /** @hidden */
  80777. export interface IGLTFAnimationChannelTarget {
  80778. id: string;
  80779. path: string;
  80780. }
  80781. /** @hidden */
  80782. export interface IGLTFAnimationChannel {
  80783. sampler: string;
  80784. target: IGLTFAnimationChannelTarget;
  80785. }
  80786. /** @hidden */
  80787. export interface IGLTFAnimationSampler {
  80788. input: string;
  80789. output: string;
  80790. interpolation?: string;
  80791. }
  80792. /** @hidden */
  80793. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  80794. channels?: IGLTFAnimationChannel[];
  80795. parameters?: {
  80796. [key: string]: string;
  80797. };
  80798. samplers?: {
  80799. [key: string]: IGLTFAnimationSampler;
  80800. };
  80801. }
  80802. /** @hidden */
  80803. export interface IGLTFNodeInstanceSkin {
  80804. skeletons: string[];
  80805. skin: string;
  80806. meshes: string[];
  80807. }
  80808. /** @hidden */
  80809. export interface IGLTFSkins extends IGLTFChildRootProperty {
  80810. bindShapeMatrix: number[];
  80811. inverseBindMatrices: string;
  80812. jointNames: string[];
  80813. babylonSkeleton?: Skeleton;
  80814. }
  80815. /** @hidden */
  80816. export interface IGLTFNode extends IGLTFChildRootProperty {
  80817. camera?: string;
  80818. children: string[];
  80819. skin?: string;
  80820. jointName?: string;
  80821. light?: string;
  80822. matrix: number[];
  80823. mesh?: string;
  80824. meshes?: string[];
  80825. rotation?: number[];
  80826. scale?: number[];
  80827. translation?: number[];
  80828. babylonNode?: Node;
  80829. }
  80830. /** @hidden */
  80831. export interface IGLTFScene extends IGLTFChildRootProperty {
  80832. nodes: string[];
  80833. }
  80834. /** @hidden */
  80835. export interface IGLTFRuntime {
  80836. extensions: {
  80837. [key: string]: any;
  80838. };
  80839. accessors: {
  80840. [key: string]: IGLTFAccessor;
  80841. };
  80842. buffers: {
  80843. [key: string]: IGLTFBuffer;
  80844. };
  80845. bufferViews: {
  80846. [key: string]: IGLTFBufferView;
  80847. };
  80848. meshes: {
  80849. [key: string]: IGLTFMesh;
  80850. };
  80851. lights: {
  80852. [key: string]: IGLTFLight;
  80853. };
  80854. cameras: {
  80855. [key: string]: IGLTFCamera;
  80856. };
  80857. nodes: {
  80858. [key: string]: IGLTFNode;
  80859. };
  80860. images: {
  80861. [key: string]: IGLTFImage;
  80862. };
  80863. textures: {
  80864. [key: string]: IGLTFTexture;
  80865. };
  80866. shaders: {
  80867. [key: string]: IGLTFShader;
  80868. };
  80869. programs: {
  80870. [key: string]: IGLTFProgram;
  80871. };
  80872. samplers: {
  80873. [key: string]: IGLTFSampler;
  80874. };
  80875. techniques: {
  80876. [key: string]: IGLTFTechnique;
  80877. };
  80878. materials: {
  80879. [key: string]: IGLTFMaterial;
  80880. };
  80881. animations: {
  80882. [key: string]: IGLTFAnimation;
  80883. };
  80884. skins: {
  80885. [key: string]: IGLTFSkins;
  80886. };
  80887. currentScene?: Object;
  80888. scenes: {
  80889. [key: string]: IGLTFScene;
  80890. };
  80891. extensionsUsed: string[];
  80892. extensionsRequired?: string[];
  80893. buffersCount: number;
  80894. shaderscount: number;
  80895. scene: Scene;
  80896. rootUrl: string;
  80897. loadedBufferCount: number;
  80898. loadedBufferViews: {
  80899. [name: string]: ArrayBufferView;
  80900. };
  80901. loadedShaderCount: number;
  80902. importOnlyMeshes: boolean;
  80903. importMeshesNames?: string[];
  80904. dummyNodes: Node[];
  80905. forAssetContainer: boolean;
  80906. }
  80907. /** @hidden */
  80908. export interface INodeToRoot {
  80909. bone: Bone;
  80910. node: IGLTFNode;
  80911. id: string;
  80912. }
  80913. /** @hidden */
  80914. export interface IJointNode {
  80915. node: IGLTFNode;
  80916. id: string;
  80917. }
  80918. }
  80919. declare module BABYLON.GLTF1 {
  80920. /**
  80921. * Utils functions for GLTF
  80922. * @hidden
  80923. */
  80924. export class GLTFUtils {
  80925. /**
  80926. * Sets the given "parameter" matrix
  80927. * @param scene: the Scene object
  80928. * @param source: the source node where to pick the matrix
  80929. * @param parameter: the GLTF technique parameter
  80930. * @param uniformName: the name of the shader's uniform
  80931. * @param shaderMaterial: the shader material
  80932. */
  80933. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  80934. /**
  80935. * Sets the given "parameter" matrix
  80936. * @param shaderMaterial: the shader material
  80937. * @param uniform: the name of the shader's uniform
  80938. * @param value: the value of the uniform
  80939. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  80940. */
  80941. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  80942. /**
  80943. * Returns the wrap mode of the texture
  80944. * @param mode: the mode value
  80945. */
  80946. static GetWrapMode(mode: number): number;
  80947. /**
  80948. * Returns the byte stride giving an accessor
  80949. * @param accessor: the GLTF accessor objet
  80950. */
  80951. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  80952. /**
  80953. * Returns the texture filter mode giving a mode value
  80954. * @param mode: the filter mode value
  80955. */
  80956. static GetTextureFilterMode(mode: number): ETextureFilterType;
  80957. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  80958. /**
  80959. * Returns a buffer from its accessor
  80960. * @param gltfRuntime: the GLTF runtime
  80961. * @param accessor: the GLTF accessor
  80962. */
  80963. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  80964. /**
  80965. * Decodes a buffer view into a string
  80966. * @param view: the buffer view
  80967. */
  80968. static DecodeBufferToText(view: ArrayBufferView): string;
  80969. /**
  80970. * Returns the default material of gltf. Related to
  80971. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  80972. * @param scene: the Babylon.js scene
  80973. */
  80974. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  80975. private static _DefaultMaterial;
  80976. }
  80977. }
  80978. declare module BABYLON.GLTF1 {
  80979. /**
  80980. * Implementation of the base glTF spec
  80981. * @hidden
  80982. */
  80983. export class GLTFLoaderBase {
  80984. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  80985. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80986. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  80987. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80988. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  80989. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80990. }
  80991. /**
  80992. * glTF V1 Loader
  80993. * @hidden
  80994. */
  80995. export class GLTFLoader implements IGLTFLoader {
  80996. static Extensions: {
  80997. [name: string]: GLTFLoaderExtension;
  80998. };
  80999. static RegisterExtension(extension: GLTFLoaderExtension): void;
  81000. state: Nullable<GLTFLoaderState>;
  81001. dispose(): void;
  81002. private _importMeshAsync;
  81003. /**
  81004. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  81005. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81006. * @param scene the scene the meshes should be added to
  81007. * @param forAssetContainer defines if the entities must be stored in the scene
  81008. * @param data gltf data containing information of the meshes in a loaded file
  81009. * @param rootUrl root url to load from
  81010. * @param onProgress event that fires when loading progress has occured
  81011. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81012. */
  81013. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  81014. private _loadAsync;
  81015. /**
  81016. * Imports all objects from a loaded gltf file and adds them to the scene
  81017. * @param scene the scene the objects should be added to
  81018. * @param data gltf data containing information of the meshes in a loaded file
  81019. * @param rootUrl root url to load from
  81020. * @param onProgress event that fires when loading progress has occured
  81021. * @returns a promise which completes when objects have been loaded to the scene
  81022. */
  81023. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  81024. private _loadShadersAsync;
  81025. private _loadBuffersAsync;
  81026. private _createNodes;
  81027. }
  81028. /** @hidden */
  81029. export abstract class GLTFLoaderExtension {
  81030. private _name;
  81031. constructor(name: string);
  81032. get name(): string;
  81033. /**
  81034. * Defines an override for loading the runtime
  81035. * Return true to stop further extensions from loading the runtime
  81036. */
  81037. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  81038. /**
  81039. * Defines an onverride for creating gltf runtime
  81040. * Return true to stop further extensions from creating the runtime
  81041. */
  81042. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  81043. /**
  81044. * Defines an override for loading buffers
  81045. * Return true to stop further extensions from loading this buffer
  81046. */
  81047. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  81048. /**
  81049. * Defines an override for loading texture buffers
  81050. * Return true to stop further extensions from loading this texture data
  81051. */
  81052. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81053. /**
  81054. * Defines an override for creating textures
  81055. * Return true to stop further extensions from loading this texture
  81056. */
  81057. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  81058. /**
  81059. * Defines an override for loading shader strings
  81060. * Return true to stop further extensions from loading this shader data
  81061. */
  81062. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81063. /**
  81064. * Defines an override for loading materials
  81065. * Return true to stop further extensions from loading this material
  81066. */
  81067. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81068. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  81069. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  81070. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81071. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81072. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  81073. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81074. private static LoadTextureBufferAsync;
  81075. private static CreateTextureAsync;
  81076. private static ApplyExtensions;
  81077. }
  81078. }
  81079. declare module BABYLON.GLTF1 {
  81080. /** @hidden */
  81081. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  81082. private _bin;
  81083. constructor();
  81084. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  81085. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81086. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81087. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81088. }
  81089. }
  81090. declare module BABYLON.GLTF1 {
  81091. /** @hidden */
  81092. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  81093. constructor();
  81094. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  81095. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81096. private _loadTexture;
  81097. }
  81098. }
  81099. declare module BABYLON.GLTF2.Loader {
  81100. /**
  81101. * Loader interface with an index field.
  81102. */
  81103. export interface IArrayItem {
  81104. /**
  81105. * The index of this item in the array.
  81106. */
  81107. index: number;
  81108. }
  81109. /**
  81110. * Loader interface with additional members.
  81111. */
  81112. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  81113. /** @hidden */
  81114. _data?: Promise<ArrayBufferView>;
  81115. /** @hidden */
  81116. _babylonVertexBuffer?: Promise<VertexBuffer>;
  81117. }
  81118. /**
  81119. * Loader interface with additional members.
  81120. */
  81121. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  81122. }
  81123. /** @hidden */
  81124. export interface _IAnimationSamplerData {
  81125. input: Float32Array;
  81126. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  81127. output: Float32Array;
  81128. }
  81129. /**
  81130. * Loader interface with additional members.
  81131. */
  81132. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  81133. /** @hidden */
  81134. _data?: Promise<_IAnimationSamplerData>;
  81135. }
  81136. /**
  81137. * Loader interface with additional members.
  81138. */
  81139. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  81140. channels: IAnimationChannel[];
  81141. samplers: IAnimationSampler[];
  81142. /** @hidden */
  81143. _babylonAnimationGroup?: AnimationGroup;
  81144. }
  81145. /**
  81146. * Loader interface with additional members.
  81147. */
  81148. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  81149. /** @hidden */
  81150. _data?: Promise<ArrayBufferView>;
  81151. }
  81152. /**
  81153. * Loader interface with additional members.
  81154. */
  81155. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  81156. /** @hidden */
  81157. _data?: Promise<ArrayBufferView>;
  81158. /** @hidden */
  81159. _babylonBuffer?: Promise<Buffer>;
  81160. }
  81161. /**
  81162. * Loader interface with additional members.
  81163. */
  81164. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  81165. }
  81166. /**
  81167. * Loader interface with additional members.
  81168. */
  81169. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  81170. /** @hidden */
  81171. _data?: Promise<ArrayBufferView>;
  81172. }
  81173. /**
  81174. * Loader interface with additional members.
  81175. */
  81176. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  81177. }
  81178. /**
  81179. * Loader interface with additional members.
  81180. */
  81181. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  81182. }
  81183. /**
  81184. * Loader interface with additional members.
  81185. */
  81186. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  81187. baseColorTexture?: ITextureInfo;
  81188. metallicRoughnessTexture?: ITextureInfo;
  81189. }
  81190. /**
  81191. * Loader interface with additional members.
  81192. */
  81193. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  81194. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81195. normalTexture?: IMaterialNormalTextureInfo;
  81196. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81197. emissiveTexture?: ITextureInfo;
  81198. /** @hidden */
  81199. _data?: {
  81200. [babylonDrawMode: number]: {
  81201. babylonMaterial: Material;
  81202. babylonMeshes: AbstractMesh[];
  81203. promise: Promise<void>;
  81204. };
  81205. };
  81206. }
  81207. /**
  81208. * Loader interface with additional members.
  81209. */
  81210. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  81211. primitives: IMeshPrimitive[];
  81212. }
  81213. /**
  81214. * Loader interface with additional members.
  81215. */
  81216. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  81217. /** @hidden */
  81218. _instanceData?: {
  81219. babylonSourceMesh: Mesh;
  81220. promise: Promise<any>;
  81221. };
  81222. }
  81223. /**
  81224. * Loader interface with additional members.
  81225. */
  81226. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  81227. /**
  81228. * The parent glTF node.
  81229. */
  81230. parent?: INode;
  81231. /** @hidden */
  81232. _babylonTransformNode?: TransformNode;
  81233. /** @hidden */
  81234. _primitiveBabylonMeshes?: AbstractMesh[];
  81235. /** @hidden */
  81236. _babylonBones?: Bone[];
  81237. /** @hidden */
  81238. _numMorphTargets?: number;
  81239. }
  81240. /** @hidden */
  81241. export interface _ISamplerData {
  81242. noMipMaps: boolean;
  81243. samplingMode: number;
  81244. wrapU: number;
  81245. wrapV: number;
  81246. }
  81247. /**
  81248. * Loader interface with additional members.
  81249. */
  81250. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  81251. /** @hidden */
  81252. _data?: _ISamplerData;
  81253. }
  81254. /**
  81255. * Loader interface with additional members.
  81256. */
  81257. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  81258. }
  81259. /**
  81260. * Loader interface with additional members.
  81261. */
  81262. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  81263. /** @hidden */
  81264. _data?: {
  81265. babylonSkeleton: Skeleton;
  81266. promise: Promise<void>;
  81267. };
  81268. }
  81269. /**
  81270. * Loader interface with additional members.
  81271. */
  81272. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  81273. }
  81274. /**
  81275. * Loader interface with additional members.
  81276. */
  81277. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  81278. }
  81279. /**
  81280. * Loader interface with additional members.
  81281. */
  81282. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  81283. accessors?: IAccessor[];
  81284. animations?: IAnimation[];
  81285. buffers?: IBuffer[];
  81286. bufferViews?: IBufferView[];
  81287. cameras?: ICamera[];
  81288. images?: IImage[];
  81289. materials?: IMaterial[];
  81290. meshes?: IMesh[];
  81291. nodes?: INode[];
  81292. samplers?: ISampler[];
  81293. scenes?: IScene[];
  81294. skins?: ISkin[];
  81295. textures?: ITexture[];
  81296. }
  81297. }
  81298. declare module BABYLON.GLTF2 {
  81299. /**
  81300. * Interface for a glTF loader extension.
  81301. */
  81302. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  81303. /**
  81304. * Called after the loader state changes to LOADING.
  81305. */
  81306. onLoading?(): void;
  81307. /**
  81308. * Called after the loader state changes to READY.
  81309. */
  81310. onReady?(): void;
  81311. /**
  81312. * Define this method to modify the default behavior when loading scenes.
  81313. * @param context The context when loading the asset
  81314. * @param scene The glTF scene property
  81315. * @returns A promise that resolves when the load is complete or null if not handled
  81316. */
  81317. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  81318. /**
  81319. * Define this method to modify the default behavior when loading nodes.
  81320. * @param context The context when loading the asset
  81321. * @param node The glTF node property
  81322. * @param assign A function called synchronously after parsing the glTF properties
  81323. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  81324. */
  81325. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81326. /**
  81327. * Define this method to modify the default behavior when loading cameras.
  81328. * @param context The context when loading the asset
  81329. * @param camera The glTF camera property
  81330. * @param assign A function called synchronously after parsing the glTF properties
  81331. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  81332. */
  81333. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81334. /**
  81335. * @hidden
  81336. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  81337. * @param context The context when loading the asset
  81338. * @param primitive The glTF mesh primitive property
  81339. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  81340. */
  81341. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81342. /**
  81343. * @hidden
  81344. * Define this method to modify the default behavior when loading data for mesh primitives.
  81345. * @param context The context when loading the asset
  81346. * @param name The mesh name when loading the asset
  81347. * @param node The glTF node when loading the asset
  81348. * @param mesh The glTF mesh when loading the asset
  81349. * @param primitive The glTF mesh primitive property
  81350. * @param assign A function called synchronously after parsing the glTF properties
  81351. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81352. */
  81353. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81354. /**
  81355. * @hidden
  81356. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  81357. * @param context The context when loading the asset
  81358. * @param material The glTF material property
  81359. * @param assign A function called synchronously after parsing the glTF properties
  81360. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  81361. */
  81362. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81363. /**
  81364. * Define this method to modify the default behavior when creating materials.
  81365. * @param context The context when loading the asset
  81366. * @param material The glTF material property
  81367. * @param babylonDrawMode The draw mode for the Babylon material
  81368. * @returns The Babylon material or null if not handled
  81369. */
  81370. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81371. /**
  81372. * Define this method to modify the default behavior when loading material properties.
  81373. * @param context The context when loading the asset
  81374. * @param material The glTF material property
  81375. * @param babylonMaterial The Babylon material
  81376. * @returns A promise that resolves when the load is complete or null if not handled
  81377. */
  81378. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81379. /**
  81380. * Define this method to modify the default behavior when loading texture infos.
  81381. * @param context The context when loading the asset
  81382. * @param textureInfo The glTF texture info property
  81383. * @param assign A function called synchronously after parsing the glTF properties
  81384. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81385. */
  81386. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81387. /**
  81388. * @hidden
  81389. * Define this method to modify the default behavior when loading textures.
  81390. * @param context The context when loading the asset
  81391. * @param texture The glTF texture property
  81392. * @param assign A function called synchronously after parsing the glTF properties
  81393. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  81394. */
  81395. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81396. /**
  81397. * Define this method to modify the default behavior when loading animations.
  81398. * @param context The context when loading the asset
  81399. * @param animation The glTF animation property
  81400. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  81401. */
  81402. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81403. /**
  81404. * @hidden
  81405. * Define this method to modify the default behavior when loading skins.
  81406. * @param context The context when loading the asset
  81407. * @param node The glTF node property
  81408. * @param skin The glTF skin property
  81409. * @returns A promise that resolves when the load is complete or null if not handled
  81410. */
  81411. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  81412. /**
  81413. * @hidden
  81414. * Define this method to modify the default behavior when loading uris.
  81415. * @param context The context when loading the asset
  81416. * @param property The glTF property associated with the uri
  81417. * @param uri The uri to load
  81418. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81419. */
  81420. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81421. /**
  81422. * Define this method to modify the default behavior when loading buffer views.
  81423. * @param context The context when loading the asset
  81424. * @param bufferView The glTF buffer view property
  81425. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81426. */
  81427. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  81428. /**
  81429. * Define this method to modify the default behavior when loading buffers.
  81430. * @param context The context when loading the asset
  81431. * @param buffer The glTF buffer property
  81432. * @param byteOffset The byte offset to load
  81433. * @param byteLength The byte length to load
  81434. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  81435. */
  81436. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81437. }
  81438. }
  81439. declare module BABYLON.GLTF2 {
  81440. /**
  81441. * Helper class for working with arrays when loading the glTF asset
  81442. */
  81443. export class ArrayItem {
  81444. /**
  81445. * Gets an item from the given array.
  81446. * @param context The context when loading the asset
  81447. * @param array The array to get the item from
  81448. * @param index The index to the array
  81449. * @returns The array item
  81450. */
  81451. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  81452. /**
  81453. * Assign an `index` field to each item of the given array.
  81454. * @param array The array of items
  81455. */
  81456. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  81457. }
  81458. /**
  81459. * The glTF 2.0 loader
  81460. */
  81461. export class GLTFLoader implements IGLTFLoader {
  81462. /** @hidden */
  81463. _completePromises: Promise<any>[];
  81464. /** @hidden */
  81465. _forAssetContainer: boolean;
  81466. /** Storage */
  81467. _babylonLights: Light[];
  81468. /** @hidden */
  81469. _disableInstancedMesh: number;
  81470. private _disposed;
  81471. private _parent;
  81472. private _state;
  81473. private _extensions;
  81474. private _rootUrl;
  81475. private _fileName;
  81476. private _uniqueRootUrl;
  81477. private _gltf;
  81478. private _bin;
  81479. private _babylonScene;
  81480. private _rootBabylonMesh;
  81481. private _defaultBabylonMaterialData;
  81482. private static _RegisteredExtensions;
  81483. /**
  81484. * The default glTF sampler.
  81485. */
  81486. static readonly DefaultSampler: ISampler;
  81487. /**
  81488. * Registers a loader extension.
  81489. * @param name The name of the loader extension.
  81490. * @param factory The factory function that creates the loader extension.
  81491. */
  81492. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  81493. /**
  81494. * Unregisters a loader extension.
  81495. * @param name The name of the loader extension.
  81496. * @returns A boolean indicating whether the extension has been unregistered
  81497. */
  81498. static UnregisterExtension(name: string): boolean;
  81499. /**
  81500. * The loader state.
  81501. */
  81502. get state(): Nullable<GLTFLoaderState>;
  81503. /**
  81504. * The object that represents the glTF JSON.
  81505. */
  81506. get gltf(): IGLTF;
  81507. /**
  81508. * The BIN chunk of a binary glTF.
  81509. */
  81510. get bin(): Nullable<IDataBuffer>;
  81511. /**
  81512. * The parent file loader.
  81513. */
  81514. get parent(): GLTFFileLoader;
  81515. /**
  81516. * The Babylon scene when loading the asset.
  81517. */
  81518. get babylonScene(): Scene;
  81519. /**
  81520. * The root Babylon mesh when loading the asset.
  81521. */
  81522. get rootBabylonMesh(): Mesh;
  81523. /** @hidden */
  81524. constructor(parent: GLTFFileLoader);
  81525. /** @hidden */
  81526. dispose(): void;
  81527. /** @hidden */
  81528. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  81529. /** @hidden */
  81530. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81531. private _loadAsync;
  81532. private _loadData;
  81533. private _setupData;
  81534. private _loadExtensions;
  81535. private _checkExtensions;
  81536. private _setState;
  81537. private _createRootNode;
  81538. /**
  81539. * Loads a glTF scene.
  81540. * @param context The context when loading the asset
  81541. * @param scene The glTF scene property
  81542. * @returns A promise that resolves when the load is complete
  81543. */
  81544. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  81545. private _forEachPrimitive;
  81546. private _getMeshes;
  81547. private _getTransformNodes;
  81548. private _getSkeletons;
  81549. private _getAnimationGroups;
  81550. private _startAnimations;
  81551. /**
  81552. * Loads a glTF node.
  81553. * @param context The context when loading the asset
  81554. * @param node The glTF node property
  81555. * @param assign A function called synchronously after parsing the glTF properties
  81556. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  81557. */
  81558. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  81559. private _loadMeshAsync;
  81560. /**
  81561. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  81562. * @param context The context when loading the asset
  81563. * @param name The mesh name when loading the asset
  81564. * @param node The glTF node when loading the asset
  81565. * @param mesh The glTF mesh when loading the asset
  81566. * @param primitive The glTF mesh primitive property
  81567. * @param assign A function called synchronously after parsing the glTF properties
  81568. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  81569. */
  81570. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  81571. private _loadVertexDataAsync;
  81572. private _createMorphTargets;
  81573. private _loadMorphTargetsAsync;
  81574. private _loadMorphTargetVertexDataAsync;
  81575. private static _LoadTransform;
  81576. private _loadSkinAsync;
  81577. private _loadBones;
  81578. private _loadBone;
  81579. private _loadSkinInverseBindMatricesDataAsync;
  81580. private _updateBoneMatrices;
  81581. private _getNodeMatrix;
  81582. /**
  81583. * Loads a glTF camera.
  81584. * @param context The context when loading the asset
  81585. * @param camera The glTF camera property
  81586. * @param assign A function called synchronously after parsing the glTF properties
  81587. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  81588. */
  81589. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  81590. private _loadAnimationsAsync;
  81591. /**
  81592. * Loads a glTF animation.
  81593. * @param context The context when loading the asset
  81594. * @param animation The glTF animation property
  81595. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  81596. */
  81597. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  81598. /**
  81599. * @hidden Loads a glTF animation channel.
  81600. * @param context The context when loading the asset
  81601. * @param animationContext The context of the animation when loading the asset
  81602. * @param animation The glTF animation property
  81603. * @param channel The glTF animation channel property
  81604. * @param babylonAnimationGroup The babylon animation group property
  81605. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  81606. * @returns A void promise when the channel load is complete
  81607. */
  81608. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  81609. private _loadAnimationSamplerAsync;
  81610. private _loadBufferAsync;
  81611. /**
  81612. * Loads a glTF buffer view.
  81613. * @param context The context when loading the asset
  81614. * @param bufferView The glTF buffer view property
  81615. * @returns A promise that resolves with the loaded data when the load is complete
  81616. */
  81617. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  81618. private _loadAccessorAsync;
  81619. /** @hidden */
  81620. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  81621. private _loadIndicesAccessorAsync;
  81622. private _loadVertexBufferViewAsync;
  81623. private _loadVertexAccessorAsync;
  81624. private _loadMaterialMetallicRoughnessPropertiesAsync;
  81625. /** @hidden */
  81626. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  81627. private _createDefaultMaterial;
  81628. /**
  81629. * Creates a Babylon material from a glTF material.
  81630. * @param context The context when loading the asset
  81631. * @param material The glTF material property
  81632. * @param babylonDrawMode The draw mode for the Babylon material
  81633. * @returns The Babylon material
  81634. */
  81635. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  81636. /**
  81637. * Loads properties from a glTF material into a Babylon material.
  81638. * @param context The context when loading the asset
  81639. * @param material The glTF material property
  81640. * @param babylonMaterial The Babylon material
  81641. * @returns A promise that resolves when the load is complete
  81642. */
  81643. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81644. /**
  81645. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  81646. * @param context The context when loading the asset
  81647. * @param material The glTF material property
  81648. * @param babylonMaterial The Babylon material
  81649. * @returns A promise that resolves when the load is complete
  81650. */
  81651. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  81652. /**
  81653. * Loads the alpha properties from a glTF material into a Babylon material.
  81654. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  81655. * @param context The context when loading the asset
  81656. * @param material The glTF material property
  81657. * @param babylonMaterial The Babylon material
  81658. */
  81659. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  81660. /**
  81661. * Loads a glTF texture info.
  81662. * @param context The context when loading the asset
  81663. * @param textureInfo The glTF texture info property
  81664. * @param assign A function called synchronously after parsing the glTF properties
  81665. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  81666. */
  81667. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81668. /** @hidden */
  81669. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81670. /** @hidden */
  81671. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  81672. private _loadSampler;
  81673. /**
  81674. * Loads a glTF image.
  81675. * @param context The context when loading the asset
  81676. * @param image The glTF image property
  81677. * @returns A promise that resolves with the loaded data when the load is complete
  81678. */
  81679. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  81680. /**
  81681. * Loads a glTF uri.
  81682. * @param context The context when loading the asset
  81683. * @param property The glTF property associated with the uri
  81684. * @param uri The base64 or relative uri
  81685. * @returns A promise that resolves with the loaded data when the load is complete
  81686. */
  81687. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  81688. /**
  81689. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  81690. * @param babylonObject the Babylon object with metadata
  81691. * @param pointer the JSON pointer
  81692. */
  81693. static AddPointerMetadata(babylonObject: {
  81694. metadata: any;
  81695. }, pointer: string): void;
  81696. private static _GetTextureWrapMode;
  81697. private static _GetTextureSamplingMode;
  81698. private static _GetTypedArrayConstructor;
  81699. private static _GetTypedArray;
  81700. private static _GetNumComponents;
  81701. private static _ValidateUri;
  81702. /** @hidden */
  81703. static _GetDrawMode(context: string, mode: number | undefined): number;
  81704. private _compileMaterialsAsync;
  81705. private _compileShadowGeneratorsAsync;
  81706. private _forEachExtensions;
  81707. private _applyExtensions;
  81708. private _extensionsOnLoading;
  81709. private _extensionsOnReady;
  81710. private _extensionsLoadSceneAsync;
  81711. private _extensionsLoadNodeAsync;
  81712. private _extensionsLoadCameraAsync;
  81713. private _extensionsLoadVertexDataAsync;
  81714. private _extensionsLoadMeshPrimitiveAsync;
  81715. private _extensionsLoadMaterialAsync;
  81716. private _extensionsCreateMaterial;
  81717. private _extensionsLoadMaterialPropertiesAsync;
  81718. private _extensionsLoadTextureInfoAsync;
  81719. private _extensionsLoadTextureAsync;
  81720. private _extensionsLoadAnimationAsync;
  81721. private _extensionsLoadSkinAsync;
  81722. private _extensionsLoadUriAsync;
  81723. private _extensionsLoadBufferViewAsync;
  81724. private _extensionsLoadBufferAsync;
  81725. /**
  81726. * Helper method called by a loader extension to load an glTF extension.
  81727. * @param context The context when loading the asset
  81728. * @param property The glTF property to load the extension from
  81729. * @param extensionName The name of the extension to load
  81730. * @param actionAsync The action to run
  81731. * @returns The promise returned by actionAsync or null if the extension does not exist
  81732. */
  81733. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81734. /**
  81735. * Helper method called by a loader extension to load a glTF extra.
  81736. * @param context The context when loading the asset
  81737. * @param property The glTF property to load the extra from
  81738. * @param extensionName The name of the extension to load
  81739. * @param actionAsync The action to run
  81740. * @returns The promise returned by actionAsync or null if the extra does not exist
  81741. */
  81742. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81743. /**
  81744. * Checks for presence of an extension.
  81745. * @param name The name of the extension to check
  81746. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  81747. */
  81748. isExtensionUsed(name: string): boolean;
  81749. /**
  81750. * Increments the indentation level and logs a message.
  81751. * @param message The message to log
  81752. */
  81753. logOpen(message: string): void;
  81754. /**
  81755. * Decrements the indentation level.
  81756. */
  81757. logClose(): void;
  81758. /**
  81759. * Logs a message
  81760. * @param message The message to log
  81761. */
  81762. log(message: string): void;
  81763. /**
  81764. * Starts a performance counter.
  81765. * @param counterName The name of the performance counter
  81766. */
  81767. startPerformanceCounter(counterName: string): void;
  81768. /**
  81769. * Ends a performance counter.
  81770. * @param counterName The name of the performance counter
  81771. */
  81772. endPerformanceCounter(counterName: string): void;
  81773. }
  81774. }
  81775. declare module BABYLON.GLTF2.Loader.Extensions {
  81776. /** @hidden */
  81777. interface IEXTLightsImageBased_LightImageBased {
  81778. _babylonTexture?: BaseTexture;
  81779. _loaded?: Promise<void>;
  81780. }
  81781. /**
  81782. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  81783. */
  81784. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  81785. /**
  81786. * The name of this extension.
  81787. */
  81788. readonly name: string;
  81789. /**
  81790. * Defines whether this extension is enabled.
  81791. */
  81792. enabled: boolean;
  81793. private _loader;
  81794. private _lights?;
  81795. /** @hidden */
  81796. constructor(loader: GLTFLoader);
  81797. /** @hidden */
  81798. dispose(): void;
  81799. /** @hidden */
  81800. onLoading(): void;
  81801. /** @hidden */
  81802. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81803. private _loadLightAsync;
  81804. }
  81805. }
  81806. declare module BABYLON.GLTF2.Loader.Extensions {
  81807. /**
  81808. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  81809. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  81810. * !!! Experimental Extension Subject to Changes !!!
  81811. */
  81812. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  81813. /**
  81814. * The name of this extension.
  81815. */
  81816. readonly name: string;
  81817. /**
  81818. * Defines whether this extension is enabled.
  81819. */
  81820. enabled: boolean;
  81821. private _loader;
  81822. /** @hidden */
  81823. constructor(loader: GLTFLoader);
  81824. /** @hidden */
  81825. dispose(): void;
  81826. /** @hidden */
  81827. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81828. }
  81829. }
  81830. declare module BABYLON.GLTF2.Loader.Extensions {
  81831. /**
  81832. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  81833. */
  81834. export class EXT_texture_webp implements IGLTFLoaderExtension {
  81835. /** The name of this extension. */
  81836. readonly name: string;
  81837. /** Defines whether this extension is enabled. */
  81838. enabled: boolean;
  81839. private _loader;
  81840. /** @hidden */
  81841. constructor(loader: GLTFLoader);
  81842. /** @hidden */
  81843. dispose(): void;
  81844. /** @hidden */
  81845. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81846. }
  81847. }
  81848. declare module BABYLON.GLTF2.Loader.Extensions {
  81849. /**
  81850. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  81851. */
  81852. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  81853. /**
  81854. * The name of this extension.
  81855. */
  81856. readonly name: string;
  81857. /**
  81858. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  81859. */
  81860. dracoCompression?: DracoCompression;
  81861. /**
  81862. * Defines whether this extension is enabled.
  81863. */
  81864. enabled: boolean;
  81865. private _loader;
  81866. /** @hidden */
  81867. constructor(loader: GLTFLoader);
  81868. /** @hidden */
  81869. dispose(): void;
  81870. /** @hidden */
  81871. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81872. }
  81873. }
  81874. declare module BABYLON.GLTF2.Loader.Extensions {
  81875. /**
  81876. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  81877. */
  81878. export class KHR_lights implements IGLTFLoaderExtension {
  81879. /**
  81880. * The name of this extension.
  81881. */
  81882. readonly name: string;
  81883. /**
  81884. * Defines whether this extension is enabled.
  81885. */
  81886. enabled: boolean;
  81887. private _loader;
  81888. private _lights?;
  81889. /** @hidden */
  81890. constructor(loader: GLTFLoader);
  81891. /** @hidden */
  81892. dispose(): void;
  81893. /** @hidden */
  81894. onLoading(): void;
  81895. /** @hidden */
  81896. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81897. }
  81898. }
  81899. declare module BABYLON.GLTF2.Loader.Extensions {
  81900. /**
  81901. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  81902. */
  81903. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  81904. /**
  81905. * The name of this extension.
  81906. */
  81907. readonly name: string;
  81908. /**
  81909. * Defines whether this extension is enabled.
  81910. */
  81911. enabled: boolean;
  81912. /**
  81913. * Defines a number that determines the order the extensions are applied.
  81914. */
  81915. order: number;
  81916. private _loader;
  81917. /** @hidden */
  81918. constructor(loader: GLTFLoader);
  81919. /** @hidden */
  81920. dispose(): void;
  81921. /** @hidden */
  81922. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81923. private _loadSpecularGlossinessPropertiesAsync;
  81924. }
  81925. }
  81926. declare module BABYLON.GLTF2.Loader.Extensions {
  81927. /**
  81928. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  81929. */
  81930. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  81931. /**
  81932. * The name of this extension.
  81933. */
  81934. readonly name: string;
  81935. /**
  81936. * Defines whether this extension is enabled.
  81937. */
  81938. enabled: boolean;
  81939. /**
  81940. * Defines a number that determines the order the extensions are applied.
  81941. */
  81942. order: number;
  81943. private _loader;
  81944. /** @hidden */
  81945. constructor(loader: GLTFLoader);
  81946. /** @hidden */
  81947. dispose(): void;
  81948. /** @hidden */
  81949. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81950. private _loadUnlitPropertiesAsync;
  81951. }
  81952. }
  81953. declare module BABYLON.GLTF2.Loader.Extensions {
  81954. /**
  81955. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  81956. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  81957. * !!! Experimental Extension Subject to Changes !!!
  81958. */
  81959. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  81960. /**
  81961. * The name of this extension.
  81962. */
  81963. readonly name: string;
  81964. /**
  81965. * Defines whether this extension is enabled.
  81966. */
  81967. enabled: boolean;
  81968. /**
  81969. * Defines a number that determines the order the extensions are applied.
  81970. */
  81971. order: number;
  81972. private _loader;
  81973. /** @hidden */
  81974. constructor(loader: GLTFLoader);
  81975. /** @hidden */
  81976. dispose(): void;
  81977. /** @hidden */
  81978. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81979. private _loadClearCoatPropertiesAsync;
  81980. }
  81981. }
  81982. declare module BABYLON.GLTF2.Loader.Extensions {
  81983. /**
  81984. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  81985. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  81986. * !!! Experimental Extension Subject to Changes !!!
  81987. */
  81988. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  81989. /**
  81990. * The name of this extension.
  81991. */
  81992. readonly name: string;
  81993. /**
  81994. * Defines whether this extension is enabled.
  81995. */
  81996. enabled: boolean;
  81997. /**
  81998. * Defines a number that determines the order the extensions are applied.
  81999. */
  82000. order: number;
  82001. private _loader;
  82002. /** @hidden */
  82003. constructor(loader: GLTFLoader);
  82004. /** @hidden */
  82005. dispose(): void;
  82006. /** @hidden */
  82007. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82008. private _loadSheenPropertiesAsync;
  82009. }
  82010. }
  82011. declare module BABYLON.GLTF2.Loader.Extensions {
  82012. /**
  82013. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  82014. * !!! Experimental Extension Subject to Changes !!!
  82015. */
  82016. export class KHR_materials_specular implements IGLTFLoaderExtension {
  82017. /**
  82018. * The name of this extension.
  82019. */
  82020. readonly name: string;
  82021. /**
  82022. * Defines whether this extension is enabled.
  82023. */
  82024. enabled: boolean;
  82025. /**
  82026. * Defines a number that determines the order the extensions are applied.
  82027. */
  82028. order: number;
  82029. private _loader;
  82030. /** @hidden */
  82031. constructor(loader: GLTFLoader);
  82032. /** @hidden */
  82033. dispose(): void;
  82034. /** @hidden */
  82035. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82036. private _loadSpecularPropertiesAsync;
  82037. }
  82038. }
  82039. declare module BABYLON.GLTF2.Loader.Extensions {
  82040. /**
  82041. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  82042. * !!! Experimental Extension Subject to Changes !!!
  82043. */
  82044. export class KHR_materials_ior implements IGLTFLoaderExtension {
  82045. /**
  82046. * Default ior Value from the spec.
  82047. */
  82048. private static readonly _DEFAULT_IOR;
  82049. /**
  82050. * The name of this extension.
  82051. */
  82052. readonly name: string;
  82053. /**
  82054. * Defines whether this extension is enabled.
  82055. */
  82056. enabled: boolean;
  82057. /**
  82058. * Defines a number that determines the order the extensions are applied.
  82059. */
  82060. order: number;
  82061. private _loader;
  82062. /** @hidden */
  82063. constructor(loader: GLTFLoader);
  82064. /** @hidden */
  82065. dispose(): void;
  82066. /** @hidden */
  82067. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82068. private _loadIorPropertiesAsync;
  82069. }
  82070. }
  82071. declare module BABYLON.GLTF2.Loader.Extensions {
  82072. /**
  82073. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  82074. * !!! Experimental Extension Subject to Changes !!!
  82075. */
  82076. export class KHR_materials_variants implements IGLTFLoaderExtension {
  82077. /**
  82078. * The name of this extension.
  82079. */
  82080. readonly name: string;
  82081. /**
  82082. * Defines whether this extension is enabled.
  82083. */
  82084. enabled: boolean;
  82085. private _loader;
  82086. private _variants?;
  82087. /** @hidden */
  82088. constructor(loader: GLTFLoader);
  82089. /** @hidden */
  82090. dispose(): void;
  82091. /**
  82092. * Gets the list of available variant names for this asset.
  82093. * @param rootMesh The glTF root mesh
  82094. * @returns the list of all the variant names for this model
  82095. */
  82096. static GetAvailableVariants(rootMesh: Mesh): string[];
  82097. /**
  82098. * Gets the list of available variant names for this asset.
  82099. * @param rootMesh The glTF root mesh
  82100. * @returns the list of all the variant names for this model
  82101. */
  82102. getAvailableVariants(rootMesh: Mesh): string[];
  82103. /**
  82104. * Select a variant given a variant name or a list of variant names.
  82105. * @param rootMesh The glTF root mesh
  82106. * @param variantName The variant name(s) to select.
  82107. */
  82108. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82109. /**
  82110. * Select a variant given a variant name or a list of variant names.
  82111. * @param rootMesh The glTF root mesh
  82112. * @param variantName The variant name(s) to select.
  82113. */
  82114. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82115. /**
  82116. * Reset back to the original before selecting a variant.
  82117. * @param rootMesh The glTF root mesh
  82118. */
  82119. static Reset(rootMesh: Mesh): void;
  82120. /**
  82121. * Reset back to the original before selecting a variant.
  82122. * @param rootMesh The glTF root mesh
  82123. */
  82124. reset(rootMesh: Mesh): void;
  82125. /**
  82126. * Gets the last selected variant name(s) or null if original.
  82127. * @param rootMesh The glTF root mesh
  82128. * @returns The selected variant name(s).
  82129. */
  82130. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82131. /**
  82132. * Gets the last selected variant name(s) or null if original.
  82133. * @param rootMesh The glTF root mesh
  82134. * @returns The selected variant name(s).
  82135. */
  82136. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82137. private static _GetExtensionMetadata;
  82138. /** @hidden */
  82139. onLoading(): void;
  82140. /** @hidden */
  82141. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82142. }
  82143. }
  82144. declare module BABYLON.GLTF2.Loader.Extensions {
  82145. /**
  82146. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  82147. * !!! Experimental Extension Subject to Changes !!!
  82148. */
  82149. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  82150. /**
  82151. * The name of this extension.
  82152. */
  82153. readonly name: string;
  82154. /**
  82155. * Defines whether this extension is enabled.
  82156. */
  82157. enabled: boolean;
  82158. /**
  82159. * Defines a number that determines the order the extensions are applied.
  82160. */
  82161. order: number;
  82162. private _loader;
  82163. /** @hidden */
  82164. constructor(loader: GLTFLoader);
  82165. /** @hidden */
  82166. dispose(): void;
  82167. /** @hidden */
  82168. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82169. private _loadTransparentPropertiesAsync;
  82170. }
  82171. }
  82172. declare module BABYLON.GLTF2.Loader.Extensions {
  82173. /**
  82174. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  82175. */
  82176. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  82177. /**
  82178. * The name of this extension.
  82179. */
  82180. readonly name: string;
  82181. /**
  82182. * Defines whether this extension is enabled.
  82183. */
  82184. enabled: boolean;
  82185. /** @hidden */
  82186. constructor(loader: GLTFLoader);
  82187. /** @hidden */
  82188. dispose(): void;
  82189. }
  82190. }
  82191. declare module BABYLON.GLTF2.Loader.Extensions {
  82192. /**
  82193. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  82194. * !!! Experimental Extension Subject to Changes !!!
  82195. */
  82196. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  82197. /** The name of this extension. */
  82198. readonly name: string;
  82199. /** Defines whether this extension is enabled. */
  82200. enabled: boolean;
  82201. private _loader;
  82202. /** @hidden */
  82203. constructor(loader: GLTFLoader);
  82204. /** @hidden */
  82205. dispose(): void;
  82206. /** @hidden */
  82207. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82208. }
  82209. }
  82210. declare module BABYLON.GLTF2.Loader.Extensions {
  82211. /**
  82212. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  82213. */
  82214. export class KHR_texture_transform implements IGLTFLoaderExtension {
  82215. /**
  82216. * The name of this extension.
  82217. */
  82218. readonly name: string;
  82219. /**
  82220. * Defines whether this extension is enabled.
  82221. */
  82222. enabled: boolean;
  82223. private _loader;
  82224. /** @hidden */
  82225. constructor(loader: GLTFLoader);
  82226. /** @hidden */
  82227. dispose(): void;
  82228. /** @hidden */
  82229. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82230. }
  82231. }
  82232. declare module BABYLON.GLTF2.Loader.Extensions {
  82233. /**
  82234. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  82235. * !!! Experimental Extension Subject to Changes !!!
  82236. */
  82237. export class KHR_xmp implements IGLTFLoaderExtension {
  82238. /**
  82239. * The name of this extension.
  82240. */
  82241. readonly name: string;
  82242. /**
  82243. * Defines whether this extension is enabled.
  82244. */
  82245. enabled: boolean;
  82246. /**
  82247. * Defines a number that determines the order the extensions are applied.
  82248. */
  82249. order: number;
  82250. private _loader;
  82251. /** @hidden */
  82252. constructor(loader: GLTFLoader);
  82253. /** @hidden */
  82254. dispose(): void;
  82255. /**
  82256. * Called after the loader state changes to LOADING.
  82257. */
  82258. onLoading(): void;
  82259. }
  82260. }
  82261. declare module BABYLON.GLTF2.Loader.Extensions {
  82262. /**
  82263. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  82264. */
  82265. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  82266. /**
  82267. * The name of this extension.
  82268. */
  82269. readonly name: string;
  82270. /**
  82271. * Defines whether this extension is enabled.
  82272. */
  82273. enabled: boolean;
  82274. private _loader;
  82275. private _clips;
  82276. private _emitters;
  82277. /** @hidden */
  82278. constructor(loader: GLTFLoader);
  82279. /** @hidden */
  82280. dispose(): void;
  82281. /** @hidden */
  82282. onLoading(): void;
  82283. /** @hidden */
  82284. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82285. /** @hidden */
  82286. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82287. /** @hidden */
  82288. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82289. private _loadClipAsync;
  82290. private _loadEmitterAsync;
  82291. private _getEventAction;
  82292. private _loadAnimationEventAsync;
  82293. }
  82294. }
  82295. declare module BABYLON.GLTF2.Loader.Extensions {
  82296. /**
  82297. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  82298. */
  82299. export class MSFT_lod implements IGLTFLoaderExtension {
  82300. /**
  82301. * The name of this extension.
  82302. */
  82303. readonly name: string;
  82304. /**
  82305. * Defines whether this extension is enabled.
  82306. */
  82307. enabled: boolean;
  82308. /**
  82309. * Defines a number that determines the order the extensions are applied.
  82310. */
  82311. order: number;
  82312. /**
  82313. * Maximum number of LODs to load, starting from the lowest LOD.
  82314. */
  82315. maxLODsToLoad: number;
  82316. /**
  82317. * Observable raised when all node LODs of one level are loaded.
  82318. * The event data is the index of the loaded LOD starting from zero.
  82319. * Dispose the loader to cancel the loading of the next level of LODs.
  82320. */
  82321. onNodeLODsLoadedObservable: Observable<number>;
  82322. /**
  82323. * Observable raised when all material LODs of one level are loaded.
  82324. * The event data is the index of the loaded LOD starting from zero.
  82325. * Dispose the loader to cancel the loading of the next level of LODs.
  82326. */
  82327. onMaterialLODsLoadedObservable: Observable<number>;
  82328. private _loader;
  82329. private _bufferLODs;
  82330. private _nodeIndexLOD;
  82331. private _nodeSignalLODs;
  82332. private _nodePromiseLODs;
  82333. private _nodeBufferLODs;
  82334. private _materialIndexLOD;
  82335. private _materialSignalLODs;
  82336. private _materialPromiseLODs;
  82337. private _materialBufferLODs;
  82338. /** @hidden */
  82339. constructor(loader: GLTFLoader);
  82340. /** @hidden */
  82341. dispose(): void;
  82342. /** @hidden */
  82343. onReady(): void;
  82344. /** @hidden */
  82345. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82346. /** @hidden */
  82347. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82348. /** @hidden */
  82349. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82350. /** @hidden */
  82351. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82352. /** @hidden */
  82353. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82354. private _loadBufferLOD;
  82355. /**
  82356. * Gets an array of LOD properties from lowest to highest.
  82357. */
  82358. private _getLODs;
  82359. private _disposeTransformNode;
  82360. private _disposeMaterials;
  82361. }
  82362. }
  82363. declare module BABYLON.GLTF2.Loader.Extensions {
  82364. /** @hidden */
  82365. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  82366. readonly name: string;
  82367. enabled: boolean;
  82368. private _loader;
  82369. constructor(loader: GLTFLoader);
  82370. dispose(): void;
  82371. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82372. }
  82373. }
  82374. declare module BABYLON.GLTF2.Loader.Extensions {
  82375. /** @hidden */
  82376. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  82377. readonly name: string;
  82378. enabled: boolean;
  82379. private _loader;
  82380. constructor(loader: GLTFLoader);
  82381. dispose(): void;
  82382. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82383. }
  82384. }
  82385. declare module BABYLON.GLTF2.Loader.Extensions {
  82386. /**
  82387. * Store glTF extras (if present) in BJS objects' metadata
  82388. */
  82389. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  82390. /**
  82391. * The name of this extension.
  82392. */
  82393. readonly name: string;
  82394. /**
  82395. * Defines whether this extension is enabled.
  82396. */
  82397. enabled: boolean;
  82398. private _loader;
  82399. private _assignExtras;
  82400. /** @hidden */
  82401. constructor(loader: GLTFLoader);
  82402. /** @hidden */
  82403. dispose(): void;
  82404. /** @hidden */
  82405. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82406. /** @hidden */
  82407. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82408. /** @hidden */
  82409. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82410. }
  82411. }
  82412. declare module BABYLON {
  82413. /**
  82414. * Class reading and parsing the MTL file bundled with the obj file.
  82415. */
  82416. export class MTLFileLoader {
  82417. /**
  82418. * Invert Y-Axis of referenced textures on load
  82419. */
  82420. static INVERT_TEXTURE_Y: boolean;
  82421. /**
  82422. * All material loaded from the mtl will be set here
  82423. */
  82424. materials: StandardMaterial[];
  82425. /**
  82426. * This function will read the mtl file and create each material described inside
  82427. * This function could be improve by adding :
  82428. * -some component missing (Ni, Tf...)
  82429. * -including the specific options available
  82430. *
  82431. * @param scene defines the scene the material will be created in
  82432. * @param data defines the mtl data to parse
  82433. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  82434. * @param forAssetContainer defines if the material should be registered in the scene
  82435. */
  82436. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  82437. /**
  82438. * Gets the texture for the material.
  82439. *
  82440. * If the material is imported from input file,
  82441. * We sanitize the url to ensure it takes the textre from aside the material.
  82442. *
  82443. * @param rootUrl The root url to load from
  82444. * @param value The value stored in the mtl
  82445. * @return The Texture
  82446. */
  82447. private static _getTexture;
  82448. }
  82449. }
  82450. declare module BABYLON {
  82451. /**
  82452. * Options for loading OBJ/MTL files
  82453. */
  82454. type MeshLoadOptions = {
  82455. /**
  82456. * Defines if UVs are optimized by default during load.
  82457. */
  82458. OptimizeWithUV: boolean;
  82459. /**
  82460. * Defines custom scaling of UV coordinates of loaded meshes.
  82461. */
  82462. UVScaling: Vector2;
  82463. /**
  82464. * Invert model on y-axis (does a model scaling inversion)
  82465. */
  82466. InvertY: boolean;
  82467. /**
  82468. * Invert Y-Axis of referenced textures on load
  82469. */
  82470. InvertTextureY: boolean;
  82471. /**
  82472. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82473. */
  82474. ImportVertexColors: boolean;
  82475. /**
  82476. * Compute the normals for the model, even if normals are present in the file.
  82477. */
  82478. ComputeNormals: boolean;
  82479. /**
  82480. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82481. */
  82482. SkipMaterials: boolean;
  82483. /**
  82484. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82485. */
  82486. MaterialLoadingFailsSilently: boolean;
  82487. };
  82488. /**
  82489. * OBJ file type loader.
  82490. * This is a babylon scene loader plugin.
  82491. */
  82492. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82493. /**
  82494. * Defines if UVs are optimized by default during load.
  82495. */
  82496. static OPTIMIZE_WITH_UV: boolean;
  82497. /**
  82498. * Invert model on y-axis (does a model scaling inversion)
  82499. */
  82500. static INVERT_Y: boolean;
  82501. /**
  82502. * Invert Y-Axis of referenced textures on load
  82503. */
  82504. static get INVERT_TEXTURE_Y(): boolean;
  82505. static set INVERT_TEXTURE_Y(value: boolean);
  82506. /**
  82507. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  82508. */
  82509. static IMPORT_VERTEX_COLORS: boolean;
  82510. /**
  82511. * Compute the normals for the model, even if normals are present in the file.
  82512. */
  82513. static COMPUTE_NORMALS: boolean;
  82514. /**
  82515. * Defines custom scaling of UV coordinates of loaded meshes.
  82516. */
  82517. static UV_SCALING: Vector2;
  82518. /**
  82519. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  82520. */
  82521. static SKIP_MATERIALS: boolean;
  82522. /**
  82523. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  82524. *
  82525. * Defaults to true for backwards compatibility.
  82526. */
  82527. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  82528. /**
  82529. * Defines the name of the plugin.
  82530. */
  82531. name: string;
  82532. /**
  82533. * Defines the extension the plugin is able to load.
  82534. */
  82535. extensions: string;
  82536. /** @hidden */
  82537. obj: RegExp;
  82538. /** @hidden */
  82539. group: RegExp;
  82540. /** @hidden */
  82541. mtllib: RegExp;
  82542. /** @hidden */
  82543. usemtl: RegExp;
  82544. /** @hidden */
  82545. smooth: RegExp;
  82546. /** @hidden */
  82547. vertexPattern: RegExp;
  82548. /** @hidden */
  82549. normalPattern: RegExp;
  82550. /** @hidden */
  82551. uvPattern: RegExp;
  82552. /** @hidden */
  82553. facePattern1: RegExp;
  82554. /** @hidden */
  82555. facePattern2: RegExp;
  82556. /** @hidden */
  82557. facePattern3: RegExp;
  82558. /** @hidden */
  82559. facePattern4: RegExp;
  82560. /** @hidden */
  82561. facePattern5: RegExp;
  82562. private _forAssetContainer;
  82563. private _meshLoadOptions;
  82564. /**
  82565. * Creates loader for .OBJ files
  82566. *
  82567. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  82568. */
  82569. constructor(meshLoadOptions?: MeshLoadOptions);
  82570. private static get currentMeshLoadOptions();
  82571. /**
  82572. * Calls synchronously the MTL file attached to this obj.
  82573. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  82574. * Without this function materials are not displayed in the first frame (but displayed after).
  82575. * In consequence it is impossible to get material information in your HTML file
  82576. *
  82577. * @param url The URL of the MTL file
  82578. * @param rootUrl
  82579. * @param onSuccess Callback function to be called when the MTL file is loaded
  82580. * @private
  82581. */
  82582. private _loadMTL;
  82583. /**
  82584. * Instantiates a OBJ file loader plugin.
  82585. * @returns the created plugin
  82586. */
  82587. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  82588. /**
  82589. * If the data string can be loaded directly.
  82590. *
  82591. * @param data string containing the file data
  82592. * @returns if the data can be loaded directly
  82593. */
  82594. canDirectLoad(data: string): boolean;
  82595. /**
  82596. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  82597. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  82598. * @param scene the scene the meshes should be added to
  82599. * @param data the OBJ data to load
  82600. * @param rootUrl root url to load from
  82601. * @param onProgress event that fires when loading progress has occured
  82602. * @param fileName Defines the name of the file to load
  82603. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  82604. */
  82605. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  82606. meshes: AbstractMesh[];
  82607. particleSystems: IParticleSystem[];
  82608. skeletons: Skeleton[];
  82609. animationGroups: AnimationGroup[];
  82610. }>;
  82611. /**
  82612. * Imports all objects from the loaded OBJ data and adds them to the scene
  82613. * @param scene the scene the objects should be added to
  82614. * @param data the OBJ data to load
  82615. * @param rootUrl root url to load from
  82616. * @param onProgress event that fires when loading progress has occured
  82617. * @param fileName Defines the name of the file to load
  82618. * @returns a promise which completes when objects have been loaded to the scene
  82619. */
  82620. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82621. /**
  82622. * Load into an asset container.
  82623. * @param scene The scene to load into
  82624. * @param data The data to import
  82625. * @param rootUrl The root url for scene and resources
  82626. * @param onProgress The callback when the load progresses
  82627. * @param fileName Defines the name of the file to load
  82628. * @returns The loaded asset container
  82629. */
  82630. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82631. /**
  82632. * Read the OBJ file and create an Array of meshes.
  82633. * Each mesh contains all information given by the OBJ and the MTL file.
  82634. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  82635. *
  82636. * @param meshesNames
  82637. * @param scene Scene The scene where are displayed the data
  82638. * @param data String The content of the obj file
  82639. * @param rootUrl String The path to the folder
  82640. * @returns Array<AbstractMesh>
  82641. * @private
  82642. */
  82643. private _parseSolid;
  82644. }
  82645. }
  82646. declare module BABYLON {
  82647. /**
  82648. * STL file type loader.
  82649. * This is a babylon scene loader plugin.
  82650. */
  82651. export class STLFileLoader implements ISceneLoaderPlugin {
  82652. /** @hidden */
  82653. solidPattern: RegExp;
  82654. /** @hidden */
  82655. facetsPattern: RegExp;
  82656. /** @hidden */
  82657. normalPattern: RegExp;
  82658. /** @hidden */
  82659. vertexPattern: RegExp;
  82660. /**
  82661. * Defines the name of the plugin.
  82662. */
  82663. name: string;
  82664. /**
  82665. * Defines the extensions the stl loader is able to load.
  82666. * force data to come in as an ArrayBuffer
  82667. * we'll convert to string if it looks like it's an ASCII .stl
  82668. */
  82669. extensions: ISceneLoaderPluginExtensions;
  82670. /**
  82671. * Import meshes into a scene.
  82672. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  82673. * @param scene The scene to import into
  82674. * @param data The data to import
  82675. * @param rootUrl The root url for scene and resources
  82676. * @param meshes The meshes array to import into
  82677. * @param particleSystems The particle systems array to import into
  82678. * @param skeletons The skeletons array to import into
  82679. * @param onError The callback when import fails
  82680. * @returns True if successful or false otherwise
  82681. */
  82682. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  82683. /**
  82684. * Load into a scene.
  82685. * @param scene The scene to load into
  82686. * @param data The data to import
  82687. * @param rootUrl The root url for scene and resources
  82688. * @param onError The callback when import fails
  82689. * @returns true if successful or false otherwise
  82690. */
  82691. load(scene: Scene, data: any, rootUrl: string): boolean;
  82692. /**
  82693. * Load into an asset container.
  82694. * @param scene The scene to load into
  82695. * @param data The data to import
  82696. * @param rootUrl The root url for scene and resources
  82697. * @param onError The callback when import fails
  82698. * @returns The loaded asset container
  82699. */
  82700. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  82701. private _isBinary;
  82702. private _parseBinary;
  82703. private _parseASCII;
  82704. }
  82705. }
  82706. declare module BABYLON {
  82707. /**
  82708. * Class for generating OBJ data from a Babylon scene.
  82709. */
  82710. export class OBJExport {
  82711. /**
  82712. * Exports the geometry of a Mesh array in .OBJ file format (text)
  82713. * @param mesh defines the list of meshes to serialize
  82714. * @param materials defines if materials should be exported
  82715. * @param matlibname defines the name of the associated mtl file
  82716. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  82717. * @returns the OBJ content
  82718. */
  82719. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  82720. /**
  82721. * Exports the material(s) of a mesh in .MTL file format (text)
  82722. * @param mesh defines the mesh to extract the material from
  82723. * @returns the mtl content
  82724. */
  82725. static MTL(mesh: Mesh): string;
  82726. }
  82727. }
  82728. declare module BABYLON {
  82729. /** @hidden */
  82730. export var __IGLTFExporterExtension: number;
  82731. /**
  82732. * Interface for extending the exporter
  82733. * @hidden
  82734. */
  82735. export interface IGLTFExporterExtension {
  82736. /**
  82737. * The name of this extension
  82738. */
  82739. readonly name: string;
  82740. /**
  82741. * Defines whether this extension is enabled
  82742. */
  82743. enabled: boolean;
  82744. /**
  82745. * Defines whether this extension is required
  82746. */
  82747. required: boolean;
  82748. }
  82749. }
  82750. declare module BABYLON.GLTF2.Exporter {
  82751. /** @hidden */
  82752. export var __IGLTFExporterExtensionV2: number;
  82753. /**
  82754. * Interface for a glTF exporter extension
  82755. * @hidden
  82756. */
  82757. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  82758. /**
  82759. * Define this method to modify the default behavior before exporting a texture
  82760. * @param context The context when loading the asset
  82761. * @param babylonTexture The Babylon.js texture
  82762. * @param mimeType The mime-type of the generated image
  82763. * @returns A promise that resolves with the exported texture
  82764. */
  82765. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  82766. /**
  82767. * Define this method to get notified when a texture info is created
  82768. * @param context The context when loading the asset
  82769. * @param textureInfo The glTF texture info
  82770. * @param babylonTexture The Babylon.js texture
  82771. */
  82772. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82773. /**
  82774. * Define this method to modify the default behavior when exporting texture info
  82775. * @param context The context when loading the asset
  82776. * @param meshPrimitive glTF mesh primitive
  82777. * @param babylonSubMesh Babylon submesh
  82778. * @param binaryWriter glTF serializer binary writer instance
  82779. * @returns nullable IMeshPrimitive promise
  82780. */
  82781. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  82782. /**
  82783. * Define this method to modify the default behavior when exporting a node
  82784. * @param context The context when exporting the node
  82785. * @param node glTF node
  82786. * @param babylonNode BabylonJS node
  82787. * @returns nullable INode promise
  82788. */
  82789. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82790. [key: number]: number;
  82791. }): Promise<Nullable<INode>>;
  82792. /**
  82793. * Define this method to modify the default behavior when exporting a material
  82794. * @param material glTF material
  82795. * @param babylonMaterial BabylonJS material
  82796. * @returns nullable IMaterial promise
  82797. */
  82798. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  82799. /**
  82800. * Define this method to return additional textures to export from a material
  82801. * @param material glTF material
  82802. * @param babylonMaterial BabylonJS material
  82803. * @returns List of textures
  82804. */
  82805. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82806. /** Gets a boolean indicating that this extension was used */
  82807. wasUsed: boolean;
  82808. /** Gets a boolean indicating that this extension is required for the file to work */
  82809. required: boolean;
  82810. /**
  82811. * Called after the exporter state changes to EXPORTING
  82812. */
  82813. onExporting?(): void;
  82814. }
  82815. }
  82816. declare module BABYLON.GLTF2.Exporter {
  82817. /**
  82818. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  82819. * @hidden
  82820. */
  82821. export class _GLTFMaterialExporter {
  82822. /**
  82823. * Represents the dielectric specular values for R, G and B
  82824. */
  82825. private static readonly _DielectricSpecular;
  82826. /**
  82827. * Allows the maximum specular power to be defined for material calculations
  82828. */
  82829. private static readonly _MaxSpecularPower;
  82830. /**
  82831. * Mapping to store textures
  82832. */
  82833. private _textureMap;
  82834. /**
  82835. * Numeric tolerance value
  82836. */
  82837. private static readonly _Epsilon;
  82838. /**
  82839. * Reference to the glTF Exporter
  82840. */
  82841. private _exporter;
  82842. constructor(exporter: _Exporter);
  82843. /**
  82844. * Specifies if two colors are approximately equal in value
  82845. * @param color1 first color to compare to
  82846. * @param color2 second color to compare to
  82847. * @param epsilon threshold value
  82848. */
  82849. private static FuzzyEquals;
  82850. /**
  82851. * Gets the materials from a Babylon scene and converts them to glTF materials
  82852. * @param scene babylonjs scene
  82853. * @param mimeType texture mime type
  82854. * @param images array of images
  82855. * @param textures array of textures
  82856. * @param materials array of materials
  82857. * @param imageData mapping of texture names to base64 textures
  82858. * @param hasTextureCoords specifies if texture coordinates are present on the material
  82859. */
  82860. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  82861. /**
  82862. * Makes a copy of the glTF material without the texture parameters
  82863. * @param originalMaterial original glTF material
  82864. * @returns glTF material without texture parameters
  82865. */
  82866. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  82867. /**
  82868. * Specifies if the material has any texture parameters present
  82869. * @param material glTF Material
  82870. * @returns boolean specifying if texture parameters are present
  82871. */
  82872. _hasTexturesPresent(material: IMaterial): boolean;
  82873. /**
  82874. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  82875. * @param babylonStandardMaterial
  82876. * @returns glTF Metallic Roughness Material representation
  82877. */
  82878. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  82879. /**
  82880. * Computes the metallic factor
  82881. * @param diffuse diffused value
  82882. * @param specular specular value
  82883. * @param oneMinusSpecularStrength one minus the specular strength
  82884. * @returns metallic value
  82885. */
  82886. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  82887. /**
  82888. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  82889. * @param glTFMaterial glTF material
  82890. * @param babylonMaterial Babylon material
  82891. */
  82892. private static _SetAlphaMode;
  82893. /**
  82894. * Converts a Babylon Standard Material to a glTF Material
  82895. * @param babylonStandardMaterial BJS Standard Material
  82896. * @param mimeType mime type to use for the textures
  82897. * @param images array of glTF image interfaces
  82898. * @param textures array of glTF texture interfaces
  82899. * @param materials array of glTF material interfaces
  82900. * @param imageData map of image file name to data
  82901. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82902. */
  82903. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82904. private _finishMaterial;
  82905. /**
  82906. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82907. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  82908. * @param mimeType mime type to use for the textures
  82909. * @param images array of glTF image interfaces
  82910. * @param textures array of glTF texture interfaces
  82911. * @param materials array of glTF material interfaces
  82912. * @param imageData map of image file name to data
  82913. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82914. */
  82915. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82916. /**
  82917. * Converts an image typed array buffer to a base64 image
  82918. * @param buffer typed array buffer
  82919. * @param width width of the image
  82920. * @param height height of the image
  82921. * @param mimeType mimetype of the image
  82922. * @returns base64 image string
  82923. */
  82924. private _createBase64FromCanvasAsync;
  82925. /**
  82926. * Generates a white texture based on the specified width and height
  82927. * @param width width of the texture in pixels
  82928. * @param height height of the texture in pixels
  82929. * @param scene babylonjs scene
  82930. * @returns white texture
  82931. */
  82932. private _createWhiteTexture;
  82933. /**
  82934. * 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
  82935. * @param texture1 first texture to resize
  82936. * @param texture2 second texture to resize
  82937. * @param scene babylonjs scene
  82938. * @returns resized textures or null
  82939. */
  82940. private _resizeTexturesToSameDimensions;
  82941. /**
  82942. * Converts an array of pixels to a Float32Array
  82943. * Throws an error if the pixel format is not supported
  82944. * @param pixels - array buffer containing pixel values
  82945. * @returns Float32 of pixels
  82946. */
  82947. private _convertPixelArrayToFloat32;
  82948. /**
  82949. * Convert Specular Glossiness Textures to Metallic Roughness
  82950. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  82951. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  82952. * @param diffuseTexture texture used to store diffuse information
  82953. * @param specularGlossinessTexture texture used to store specular and glossiness information
  82954. * @param factors specular glossiness material factors
  82955. * @param mimeType the mime type to use for the texture
  82956. * @returns pbr metallic roughness interface or null
  82957. */
  82958. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  82959. /**
  82960. * Converts specular glossiness material properties to metallic roughness
  82961. * @param specularGlossiness interface with specular glossiness material properties
  82962. * @returns interface with metallic roughness material properties
  82963. */
  82964. private _convertSpecularGlossinessToMetallicRoughness;
  82965. /**
  82966. * Calculates the surface reflectance, independent of lighting conditions
  82967. * @param color Color source to calculate brightness from
  82968. * @returns number representing the perceived brightness, or zero if color is undefined
  82969. */
  82970. private _getPerceivedBrightness;
  82971. /**
  82972. * Returns the maximum color component value
  82973. * @param color
  82974. * @returns maximum color component value, or zero if color is null or undefined
  82975. */
  82976. private _getMaxComponent;
  82977. /**
  82978. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  82979. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82980. * @param mimeType mime type to use for the textures
  82981. * @param images array of glTF image interfaces
  82982. * @param textures array of glTF texture interfaces
  82983. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82984. * @param imageData map of image file name to data
  82985. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82986. * @returns glTF PBR Metallic Roughness factors
  82987. */
  82988. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  82989. private _getGLTFTextureSampler;
  82990. private _getGLTFTextureWrapMode;
  82991. private _getGLTFTextureWrapModesSampler;
  82992. /**
  82993. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  82994. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82995. * @param mimeType mime type to use for the textures
  82996. * @param images array of glTF image interfaces
  82997. * @param textures array of glTF texture interfaces
  82998. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82999. * @param imageData map of image file name to data
  83000. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83001. * @returns glTF PBR Metallic Roughness factors
  83002. */
  83003. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  83004. /**
  83005. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83006. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83007. * @param mimeType mime type to use for the textures
  83008. * @param images array of glTF image interfaces
  83009. * @param textures array of glTF texture interfaces
  83010. * @param materials array of glTF material interfaces
  83011. * @param imageData map of image file name to data
  83012. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83013. */
  83014. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83015. private setMetallicRoughnessPbrMaterial;
  83016. private getPixelsFromTexture;
  83017. /**
  83018. * Extracts a texture from a Babylon texture into file data and glTF data
  83019. * @param babylonTexture Babylon texture to extract
  83020. * @param mimeType Mime Type of the babylonTexture
  83021. * @return glTF texture info, or null if the texture format is not supported
  83022. */
  83023. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83024. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83025. /**
  83026. * Builds a texture from base64 string
  83027. * @param base64Texture base64 texture string
  83028. * @param baseTextureName Name to use for the texture
  83029. * @param mimeType image mime type for the texture
  83030. * @param images array of images
  83031. * @param textures array of textures
  83032. * @param imageData map of image data
  83033. * @returns glTF texture info, or null if the texture format is not supported
  83034. */
  83035. private _getTextureInfoFromBase64;
  83036. }
  83037. }
  83038. declare module BABYLON {
  83039. /**
  83040. * Class for holding and downloading glTF file data
  83041. */
  83042. export class GLTFData {
  83043. /**
  83044. * Object which contains the file name as the key and its data as the value
  83045. */
  83046. glTFFiles: {
  83047. [fileName: string]: string | Blob;
  83048. };
  83049. /**
  83050. * Initializes the glTF file object
  83051. */
  83052. constructor();
  83053. /**
  83054. * Downloads the glTF data as files based on their names and data
  83055. */
  83056. downloadFiles(): void;
  83057. }
  83058. }
  83059. declare module BABYLON {
  83060. /**
  83061. * Holds a collection of exporter options and parameters
  83062. */
  83063. export interface IExportOptions {
  83064. /**
  83065. * Function which indicates whether a babylon node should be exported or not
  83066. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  83067. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  83068. */
  83069. shouldExportNode?(node: Node): boolean;
  83070. /**
  83071. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  83072. * @param metadata source metadata to read from
  83073. * @returns the data to store to glTF node extras
  83074. */
  83075. metadataSelector?(metadata: any): any;
  83076. /**
  83077. * The sample rate to bake animation curves
  83078. */
  83079. animationSampleRate?: number;
  83080. /**
  83081. * Begin serialization without waiting for the scene to be ready
  83082. */
  83083. exportWithoutWaitingForScene?: boolean;
  83084. /**
  83085. * Indicates if coordinate system swapping root nodes should be included in export
  83086. */
  83087. includeCoordinateSystemConversionNodes?: boolean;
  83088. }
  83089. /**
  83090. * Class for generating glTF data from a Babylon scene.
  83091. */
  83092. export class GLTF2Export {
  83093. /**
  83094. * Exports the geometry of the scene to .gltf file format asynchronously
  83095. * @param scene Babylon scene with scene hierarchy information
  83096. * @param filePrefix File prefix to use when generating the glTF file
  83097. * @param options Exporter options
  83098. * @returns Returns an object with a .gltf file and associates texture names
  83099. * as keys and their data and paths as values
  83100. */
  83101. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83102. private static _PreExportAsync;
  83103. private static _PostExportAsync;
  83104. /**
  83105. * Exports the geometry of the scene to .glb file format asychronously
  83106. * @param scene Babylon scene with scene hierarchy information
  83107. * @param filePrefix File prefix to use when generating glb file
  83108. * @param options Exporter options
  83109. * @returns Returns an object with a .glb filename as key and data as value
  83110. */
  83111. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83112. }
  83113. }
  83114. declare module BABYLON.GLTF2.Exporter {
  83115. /**
  83116. * @hidden
  83117. */
  83118. export class _GLTFUtilities {
  83119. /**
  83120. * Creates a buffer view based on the supplied arguments
  83121. * @param bufferIndex index value of the specified buffer
  83122. * @param byteOffset byte offset value
  83123. * @param byteLength byte length of the bufferView
  83124. * @param byteStride byte distance between conequential elements
  83125. * @param name name of the buffer view
  83126. * @returns bufferView for glTF
  83127. */
  83128. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  83129. /**
  83130. * Creates an accessor based on the supplied arguments
  83131. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  83132. * @param name The name of the accessor
  83133. * @param type The type of the accessor
  83134. * @param componentType The datatype of components in the attribute
  83135. * @param count The number of attributes referenced by this accessor
  83136. * @param byteOffset The offset relative to the start of the bufferView in bytes
  83137. * @param min Minimum value of each component in this attribute
  83138. * @param max Maximum value of each component in this attribute
  83139. * @returns accessor for glTF
  83140. */
  83141. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  83142. /**
  83143. * Calculates the minimum and maximum values of an array of position floats
  83144. * @param positions Positions array of a mesh
  83145. * @param vertexStart Starting vertex offset to calculate min and max values
  83146. * @param vertexCount Number of vertices to check for min and max values
  83147. * @returns min number array and max number array
  83148. */
  83149. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  83150. min: number[];
  83151. max: number[];
  83152. };
  83153. /**
  83154. * Converts a new right-handed Vector3
  83155. * @param vector vector3 array
  83156. * @returns right-handed Vector3
  83157. */
  83158. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  83159. /**
  83160. * Converts a Vector3 to right-handed
  83161. * @param vector Vector3 to convert to right-handed
  83162. */
  83163. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  83164. /**
  83165. * Converts a three element number array to right-handed
  83166. * @param vector number array to convert to right-handed
  83167. */
  83168. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  83169. /**
  83170. * Converts a new right-handed Vector3
  83171. * @param vector vector3 array
  83172. * @returns right-handed Vector3
  83173. */
  83174. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  83175. /**
  83176. * Converts a Vector3 to right-handed
  83177. * @param vector Vector3 to convert to right-handed
  83178. */
  83179. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  83180. /**
  83181. * Converts a three element number array to right-handed
  83182. * @param vector number array to convert to right-handed
  83183. */
  83184. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  83185. /**
  83186. * Converts a Vector4 to right-handed
  83187. * @param vector Vector4 to convert to right-handed
  83188. */
  83189. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  83190. /**
  83191. * Converts a Vector4 to right-handed
  83192. * @param vector Vector4 to convert to right-handed
  83193. */
  83194. static _GetRightHandedArray4FromRef(vector: number[]): void;
  83195. /**
  83196. * Converts a Quaternion to right-handed
  83197. * @param quaternion Source quaternion to convert to right-handed
  83198. */
  83199. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  83200. /**
  83201. * Converts a Quaternion to right-handed
  83202. * @param quaternion Source quaternion to convert to right-handed
  83203. */
  83204. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  83205. static _NormalizeTangentFromRef(tangent: Vector4): void;
  83206. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  83207. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  83208. }
  83209. }
  83210. declare module BABYLON.GLTF2.Exporter {
  83211. /**
  83212. * Converts Babylon Scene into glTF 2.0.
  83213. * @hidden
  83214. */
  83215. export class _Exporter {
  83216. /**
  83217. * Stores the glTF to export
  83218. */
  83219. _glTF: IGLTF;
  83220. /**
  83221. * Stores all generated buffer views, which represents views into the main glTF buffer data
  83222. */
  83223. _bufferViews: IBufferView[];
  83224. /**
  83225. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  83226. */
  83227. _accessors: IAccessor[];
  83228. /**
  83229. * Stores all the generated nodes, which contains transform and/or mesh information per node
  83230. */
  83231. _nodes: INode[];
  83232. /**
  83233. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  83234. */
  83235. private _scenes;
  83236. /**
  83237. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  83238. */
  83239. private _meshes;
  83240. /**
  83241. * Stores all the generated material information, which represents the appearance of each primitive
  83242. */
  83243. _materials: IMaterial[];
  83244. _materialMap: {
  83245. [materialID: number]: number;
  83246. };
  83247. /**
  83248. * Stores all the generated texture information, which is referenced by glTF materials
  83249. */
  83250. _textures: ITexture[];
  83251. /**
  83252. * Stores all the generated image information, which is referenced by glTF textures
  83253. */
  83254. _images: IImage[];
  83255. /**
  83256. * Stores all the texture samplers
  83257. */
  83258. _samplers: ISampler[];
  83259. /**
  83260. * Stores all the generated glTF skins
  83261. */
  83262. _skins: ISkin[];
  83263. /**
  83264. * Stores all the generated animation samplers, which is referenced by glTF animations
  83265. */
  83266. /**
  83267. * Stores the animations for glTF models
  83268. */
  83269. private _animations;
  83270. /**
  83271. * Stores the total amount of bytes stored in the glTF buffer
  83272. */
  83273. private _totalByteLength;
  83274. /**
  83275. * Stores a reference to the Babylon scene containing the source geometry and material information
  83276. */
  83277. _babylonScene: Scene;
  83278. /**
  83279. * Stores a map of the image data, where the key is the file name and the value
  83280. * is the image data
  83281. */
  83282. _imageData: {
  83283. [fileName: string]: {
  83284. data: Uint8Array;
  83285. mimeType: ImageMimeType;
  83286. };
  83287. };
  83288. protected _orderedImageData: Array<{
  83289. data: Uint8Array;
  83290. mimeType: ImageMimeType;
  83291. }>;
  83292. /**
  83293. * Stores a map of the unique id of a node to its index in the node array
  83294. */
  83295. _nodeMap: {
  83296. [key: number]: number;
  83297. };
  83298. /**
  83299. * Specifies if the source Babylon scene was left handed, and needed conversion.
  83300. */
  83301. _convertToRightHandedSystem: boolean;
  83302. /**
  83303. * Specifies if a Babylon node should be converted to right-handed on export
  83304. */
  83305. _convertToRightHandedSystemMap: {
  83306. [nodeId: number]: boolean;
  83307. };
  83308. _includeCoordinateSystemConversionNodes: boolean;
  83309. /**
  83310. * Baked animation sample rate
  83311. */
  83312. private _animationSampleRate;
  83313. private _options;
  83314. private _localEngine;
  83315. _glTFMaterialExporter: _GLTFMaterialExporter;
  83316. private _extensions;
  83317. private static _ExtensionNames;
  83318. private static _ExtensionFactories;
  83319. private _applyExtension;
  83320. private _applyExtensions;
  83321. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  83322. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  83323. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83324. [key: number]: number;
  83325. }): Promise<Nullable<INode>>;
  83326. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  83327. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  83328. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83329. private _forEachExtensions;
  83330. private _extensionsOnExporting;
  83331. /**
  83332. * Load glTF serializer extensions
  83333. */
  83334. private _loadExtensions;
  83335. /**
  83336. * Creates a glTF Exporter instance, which can accept optional exporter options
  83337. * @param babylonScene Babylon scene object
  83338. * @param options Options to modify the behavior of the exporter
  83339. */
  83340. constructor(babylonScene: Scene, options?: IExportOptions);
  83341. dispose(): void;
  83342. /**
  83343. * Registers a glTF exporter extension
  83344. * @param name Name of the extension to export
  83345. * @param factory The factory function that creates the exporter extension
  83346. */
  83347. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  83348. /**
  83349. * Un-registers an exporter extension
  83350. * @param name The name fo the exporter extension
  83351. * @returns A boolean indicating whether the extension has been un-registered
  83352. */
  83353. static UnregisterExtension(name: string): boolean;
  83354. /**
  83355. * Lazy load a local engine
  83356. */
  83357. _getLocalEngine(): Engine;
  83358. private reorderIndicesBasedOnPrimitiveMode;
  83359. /**
  83360. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  83361. * clock-wise during export to glTF
  83362. * @param submesh BabylonJS submesh
  83363. * @param primitiveMode Primitive mode of the mesh
  83364. * @param sideOrientation the winding order of the submesh
  83365. * @param vertexBufferKind The type of vertex attribute
  83366. * @param meshAttributeArray The vertex attribute data
  83367. * @param byteOffset The offset to the binary data
  83368. * @param binaryWriter The binary data for the glTF file
  83369. * @param convertToRightHandedSystem Converts the values to right-handed
  83370. */
  83371. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  83372. /**
  83373. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  83374. * clock-wise during export to glTF
  83375. * @param submesh BabylonJS submesh
  83376. * @param primitiveMode Primitive mode of the mesh
  83377. * @param sideOrientation the winding order of the submesh
  83378. * @param vertexBufferKind The type of vertex attribute
  83379. * @param meshAttributeArray The vertex attribute data
  83380. * @param byteOffset The offset to the binary data
  83381. * @param binaryWriter The binary data for the glTF file
  83382. * @param convertToRightHandedSystem Converts the values to right-handed
  83383. */
  83384. private reorderTriangleFillMode;
  83385. /**
  83386. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  83387. * clock-wise during export to glTF
  83388. * @param submesh BabylonJS submesh
  83389. * @param primitiveMode Primitive mode of the mesh
  83390. * @param sideOrientation the winding order of the submesh
  83391. * @param vertexBufferKind The type of vertex attribute
  83392. * @param meshAttributeArray The vertex attribute data
  83393. * @param byteOffset The offset to the binary data
  83394. * @param binaryWriter The binary data for the glTF file
  83395. * @param convertToRightHandedSystem Converts the values to right-handed
  83396. */
  83397. private reorderTriangleStripDrawMode;
  83398. /**
  83399. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  83400. * clock-wise during export to glTF
  83401. * @param submesh BabylonJS submesh
  83402. * @param primitiveMode Primitive mode of the mesh
  83403. * @param sideOrientation the winding order of the submesh
  83404. * @param vertexBufferKind The type of vertex attribute
  83405. * @param meshAttributeArray The vertex attribute data
  83406. * @param byteOffset The offset to the binary data
  83407. * @param binaryWriter The binary data for the glTF file
  83408. * @param convertToRightHandedSystem Converts the values to right-handed
  83409. */
  83410. private reorderTriangleFanMode;
  83411. /**
  83412. * Writes the vertex attribute data to binary
  83413. * @param vertices The vertices to write to the binary writer
  83414. * @param byteOffset The offset into the binary writer to overwrite binary data
  83415. * @param vertexAttributeKind The vertex attribute type
  83416. * @param meshAttributeArray The vertex attribute data
  83417. * @param binaryWriter The writer containing the binary data
  83418. * @param convertToRightHandedSystem Converts the values to right-handed
  83419. */
  83420. private writeVertexAttributeData;
  83421. /**
  83422. * Writes mesh attribute data to a data buffer
  83423. * Returns the bytelength of the data
  83424. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  83425. * @param meshAttributeArray Array containing the attribute data
  83426. * @param byteStride Specifies the space between data
  83427. * @param binaryWriter The buffer to write the binary data to
  83428. * @param convertToRightHandedSystem Converts the values to right-handed
  83429. */
  83430. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  83431. /**
  83432. * Writes mesh attribute data to a data buffer
  83433. * Returns the bytelength of the data
  83434. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  83435. * @param meshAttributeArray Array containing the attribute data
  83436. * @param byteStride Specifies the space between data
  83437. * @param binaryWriter The buffer to write the binary data to
  83438. * @param convertToRightHandedSystem Converts the values to right-handed
  83439. */
  83440. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  83441. /**
  83442. * Generates glTF json data
  83443. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  83444. * @param glTFPrefix Text to use when prefixing a glTF file
  83445. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  83446. * @returns json data as string
  83447. */
  83448. private generateJSON;
  83449. /**
  83450. * Generates data for .gltf and .bin files based on the glTF prefix string
  83451. * @param glTFPrefix Text to use when prefixing a glTF file
  83452. * @param dispose Dispose the exporter
  83453. * @returns GLTFData with glTF file data
  83454. */
  83455. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83456. /**
  83457. * Creates a binary buffer for glTF
  83458. * @returns array buffer for binary data
  83459. */
  83460. private _generateBinaryAsync;
  83461. /**
  83462. * Pads the number to a multiple of 4
  83463. * @param num number to pad
  83464. * @returns padded number
  83465. */
  83466. private _getPadding;
  83467. /**
  83468. * @hidden
  83469. */
  83470. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  83471. /**
  83472. * Sets the TRS for each node
  83473. * @param node glTF Node for storing the transformation data
  83474. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  83475. * @param convertToRightHandedSystem Converts the values to right-handed
  83476. */
  83477. private setNodeTransformation;
  83478. private getVertexBufferFromMesh;
  83479. /**
  83480. * Creates a bufferview based on the vertices type for the Babylon mesh
  83481. * @param kind Indicates the type of vertices data
  83482. * @param componentType Indicates the numerical type used to store the data
  83483. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  83484. * @param binaryWriter The buffer to write the bufferview data to
  83485. * @param convertToRightHandedSystem Converts the values to right-handed
  83486. */
  83487. private createBufferViewKind;
  83488. /**
  83489. * Creates a bufferview based on the vertices type for the Babylon mesh
  83490. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  83491. * @param babylonMorphTarget the morph target to be exported
  83492. * @param binaryWriter The buffer to write the bufferview data to
  83493. * @param convertToRightHandedSystem Converts the values to right-handed
  83494. */
  83495. private setMorphTargetAttributes;
  83496. /**
  83497. * The primitive mode of the Babylon mesh
  83498. * @param babylonMesh The BabylonJS mesh
  83499. */
  83500. private getMeshPrimitiveMode;
  83501. /**
  83502. * Sets the primitive mode of the glTF mesh primitive
  83503. * @param meshPrimitive glTF mesh primitive
  83504. * @param primitiveMode The primitive mode
  83505. */
  83506. private setPrimitiveMode;
  83507. /**
  83508. * Sets the vertex attribute accessor based of the glTF mesh primitive
  83509. * @param meshPrimitive glTF mesh primitive
  83510. * @param attributeKind vertex attribute
  83511. * @returns boolean specifying if uv coordinates are present
  83512. */
  83513. private setAttributeKind;
  83514. /**
  83515. * Sets data for the primitive attributes of each submesh
  83516. * @param mesh glTF Mesh object to store the primitive attribute information
  83517. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  83518. * @param binaryWriter Buffer to write the attribute data to
  83519. * @param convertToRightHandedSystem Converts the values to right-handed
  83520. */
  83521. private setPrimitiveAttributesAsync;
  83522. /**
  83523. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  83524. * @param node The node to check
  83525. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  83526. */
  83527. private isBabylonCoordinateSystemConvertingNode;
  83528. /**
  83529. * Creates a glTF scene based on the array of meshes
  83530. * Returns the the total byte offset
  83531. * @param babylonScene Babylon scene to get the mesh data from
  83532. * @param binaryWriter Buffer to write binary data to
  83533. */
  83534. private createSceneAsync;
  83535. /**
  83536. * Creates a mapping of Node unique id to node index and handles animations
  83537. * @param babylonScene Babylon Scene
  83538. * @param nodes Babylon transform nodes
  83539. * @param binaryWriter Buffer to write binary data to
  83540. * @returns Node mapping of unique id to index
  83541. */
  83542. private createNodeMapAndAnimationsAsync;
  83543. /**
  83544. * Creates a glTF node from a Babylon mesh
  83545. * @param babylonMesh Source Babylon mesh
  83546. * @param binaryWriter Buffer for storing geometry data
  83547. * @param convertToRightHandedSystem Converts the values to right-handed
  83548. * @param nodeMap Node mapping of unique id to glTF node index
  83549. * @returns glTF node
  83550. */
  83551. private createNodeAsync;
  83552. /**
  83553. * Creates a glTF skin from a Babylon skeleton
  83554. * @param babylonScene Babylon Scene
  83555. * @param nodes Babylon transform nodes
  83556. * @param binaryWriter Buffer to write binary data to
  83557. * @returns Node mapping of unique id to index
  83558. */
  83559. private createSkinsAsync;
  83560. }
  83561. /**
  83562. * @hidden
  83563. *
  83564. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  83565. */
  83566. export class _BinaryWriter {
  83567. /**
  83568. * Array buffer which stores all binary data
  83569. */
  83570. private _arrayBuffer;
  83571. /**
  83572. * View of the array buffer
  83573. */
  83574. private _dataView;
  83575. /**
  83576. * byte offset of data in array buffer
  83577. */
  83578. private _byteOffset;
  83579. /**
  83580. * Initialize binary writer with an initial byte length
  83581. * @param byteLength Initial byte length of the array buffer
  83582. */
  83583. constructor(byteLength: number);
  83584. /**
  83585. * Resize the array buffer to the specified byte length
  83586. * @param byteLength
  83587. */
  83588. private resizeBuffer;
  83589. /**
  83590. * Get an array buffer with the length of the byte offset
  83591. * @returns ArrayBuffer resized to the byte offset
  83592. */
  83593. getArrayBuffer(): ArrayBuffer;
  83594. /**
  83595. * Get the byte offset of the array buffer
  83596. * @returns byte offset
  83597. */
  83598. getByteOffset(): number;
  83599. /**
  83600. * Stores an UInt8 in the array buffer
  83601. * @param entry
  83602. * @param byteOffset If defined, specifies where to set the value as an offset.
  83603. */
  83604. setUInt8(entry: number, byteOffset?: number): void;
  83605. /**
  83606. * Stores an UInt16 in the array buffer
  83607. * @param entry
  83608. * @param byteOffset If defined, specifies where to set the value as an offset.
  83609. */
  83610. setUInt16(entry: number, byteOffset?: number): void;
  83611. /**
  83612. * Gets an UInt32 in the array buffer
  83613. * @param entry
  83614. * @param byteOffset If defined, specifies where to set the value as an offset.
  83615. */
  83616. getUInt32(byteOffset: number): number;
  83617. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83618. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  83619. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83620. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  83621. /**
  83622. * Stores a Float32 in the array buffer
  83623. * @param entry
  83624. */
  83625. setFloat32(entry: number, byteOffset?: number): void;
  83626. /**
  83627. * Stores an UInt32 in the array buffer
  83628. * @param entry
  83629. * @param byteOffset If defined, specifies where to set the value as an offset.
  83630. */
  83631. setUInt32(entry: number, byteOffset?: number): void;
  83632. }
  83633. }
  83634. declare module BABYLON.GLTF2.Exporter {
  83635. /**
  83636. * @hidden
  83637. * Interface to store animation data.
  83638. */
  83639. export interface _IAnimationData {
  83640. /**
  83641. * Keyframe data.
  83642. */
  83643. inputs: number[];
  83644. /**
  83645. * Value data.
  83646. */
  83647. outputs: number[][];
  83648. /**
  83649. * Animation interpolation data.
  83650. */
  83651. samplerInterpolation: AnimationSamplerInterpolation;
  83652. /**
  83653. * Minimum keyframe value.
  83654. */
  83655. inputsMin: number;
  83656. /**
  83657. * Maximum keyframe value.
  83658. */
  83659. inputsMax: number;
  83660. }
  83661. /**
  83662. * @hidden
  83663. */
  83664. export interface _IAnimationInfo {
  83665. /**
  83666. * The target channel for the animation
  83667. */
  83668. animationChannelTargetPath: AnimationChannelTargetPath;
  83669. /**
  83670. * The glTF accessor type for the data.
  83671. */
  83672. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  83673. /**
  83674. * Specifies if quaternions should be used.
  83675. */
  83676. useQuaternion: boolean;
  83677. }
  83678. /**
  83679. * @hidden
  83680. * Utility class for generating glTF animation data from BabylonJS.
  83681. */
  83682. export class _GLTFAnimation {
  83683. /**
  83684. * @ignore
  83685. *
  83686. * Creates glTF channel animation from BabylonJS animation.
  83687. * @param babylonTransformNode - BabylonJS mesh.
  83688. * @param animation - animation.
  83689. * @param animationChannelTargetPath - The target animation channel.
  83690. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  83691. * @param useQuaternion - Specifies if quaternions are used.
  83692. * @returns nullable IAnimationData
  83693. */
  83694. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  83695. private static _DeduceAnimationInfo;
  83696. /**
  83697. * @ignore
  83698. * Create node animations from the transform node animations
  83699. * @param babylonNode
  83700. * @param runtimeGLTFAnimation
  83701. * @param idleGLTFAnimations
  83702. * @param nodeMap
  83703. * @param nodes
  83704. * @param binaryWriter
  83705. * @param bufferViews
  83706. * @param accessors
  83707. * @param convertToRightHandedSystem
  83708. * @param animationSampleRate
  83709. */
  83710. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83711. [key: number]: number;
  83712. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83713. /**
  83714. * @ignore
  83715. * Create individual morph animations from the mesh's morph target animation tracks
  83716. * @param babylonNode
  83717. * @param runtimeGLTFAnimation
  83718. * @param idleGLTFAnimations
  83719. * @param nodeMap
  83720. * @param nodes
  83721. * @param binaryWriter
  83722. * @param bufferViews
  83723. * @param accessors
  83724. * @param convertToRightHandedSystem
  83725. * @param animationSampleRate
  83726. */
  83727. static _CreateMorphTargetAnimationFromMorphTargets(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  83728. [key: number]: number;
  83729. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  83730. /**
  83731. * @ignore
  83732. * Create node and morph animations from the animation groups
  83733. * @param babylonScene
  83734. * @param glTFAnimations
  83735. * @param nodeMap
  83736. * @param nodes
  83737. * @param binaryWriter
  83738. * @param bufferViews
  83739. * @param accessors
  83740. * @param convertToRightHandedSystemMap
  83741. * @param animationSampleRate
  83742. */
  83743. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  83744. [key: number]: number;
  83745. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  83746. [nodeId: number]: boolean;
  83747. }, animationSampleRate: number): void;
  83748. private static AddAnimation;
  83749. /**
  83750. * Create a baked animation
  83751. * @param babylonTransformNode BabylonJS mesh
  83752. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  83753. * @param animationChannelTargetPath animation target channel
  83754. * @param minFrame minimum animation frame
  83755. * @param maxFrame maximum animation frame
  83756. * @param fps frames per second of the animation
  83757. * @param inputs input key frames of the animation
  83758. * @param outputs output key frame data of the animation
  83759. * @param convertToRightHandedSystem converts the values to right-handed
  83760. * @param useQuaternion specifies if quaternions should be used
  83761. */
  83762. private static _CreateBakedAnimation;
  83763. private static _ConvertFactorToVector3OrQuaternion;
  83764. private static _SetInterpolatedValue;
  83765. /**
  83766. * Creates linear animation from the animation key frames
  83767. * @param babylonTransformNode BabylonJS mesh
  83768. * @param animation BabylonJS animation
  83769. * @param animationChannelTargetPath The target animation channel
  83770. * @param frameDelta The difference between the last and first frame of the animation
  83771. * @param inputs Array to store the key frame times
  83772. * @param outputs Array to store the key frame data
  83773. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83774. * @param useQuaternion Specifies if quaternions are used in the animation
  83775. */
  83776. private static _CreateLinearOrStepAnimation;
  83777. /**
  83778. * Creates cubic spline animation from the animation key frames
  83779. * @param babylonTransformNode BabylonJS mesh
  83780. * @param animation BabylonJS animation
  83781. * @param animationChannelTargetPath The target animation channel
  83782. * @param frameDelta The difference between the last and first frame of the animation
  83783. * @param inputs Array to store the key frame times
  83784. * @param outputs Array to store the key frame data
  83785. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83786. * @param useQuaternion Specifies if quaternions are used in the animation
  83787. */
  83788. private static _CreateCubicSplineAnimation;
  83789. private static _GetBasePositionRotationOrScale;
  83790. /**
  83791. * Adds a key frame value
  83792. * @param keyFrame
  83793. * @param animation
  83794. * @param outputs
  83795. * @param animationChannelTargetPath
  83796. * @param basePositionRotationOrScale
  83797. * @param convertToRightHandedSystem
  83798. * @param useQuaternion
  83799. */
  83800. private static _AddKeyframeValue;
  83801. /**
  83802. * Determine the interpolation based on the key frames
  83803. * @param keyFrames
  83804. * @param animationChannelTargetPath
  83805. * @param useQuaternion
  83806. */
  83807. private static _DeduceInterpolation;
  83808. /**
  83809. * Adds an input tangent or output tangent to the output data
  83810. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  83811. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  83812. * @param outputs The animation data by keyframe
  83813. * @param animationChannelTargetPath The target animation channel
  83814. * @param interpolation The interpolation type
  83815. * @param keyFrame The key frame with the animation data
  83816. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  83817. * @param useQuaternion Specifies if quaternions are used
  83818. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  83819. */
  83820. private static AddSplineTangent;
  83821. /**
  83822. * Get the minimum and maximum key frames' frame values
  83823. * @param keyFrames animation key frames
  83824. * @returns the minimum and maximum key frame value
  83825. */
  83826. private static calculateMinMaxKeyFrames;
  83827. }
  83828. }
  83829. declare module BABYLON.GLTF2.Exporter {
  83830. /** @hidden */
  83831. export var textureTransformPixelShader: {
  83832. name: string;
  83833. shader: string;
  83834. };
  83835. }
  83836. declare module BABYLON.GLTF2.Exporter.Extensions {
  83837. /**
  83838. * @hidden
  83839. */
  83840. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  83841. private _recordedTextures;
  83842. /** Name of this extension */
  83843. readonly name: string;
  83844. /** Defines whether this extension is enabled */
  83845. enabled: boolean;
  83846. /** Defines whether this extension is required */
  83847. required: boolean;
  83848. /** Reference to the glTF exporter */
  83849. private _wasUsed;
  83850. constructor(exporter: _Exporter);
  83851. dispose(): void;
  83852. /** @hidden */
  83853. get wasUsed(): boolean;
  83854. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83855. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  83856. /**
  83857. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  83858. * @param babylonTexture
  83859. * @param offset
  83860. * @param rotation
  83861. * @param scale
  83862. * @param scene
  83863. */
  83864. private _textureTransformTextureAsync;
  83865. }
  83866. }
  83867. declare module BABYLON.GLTF2.Exporter.Extensions {
  83868. /**
  83869. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  83870. */
  83871. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  83872. /** The name of this extension. */
  83873. readonly name: string;
  83874. /** Defines whether this extension is enabled. */
  83875. enabled: boolean;
  83876. /** Defines whether this extension is required */
  83877. required: boolean;
  83878. /** Reference to the glTF exporter */
  83879. private _exporter;
  83880. private _lights;
  83881. /** @hidden */
  83882. constructor(exporter: _Exporter);
  83883. /** @hidden */
  83884. dispose(): void;
  83885. /** @hidden */
  83886. get wasUsed(): boolean;
  83887. /** @hidden */
  83888. onExporting(): void;
  83889. /**
  83890. * Define this method to modify the default behavior when exporting a node
  83891. * @param context The context when exporting the node
  83892. * @param node glTF node
  83893. * @param babylonNode BabylonJS node
  83894. * @param nodeMap Node mapping of unique id to glTF node index
  83895. * @returns nullable INode promise
  83896. */
  83897. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83898. [key: number]: number;
  83899. }): Promise<Nullable<INode>>;
  83900. }
  83901. }
  83902. declare module BABYLON.GLTF2.Exporter.Extensions {
  83903. /**
  83904. * @hidden
  83905. */
  83906. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  83907. /** Name of this extension */
  83908. readonly name: string;
  83909. /** Defines whether this extension is enabled */
  83910. enabled: boolean;
  83911. /** Defines whether this extension is required */
  83912. required: boolean;
  83913. /** Reference to the glTF exporter */
  83914. private _textureInfos;
  83915. private _exportedTextures;
  83916. private _wasUsed;
  83917. constructor(exporter: _Exporter);
  83918. dispose(): void;
  83919. /** @hidden */
  83920. get wasUsed(): boolean;
  83921. private _getTextureIndex;
  83922. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83923. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83924. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83925. }
  83926. }
  83927. declare module BABYLON.GLTF2.Exporter.Extensions {
  83928. /**
  83929. * @hidden
  83930. */
  83931. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  83932. /** Name of this extension */
  83933. readonly name: string;
  83934. /** Defines whether this extension is enabled */
  83935. enabled: boolean;
  83936. /** Defines whether this extension is required */
  83937. required: boolean;
  83938. private _wasUsed;
  83939. constructor(exporter: _Exporter);
  83940. /** @hidden */
  83941. get wasUsed(): boolean;
  83942. dispose(): void;
  83943. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83944. }
  83945. }
  83946. declare module BABYLON {
  83947. /**
  83948. * Class for generating STL data from a Babylon scene.
  83949. */
  83950. export class STLExport {
  83951. /**
  83952. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  83953. * @param meshes list defines the mesh to serialize
  83954. * @param download triggers the automatic download of the file.
  83955. * @param fileName changes the downloads fileName.
  83956. * @param binary changes the STL to a binary type.
  83957. * @param isLittleEndian toggle for binary type exporter.
  83958. * @returns the STL as UTF8 string
  83959. */
  83960. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  83961. }
  83962. }
  83963. declare module "babylonjs-gltf2interface" {
  83964. export = BABYLON.GLTF2;
  83965. }
  83966. /**
  83967. * Module for glTF 2.0 Interface
  83968. */
  83969. declare module BABYLON.GLTF2 {
  83970. /**
  83971. * The datatype of the components in the attribute
  83972. */
  83973. const enum AccessorComponentType {
  83974. /**
  83975. * Byte
  83976. */
  83977. BYTE = 5120,
  83978. /**
  83979. * Unsigned Byte
  83980. */
  83981. UNSIGNED_BYTE = 5121,
  83982. /**
  83983. * Short
  83984. */
  83985. SHORT = 5122,
  83986. /**
  83987. * Unsigned Short
  83988. */
  83989. UNSIGNED_SHORT = 5123,
  83990. /**
  83991. * Unsigned Int
  83992. */
  83993. UNSIGNED_INT = 5125,
  83994. /**
  83995. * Float
  83996. */
  83997. FLOAT = 5126,
  83998. }
  83999. /**
  84000. * Specifies if the attirbute is a scalar, vector, or matrix
  84001. */
  84002. const enum AccessorType {
  84003. /**
  84004. * Scalar
  84005. */
  84006. SCALAR = "SCALAR",
  84007. /**
  84008. * Vector2
  84009. */
  84010. VEC2 = "VEC2",
  84011. /**
  84012. * Vector3
  84013. */
  84014. VEC3 = "VEC3",
  84015. /**
  84016. * Vector4
  84017. */
  84018. VEC4 = "VEC4",
  84019. /**
  84020. * Matrix2x2
  84021. */
  84022. MAT2 = "MAT2",
  84023. /**
  84024. * Matrix3x3
  84025. */
  84026. MAT3 = "MAT3",
  84027. /**
  84028. * Matrix4x4
  84029. */
  84030. MAT4 = "MAT4",
  84031. }
  84032. /**
  84033. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84034. */
  84035. const enum AnimationChannelTargetPath {
  84036. /**
  84037. * Translation
  84038. */
  84039. TRANSLATION = "translation",
  84040. /**
  84041. * Rotation
  84042. */
  84043. ROTATION = "rotation",
  84044. /**
  84045. * Scale
  84046. */
  84047. SCALE = "scale",
  84048. /**
  84049. * Weights
  84050. */
  84051. WEIGHTS = "weights",
  84052. }
  84053. /**
  84054. * Interpolation algorithm
  84055. */
  84056. const enum AnimationSamplerInterpolation {
  84057. /**
  84058. * The animated values are linearly interpolated between keyframes
  84059. */
  84060. LINEAR = "LINEAR",
  84061. /**
  84062. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  84063. */
  84064. STEP = "STEP",
  84065. /**
  84066. * The animation's interpolation is computed using a cubic spline with specified tangents
  84067. */
  84068. CUBICSPLINE = "CUBICSPLINE",
  84069. }
  84070. /**
  84071. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84072. */
  84073. const enum CameraType {
  84074. /**
  84075. * A perspective camera containing properties to create a perspective projection matrix
  84076. */
  84077. PERSPECTIVE = "perspective",
  84078. /**
  84079. * An orthographic camera containing properties to create an orthographic projection matrix
  84080. */
  84081. ORTHOGRAPHIC = "orthographic",
  84082. }
  84083. /**
  84084. * The mime-type of the image
  84085. */
  84086. const enum ImageMimeType {
  84087. /**
  84088. * JPEG Mime-type
  84089. */
  84090. JPEG = "image/jpeg",
  84091. /**
  84092. * PNG Mime-type
  84093. */
  84094. PNG = "image/png",
  84095. }
  84096. /**
  84097. * The alpha rendering mode of the material
  84098. */
  84099. const enum MaterialAlphaMode {
  84100. /**
  84101. * The alpha value is ignored and the rendered output is fully opaque
  84102. */
  84103. OPAQUE = "OPAQUE",
  84104. /**
  84105. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  84106. */
  84107. MASK = "MASK",
  84108. /**
  84109. * 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)
  84110. */
  84111. BLEND = "BLEND",
  84112. }
  84113. /**
  84114. * The type of the primitives to render
  84115. */
  84116. const enum MeshPrimitiveMode {
  84117. /**
  84118. * Points
  84119. */
  84120. POINTS = 0,
  84121. /**
  84122. * Lines
  84123. */
  84124. LINES = 1,
  84125. /**
  84126. * Line Loop
  84127. */
  84128. LINE_LOOP = 2,
  84129. /**
  84130. * Line Strip
  84131. */
  84132. LINE_STRIP = 3,
  84133. /**
  84134. * Triangles
  84135. */
  84136. TRIANGLES = 4,
  84137. /**
  84138. * Triangle Strip
  84139. */
  84140. TRIANGLE_STRIP = 5,
  84141. /**
  84142. * Triangle Fan
  84143. */
  84144. TRIANGLE_FAN = 6,
  84145. }
  84146. /**
  84147. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84148. */
  84149. const enum TextureMagFilter {
  84150. /**
  84151. * Nearest
  84152. */
  84153. NEAREST = 9728,
  84154. /**
  84155. * Linear
  84156. */
  84157. LINEAR = 9729,
  84158. }
  84159. /**
  84160. * Minification filter. All valid values correspond to WebGL enums
  84161. */
  84162. const enum TextureMinFilter {
  84163. /**
  84164. * Nearest
  84165. */
  84166. NEAREST = 9728,
  84167. /**
  84168. * Linear
  84169. */
  84170. LINEAR = 9729,
  84171. /**
  84172. * Nearest Mip-Map Nearest
  84173. */
  84174. NEAREST_MIPMAP_NEAREST = 9984,
  84175. /**
  84176. * Linear Mipmap Nearest
  84177. */
  84178. LINEAR_MIPMAP_NEAREST = 9985,
  84179. /**
  84180. * Nearest Mipmap Linear
  84181. */
  84182. NEAREST_MIPMAP_LINEAR = 9986,
  84183. /**
  84184. * Linear Mipmap Linear
  84185. */
  84186. LINEAR_MIPMAP_LINEAR = 9987,
  84187. }
  84188. /**
  84189. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84190. */
  84191. const enum TextureWrapMode {
  84192. /**
  84193. * Clamp to Edge
  84194. */
  84195. CLAMP_TO_EDGE = 33071,
  84196. /**
  84197. * Mirrored Repeat
  84198. */
  84199. MIRRORED_REPEAT = 33648,
  84200. /**
  84201. * Repeat
  84202. */
  84203. REPEAT = 10497,
  84204. }
  84205. /**
  84206. * glTF Property
  84207. */
  84208. interface IProperty {
  84209. /**
  84210. * Dictionary object with extension-specific objects
  84211. */
  84212. extensions?: {
  84213. [key: string]: any;
  84214. };
  84215. /**
  84216. * Application-Specific data
  84217. */
  84218. extras?: any;
  84219. }
  84220. /**
  84221. * glTF Child of Root Property
  84222. */
  84223. interface IChildRootProperty extends IProperty {
  84224. /**
  84225. * The user-defined name of this object
  84226. */
  84227. name?: string;
  84228. }
  84229. /**
  84230. * Indices of those attributes that deviate from their initialization value
  84231. */
  84232. interface IAccessorSparseIndices extends IProperty {
  84233. /**
  84234. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84235. */
  84236. bufferView: number;
  84237. /**
  84238. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84239. */
  84240. byteOffset?: number;
  84241. /**
  84242. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  84243. */
  84244. componentType: AccessorComponentType;
  84245. }
  84246. /**
  84247. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  84248. */
  84249. interface IAccessorSparseValues extends IProperty {
  84250. /**
  84251. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  84252. */
  84253. bufferView: number;
  84254. /**
  84255. * The offset relative to the start of the bufferView in bytes. Must be aligned
  84256. */
  84257. byteOffset?: number;
  84258. }
  84259. /**
  84260. * Sparse storage of attributes that deviate from their initialization value
  84261. */
  84262. interface IAccessorSparse extends IProperty {
  84263. /**
  84264. * The number of attributes encoded in this sparse accessor
  84265. */
  84266. count: number;
  84267. /**
  84268. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  84269. */
  84270. indices: IAccessorSparseIndices;
  84271. /**
  84272. * 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
  84273. */
  84274. values: IAccessorSparseValues;
  84275. }
  84276. /**
  84277. * 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
  84278. */
  84279. interface IAccessor extends IChildRootProperty {
  84280. /**
  84281. * The index of the bufferview
  84282. */
  84283. bufferView?: number;
  84284. /**
  84285. * The offset relative to the start of the bufferView in bytes
  84286. */
  84287. byteOffset?: number;
  84288. /**
  84289. * The datatype of components in the attribute
  84290. */
  84291. componentType: AccessorComponentType;
  84292. /**
  84293. * Specifies whether integer data values should be normalized
  84294. */
  84295. normalized?: boolean;
  84296. /**
  84297. * The number of attributes referenced by this accessor
  84298. */
  84299. count: number;
  84300. /**
  84301. * Specifies if the attribute is a scalar, vector, or matrix
  84302. */
  84303. type: AccessorType;
  84304. /**
  84305. * Maximum value of each component in this attribute
  84306. */
  84307. max?: number[];
  84308. /**
  84309. * Minimum value of each component in this attribute
  84310. */
  84311. min?: number[];
  84312. /**
  84313. * Sparse storage of attributes that deviate from their initialization value
  84314. */
  84315. sparse?: IAccessorSparse;
  84316. }
  84317. /**
  84318. * Targets an animation's sampler at a node's property
  84319. */
  84320. interface IAnimationChannel extends IProperty {
  84321. /**
  84322. * The index of a sampler in this animation used to compute the value for the target
  84323. */
  84324. sampler: number;
  84325. /**
  84326. * The index of the node and TRS property to target
  84327. */
  84328. target: IAnimationChannelTarget;
  84329. }
  84330. /**
  84331. * The index of the node and TRS property that an animation channel targets
  84332. */
  84333. interface IAnimationChannelTarget extends IProperty {
  84334. /**
  84335. * The index of the node to target
  84336. */
  84337. node: number;
  84338. /**
  84339. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84340. */
  84341. path: AnimationChannelTargetPath;
  84342. }
  84343. /**
  84344. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84345. */
  84346. interface IAnimationSampler extends IProperty {
  84347. /**
  84348. * The index of an accessor containing keyframe input values, e.g., time
  84349. */
  84350. input: number;
  84351. /**
  84352. * Interpolation algorithm
  84353. */
  84354. interpolation?: AnimationSamplerInterpolation;
  84355. /**
  84356. * The index of an accessor, containing keyframe output values
  84357. */
  84358. output: number;
  84359. }
  84360. /**
  84361. * A keyframe animation
  84362. */
  84363. interface IAnimation extends IChildRootProperty {
  84364. /**
  84365. * An array of channels, each of which targets an animation's sampler at a node's property
  84366. */
  84367. channels: IAnimationChannel[];
  84368. /**
  84369. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  84370. */
  84371. samplers: IAnimationSampler[];
  84372. }
  84373. /**
  84374. * Metadata about the glTF asset
  84375. */
  84376. interface IAsset extends IChildRootProperty {
  84377. /**
  84378. * A copyright message suitable for display to credit the content creator
  84379. */
  84380. copyright?: string;
  84381. /**
  84382. * Tool that generated this glTF model. Useful for debugging
  84383. */
  84384. generator?: string;
  84385. /**
  84386. * The glTF version that this asset targets
  84387. */
  84388. version: string;
  84389. /**
  84390. * The minimum glTF version that this asset targets
  84391. */
  84392. minVersion?: string;
  84393. }
  84394. /**
  84395. * A buffer points to binary geometry, animation, or skins
  84396. */
  84397. interface IBuffer extends IChildRootProperty {
  84398. /**
  84399. * 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
  84400. */
  84401. uri?: string;
  84402. /**
  84403. * The length of the buffer in bytes
  84404. */
  84405. byteLength: number;
  84406. }
  84407. /**
  84408. * A view into a buffer generally representing a subset of the buffer
  84409. */
  84410. interface IBufferView extends IChildRootProperty {
  84411. /**
  84412. * The index of the buffer
  84413. */
  84414. buffer: number;
  84415. /**
  84416. * The offset into the buffer in bytes
  84417. */
  84418. byteOffset?: number;
  84419. /**
  84420. * The lenth of the bufferView in bytes
  84421. */
  84422. byteLength: number;
  84423. /**
  84424. * The stride, in bytes
  84425. */
  84426. byteStride?: number;
  84427. }
  84428. /**
  84429. * An orthographic camera containing properties to create an orthographic projection matrix
  84430. */
  84431. interface ICameraOrthographic extends IProperty {
  84432. /**
  84433. * The floating-point horizontal magnification of the view. Must not be zero
  84434. */
  84435. xmag: number;
  84436. /**
  84437. * The floating-point vertical magnification of the view. Must not be zero
  84438. */
  84439. ymag: number;
  84440. /**
  84441. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  84442. */
  84443. zfar: number;
  84444. /**
  84445. * The floating-point distance to the near clipping plane
  84446. */
  84447. znear: number;
  84448. }
  84449. /**
  84450. * A perspective camera containing properties to create a perspective projection matrix
  84451. */
  84452. interface ICameraPerspective extends IProperty {
  84453. /**
  84454. * The floating-point aspect ratio of the field of view
  84455. */
  84456. aspectRatio?: number;
  84457. /**
  84458. * The floating-point vertical field of view in radians
  84459. */
  84460. yfov: number;
  84461. /**
  84462. * The floating-point distance to the far clipping plane
  84463. */
  84464. zfar?: number;
  84465. /**
  84466. * The floating-point distance to the near clipping plane
  84467. */
  84468. znear: number;
  84469. }
  84470. /**
  84471. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84472. */
  84473. interface ICamera extends IChildRootProperty {
  84474. /**
  84475. * An orthographic camera containing properties to create an orthographic projection matrix
  84476. */
  84477. orthographic?: ICameraOrthographic;
  84478. /**
  84479. * A perspective camera containing properties to create a perspective projection matrix
  84480. */
  84481. perspective?: ICameraPerspective;
  84482. /**
  84483. * Specifies if the camera uses a perspective or orthographic projection
  84484. */
  84485. type: CameraType;
  84486. }
  84487. /**
  84488. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  84489. */
  84490. interface IImage extends IChildRootProperty {
  84491. /**
  84492. * 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
  84493. */
  84494. uri?: string;
  84495. /**
  84496. * The image's MIME type
  84497. */
  84498. mimeType?: ImageMimeType;
  84499. /**
  84500. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  84501. */
  84502. bufferView?: number;
  84503. }
  84504. /**
  84505. * Material Normal Texture Info
  84506. */
  84507. interface IMaterialNormalTextureInfo extends ITextureInfo {
  84508. /**
  84509. * The scalar multiplier applied to each normal vector of the normal texture
  84510. */
  84511. scale?: number;
  84512. }
  84513. /**
  84514. * Material Occlusion Texture Info
  84515. */
  84516. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  84517. /**
  84518. * A scalar multiplier controlling the amount of occlusion applied
  84519. */
  84520. strength?: number;
  84521. }
  84522. /**
  84523. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  84524. */
  84525. interface IMaterialPbrMetallicRoughness {
  84526. /**
  84527. * The material's base color factor
  84528. */
  84529. baseColorFactor?: number[];
  84530. /**
  84531. * The base color texture
  84532. */
  84533. baseColorTexture?: ITextureInfo;
  84534. /**
  84535. * The metalness of the material
  84536. */
  84537. metallicFactor?: number;
  84538. /**
  84539. * The roughness of the material
  84540. */
  84541. roughnessFactor?: number;
  84542. /**
  84543. * The metallic-roughness texture
  84544. */
  84545. metallicRoughnessTexture?: ITextureInfo;
  84546. }
  84547. /**
  84548. * The material appearance of a primitive
  84549. */
  84550. interface IMaterial extends IChildRootProperty {
  84551. /**
  84552. * 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
  84553. */
  84554. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  84555. /**
  84556. * The normal map texture
  84557. */
  84558. normalTexture?: IMaterialNormalTextureInfo;
  84559. /**
  84560. * The occlusion map texture
  84561. */
  84562. occlusionTexture?: IMaterialOcclusionTextureInfo;
  84563. /**
  84564. * The emissive map texture
  84565. */
  84566. emissiveTexture?: ITextureInfo;
  84567. /**
  84568. * 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
  84569. */
  84570. emissiveFactor?: number[];
  84571. /**
  84572. * The alpha rendering mode of the material
  84573. */
  84574. alphaMode?: MaterialAlphaMode;
  84575. /**
  84576. * The alpha cutoff value of the material
  84577. */
  84578. alphaCutoff?: number;
  84579. /**
  84580. * Specifies whether the material is double sided
  84581. */
  84582. doubleSided?: boolean;
  84583. }
  84584. /**
  84585. * Geometry to be rendered with the given material
  84586. */
  84587. interface IMeshPrimitive extends IProperty {
  84588. /**
  84589. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  84590. */
  84591. attributes: {
  84592. [name: string]: number;
  84593. };
  84594. /**
  84595. * The index of the accessor that contains the indices
  84596. */
  84597. indices?: number;
  84598. /**
  84599. * The index of the material to apply to this primitive when rendering
  84600. */
  84601. material?: number;
  84602. /**
  84603. * The type of primitives to render. All valid values correspond to WebGL enums
  84604. */
  84605. mode?: MeshPrimitiveMode;
  84606. /**
  84607. * 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
  84608. */
  84609. targets?: {
  84610. [name: string]: number;
  84611. }[];
  84612. }
  84613. /**
  84614. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  84615. */
  84616. interface IMesh extends IChildRootProperty {
  84617. /**
  84618. * An array of primitives, each defining geometry to be rendered with a material
  84619. */
  84620. primitives: IMeshPrimitive[];
  84621. /**
  84622. * Array of weights to be applied to the Morph Targets
  84623. */
  84624. weights?: number[];
  84625. }
  84626. /**
  84627. * A node in the node hierarchy
  84628. */
  84629. interface INode extends IChildRootProperty {
  84630. /**
  84631. * The index of the camera referenced by this node
  84632. */
  84633. camera?: number;
  84634. /**
  84635. * The indices of this node's children
  84636. */
  84637. children?: number[];
  84638. /**
  84639. * The index of the skin referenced by this node
  84640. */
  84641. skin?: number;
  84642. /**
  84643. * A floating-point 4x4 transformation matrix stored in column-major order
  84644. */
  84645. matrix?: number[];
  84646. /**
  84647. * The index of the mesh in this node
  84648. */
  84649. mesh?: number;
  84650. /**
  84651. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  84652. */
  84653. rotation?: number[];
  84654. /**
  84655. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  84656. */
  84657. scale?: number[];
  84658. /**
  84659. * The node's translation along the x, y, and z axes
  84660. */
  84661. translation?: number[];
  84662. /**
  84663. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  84664. */
  84665. weights?: number[];
  84666. }
  84667. /**
  84668. * Texture sampler properties for filtering and wrapping modes
  84669. */
  84670. interface ISampler extends IChildRootProperty {
  84671. /**
  84672. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84673. */
  84674. magFilter?: TextureMagFilter;
  84675. /**
  84676. * Minification filter. All valid values correspond to WebGL enums
  84677. */
  84678. minFilter?: TextureMinFilter;
  84679. /**
  84680. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84681. */
  84682. wrapS?: TextureWrapMode;
  84683. /**
  84684. * T (V) wrapping mode. All valid values correspond to WebGL enums
  84685. */
  84686. wrapT?: TextureWrapMode;
  84687. }
  84688. /**
  84689. * The root nodes of a scene
  84690. */
  84691. interface IScene extends IChildRootProperty {
  84692. /**
  84693. * The indices of each root node
  84694. */
  84695. nodes: number[];
  84696. }
  84697. /**
  84698. * Joints and matrices defining a skin
  84699. */
  84700. interface ISkin extends IChildRootProperty {
  84701. /**
  84702. * 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
  84703. */
  84704. inverseBindMatrices?: number;
  84705. /**
  84706. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  84707. */
  84708. skeleton?: number;
  84709. /**
  84710. * 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)
  84711. */
  84712. joints: number[];
  84713. }
  84714. /**
  84715. * A texture and its sampler
  84716. */
  84717. interface ITexture extends IChildRootProperty {
  84718. /**
  84719. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  84720. */
  84721. sampler?: number;
  84722. /**
  84723. * The index of the image used by this texture
  84724. */
  84725. source: number;
  84726. }
  84727. /**
  84728. * Reference to a texture
  84729. */
  84730. interface ITextureInfo extends IProperty {
  84731. /**
  84732. * The index of the texture
  84733. */
  84734. index: number;
  84735. /**
  84736. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  84737. */
  84738. texCoord?: number;
  84739. }
  84740. /**
  84741. * The root object for a glTF asset
  84742. */
  84743. interface IGLTF extends IProperty {
  84744. /**
  84745. * An array of accessors. An accessor is a typed view into a bufferView
  84746. */
  84747. accessors?: IAccessor[];
  84748. /**
  84749. * An array of keyframe animations
  84750. */
  84751. animations?: IAnimation[];
  84752. /**
  84753. * Metadata about the glTF asset
  84754. */
  84755. asset: IAsset;
  84756. /**
  84757. * An array of buffers. A buffer points to binary geometry, animation, or skins
  84758. */
  84759. buffers?: IBuffer[];
  84760. /**
  84761. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  84762. */
  84763. bufferViews?: IBufferView[];
  84764. /**
  84765. * An array of cameras
  84766. */
  84767. cameras?: ICamera[];
  84768. /**
  84769. * Names of glTF extensions used somewhere in this asset
  84770. */
  84771. extensionsUsed?: string[];
  84772. /**
  84773. * Names of glTF extensions required to properly load this asset
  84774. */
  84775. extensionsRequired?: string[];
  84776. /**
  84777. * An array of images. An image defines data used to create a texture
  84778. */
  84779. images?: IImage[];
  84780. /**
  84781. * An array of materials. A material defines the appearance of a primitive
  84782. */
  84783. materials?: IMaterial[];
  84784. /**
  84785. * An array of meshes. A mesh is a set of primitives to be rendered
  84786. */
  84787. meshes?: IMesh[];
  84788. /**
  84789. * An array of nodes
  84790. */
  84791. nodes?: INode[];
  84792. /**
  84793. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  84794. */
  84795. samplers?: ISampler[];
  84796. /**
  84797. * The index of the default scene
  84798. */
  84799. scene?: number;
  84800. /**
  84801. * An array of scenes
  84802. */
  84803. scenes?: IScene[];
  84804. /**
  84805. * An array of skins. A skin is defined by joints and matrices
  84806. */
  84807. skins?: ISkin[];
  84808. /**
  84809. * An array of textures
  84810. */
  84811. textures?: ITexture[];
  84812. }
  84813. /**
  84814. * The glTF validation results
  84815. * @ignore
  84816. */
  84817. interface IGLTFValidationResults {
  84818. info: {
  84819. generator: string;
  84820. hasAnimations: boolean;
  84821. hasDefaultScene: boolean;
  84822. hasMaterials: boolean;
  84823. hasMorphTargets: boolean;
  84824. hasSkins: boolean;
  84825. hasTextures: boolean;
  84826. maxAttributesUsed: number;
  84827. primitivesCount: number
  84828. };
  84829. issues: {
  84830. messages: Array<string>;
  84831. numErrors: number;
  84832. numHints: number;
  84833. numInfos: number;
  84834. numWarnings: number;
  84835. truncated: boolean
  84836. };
  84837. mimeType: string;
  84838. uri: string;
  84839. validatedAt: string;
  84840. validatorVersion: string;
  84841. }
  84842. /**
  84843. * The glTF validation options
  84844. */
  84845. interface IGLTFValidationOptions {
  84846. /** Uri to use */
  84847. uri?: string;
  84848. /** Function used to load external resources */
  84849. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  84850. /** Boolean indicating that we need to validate accessor data */
  84851. validateAccessorData?: boolean;
  84852. /** max number of issues allowed */
  84853. maxIssues?: number;
  84854. /** Ignored issues */
  84855. ignoredIssues?: Array<string>;
  84856. /** Value to override severy settings */
  84857. severityOverrides?: Object;
  84858. }
  84859. /**
  84860. * The glTF validator object
  84861. * @ignore
  84862. */
  84863. interface IGLTFValidator {
  84864. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84865. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84866. }
  84867. /**
  84868. * Interfaces from the EXT_lights_image_based extension
  84869. */
  84870. /** @hidden */
  84871. interface IEXTLightsImageBased_LightReferenceImageBased {
  84872. light: number;
  84873. }
  84874. /** @hidden */
  84875. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  84876. intensity: number;
  84877. rotation: number[];
  84878. specularImageSize: number;
  84879. specularImages: number[][];
  84880. irradianceCoefficients: number[][];
  84881. }
  84882. /** @hidden */
  84883. interface IEXTLightsImageBased {
  84884. lights: IEXTLightsImageBased_LightImageBased[];
  84885. }
  84886. /**
  84887. * Interfaces from the EXT_mesh_gpu_instancing extension
  84888. * !!! Experimental Extension Subject to Changes !!!
  84889. */
  84890. /** @hidden */
  84891. interface IEXTMeshGpuInstancing {
  84892. mesh?: number;
  84893. attributes: { [name: string]: number };
  84894. }
  84895. /**
  84896. * Interfaces from the KHR_draco_mesh_compression extension
  84897. */
  84898. /** @hidden */
  84899. interface IKHRDracoMeshCompression {
  84900. bufferView: number;
  84901. attributes: { [name: string]: number };
  84902. }
  84903. /**
  84904. * Interfaces from the KHR_lights_punctual extension
  84905. */
  84906. /** @hidden */
  84907. const enum IKHRLightsPunctual_LightType {
  84908. DIRECTIONAL = "directional",
  84909. POINT = "point",
  84910. SPOT = "spot"
  84911. }
  84912. /** @hidden */
  84913. interface IKHRLightsPunctual_LightReference {
  84914. light: number;
  84915. }
  84916. /** @hidden */
  84917. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  84918. type: IKHRLightsPunctual_LightType;
  84919. color?: number[];
  84920. intensity?: number;
  84921. range?: number;
  84922. spot?: {
  84923. innerConeAngle?: number;
  84924. outerConeAngle?: number;
  84925. };
  84926. }
  84927. /** @hidden */
  84928. interface IKHRLightsPunctual {
  84929. lights: IKHRLightsPunctual_Light[];
  84930. }
  84931. /**
  84932. * Interfaces from the KHR_materials_clearcoat extension
  84933. * !!! Experimental Extension Subject to Changes !!!
  84934. */
  84935. /** @hidden */
  84936. interface IKHRMaterialsClearcoat {
  84937. clearcoatFactor: number;
  84938. clearcoatTexture: ITextureInfo;
  84939. clearcoatRoughnessFactor: number;
  84940. clearcoatRoughnessTexture: ITextureInfo;
  84941. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  84942. }
  84943. /**
  84944. * Interfaces from the KHR_materials_ior extension
  84945. * !!! Experimental Extension Subject to Changes !!!
  84946. */
  84947. /** @hidden */
  84948. interface IKHRMaterialsIor {
  84949. ior: number;
  84950. }
  84951. /**
  84952. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  84953. */
  84954. /** @hidden */
  84955. interface IKHRMaterialsPbrSpecularGlossiness {
  84956. diffuseFactor: number[];
  84957. diffuseTexture: ITextureInfo;
  84958. specularFactor: number[];
  84959. glossinessFactor: number;
  84960. specularGlossinessTexture: ITextureInfo;
  84961. }
  84962. /**
  84963. * Interfaces from the KHR_materials_sheen extension
  84964. * !!! Experimental Extension Subject to Changes !!!
  84965. */
  84966. /** @hidden */
  84967. interface IKHRMaterialsSheen {
  84968. sheenColorFactor?: number[];
  84969. sheenTexture?: ITextureInfo;
  84970. sheenRoughnessFactor?: number;
  84971. }
  84972. /**
  84973. * Interfaces from the KHR_materials_specular extension
  84974. * !!! Experimental Extension Subject to Changes !!!
  84975. */
  84976. /** @hidden */
  84977. interface IKHRMaterialsSpecular {
  84978. specularFactor: number;
  84979. specularColorFactor: number[];
  84980. specularTexture: ITextureInfo;
  84981. }
  84982. /**
  84983. * Interfaces from the KHR_materials_transmission extension
  84984. * !!! Experimental Extension Subject to Changes !!!
  84985. */
  84986. /** @hidden */
  84987. interface IKHRMaterialsTransmission {
  84988. transmissionFactor?: number;
  84989. transmissionTexture?: ITextureInfo;
  84990. }
  84991. /**
  84992. * Interfaces from the KHR_materials_variants extension
  84993. * !!! Experimental Extension Subject to Changes !!!
  84994. */
  84995. /** @hidden */
  84996. interface IKHRMaterialVariants_Mapping extends IProperty {
  84997. mappings: Array<{
  84998. variants: number[];
  84999. material: number;
  85000. }>;
  85001. }
  85002. /** @hidden */
  85003. interface IKHRMaterialVariants_Variant extends IProperty {
  85004. name: string;
  85005. }
  85006. /** @hidden */
  85007. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  85008. variants: Array<IKHRMaterialVariants_Variant>;
  85009. }
  85010. /**
  85011. * Interfaces from the KHR_texture_basisu extension
  85012. * !!! Experimental Extension Subject to Changes !!!
  85013. */
  85014. /** @hidden */
  85015. interface IKHRTextureBasisU {
  85016. source: number;
  85017. }
  85018. /**
  85019. * Interfaces from the EXT_texture_webp extension
  85020. */
  85021. /** @hidden */
  85022. interface IEXTTextureWebP {
  85023. source: number;
  85024. }
  85025. /**
  85026. * Interfaces from the KHR_texture_transform extension
  85027. */
  85028. /** @hidden */
  85029. interface IKHRTextureTransform {
  85030. offset?: number[];
  85031. rotation?: number;
  85032. scale?: number[];
  85033. texCoord?: number;
  85034. }
  85035. /**
  85036. * Interfaces from the KHR_xmp extension
  85037. * !!! Experimental Extension Subject to Changes !!!
  85038. */
  85039. /** @hidden */
  85040. interface IKHRXmp_Data {
  85041. [key: string]: unknown;
  85042. }
  85043. /** @hidden */
  85044. interface IKHRXmp_Gltf {
  85045. packets: IKHRXmp_Data[];
  85046. }
  85047. /** @hidden */
  85048. interface IKHRXmp_Node {
  85049. packet: number;
  85050. }
  85051. /**
  85052. * Interfaces from the MSFT_audio_emitter extension
  85053. */
  85054. /** @hidden */
  85055. interface IMSFTAudioEmitter_ClipReference {
  85056. clip: number;
  85057. weight?: number;
  85058. }
  85059. /** @hidden */
  85060. interface IMSFTAudioEmitter_EmittersReference {
  85061. emitters: number[];
  85062. }
  85063. /** @hidden */
  85064. const enum IMSFTAudioEmitter_DistanceModel {
  85065. linear = "linear",
  85066. inverse = "inverse",
  85067. exponential = "exponential",
  85068. }
  85069. /** @hidden */
  85070. interface IMSFTAudioEmitter_Emitter {
  85071. name?: string;
  85072. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  85073. refDistance?: number;
  85074. maxDistance?: number;
  85075. rolloffFactor?: number;
  85076. innerAngle?: number;
  85077. outerAngle?: number;
  85078. loop?: boolean;
  85079. volume?: number;
  85080. clips: IMSFTAudioEmitter_ClipReference[];
  85081. }
  85082. /** @hidden */
  85083. const enum IMSFTAudioEmitter_AudioMimeType {
  85084. WAV = "audio/wav",
  85085. }
  85086. /** @hidden */
  85087. interface IMSFTAudioEmitter_Clip extends IProperty {
  85088. uri?: string;
  85089. bufferView?: number;
  85090. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  85091. }
  85092. /** @hidden */
  85093. const enum IMSFTAudioEmitter_AnimationEventAction {
  85094. play = "play",
  85095. pause = "pause",
  85096. stop = "stop",
  85097. }
  85098. /** @hidden */
  85099. interface IMSFTAudioEmitter_AnimationEvent {
  85100. action: IMSFTAudioEmitter_AnimationEventAction;
  85101. emitter: number;
  85102. time: number;
  85103. startOffset?: number;
  85104. }
  85105. /**
  85106. * Interfaces from the MSFT_lod extension
  85107. */
  85108. /** @hidden */
  85109. interface IMSFTLOD {
  85110. ids: number[];
  85111. }
  85112. }
  85113. declare module BABYLON {
  85114. /** @hidden */
  85115. export var cellPixelShader: {
  85116. name: string;
  85117. shader: string;
  85118. };
  85119. }
  85120. declare module BABYLON {
  85121. /** @hidden */
  85122. export var cellVertexShader: {
  85123. name: string;
  85124. shader: string;
  85125. };
  85126. }
  85127. declare module BABYLON {
  85128. export class CellMaterial extends BABYLON.PushMaterial {
  85129. private _diffuseTexture;
  85130. diffuseTexture: BABYLON.BaseTexture;
  85131. diffuseColor: BABYLON.Color3;
  85132. _computeHighLevel: boolean;
  85133. computeHighLevel: boolean;
  85134. private _disableLighting;
  85135. disableLighting: boolean;
  85136. private _maxSimultaneousLights;
  85137. maxSimultaneousLights: number;
  85138. constructor(name: string, scene: BABYLON.Scene);
  85139. needAlphaBlending(): boolean;
  85140. needAlphaTesting(): boolean;
  85141. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85142. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85143. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85144. getAnimatables(): BABYLON.IAnimatable[];
  85145. getActiveTextures(): BABYLON.BaseTexture[];
  85146. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85147. dispose(forceDisposeEffect?: boolean): void;
  85148. getClassName(): string;
  85149. clone(name: string): CellMaterial;
  85150. serialize(): any;
  85151. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  85152. }
  85153. }
  85154. declare module BABYLON {
  85155. export class CustomShaderStructure {
  85156. FragmentStore: string;
  85157. VertexStore: string;
  85158. constructor();
  85159. }
  85160. export class ShaderSpecialParts {
  85161. constructor();
  85162. Fragment_Begin: string;
  85163. Fragment_Definitions: string;
  85164. Fragment_MainBegin: string;
  85165. Fragment_Custom_Diffuse: string;
  85166. Fragment_Before_Lights: string;
  85167. Fragment_Before_Fog: string;
  85168. Fragment_Custom_Alpha: string;
  85169. Fragment_Before_FragColor: string;
  85170. Vertex_Begin: string;
  85171. Vertex_Definitions: string;
  85172. Vertex_MainBegin: string;
  85173. Vertex_Before_PositionUpdated: string;
  85174. Vertex_Before_NormalUpdated: string;
  85175. Vertex_After_WorldPosComputed: string;
  85176. Vertex_MainEnd: string;
  85177. }
  85178. export class CustomMaterial extends BABYLON.StandardMaterial {
  85179. static ShaderIndexer: number;
  85180. CustomParts: ShaderSpecialParts;
  85181. _isCreatedShader: boolean;
  85182. _createdShaderName: string;
  85183. _customUniform: string[];
  85184. _newUniforms: string[];
  85185. _newUniformInstances: {
  85186. [name: string]: any;
  85187. };
  85188. _newSamplerInstances: {
  85189. [name: string]: BABYLON.Texture;
  85190. };
  85191. _customAttributes: string[];
  85192. FragmentShader: string;
  85193. VertexShader: string;
  85194. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85195. ReviewUniform(name: string, arr: string[]): string[];
  85196. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85197. constructor(name: string, scene: BABYLON.Scene);
  85198. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  85199. AddAttribute(name: string): CustomMaterial;
  85200. Fragment_Begin(shaderPart: string): CustomMaterial;
  85201. Fragment_Definitions(shaderPart: string): CustomMaterial;
  85202. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  85203. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  85204. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  85205. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  85206. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  85207. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  85208. Vertex_Begin(shaderPart: string): CustomMaterial;
  85209. Vertex_Definitions(shaderPart: string): CustomMaterial;
  85210. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  85211. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  85212. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  85213. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  85214. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  85215. }
  85216. }
  85217. declare module BABYLON {
  85218. export class ShaderAlebdoParts {
  85219. constructor();
  85220. Fragment_Begin: string;
  85221. Fragment_Definitions: string;
  85222. Fragment_MainBegin: string;
  85223. Fragment_Custom_Albedo: string;
  85224. Fragment_Before_Lights: string;
  85225. Fragment_Custom_MetallicRoughness: string;
  85226. Fragment_Custom_MicroSurface: string;
  85227. Fragment_Before_Fog: string;
  85228. Fragment_Custom_Alpha: string;
  85229. Fragment_Before_FragColor: string;
  85230. Vertex_Begin: string;
  85231. Vertex_Definitions: string;
  85232. Vertex_MainBegin: string;
  85233. Vertex_Before_PositionUpdated: string;
  85234. Vertex_Before_NormalUpdated: string;
  85235. Vertex_After_WorldPosComputed: string;
  85236. Vertex_MainEnd: string;
  85237. }
  85238. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  85239. static ShaderIndexer: number;
  85240. CustomParts: ShaderAlebdoParts;
  85241. _isCreatedShader: boolean;
  85242. _createdShaderName: string;
  85243. _customUniform: string[];
  85244. _newUniforms: string[];
  85245. _newUniformInstances: {
  85246. [name: string]: any;
  85247. };
  85248. _newSamplerInstances: {
  85249. [name: string]: BABYLON.Texture;
  85250. };
  85251. _customAttributes: string[];
  85252. FragmentShader: string;
  85253. VertexShader: string;
  85254. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85255. ReviewUniform(name: string, arr: string[]): string[];
  85256. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85257. constructor(name: string, scene: BABYLON.Scene);
  85258. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  85259. AddAttribute(name: string): PBRCustomMaterial;
  85260. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  85261. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  85262. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  85263. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  85264. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  85265. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  85266. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  85267. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  85268. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  85269. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  85270. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  85271. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  85272. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  85273. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  85274. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  85275. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  85276. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  85277. }
  85278. }
  85279. declare module BABYLON {
  85280. /** @hidden */
  85281. export var firePixelShader: {
  85282. name: string;
  85283. shader: string;
  85284. };
  85285. }
  85286. declare module BABYLON {
  85287. /** @hidden */
  85288. export var fireVertexShader: {
  85289. name: string;
  85290. shader: string;
  85291. };
  85292. }
  85293. declare module BABYLON {
  85294. export class FireMaterial extends BABYLON.PushMaterial {
  85295. private _diffuseTexture;
  85296. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85297. private _distortionTexture;
  85298. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85299. private _opacityTexture;
  85300. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85301. diffuseColor: BABYLON.Color3;
  85302. speed: number;
  85303. private _scaledDiffuse;
  85304. private _lastTime;
  85305. constructor(name: string, scene: BABYLON.Scene);
  85306. needAlphaBlending(): boolean;
  85307. needAlphaTesting(): boolean;
  85308. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85309. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85310. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85311. getAnimatables(): BABYLON.IAnimatable[];
  85312. getActiveTextures(): BABYLON.BaseTexture[];
  85313. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85314. getClassName(): string;
  85315. dispose(forceDisposeEffect?: boolean): void;
  85316. clone(name: string): FireMaterial;
  85317. serialize(): any;
  85318. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  85319. }
  85320. }
  85321. declare module BABYLON {
  85322. /** @hidden */
  85323. export var furPixelShader: {
  85324. name: string;
  85325. shader: string;
  85326. };
  85327. }
  85328. declare module BABYLON {
  85329. /** @hidden */
  85330. export var furVertexShader: {
  85331. name: string;
  85332. shader: string;
  85333. };
  85334. }
  85335. declare module BABYLON {
  85336. export class FurMaterial extends BABYLON.PushMaterial {
  85337. private _diffuseTexture;
  85338. diffuseTexture: BABYLON.BaseTexture;
  85339. private _heightTexture;
  85340. heightTexture: BABYLON.BaseTexture;
  85341. diffuseColor: BABYLON.Color3;
  85342. furLength: number;
  85343. furAngle: number;
  85344. furColor: BABYLON.Color3;
  85345. furOffset: number;
  85346. furSpacing: number;
  85347. furGravity: BABYLON.Vector3;
  85348. furSpeed: number;
  85349. furDensity: number;
  85350. furOcclusion: number;
  85351. furTexture: BABYLON.DynamicTexture;
  85352. private _disableLighting;
  85353. disableLighting: boolean;
  85354. private _maxSimultaneousLights;
  85355. maxSimultaneousLights: number;
  85356. highLevelFur: boolean;
  85357. _meshes: BABYLON.AbstractMesh[];
  85358. private _furTime;
  85359. constructor(name: string, scene: BABYLON.Scene);
  85360. get furTime(): number;
  85361. set furTime(furTime: number);
  85362. needAlphaBlending(): boolean;
  85363. needAlphaTesting(): boolean;
  85364. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85365. updateFur(): void;
  85366. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85367. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85368. getAnimatables(): BABYLON.IAnimatable[];
  85369. getActiveTextures(): BABYLON.BaseTexture[];
  85370. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85371. dispose(forceDisposeEffect?: boolean): void;
  85372. clone(name: string): FurMaterial;
  85373. serialize(): any;
  85374. getClassName(): string;
  85375. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  85376. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  85377. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  85378. }
  85379. }
  85380. declare module BABYLON {
  85381. /** @hidden */
  85382. export var gradientPixelShader: {
  85383. name: string;
  85384. shader: string;
  85385. };
  85386. }
  85387. declare module BABYLON {
  85388. /** @hidden */
  85389. export var gradientVertexShader: {
  85390. name: string;
  85391. shader: string;
  85392. };
  85393. }
  85394. declare module BABYLON {
  85395. export class GradientMaterial extends BABYLON.PushMaterial {
  85396. private _maxSimultaneousLights;
  85397. maxSimultaneousLights: number;
  85398. topColor: BABYLON.Color3;
  85399. topColorAlpha: number;
  85400. bottomColor: BABYLON.Color3;
  85401. bottomColorAlpha: number;
  85402. offset: number;
  85403. scale: number;
  85404. smoothness: number;
  85405. private _disableLighting;
  85406. disableLighting: boolean;
  85407. constructor(name: string, scene: BABYLON.Scene);
  85408. needAlphaBlending(): boolean;
  85409. needAlphaTesting(): boolean;
  85410. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85411. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85412. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85413. getAnimatables(): BABYLON.IAnimatable[];
  85414. dispose(forceDisposeEffect?: boolean): void;
  85415. clone(name: string): GradientMaterial;
  85416. serialize(): any;
  85417. getClassName(): string;
  85418. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  85419. }
  85420. }
  85421. declare module BABYLON {
  85422. /** @hidden */
  85423. export var gridPixelShader: {
  85424. name: string;
  85425. shader: string;
  85426. };
  85427. }
  85428. declare module BABYLON {
  85429. /** @hidden */
  85430. export var gridVertexShader: {
  85431. name: string;
  85432. shader: string;
  85433. };
  85434. }
  85435. declare module BABYLON {
  85436. /**
  85437. * The grid materials allows you to wrap any shape with a grid.
  85438. * Colors are customizable.
  85439. */
  85440. export class GridMaterial extends BABYLON.PushMaterial {
  85441. /**
  85442. * Main color of the grid (e.g. between lines)
  85443. */
  85444. mainColor: BABYLON.Color3;
  85445. /**
  85446. * Color of the grid lines.
  85447. */
  85448. lineColor: BABYLON.Color3;
  85449. /**
  85450. * The scale of the grid compared to unit.
  85451. */
  85452. gridRatio: number;
  85453. /**
  85454. * Allows setting an offset for the grid lines.
  85455. */
  85456. gridOffset: BABYLON.Vector3;
  85457. /**
  85458. * The frequency of thicker lines.
  85459. */
  85460. majorUnitFrequency: number;
  85461. /**
  85462. * The visibility of minor units in the grid.
  85463. */
  85464. minorUnitVisibility: number;
  85465. /**
  85466. * The grid opacity outside of the lines.
  85467. */
  85468. opacity: number;
  85469. /**
  85470. * Determine RBG output is premultiplied by alpha value.
  85471. */
  85472. preMultiplyAlpha: boolean;
  85473. private _opacityTexture;
  85474. opacityTexture: BABYLON.BaseTexture;
  85475. private _gridControl;
  85476. /**
  85477. * constructor
  85478. * @param name The name given to the material in order to identify it afterwards.
  85479. * @param scene The scene the material is used in.
  85480. */
  85481. constructor(name: string, scene: BABYLON.Scene);
  85482. /**
  85483. * Returns wehter or not the grid requires alpha blending.
  85484. */
  85485. needAlphaBlending(): boolean;
  85486. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85487. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85488. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85489. /**
  85490. * Dispose the material and its associated resources.
  85491. * @param forceDisposeEffect will also dispose the used effect when true
  85492. */
  85493. dispose(forceDisposeEffect?: boolean): void;
  85494. clone(name: string): GridMaterial;
  85495. serialize(): any;
  85496. getClassName(): string;
  85497. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  85498. }
  85499. }
  85500. declare module BABYLON {
  85501. /** @hidden */
  85502. export var lavaPixelShader: {
  85503. name: string;
  85504. shader: string;
  85505. };
  85506. }
  85507. declare module BABYLON {
  85508. /** @hidden */
  85509. export var lavaVertexShader: {
  85510. name: string;
  85511. shader: string;
  85512. };
  85513. }
  85514. declare module BABYLON {
  85515. export class LavaMaterial extends BABYLON.PushMaterial {
  85516. private _diffuseTexture;
  85517. diffuseTexture: BABYLON.BaseTexture;
  85518. noiseTexture: BABYLON.BaseTexture;
  85519. fogColor: BABYLON.Color3;
  85520. speed: number;
  85521. movingSpeed: number;
  85522. lowFrequencySpeed: number;
  85523. fogDensity: number;
  85524. private _lastTime;
  85525. diffuseColor: BABYLON.Color3;
  85526. private _disableLighting;
  85527. disableLighting: boolean;
  85528. private _unlit;
  85529. unlit: boolean;
  85530. private _maxSimultaneousLights;
  85531. maxSimultaneousLights: number;
  85532. private _scaledDiffuse;
  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. dispose(forceDisposeEffect?: boolean): void;
  85543. clone(name: string): LavaMaterial;
  85544. serialize(): any;
  85545. getClassName(): string;
  85546. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  85547. }
  85548. }
  85549. declare module BABYLON {
  85550. /** @hidden */
  85551. export var mixPixelShader: {
  85552. name: string;
  85553. shader: string;
  85554. };
  85555. }
  85556. declare module BABYLON {
  85557. /** @hidden */
  85558. export var mixVertexShader: {
  85559. name: string;
  85560. shader: string;
  85561. };
  85562. }
  85563. declare module BABYLON {
  85564. export class MixMaterial extends BABYLON.PushMaterial {
  85565. /**
  85566. * Mix textures
  85567. */
  85568. private _mixTexture1;
  85569. mixTexture1: BABYLON.BaseTexture;
  85570. private _mixTexture2;
  85571. mixTexture2: BABYLON.BaseTexture;
  85572. /**
  85573. * Diffuse textures
  85574. */
  85575. private _diffuseTexture1;
  85576. diffuseTexture1: BABYLON.Texture;
  85577. private _diffuseTexture2;
  85578. diffuseTexture2: BABYLON.Texture;
  85579. private _diffuseTexture3;
  85580. diffuseTexture3: BABYLON.Texture;
  85581. private _diffuseTexture4;
  85582. diffuseTexture4: BABYLON.Texture;
  85583. private _diffuseTexture5;
  85584. diffuseTexture5: BABYLON.Texture;
  85585. private _diffuseTexture6;
  85586. diffuseTexture6: BABYLON.Texture;
  85587. private _diffuseTexture7;
  85588. diffuseTexture7: BABYLON.Texture;
  85589. private _diffuseTexture8;
  85590. diffuseTexture8: BABYLON.Texture;
  85591. /**
  85592. * Uniforms
  85593. */
  85594. diffuseColor: BABYLON.Color3;
  85595. specularColor: BABYLON.Color3;
  85596. specularPower: number;
  85597. private _disableLighting;
  85598. disableLighting: boolean;
  85599. private _maxSimultaneousLights;
  85600. maxSimultaneousLights: number;
  85601. constructor(name: string, scene: BABYLON.Scene);
  85602. needAlphaBlending(): boolean;
  85603. needAlphaTesting(): boolean;
  85604. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85605. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85606. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85607. getAnimatables(): BABYLON.IAnimatable[];
  85608. getActiveTextures(): BABYLON.BaseTexture[];
  85609. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85610. dispose(forceDisposeEffect?: boolean): void;
  85611. clone(name: string): MixMaterial;
  85612. serialize(): any;
  85613. getClassName(): string;
  85614. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  85615. }
  85616. }
  85617. declare module BABYLON {
  85618. /** @hidden */
  85619. export var normalPixelShader: {
  85620. name: string;
  85621. shader: string;
  85622. };
  85623. }
  85624. declare module BABYLON {
  85625. /** @hidden */
  85626. export var normalVertexShader: {
  85627. name: string;
  85628. shader: string;
  85629. };
  85630. }
  85631. declare module BABYLON {
  85632. export class NormalMaterial extends BABYLON.PushMaterial {
  85633. private _diffuseTexture;
  85634. diffuseTexture: BABYLON.BaseTexture;
  85635. diffuseColor: BABYLON.Color3;
  85636. private _disableLighting;
  85637. disableLighting: boolean;
  85638. private _maxSimultaneousLights;
  85639. maxSimultaneousLights: number;
  85640. constructor(name: string, scene: BABYLON.Scene);
  85641. needAlphaBlending(): boolean;
  85642. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  85643. needAlphaTesting(): boolean;
  85644. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85645. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85646. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85647. getAnimatables(): BABYLON.IAnimatable[];
  85648. getActiveTextures(): BABYLON.BaseTexture[];
  85649. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85650. dispose(forceDisposeEffect?: boolean): void;
  85651. clone(name: string): NormalMaterial;
  85652. serialize(): any;
  85653. getClassName(): string;
  85654. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  85655. }
  85656. }
  85657. declare module BABYLON {
  85658. /** @hidden */
  85659. export var shadowOnlyPixelShader: {
  85660. name: string;
  85661. shader: string;
  85662. };
  85663. }
  85664. declare module BABYLON {
  85665. /** @hidden */
  85666. export var shadowOnlyVertexShader: {
  85667. name: string;
  85668. shader: string;
  85669. };
  85670. }
  85671. declare module BABYLON {
  85672. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  85673. private _activeLight;
  85674. private _needAlphaBlending;
  85675. constructor(name: string, scene: BABYLON.Scene);
  85676. shadowColor: BABYLON.Color3;
  85677. needAlphaBlending(): boolean;
  85678. needAlphaTesting(): boolean;
  85679. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85680. get activeLight(): BABYLON.IShadowLight;
  85681. set activeLight(light: BABYLON.IShadowLight);
  85682. private _getFirstShadowLightForMesh;
  85683. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85684. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85685. clone(name: string): ShadowOnlyMaterial;
  85686. serialize(): any;
  85687. getClassName(): string;
  85688. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  85689. }
  85690. }
  85691. declare module BABYLON {
  85692. /** @hidden */
  85693. export var simplePixelShader: {
  85694. name: string;
  85695. shader: string;
  85696. };
  85697. }
  85698. declare module BABYLON {
  85699. /** @hidden */
  85700. export var simpleVertexShader: {
  85701. name: string;
  85702. shader: string;
  85703. };
  85704. }
  85705. declare module BABYLON {
  85706. export class SimpleMaterial extends BABYLON.PushMaterial {
  85707. private _diffuseTexture;
  85708. diffuseTexture: BABYLON.BaseTexture;
  85709. diffuseColor: BABYLON.Color3;
  85710. private _disableLighting;
  85711. disableLighting: boolean;
  85712. private _maxSimultaneousLights;
  85713. maxSimultaneousLights: number;
  85714. constructor(name: string, scene: BABYLON.Scene);
  85715. needAlphaBlending(): boolean;
  85716. needAlphaTesting(): boolean;
  85717. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85718. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85719. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85720. getAnimatables(): BABYLON.IAnimatable[];
  85721. getActiveTextures(): BABYLON.BaseTexture[];
  85722. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85723. dispose(forceDisposeEffect?: boolean): void;
  85724. clone(name: string): SimpleMaterial;
  85725. serialize(): any;
  85726. getClassName(): string;
  85727. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  85728. }
  85729. }
  85730. declare module BABYLON {
  85731. /** @hidden */
  85732. export var skyPixelShader: {
  85733. name: string;
  85734. shader: string;
  85735. };
  85736. }
  85737. declare module BABYLON {
  85738. /** @hidden */
  85739. export var skyVertexShader: {
  85740. name: string;
  85741. shader: string;
  85742. };
  85743. }
  85744. declare module BABYLON {
  85745. /**
  85746. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  85747. * @see https://doc.babylonjs.com/extensions/sky
  85748. */
  85749. export class SkyMaterial extends BABYLON.PushMaterial {
  85750. /**
  85751. * Defines the overall luminance of sky in interval ]0, 1[.
  85752. */
  85753. luminance: number;
  85754. /**
  85755. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  85756. */
  85757. turbidity: number;
  85758. /**
  85759. * Defines the sky appearance (light intensity).
  85760. */
  85761. rayleigh: number;
  85762. /**
  85763. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  85764. */
  85765. mieCoefficient: number;
  85766. /**
  85767. * Defines the amount of haze particles following the Mie scattering theory.
  85768. */
  85769. mieDirectionalG: number;
  85770. /**
  85771. * Defines the distance of the sun according to the active scene camera.
  85772. */
  85773. distance: number;
  85774. /**
  85775. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  85776. * "inclined".
  85777. */
  85778. inclination: number;
  85779. /**
  85780. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  85781. * an object direction and a reference direction.
  85782. */
  85783. azimuth: number;
  85784. /**
  85785. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  85786. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  85787. */
  85788. sunPosition: BABYLON.Vector3;
  85789. /**
  85790. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  85791. * .sunPosition property.
  85792. */
  85793. useSunPosition: boolean;
  85794. /**
  85795. * Defines an offset vector used to get a horizon offset.
  85796. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  85797. */
  85798. cameraOffset: BABYLON.Vector3;
  85799. private _cameraPosition;
  85800. /**
  85801. * Instantiates a new sky material.
  85802. * This material allows to create dynamic and texture free
  85803. * effects for skyboxes by taking care of the atmosphere state.
  85804. * @see https://doc.babylonjs.com/extensions/sky
  85805. * @param name Define the name of the material in the scene
  85806. * @param scene Define the scene the material belong to
  85807. */
  85808. constructor(name: string, scene: BABYLON.Scene);
  85809. /**
  85810. * Specifies if the material will require alpha blending
  85811. * @returns a boolean specifying if alpha blending is needed
  85812. */
  85813. needAlphaBlending(): boolean;
  85814. /**
  85815. * Specifies if this material should be rendered in alpha test mode
  85816. * @returns false as the sky material doesn't need alpha testing.
  85817. */
  85818. needAlphaTesting(): boolean;
  85819. /**
  85820. * Get the texture used for alpha test purpose.
  85821. * @returns null as the sky material has no texture.
  85822. */
  85823. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85824. /**
  85825. * Get if the submesh is ready to be used and all its information available.
  85826. * Child classes can use it to update shaders
  85827. * @param mesh defines the mesh to check
  85828. * @param subMesh defines which submesh to check
  85829. * @param useInstances specifies that instances should be used
  85830. * @returns a boolean indicating that the submesh is ready or not
  85831. */
  85832. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85833. /**
  85834. * Binds the submesh to this material by preparing the effect and shader to draw
  85835. * @param world defines the world transformation matrix
  85836. * @param mesh defines the mesh containing the submesh
  85837. * @param subMesh defines the submesh to bind the material to
  85838. */
  85839. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85840. /**
  85841. * Get the list of animatables in the material.
  85842. * @returns the list of animatables object used in the material
  85843. */
  85844. getAnimatables(): BABYLON.IAnimatable[];
  85845. /**
  85846. * Disposes the material
  85847. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85848. */
  85849. dispose(forceDisposeEffect?: boolean): void;
  85850. /**
  85851. * Makes a duplicate of the material, and gives it a new name
  85852. * @param name defines the new name for the duplicated material
  85853. * @returns the cloned material
  85854. */
  85855. clone(name: string): SkyMaterial;
  85856. /**
  85857. * Serializes this material in a JSON representation
  85858. * @returns the serialized material object
  85859. */
  85860. serialize(): any;
  85861. /**
  85862. * Gets the current class name of the material e.g. "SkyMaterial"
  85863. * Mainly use in serialization.
  85864. * @returns the class name
  85865. */
  85866. getClassName(): string;
  85867. /**
  85868. * Creates a sky material from parsed material data
  85869. * @param source defines the JSON representation of the material
  85870. * @param scene defines the hosting scene
  85871. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85872. * @returns a new sky material
  85873. */
  85874. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  85875. }
  85876. }
  85877. declare module BABYLON {
  85878. /** @hidden */
  85879. export var terrainPixelShader: {
  85880. name: string;
  85881. shader: string;
  85882. };
  85883. }
  85884. declare module BABYLON {
  85885. /** @hidden */
  85886. export var terrainVertexShader: {
  85887. name: string;
  85888. shader: string;
  85889. };
  85890. }
  85891. declare module BABYLON {
  85892. export class TerrainMaterial extends BABYLON.PushMaterial {
  85893. private _mixTexture;
  85894. mixTexture: BABYLON.BaseTexture;
  85895. private _diffuseTexture1;
  85896. diffuseTexture1: BABYLON.Texture;
  85897. private _diffuseTexture2;
  85898. diffuseTexture2: BABYLON.Texture;
  85899. private _diffuseTexture3;
  85900. diffuseTexture3: BABYLON.Texture;
  85901. private _bumpTexture1;
  85902. bumpTexture1: BABYLON.Texture;
  85903. private _bumpTexture2;
  85904. bumpTexture2: BABYLON.Texture;
  85905. private _bumpTexture3;
  85906. bumpTexture3: BABYLON.Texture;
  85907. diffuseColor: BABYLON.Color3;
  85908. specularColor: BABYLON.Color3;
  85909. specularPower: number;
  85910. private _disableLighting;
  85911. disableLighting: boolean;
  85912. private _maxSimultaneousLights;
  85913. maxSimultaneousLights: number;
  85914. constructor(name: string, scene: BABYLON.Scene);
  85915. needAlphaBlending(): boolean;
  85916. needAlphaTesting(): boolean;
  85917. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85918. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85919. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85920. getAnimatables(): BABYLON.IAnimatable[];
  85921. getActiveTextures(): BABYLON.BaseTexture[];
  85922. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85923. dispose(forceDisposeEffect?: boolean): void;
  85924. clone(name: string): TerrainMaterial;
  85925. serialize(): any;
  85926. getClassName(): string;
  85927. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  85928. }
  85929. }
  85930. declare module BABYLON {
  85931. /** @hidden */
  85932. export var triplanarPixelShader: {
  85933. name: string;
  85934. shader: string;
  85935. };
  85936. }
  85937. declare module BABYLON {
  85938. /** @hidden */
  85939. export var triplanarVertexShader: {
  85940. name: string;
  85941. shader: string;
  85942. };
  85943. }
  85944. declare module BABYLON {
  85945. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  85946. mixTexture: BABYLON.BaseTexture;
  85947. private _diffuseTextureX;
  85948. diffuseTextureX: BABYLON.BaseTexture;
  85949. private _diffuseTextureY;
  85950. diffuseTextureY: BABYLON.BaseTexture;
  85951. private _diffuseTextureZ;
  85952. diffuseTextureZ: BABYLON.BaseTexture;
  85953. private _normalTextureX;
  85954. normalTextureX: BABYLON.BaseTexture;
  85955. private _normalTextureY;
  85956. normalTextureY: BABYLON.BaseTexture;
  85957. private _normalTextureZ;
  85958. normalTextureZ: BABYLON.BaseTexture;
  85959. tileSize: number;
  85960. diffuseColor: BABYLON.Color3;
  85961. specularColor: BABYLON.Color3;
  85962. specularPower: number;
  85963. private _disableLighting;
  85964. disableLighting: boolean;
  85965. private _maxSimultaneousLights;
  85966. maxSimultaneousLights: number;
  85967. constructor(name: string, scene: BABYLON.Scene);
  85968. needAlphaBlending(): boolean;
  85969. needAlphaTesting(): boolean;
  85970. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85971. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85972. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85973. getAnimatables(): BABYLON.IAnimatable[];
  85974. getActiveTextures(): BABYLON.BaseTexture[];
  85975. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85976. dispose(forceDisposeEffect?: boolean): void;
  85977. clone(name: string): TriPlanarMaterial;
  85978. serialize(): any;
  85979. getClassName(): string;
  85980. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  85981. }
  85982. }
  85983. declare module BABYLON {
  85984. /** @hidden */
  85985. export var waterPixelShader: {
  85986. name: string;
  85987. shader: string;
  85988. };
  85989. }
  85990. declare module BABYLON {
  85991. /** @hidden */
  85992. export var waterVertexShader: {
  85993. name: string;
  85994. shader: string;
  85995. };
  85996. }
  85997. declare module BABYLON {
  85998. export class WaterMaterial extends BABYLON.PushMaterial {
  85999. renderTargetSize: BABYLON.Vector2;
  86000. private _bumpTexture;
  86001. bumpTexture: BABYLON.BaseTexture;
  86002. diffuseColor: BABYLON.Color3;
  86003. specularColor: BABYLON.Color3;
  86004. specularPower: number;
  86005. private _disableLighting;
  86006. disableLighting: boolean;
  86007. private _maxSimultaneousLights;
  86008. maxSimultaneousLights: number;
  86009. /**
  86010. * @param {number}: Represents the wind force
  86011. */
  86012. windForce: number;
  86013. /**
  86014. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  86015. */
  86016. windDirection: BABYLON.Vector2;
  86017. /**
  86018. * @param {number}: Wave height, represents the height of the waves
  86019. */
  86020. waveHeight: number;
  86021. /**
  86022. * @param {number}: Bump height, represents the bump height related to the bump map
  86023. */
  86024. bumpHeight: number;
  86025. /**
  86026. * @param {boolean}: Add a smaller moving bump to less steady waves.
  86027. */
  86028. private _bumpSuperimpose;
  86029. bumpSuperimpose: boolean;
  86030. /**
  86031. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  86032. */
  86033. private _fresnelSeparate;
  86034. fresnelSeparate: boolean;
  86035. /**
  86036. * @param {boolean}: bump Waves modify the reflection.
  86037. */
  86038. private _bumpAffectsReflection;
  86039. bumpAffectsReflection: boolean;
  86040. /**
  86041. * @param {number}: The water color blended with the refraction (near)
  86042. */
  86043. waterColor: BABYLON.Color3;
  86044. /**
  86045. * @param {number}: The blend factor related to the water color
  86046. */
  86047. colorBlendFactor: number;
  86048. /**
  86049. * @param {number}: The water color blended with the reflection (far)
  86050. */
  86051. waterColor2: BABYLON.Color3;
  86052. /**
  86053. * @param {number}: The blend factor related to the water color (reflection, far)
  86054. */
  86055. colorBlendFactor2: number;
  86056. /**
  86057. * @param {number}: Represents the maximum length of a wave
  86058. */
  86059. waveLength: number;
  86060. /**
  86061. * @param {number}: Defines the waves speed
  86062. */
  86063. waveSpeed: number;
  86064. /**
  86065. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  86066. * will avoid calculating useless pixels in the pixel shader of the water material.
  86067. */
  86068. disableClipPlane: boolean;
  86069. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  86070. private _mesh;
  86071. private _refractionRTT;
  86072. private _reflectionRTT;
  86073. private _reflectionTransform;
  86074. private _lastTime;
  86075. private _lastDeltaTime;
  86076. private _useLogarithmicDepth;
  86077. private _waitingRenderList;
  86078. private _imageProcessingConfiguration;
  86079. private _imageProcessingObserver;
  86080. /**
  86081. * Gets a boolean indicating that current material needs to register RTT
  86082. */
  86083. get hasRenderTargetTextures(): boolean;
  86084. /**
  86085. * Constructor
  86086. */
  86087. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  86088. get useLogarithmicDepth(): boolean;
  86089. set useLogarithmicDepth(value: boolean);
  86090. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86091. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86092. addToRenderList(node: any): void;
  86093. enableRenderTargets(enable: boolean): void;
  86094. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  86095. get renderTargetsEnabled(): boolean;
  86096. needAlphaBlending(): boolean;
  86097. needAlphaTesting(): boolean;
  86098. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86099. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86100. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86101. private _createRenderTargets;
  86102. getAnimatables(): BABYLON.IAnimatable[];
  86103. getActiveTextures(): BABYLON.BaseTexture[];
  86104. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86105. dispose(forceDisposeEffect?: boolean): void;
  86106. clone(name: string): WaterMaterial;
  86107. serialize(): any;
  86108. getClassName(): string;
  86109. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  86110. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  86111. }
  86112. }
  86113. declare module BABYLON {
  86114. /** @hidden */
  86115. export var asciiartPixelShader: {
  86116. name: string;
  86117. shader: string;
  86118. };
  86119. }
  86120. declare module BABYLON {
  86121. /**
  86122. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  86123. *
  86124. * It basically takes care rendering the font front the given font size to a texture.
  86125. * This is used later on in the postprocess.
  86126. */
  86127. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  86128. private _font;
  86129. private _text;
  86130. private _charSize;
  86131. /**
  86132. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86133. */
  86134. get charSize(): number;
  86135. /**
  86136. * Create a new instance of the Ascii Art FontTexture class
  86137. * @param name the name of the texture
  86138. * @param font the font to use, use the W3C CSS notation
  86139. * @param text the caracter set to use in the rendering.
  86140. * @param scene the scene that owns the texture
  86141. */
  86142. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86143. /**
  86144. * Gets the max char width of a font.
  86145. * @param font the font to use, use the W3C CSS notation
  86146. * @return the max char width
  86147. */
  86148. private getFontWidth;
  86149. /**
  86150. * Gets the max char height of a font.
  86151. * @param font the font to use, use the W3C CSS notation
  86152. * @return the max char height
  86153. */
  86154. private getFontHeight;
  86155. /**
  86156. * Clones the current AsciiArtTexture.
  86157. * @return the clone of the texture.
  86158. */
  86159. clone(): AsciiArtFontTexture;
  86160. /**
  86161. * Parses a json object representing the texture and returns an instance of it.
  86162. * @param source the source JSON representation
  86163. * @param scene the scene to create the texture for
  86164. * @return the parsed texture
  86165. */
  86166. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  86167. }
  86168. /**
  86169. * Option available in the Ascii Art Post Process.
  86170. */
  86171. export interface IAsciiArtPostProcessOptions {
  86172. /**
  86173. * The font to use following the w3c font definition.
  86174. */
  86175. font?: string;
  86176. /**
  86177. * The character set to use in the postprocess.
  86178. */
  86179. characterSet?: string;
  86180. /**
  86181. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86182. * This number is defined between 0 and 1;
  86183. */
  86184. mixToTile?: number;
  86185. /**
  86186. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86187. * This number is defined between 0 and 1;
  86188. */
  86189. mixToNormal?: number;
  86190. }
  86191. /**
  86192. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  86193. *
  86194. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86195. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  86196. */
  86197. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  86198. /**
  86199. * The font texture used to render the char in the post process.
  86200. */
  86201. private _asciiArtFontTexture;
  86202. /**
  86203. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86204. * This number is defined between 0 and 1;
  86205. */
  86206. mixToTile: number;
  86207. /**
  86208. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86209. * This number is defined between 0 and 1;
  86210. */
  86211. mixToNormal: number;
  86212. /**
  86213. * Instantiates a new Ascii Art Post Process.
  86214. * @param name the name to give to the postprocess
  86215. * @camera the camera to apply the post process to.
  86216. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  86217. */
  86218. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  86219. }
  86220. }
  86221. declare module BABYLON {
  86222. /** @hidden */
  86223. export var digitalrainPixelShader: {
  86224. name: string;
  86225. shader: string;
  86226. };
  86227. }
  86228. declare module BABYLON {
  86229. /**
  86230. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  86231. *
  86232. * It basically takes care rendering the font front the given font size to a texture.
  86233. * This is used later on in the postprocess.
  86234. */
  86235. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  86236. private _font;
  86237. private _text;
  86238. private _charSize;
  86239. /**
  86240. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86241. */
  86242. get charSize(): number;
  86243. /**
  86244. * Create a new instance of the Digital Rain FontTexture class
  86245. * @param name the name of the texture
  86246. * @param font the font to use, use the W3C CSS notation
  86247. * @param text the caracter set to use in the rendering.
  86248. * @param scene the scene that owns the texture
  86249. */
  86250. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86251. /**
  86252. * Gets the max char width of a font.
  86253. * @param font the font to use, use the W3C CSS notation
  86254. * @return the max char width
  86255. */
  86256. private getFontWidth;
  86257. /**
  86258. * Gets the max char height of a font.
  86259. * @param font the font to use, use the W3C CSS notation
  86260. * @return the max char height
  86261. */
  86262. private getFontHeight;
  86263. /**
  86264. * Clones the current DigitalRainFontTexture.
  86265. * @return the clone of the texture.
  86266. */
  86267. clone(): DigitalRainFontTexture;
  86268. /**
  86269. * Parses a json object representing the texture and returns an instance of it.
  86270. * @param source the source JSON representation
  86271. * @param scene the scene to create the texture for
  86272. * @return the parsed texture
  86273. */
  86274. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  86275. }
  86276. /**
  86277. * Option available in the Digital Rain Post Process.
  86278. */
  86279. export interface IDigitalRainPostProcessOptions {
  86280. /**
  86281. * The font to use following the w3c font definition.
  86282. */
  86283. font?: string;
  86284. /**
  86285. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86286. * This number is defined between 0 and 1;
  86287. */
  86288. mixToTile?: number;
  86289. /**
  86290. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86291. * This number is defined between 0 and 1;
  86292. */
  86293. mixToNormal?: number;
  86294. }
  86295. /**
  86296. * DigitalRainPostProcess helps rendering everithing in digital rain.
  86297. *
  86298. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86299. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  86300. */
  86301. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  86302. /**
  86303. * The font texture used to render the char in the post process.
  86304. */
  86305. private _digitalRainFontTexture;
  86306. /**
  86307. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  86308. * This number is defined between 0 and 1;
  86309. */
  86310. mixToTile: number;
  86311. /**
  86312. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  86313. * This number is defined between 0 and 1;
  86314. */
  86315. mixToNormal: number;
  86316. /**
  86317. * Instantiates a new Digital Rain Post Process.
  86318. * @param name the name to give to the postprocess
  86319. * @camera the camera to apply the post process to.
  86320. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  86321. */
  86322. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  86323. }
  86324. }
  86325. declare module BABYLON {
  86326. /** @hidden */
  86327. export var brickProceduralTexturePixelShader: {
  86328. name: string;
  86329. shader: string;
  86330. };
  86331. }
  86332. declare module BABYLON {
  86333. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  86334. private _numberOfBricksHeight;
  86335. private _numberOfBricksWidth;
  86336. private _jointColor;
  86337. private _brickColor;
  86338. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86339. updateShaderUniforms(): void;
  86340. get numberOfBricksHeight(): number;
  86341. set numberOfBricksHeight(value: number);
  86342. get numberOfBricksWidth(): number;
  86343. set numberOfBricksWidth(value: number);
  86344. get jointColor(): BABYLON.Color3;
  86345. set jointColor(value: BABYLON.Color3);
  86346. get brickColor(): BABYLON.Color3;
  86347. set brickColor(value: BABYLON.Color3);
  86348. /**
  86349. * Serializes this brick procedural texture
  86350. * @returns a serialized brick procedural texture object
  86351. */
  86352. serialize(): any;
  86353. /**
  86354. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  86355. * @param parsedTexture defines parsed texture data
  86356. * @param scene defines the current scene
  86357. * @param rootUrl defines the root URL containing brick procedural texture information
  86358. * @returns a parsed Brick Procedural BABYLON.Texture
  86359. */
  86360. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  86361. }
  86362. }
  86363. declare module BABYLON {
  86364. /** @hidden */
  86365. export var cloudProceduralTexturePixelShader: {
  86366. name: string;
  86367. shader: string;
  86368. };
  86369. }
  86370. declare module BABYLON {
  86371. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  86372. private _skyColor;
  86373. private _cloudColor;
  86374. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86375. updateShaderUniforms(): void;
  86376. get skyColor(): BABYLON.Color4;
  86377. set skyColor(value: BABYLON.Color4);
  86378. get cloudColor(): BABYLON.Color4;
  86379. set cloudColor(value: BABYLON.Color4);
  86380. /**
  86381. * Serializes this cloud procedural texture
  86382. * @returns a serialized cloud procedural texture object
  86383. */
  86384. serialize(): any;
  86385. /**
  86386. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  86387. * @param parsedTexture defines parsed texture data
  86388. * @param scene defines the current scene
  86389. * @param rootUrl defines the root URL containing cloud procedural texture information
  86390. * @returns a parsed Cloud Procedural BABYLON.Texture
  86391. */
  86392. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  86393. }
  86394. }
  86395. declare module BABYLON {
  86396. /** @hidden */
  86397. export var fireProceduralTexturePixelShader: {
  86398. name: string;
  86399. shader: string;
  86400. };
  86401. }
  86402. declare module BABYLON {
  86403. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  86404. private _time;
  86405. private _speed;
  86406. private _autoGenerateTime;
  86407. private _fireColors;
  86408. private _alphaThreshold;
  86409. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86410. updateShaderUniforms(): void;
  86411. render(useCameraPostProcess?: boolean): void;
  86412. static get PurpleFireColors(): BABYLON.Color3[];
  86413. static get GreenFireColors(): BABYLON.Color3[];
  86414. static get RedFireColors(): BABYLON.Color3[];
  86415. static get BlueFireColors(): BABYLON.Color3[];
  86416. get autoGenerateTime(): boolean;
  86417. set autoGenerateTime(value: boolean);
  86418. get fireColors(): BABYLON.Color3[];
  86419. set fireColors(value: BABYLON.Color3[]);
  86420. get time(): number;
  86421. set time(value: number);
  86422. get speed(): BABYLON.Vector2;
  86423. set speed(value: BABYLON.Vector2);
  86424. get alphaThreshold(): number;
  86425. set alphaThreshold(value: number);
  86426. /**
  86427. * Serializes this fire procedural texture
  86428. * @returns a serialized fire procedural texture object
  86429. */
  86430. serialize(): any;
  86431. /**
  86432. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  86433. * @param parsedTexture defines parsed texture data
  86434. * @param scene defines the current scene
  86435. * @param rootUrl defines the root URL containing fire procedural texture information
  86436. * @returns a parsed Fire Procedural BABYLON.Texture
  86437. */
  86438. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  86439. }
  86440. }
  86441. declare module BABYLON {
  86442. /** @hidden */
  86443. export var grassProceduralTexturePixelShader: {
  86444. name: string;
  86445. shader: string;
  86446. };
  86447. }
  86448. declare module BABYLON {
  86449. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  86450. private _grassColors;
  86451. private _groundColor;
  86452. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86453. updateShaderUniforms(): void;
  86454. get grassColors(): BABYLON.Color3[];
  86455. set grassColors(value: BABYLON.Color3[]);
  86456. get groundColor(): BABYLON.Color3;
  86457. set groundColor(value: BABYLON.Color3);
  86458. /**
  86459. * Serializes this grass procedural texture
  86460. * @returns a serialized grass procedural texture object
  86461. */
  86462. serialize(): any;
  86463. /**
  86464. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  86465. * @param parsedTexture defines parsed texture data
  86466. * @param scene defines the current scene
  86467. * @param rootUrl defines the root URL containing grass procedural texture information
  86468. * @returns a parsed Grass Procedural BABYLON.Texture
  86469. */
  86470. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  86471. }
  86472. }
  86473. declare module BABYLON {
  86474. /** @hidden */
  86475. export var marbleProceduralTexturePixelShader: {
  86476. name: string;
  86477. shader: string;
  86478. };
  86479. }
  86480. declare module BABYLON {
  86481. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  86482. private _numberOfTilesHeight;
  86483. private _numberOfTilesWidth;
  86484. private _amplitude;
  86485. private _jointColor;
  86486. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86487. updateShaderUniforms(): void;
  86488. get numberOfTilesHeight(): number;
  86489. set numberOfTilesHeight(value: number);
  86490. get amplitude(): number;
  86491. set amplitude(value: number);
  86492. get numberOfTilesWidth(): number;
  86493. set numberOfTilesWidth(value: number);
  86494. get jointColor(): BABYLON.Color3;
  86495. set jointColor(value: BABYLON.Color3);
  86496. /**
  86497. * Serializes this marble procedural texture
  86498. * @returns a serialized marble procedural texture object
  86499. */
  86500. serialize(): any;
  86501. /**
  86502. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  86503. * @param parsedTexture defines parsed texture data
  86504. * @param scene defines the current scene
  86505. * @param rootUrl defines the root URL containing marble procedural texture information
  86506. * @returns a parsed Marble Procedural BABYLON.Texture
  86507. */
  86508. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  86509. }
  86510. }
  86511. declare module BABYLON {
  86512. /** @hidden */
  86513. export var normalMapProceduralTexturePixelShader: {
  86514. name: string;
  86515. shader: string;
  86516. };
  86517. }
  86518. declare module BABYLON {
  86519. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  86520. private _baseTexture;
  86521. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86522. updateShaderUniforms(): void;
  86523. render(useCameraPostProcess?: boolean): void;
  86524. resize(size: any, generateMipMaps: any): void;
  86525. get baseTexture(): BABYLON.Texture;
  86526. set baseTexture(texture: BABYLON.Texture);
  86527. /**
  86528. * Serializes this normal map procedural texture
  86529. * @returns a serialized normal map procedural texture object
  86530. */
  86531. serialize(): any;
  86532. /**
  86533. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  86534. * @param parsedTexture defines parsed texture data
  86535. * @param scene defines the current scene
  86536. * @param rootUrl defines the root URL containing normal map procedural texture information
  86537. * @returns a parsed Normal Map Procedural BABYLON.Texture
  86538. */
  86539. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  86540. }
  86541. }
  86542. declare module BABYLON {
  86543. /** @hidden */
  86544. export var perlinNoiseProceduralTexturePixelShader: {
  86545. name: string;
  86546. shader: string;
  86547. };
  86548. }
  86549. declare module BABYLON {
  86550. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  86551. time: number;
  86552. timeScale: number;
  86553. translationSpeed: number;
  86554. private _currentTranslation;
  86555. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86556. updateShaderUniforms(): void;
  86557. render(useCameraPostProcess?: boolean): void;
  86558. resize(size: any, generateMipMaps: any): void;
  86559. /**
  86560. * Serializes this perlin noise procedural texture
  86561. * @returns a serialized perlin noise procedural texture object
  86562. */
  86563. serialize(): any;
  86564. /**
  86565. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  86566. * @param parsedTexture defines parsed texture data
  86567. * @param scene defines the current scene
  86568. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  86569. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  86570. */
  86571. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  86572. }
  86573. }
  86574. declare module BABYLON {
  86575. /** @hidden */
  86576. export var roadProceduralTexturePixelShader: {
  86577. name: string;
  86578. shader: string;
  86579. };
  86580. }
  86581. declare module BABYLON {
  86582. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  86583. private _roadColor;
  86584. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86585. updateShaderUniforms(): void;
  86586. get roadColor(): BABYLON.Color3;
  86587. set roadColor(value: BABYLON.Color3);
  86588. /**
  86589. * Serializes this road procedural texture
  86590. * @returns a serialized road procedural texture object
  86591. */
  86592. serialize(): any;
  86593. /**
  86594. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  86595. * @param parsedTexture defines parsed texture data
  86596. * @param scene defines the current scene
  86597. * @param rootUrl defines the root URL containing road procedural texture information
  86598. * @returns a parsed Road Procedural BABYLON.Texture
  86599. */
  86600. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  86601. }
  86602. }
  86603. declare module BABYLON {
  86604. /** @hidden */
  86605. export var starfieldProceduralTexturePixelShader: {
  86606. name: string;
  86607. shader: string;
  86608. };
  86609. }
  86610. declare module BABYLON {
  86611. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  86612. private _time;
  86613. private _alpha;
  86614. private _beta;
  86615. private _zoom;
  86616. private _formuparam;
  86617. private _stepsize;
  86618. private _tile;
  86619. private _brightness;
  86620. private _darkmatter;
  86621. private _distfading;
  86622. private _saturation;
  86623. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86624. updateShaderUniforms(): void;
  86625. get time(): number;
  86626. set time(value: number);
  86627. get alpha(): number;
  86628. set alpha(value: number);
  86629. get beta(): number;
  86630. set beta(value: number);
  86631. get formuparam(): number;
  86632. set formuparam(value: number);
  86633. get stepsize(): number;
  86634. set stepsize(value: number);
  86635. get zoom(): number;
  86636. set zoom(value: number);
  86637. get tile(): number;
  86638. set tile(value: number);
  86639. get brightness(): number;
  86640. set brightness(value: number);
  86641. get darkmatter(): number;
  86642. set darkmatter(value: number);
  86643. get distfading(): number;
  86644. set distfading(value: number);
  86645. get saturation(): number;
  86646. set saturation(value: number);
  86647. /**
  86648. * Serializes this starfield procedural texture
  86649. * @returns a serialized starfield procedural texture object
  86650. */
  86651. serialize(): any;
  86652. /**
  86653. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  86654. * @param parsedTexture defines parsed texture data
  86655. * @param scene defines the current scene
  86656. * @param rootUrl defines the root URL containing startfield procedural texture information
  86657. * @returns a parsed Starfield Procedural BABYLON.Texture
  86658. */
  86659. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  86660. }
  86661. }
  86662. declare module BABYLON {
  86663. /** @hidden */
  86664. export var woodProceduralTexturePixelShader: {
  86665. name: string;
  86666. shader: string;
  86667. };
  86668. }
  86669. declare module BABYLON {
  86670. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  86671. private _ampScale;
  86672. private _woodColor;
  86673. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  86674. updateShaderUniforms(): void;
  86675. get ampScale(): number;
  86676. set ampScale(value: number);
  86677. get woodColor(): BABYLON.Color3;
  86678. set woodColor(value: BABYLON.Color3);
  86679. /**
  86680. * Serializes this wood procedural texture
  86681. * @returns a serialized wood procedural texture object
  86682. */
  86683. serialize(): any;
  86684. /**
  86685. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  86686. * @param parsedTexture defines parsed texture data
  86687. * @param scene defines the current scene
  86688. * @param rootUrl defines the root URL containing wood procedural texture information
  86689. * @returns a parsed Wood Procedural BABYLON.Texture
  86690. */
  86691. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  86692. }
  86693. }